Exemple #1
0
 void TimChaConMoi(CompanyControl tempchacon)
 {
     if (tempchacon.Location.Y < caomotcap * LevelMax)
     {
         CompanyControl cha       = new CompanyControl();
         CompanyControl cungcap   = new CompanyControl();
         int            kcchacony = 10000;
         int            kchaconx  = 10000;
         //Tim cha
         foreach (CompanyControl controlcu in dstemp)
         {
             if (controlcu.Location.Y < tempchacon.Location.Y)
             {
                 int khoangcachchacony = Math.Abs(controlcu.Location.Y - tempchacon.Location.Y);
                 int khoangcachchaconx = Math.Abs(controlcu.Location.X - tempchacon.Location.X);
                 if (khoangcachchacony <= kcchacony && khoangcachchaconx <= kchaconx)
                 {
                     cha       = controlcu;
                     kcchacony = khoangcachchacony;
                     kchaconx  = khoangcachchaconx;
                 }
             }
         }
         //Tim cung cap
         foreach (CompanyControl controlcu in dstemp)
         {
             if (controlcu.Tag.ToString() == cha.Name.ToString())
             {
                 cungcap = controlcu;
                 break;
             }
         }
         DialogResult r;
         r = MessageBox.Show(String.Format("'{0}' sẽ thuộc '{1}'.Bạn có muốn cập nhật?", tempchacon.txtName.Text, cha.txtName.Text), "Xác nhận", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
         if (r == DialogResult.Yes)
         {
             string tentable   = cungcap.tentable;
             string matable    = tentable.Substring(3);
             string matablecha = cha.tentable.Substring(3);
             if (matablecha != "Company")
             {
                 DBEngine.exec(String.Format("Insert into {0} ({1}ID,{2}Code,{3}Name) values({4},'{5}','{6}')", tentable, matablecha, matable, matable, cha.ID, tempchacon.txtCode.Text, tempchacon.txtName.Text));
             }
             else
             {
                 DBEngine.exec(String.Format("Insert into {0} ({1}Code,{2}Name) values('{3}','{4}')", tentable, matable, matable, tempchacon.txtCode.Text, tempchacon.txtName.Text));
             }
             LoadTree();
         }
     }
 }
 private void EZLog(string Action, string keyName, string oldValue, string newValue, string TableName, string strEmpID)
 {
     try
     {
         DBEngine.exec("sp_EZLogMasterData",
                       "@Action", Action,
                       "@KeyName", keyName,
                       "@EmployeeID", strEmpID,
                       "@OldValue", oldValue,
                       "@NewValue", newValue,
                       "@FunctionClassName", string.Format("DataSetting.{0}", TableName),
                       "@ScreenName", screenName,
                       "@LoginID", UIMessage.userID);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }