using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using CsvReadWrite;

namespace HT_SKT_Stock
{
    public class DBConstr
    {
        public static string settingDB()
        {
            String SETTINGS_FILE = "\\FlashDisk\\BT_FILES\\drv1\\SKT_Stock\\Settings.csv";
            List<List<string>> Settings;
            String dataSource;
            String initialCatalog;
            String userId;
            String password;
            String timeout;
            List<string> tmp;
            String ConnectionString;

            Settings = new List<List<string>>();
            tmp = null;
            using (var csv = new CsvReader(SETTINGS_FILE))
            {

                while ((tmp = csv.ReadRow()) != null)
                {
                    Settings.Add(tmp);

                }

                try
                {
                    dataSource = Settings[0][1].Replace("\r", "");
                    initialCatalog = Settings[0][2].Replace("\r", "");
                    userId = Settings[0][3].Replace("\r", "");
                    password = Settings[0][4].Replace("\r", "");
                    timeout = Settings[0][5].Replace("\r", "");
                    FrmLogin._Form_LoginInstance.DevNO = Settings[0][0].Replace("\r", "");

                    //ConnectionString = "Data Source=" + dataSource + "," + port + ";Initial Catalog=" + initialCatalog + ";User Id=" + userId + ";Password=" + password + ";";

                    ConnectionString = "Server=" + dataSource + ";UID=" + userId + ";PASSWORD=" + password + ";database=" + initialCatalog + ";Connect Timeout=" + timeout + ";";


                    //        strConnString = "Server=202.151.188.68;UID=sa;PASSWORD=v6f,l6-46@2021;database=wms-skt; " +
                    //" Connect Timeout=600;";

                    return ConnectionString;
                }
                catch (Exception e)
                {

                    //return "Data Source=DESKTOP-IUU7LF3\\SQLEXPRESS2019,1433;Initial Catalog=TCSDB;User Id=sa;Password=1234;";

                    return "";
                }
            }



        }
        

       
        //public static String ConnectionString = "Data Source=DESKTOP-IUU7LF3\\SQLEXPRESS2019,1433;Initial Catalog=TCSDB;User Id=sa;Password=1234;";

        //public static String ConnectionString = "Data Source=" + dataSource + "," + port + ";Initial Catalog=" + initialCatalog + ";User Id=" + userId + ";Password=" + password + ";";

   
    }
}
