コード例 #1
0
 public static void XMLSaveWorker(string XMLName, string ClassName)
 {
     try
     {
         Type calledType          = Type.GetType("DBAutoShop.ORM." + ClassName);
         AdditionalCommonClass DB = (AdditionalCommonClass)Activator.CreateInstance(calledType);
         DatabaseControlService.SQL.SqlProcduceCommand(DB.SelectAll());
         DatabaseControlService.SQL.SQLDS.WriteXml("XML\\" + XMLName + ".XML");
     }
     catch (System.Exception ex)
     {
         MessageBox.Show("XML ERROR: " + ex.Message, "ќшибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
コード例 #2
0
 public static void XMLLoadWorker(string XMLName, string ClassName)
 {
     try
     {
         Type calledType          = Type.GetType("DBAutoShop.ORM." + ClassName);
         AdditionalCommonClass DB = (AdditionalCommonClass)Activator.CreateInstance(calledType);
         if (File.Exists("XML\\" + XMLName + ".XML"))
         {
             DatabaseControlService.SQL.SQLDS.ReadXml("XML\\" + XMLName + ".XML");
         }
         else
         {
             return;
         }
         DataSet Base = new DataSet();
         Base.ReadXml("XML\\" + XMLName + ".XML");
         if (DatabaseControlService.SQL.DataTableHasValues())
         {
             for (int i = 0; i < Base.Tables["Table"].Rows.Count; i++)
             {
                 DB.Reset();
                 DB.LoadData(Base, i);
                 if (!DB.CheckAll())
                 {
                     DatabaseControlService.SQL.SqlProcduceTransactionCommand(DB.Insert());
                 }
                 else
                 {
                     DatabaseControlService.SQL.SqlProcduceCommand(DB.SelectAll());
                     int ID = DatabaseControlService.SQL.GetIDByValue(DB.MainValue, 0, 1);
                     DB.MainID = ID;
                     DatabaseControlService.SQL.SqlProcduceTransactionCommand(DB.Update());
                 }
             }
             DatabaseControlService.SQL.SQLDS = new DataSet();
             DatabaseControlService.SQL.SQLDS.ReadXml("XML\\" + XMLName + ".XML");
         }
     }
     catch (System.Exception ex)
     {
         MessageBox.Show(ex.StackTrace);
         MessageBox.Show("XML ERROR: " + ex.Message, "ќшибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }