Beispiel #1
0
 public XtraForm2()
 {
     InitializeComponent();
     localConfig = new IniFile("Config.ini");
     UserLookAndFeel.Default.SetSkinStyle(localConfig.Read("SkinName", "DevExpress"), localConfig.Read("SkinPalette", "DevExpress"));
     shareConfig = new IniFile(@"\\172.16.0.190\mds_project\MDS\FileConfig\Configue.ini");
     db          = new cDatabase("Server=" + shareConfig.Read("Server", "Connectionstring") +
                                 ";uid=" + shareConfig.Read("Uid", "ConnectionString") +
                                 ";pwd=" + shareConfig.Read("Pwd", "ConnectionString") +
                                 ";database=" + shareConfig.Read("Database", "ConnectionString"));
     InitAccordionControl();
 }
Beispiel #2
0
        /// <summary>
        /// Exporting a SQL server database table to the local CSV file.
        /// </summary>
        public void MakeAddressbookCSVsample(DB_Type db_type)
        {
            cDatabase sqlDB = new cDatabase(db_type);

            try
            {
                sqlDB.OpenConnection();

                Console.WriteLine("Connection opened");

                sqlDB.Table2Csv(@"Data/CSV/addressbook v4.csv", "addressbook_v4", true);
                Console.WriteLine("The file addressbook v4.csv was created.");
            }
            catch (Exception ex) { Console.WriteLine("Making of a addressbook csv file failed!.. " + ex.Message); }
            finally
            {
                sqlDB.CloseConnection();
            }
        }
        /// <summary>
        /// Uploading CSV file to the SQL server database table.
        /// </summary>
        public void UploadCsvToOrders(DB_Type db_type)
        {
            cDatabase sqlDB = new cDatabase(db_type);

            try
            {
                sqlDB.OpenConnection();

                Console.WriteLine("Connection opened");

                sqlDB.Csv2Table(@"Data/CSV/orders 1000 with order id.csv", "orders", "order_id", 10, true);

                Console.WriteLine("The orders CSV file was uploaded to the SQL server.");
            }
            catch (Exception ex) { Console.WriteLine("Uploading of the CSV file to the SQL server failed!.. " + ex.Message); }
            finally
            {
                sqlDB.CloseConnection();
            }
        }
        /// <summary>
        /// Uploading CSV file to the SQL server's database table.
        /// </summary>
        public void UploadCsvToAddressbookV4(DB_Type db_type)
        {
            cDatabase sqlDB = new cDatabase(db_type);

            try
            {
                sqlDB.OpenConnection();

                Console.WriteLine("Connection opened");

                sqlDB.Csv2Table(@"Data/CSV/Route4Me Address Book 03-09-2017.csv", "addressbook_v4", "id", 33, true);

                Console.WriteLine("The file orders.csv was uploaded to the SQL server.");
            }
            catch (Exception ex) { Console.WriteLine("Uploading of the CSV file to the SQL server failed!.. " + ex.Message); }
            finally
            {
                sqlDB.CloseConnection();
            }
        }
        /// <summary>
        /// Uploading JSON orders file to the SQL server's database table.
        /// </summary>
        public void UploadOrdersJSONtoSQL(DB_Type db_type)
        {
            cDatabase sqlDB = new cDatabase(db_type);

            try
            {
                sqlDB.OpenConnection();

                Console.WriteLine("Connection opened");

                sqlDB.Json2Table(@"Data/JSON/get orders RESPONSE.json", "orders", "id", R4M_DataType.Order);

                Console.WriteLine("The JSON file was uploaded to the SQL server.");
            }
            catch (Exception ex) { Console.WriteLine("Uploading of the JSON file to the SQL server failed!.. " + ex.Message); }
            finally
            {
                sqlDB.CloseConnection();
            }
        }
        /// <summary>
        /// Uploading JSON addressbook file to the SQL server's database table.
        /// </summary>
        public void UploadAddressbookJSONtoSQL(DB_Type db_type)
        {
            cDatabase sqlDB = new cDatabase(db_type);

            try
            {
                sqlDB.OpenConnection();

                Console.WriteLine("Connection opened");

                sqlDB.Json2Table(@"Data/JSON/Addressbook Get Contacts RESPONSE.json", "addressbook_v4", "id", R4M_DataType.Addressbook);

                Console.WriteLine("The file 'Addressbook Get Contacts RESPONSE.json' was uploaded to the SQL server.");
            }
            catch (Exception ex) { Console.WriteLine("Uploading of the JSON file to the SQL server failed!.. " + ex.Message); }
            finally
            {
                sqlDB.CloseConnection();
            }


        }
Beispiel #7
0
        /// <summary>
        /// Generating of the SQL server database tables from the SQL script text files.
        /// </summary>
        public void GenerateSqlDatabase(DB_Type db_type)
        {
            cDatabase sqlDB = new cDatabase(db_type);

            try
            {
                string sAddressbookSqlCom   = "";
                string sOrdersSqlCom        = "";
                string sDictionaryDDLSqlCom = "";
                string sDictionaryDMLSqlCom = "";

                switch (db_type)
                {
                case DB_Type.MySQL:
                    sAddressbookSqlCom   = File.ReadAllText(@"Data/SQL/MySQL/addressbook_v4.sql");
                    sOrdersSqlCom        = File.ReadAllText(@"Data/SQL/MySQL/orders.sql");
                    sDictionaryDDLSqlCom = File.ReadAllText(@"Data/SQL/MySQL/csv_to_api_dictionary_DDL.sql");
                    sDictionaryDMLSqlCom = File.ReadAllText(@"Data/SQL/MySQL/csv_to_api_dictionary_DML.sql");
                    break;

                case DB_Type.MSSQL:
                    sAddressbookSqlCom   = File.ReadAllText(@"Data/SQL/MSSQL/addressbook_v4.sql");
                    sOrdersSqlCom        = File.ReadAllText(@"Data/SQL/MSSQL/orders.sql");
                    sDictionaryDDLSqlCom = File.ReadAllText(@"Data/SQL/MSSQL/csv_to_api_dictionary_DDL.sql");
                    sDictionaryDMLSqlCom = File.ReadAllText(@"Data/SQL/MSSQL/csv_to_api_dictionary_DML.sql");
                    break;

                case DB_Type.PostgreSQL:
                    sAddressbookSqlCom   = File.ReadAllText(@"Data/SQL/PostgreSQL/addressbook_v4.sql");
                    sOrdersSqlCom        = File.ReadAllText(@"Data/SQL/PostgreSQL/orders.sql");
                    sDictionaryDDLSqlCom = File.ReadAllText(@"Data/SQL/PostgreSQL/csv_to_api_dictionary_DDL.sql");
                    sDictionaryDMLSqlCom = File.ReadAllText(@"Data/SQL/PostgreSQL/csv_to_api_dictionary_DML.sql");
                    break;

                case DB_Type.SQLite:

                    break;

                case DB_Type.MS_Access:

                    break;
                }

                sqlDB.OpenConnection();

                Console.WriteLine("Connection opened");

                int iResult = sqlDB.ExecuteMulticoomandSql(sAddressbookSqlCom);
                if (iResult > 0)
                {
                    Console.WriteLine(":) The SQL table 'addressbook_v4' created successfuly!!!");
                }
                else
                {
                    Console.WriteLine(":( Creating of the SQL table 'addressbook_v4' failed...");
                }

                iResult = sqlDB.ExecuteMulticoomandSql(sOrdersSqlCom);
                if (iResult > 0)
                {
                    Console.WriteLine(":) The SQL table 'orders' created successfuly!!!");
                }
                else
                {
                    Console.WriteLine(":( Creating of the SQL table 'orders' failed...");
                }

                iResult = sqlDB.ExecuteMulticoomandSql(sDictionaryDDLSqlCom);
                if (iResult > 0)
                {
                    Console.WriteLine(":) The SQL table 'csv_to_api_dictionary' created successfuly!!!");

                    iResult = sqlDB.ExecuteMulticoomandSql(sDictionaryDMLSqlCom);
                    if (iResult > 0)
                    {
                        Console.WriteLine(":) The data was inserted into SQL table 'csv_to_api_dictionary' successfuly!!!");
                    }
                    else
                    {
                        Console.WriteLine(":( Inserting of the data in the SQL table 'csv_to_api_dictionary' failed...");
                    }
                }
                else
                {
                    Console.WriteLine(":( Creating of the SQL table 'csv_to_api_dictionary' failed...");
                }
            }
            catch (Exception ex) { Console.WriteLine("Generating of the SQL tables failed!.. " + ex.Message); }
            finally
            {
                sqlDB.CloseConnection();
            }
        }
Beispiel #8
0
        private void DEV03_Load(object sender, EventArgs e)
        {
            UserLookAndFeel.Default.StyleChanged += MyStyleChanged;
            IniFile ini = new IniFile(@"\\172.16.0.190\mds_project\MDS\FileConfig\Configue.ini");

            db      = new cDatabase("Server=" + ini.Read("Server", "ConnectionString") + ";uid=" + ini.Read("Uid", "ConnectionString") + ";pwd=" + ini.Read("Pwd", "ConnectionString") + ";database=" + ini.Read("Database", "ConnectionString"));
            dtfinfo = clinfo.DateTimeFormat;
            try
            {
                NewData();
                GetBOMList(0);
                GetUnit();
                GetFGItem();

                tabbed_Master.SelectedTabPageIndex = 0;
                tabbedBom.SelectedTabPageIndex     = 0;
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }


            ////***** SET CONNECT DB ********
            //if (this.ConnectionString != null)
            //{
            //    if (this.ConnectionString != "")
            //    {
            //        CONNECT_STRING = this.ConnectionString;
            //    }
            //}

            //this.DBC = new DatabaseConnect(CONNECT_STRING);

            //if (this.DBC.chkCONNECTION_STING() == false)
            //{
            //    this.DBC.setCONNECTION_STRING_INIFILE();
            //    if (this.DBC.chkCONNECTION_STING() == false)
            //    {
            //        return;
            //    }
            //}
            //new ObjDE.setDatabase(this.DBC);
            //******************************

            lblUser.Text = "Login : "******"SELECT TOP (1) ReadWriteStatus FROM FunctionAccess WHERE (OIDUser = '******') AND(FunctionNo = 'DEV03') ");
            //chkReadWrite = this.DBC.DBQuery(sbSQL).getInt();

            //if (chkReadWrite == 0)
            //{
            //    ribbonPageGroup1.Visible = false;
            //    //rpgManage.Visible = false;

            //    layoutControlItem29.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
            //    //simpleButton2.Enabled = false;
            //    //simpleButton3.Enabled = false;
            //    //simpleButton4.Enabled = false;
            //    //sbColor.Enabled = false;
            //    //sbSize.Enabled = false;
            //    //sbFBColor.Enabled = false;
            //    //sbTempCode.Enabled = false;
            //    //sbMTColor.Enabled = false;
            //    //sbTempCodeMat.Enabled = false;
            //    //btnOpenImg_Main.Enabled = false;
            //    //sbDelete_S.Enabled = false;
            //    //sbClear.Enabled = false;
            //    //simpleButton5.Enabled = false;
            //    //sbDelete_F.Enabled = false;
            //    //sbMatClear.Enabled = false;
            //    //btnUploadMat.Enabled = false;
            //    //simpleButton1.Enabled = false;

            //    //sbUseFor.Enabled = false;
            //    //sbUnit.Enabled = false;

            //    //sbPart.Enabled = false;
            //    //sbFBSupplier.Enabled = false;

            //    //sbMTSupplier.Enabled = false;
            //}

            //LoadListBOM();
        }