예제 #1
0
파일: Orders.cs 프로젝트: GTVolk/DBAutoShop
        public static void LoadFromXML()
        {
            try
            {
                AutomobilesData.LoadFromXML();
                Clients.LoadFromXML();

                Orders DB = new Orders();
                DatabaseControlService.SQL.SQLDS = new DataSet();
                DatabaseControlService.SQL.SQLDS.ReadXml("XML\\Orders.XML");
                DataSet Base = new DataSet();
                Base.ReadXml("XML\\Orders.XML");
                if (Base.Tables.Count == 0)
                {
                    return;
                }
                if (DatabaseControlService.SQL.DataTableHasValues())
                {
                    for (int i = 0; i < Base.Tables["Table"].Rows.Count; i++)
                    {
                        int OLD_ValueID = Convert.ToInt32(Base.Tables["Table"].Rows[i][1]);
                        DatabaseControlService.SQL.SQLDS = new DataSet();
                        DatabaseControlService.SQL.SQLDS.ReadXml("XML\\AutomobilesData.XML");
                        string OLD_Name = DatabaseControlService.SQL.GetValueByID(OLD_ValueID, 3, 0);
                        Base.Tables["Table"].Rows[i][1] = DatabaseControlService.DBECS.GetAutoIDByModel(OLD_Name);

                        OLD_ValueID = Convert.ToInt32(Base.Tables["Table"].Rows[i][2]);
                        DatabaseControlService.SQL.SQLDS = new DataSet();
                        DatabaseControlService.SQL.SQLDS.ReadXml("XML\\Clients.XML");
                        OLD_Name = DatabaseControlService.SQL.GetValueByID(OLD_ValueID, 7, 0);
                        Base.Tables["Table"].Rows[i][2] = DatabaseControlService.DBECS.GetClientIDByTelephone(OLD_Name);

                        DB.Reset();
                        DB.LoadData(Base, i);
                        if (!DB.CheckAll())
                        {
                            DatabaseControlService.SQL.SqlProcduceTransactionCommand(DB.Insert());
                        }
                        else
                        {
                            DatabaseControlService.SQL.SqlProcduceCommand(SelectAll());
                            int ID = DatabaseControlService.SQL.GetIDByAllString(DB.Auto_ID + " " + DB.Client_ID + " " + DB.Order_Date + " " + DB.Order_Condition, 0);
                            DB.Order_ID = ID;
                            DatabaseControlService.SQL.SqlProcduceTransactionCommand(DB.Update());
                        }
                    }
                    DatabaseControlService.SQL.SQLDS = new DataSet();
                    DatabaseControlService.SQL.SQLDS.ReadXml("XML\\Orders.XML");
                }
            }
            catch (System.Exception ex)
            {
                MessageBox.Show("XML ERROR: " + ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #2
0
파일: Orders.cs 프로젝트: GTVolk/DBAutoShop
        public static void SaveToXML()
        {
            try
            {
                AutomobilesData.SaveToXML();
                Clients.SaveToXML();

                DatabaseControlService.SQL.SqlProcduceCommand(SelectAll());
                DatabaseControlService.SQL.SQLDS.WriteXml("XML\\Orders.XML");
            }
            catch (System.Exception ex)
            {
                MessageBox.Show("XML ERROR: " + ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #3
0
        public static void LoadFromXML()
        {
            try
            {
                Manafacturers.LoadFromXML();
                Classes.LoadFromXML();
                Countries.LoadFromXML();
                BodyTypes.LoadFromXML();
                GearTypes.LoadFromXML();

                AutomobilesData DB = new AutomobilesData();
                DatabaseControlService.SQL.SQLDS = new DataSet();
                DatabaseControlService.SQL.SQLDS.ReadXml("XML\\AutomobilesData.XML");
                DataSet Base = new DataSet();
                Base.ReadXml("XML\\AutomobilesData.XML");
                if (Base.Tables.Count == 0)
                {
                    return;
                }
                if (DatabaseControlService.SQL.DataTableHasValues())
                {
                    for (int i = 0; i < Base.Tables["Table"].Rows.Count; i++)
                    {
                        int OLD_ValueID = Convert.ToInt32(Base.Tables["Table"].Rows[i][2]);
                        DatabaseControlService.SQL.SQLDS = new DataSet();
                        DatabaseControlService.SQL.SQLDS.ReadXml("XML\\Manafacturers.XML");
                        string OLD_Name = DatabaseControlService.SQL.GetValueByID(OLD_ValueID, 1, 0);
                        Base.Tables["Table"].Rows[i][2] = DatabaseControlService.DBECS.GetManafacturerIDByManafacturerName(OLD_Name);

                        OLD_ValueID = Convert.ToInt32(Base.Tables["Table"].Rows[i][4]);
                        DatabaseControlService.SQL.SQLDS = new DataSet();
                        DatabaseControlService.SQL.SQLDS.ReadXml("XML\\Classes.XML");
                        OLD_Name = DatabaseControlService.SQL.GetValueByID(OLD_ValueID, 1, 0);
                        Base.Tables["Table"].Rows[i][4] = DatabaseControlService.DBECS.GetClassIDByClassName(OLD_Name);

                        OLD_ValueID = Convert.ToInt32(Base.Tables["Table"].Rows[i][5]);
                        DatabaseControlService.SQL.SQLDS = new DataSet();
                        DatabaseControlService.SQL.SQLDS.ReadXml("XML\\Countries.XML");
                        OLD_Name = DatabaseControlService.SQL.GetValueByID(OLD_ValueID, 1, 0);
                        Base.Tables["Table"].Rows[i][5] = DatabaseControlService.DBECS.GetCountryIDByCountryName(OLD_Name);

                        OLD_ValueID = Convert.ToInt32(Base.Tables["Table"].Rows[i][7]);
                        DatabaseControlService.SQL.SQLDS = new DataSet();
                        DatabaseControlService.SQL.SQLDS.ReadXml("XML\\BodyTypes.XML");
                        OLD_Name = DatabaseControlService.SQL.GetValueByID(OLD_ValueID, 1, 0);
                        Base.Tables["Table"].Rows[i][7] = DatabaseControlService.DBECS.GetBodyIDByBodyName(OLD_Name);

                        OLD_ValueID = Convert.ToInt32(Base.Tables["Table"].Rows[i][23]);
                        DatabaseControlService.SQL.SQLDS = new DataSet();
                        DatabaseControlService.SQL.SQLDS.ReadXml("XML\\GearTypes.XML");
                        OLD_Name = DatabaseControlService.SQL.GetValueByID(OLD_ValueID, 1, 0);
                        Base.Tables["Table"].Rows[i][22] = DatabaseControlService.DBECS.GetGearIDByGearName(OLD_Name);

                        DB.Reset();
                        DB.LoadData(Base, i);
                        if (!DB.CheckAll())
                        {
                            DatabaseControlService.SQL.SqlProcduceTransactionCommand(DB.Insert());
                        }
                        else
                        {
                            DatabaseControlService.SQL.SqlProcduceCommand(SelectAll());
                            int ID = DatabaseControlService.SQL.GetIDByValue(DB.Model, 3, 0);
                            DB.Auto_ID = ID;
                            DatabaseControlService.SQL.SqlProcduceTransactionCommand(DB.Update());
                        }
                    }
                    DatabaseControlService.SQL.SQLDS = new DataSet();
                    DatabaseControlService.SQL.SQLDS.ReadXml("XML\\AutomobilesData.XML");
                }
            }
            catch (System.Exception ex)
            {
                MessageBox.Show("XML ERROR: " + ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }