Esempio n. 1
0
 private void BtnOK_Click(object sender, EventArgs e)
 {
     try
     {
         string strClientNameTemp = CboClientName.Text.Trim();
         string strFarmNameTemp   = CboFarmName.Text.Trim();
         string strFruitNameTemp  = CboFruitName.Text.Trim();
         //更新水果信息的客户信息
         //bool bUpdateFruitCustomerInfo = BusinessFacade.UpdateFruitCustomerInfo(Convert.ToInt32(processInfoForm.currentSelectCustomerID),
         //    strClientNameTemp, strFarmNameTemp, strFruitNameTemp);
         bool bUpdateFruitCustomerInfo = databaseOperation.UpdateFruitCustomerInfo(Convert.ToInt32(processInfoForm.currentSelectCustomerID),
                                                                                   strClientNameTemp, strFarmNameTemp, strFruitNameTemp);
         if (!bUpdateFruitCustomerInfo)
         {
             //MessageBox.Show("更新水果信息客户信息失败!");
             //MessageBox.Show("0x30003103 Update customer information failed!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
             MessageBox.Show("0x30003103 " + LanguageContainer.ClientInfoUpdateFormRangeMessagebox1Text[GlobalDataInterface.selectLanguageIndex],
                             LanguageContainer.ClientInfoUpdateFormMessageboxInformationCaption[GlobalDataInterface.selectLanguageIndex],
                             MessageBoxButtons.OK, MessageBoxIcon.Information);
             return;
         }
         //更新已保存的客户信息
         string        clientInfoContent = strClientNameTemp + "," + strFarmNameTemp + "," + strFruitNameTemp;
         StringBuilder sb = new StringBuilder();
         if (processInfoForm.mainForm.clientInfoContent == null)
         {
             sb.Append(clientInfoContent);
             sb.Append("\r\n" + strClientNameTemp);
             sb.Append("\r\n" + strFarmNameTemp);
             sb.Append("\r\n" + strFruitNameTemp);
             FileOperate.WriteFile(sb, processInfoForm.mainForm.clientInfoFileName);
             processInfoForm.mainForm.clientInfoContent = clientInfoContent;
         }
         else
         {
             FileOperate.EditFile(1, clientInfoContent, processInfoForm.mainForm.clientInfoFileName);
         }
         //再次获取客户信息
         strCustomerName = FileOperate.ReadFile(2, processInfoForm.mainForm.clientInfoFileName);
         strFarmName     = FileOperate.ReadFile(3, processInfoForm.mainForm.clientInfoFileName);
         strFruitName    = FileOperate.ReadFile(4, processInfoForm.mainForm.clientInfoFileName);
         FileOperate.EditFile(2, FunctionInterface.CombineString(strCustomerName, strClientNameTemp), processInfoForm.mainForm.clientInfoFileName);
         FileOperate.EditFile(3, FunctionInterface.CombineString(strFarmName, strFarmNameTemp), processInfoForm.mainForm.clientInfoFileName);
         FileOperate.EditFile(4, FunctionInterface.CombineString(strFruitName, strFruitNameTemp), processInfoForm.mainForm.clientInfoFileName);
         //更新ComboBox框
         processInfoForm.UpdateComboBoxContent();
         //更新主界面客户信息
         GlobalDataInterface.dataInterface.CustomerName = strClientNameTemp;
         GlobalDataInterface.dataInterface.FarmName     = strFarmNameTemp;
         GlobalDataInterface.dataInterface.FruitName    = strFruitNameTemp;
         processInfoForm.mainForm.UpdateClientInfoState();
         //更新当前选中项
         if (UpdateListViewEvent != null)
         {
             UpdateListViewEvent(strClientNameTemp, strFarmNameTemp, strFruitNameTemp);
         }
         this.Close();
     }
     catch (Exception ee)
     {
         MessageBox.Show(ee.ToString());
     }
 }
Esempio n. 2
0
 private void BtnOK_Click(object sender, EventArgs e)
 {
     try
     {
         string strClientNameTemp = CboClientName.Text.Trim();
         string strFarmNameTemp   = CboFarmName.Text.Trim();
         string strFruitNameTemp  = CboFruitName.Text.Trim();
         GlobalDataInterface.dataInterface.CustomerName = strClientNameTemp;
         GlobalDataInterface.dataInterface.FarmName     = strFarmNameTemp;
         GlobalDataInterface.dataInterface.FruitName    = strFruitNameTemp;
         string        clientInfoContent = strClientNameTemp + "," + strFarmNameTemp + "," + strFruitNameTemp;
         StringBuilder sb = new StringBuilder();
         if (mainForm.clientInfoContent == null)
         {
             sb.Append(clientInfoContent);
             sb.Append("\r\n" + strClientNameTemp);
             sb.Append("\r\n" + strFarmNameTemp);
             sb.Append("\r\n" + strFruitNameTemp);
             FileOperate.WriteFile(sb, mainForm.clientInfoFileName);
             mainForm.clientInfoContent = clientInfoContent;
         }
         else
         {
             FileOperate.EditFile(1, clientInfoContent, mainForm.clientInfoFileName);
         }
         //再次获取客户信息
         //strCustomerName = FileOperate.ReadFile(2, mainForm.clientInfoFileName);
         strCustomerName = "";
         for (int i = 0; i < customerName.Count(); i++)
         {
             strCustomerName += customerName[i].Trim() + ",";
         }
         if (strCustomerName.Length > 1)
         {
             strCustomerName = strCustomerName.Substring(0, strCustomerName.Length - 1);
         }
         //strFarmName = FileOperate.ReadFile(3, mainForm.clientInfoFileName);
         strFarmName = "";
         for (int i = 0; i < farmName.Count(); i++)
         {
             strFarmName += farmName[i].Trim() + ",";
         }
         if (strFarmName.Length > 1)
         {
             strFarmName = strFarmName.Substring(0, strFarmName.Length - 1);
         }
         //strFruitName = FileOperate.ReadFile(4, mainForm.clientInfoFileName);
         strFruitName = "";
         for (int i = 0; i < fruitName.Count(); i++)
         {
             strFruitName += fruitName[i].Trim() + ",";
         }
         if (strFruitName.Length > 1)
         {
             strFruitName = strFruitName.Substring(0, strFruitName.Length - 1);
         }
         //MessageBox.Show("strCustomerName=" + strCustomerName + " * strClientNameTemp=" + strClientNameTemp);
         FileOperate.EditFile(2, FunctionInterface.CombineString(strCustomerName, strClientNameTemp), mainForm.clientInfoFileName);
         FileOperate.EditFile(3, FunctionInterface.CombineString(strFarmName, strFarmNameTemp), mainForm.clientInfoFileName);
         FileOperate.EditFile(4, FunctionInterface.CombineString(strFruitName, strFruitNameTemp), mainForm.clientInfoFileName);
         mainForm.UpdateClientInfoState();
         //判断当前数据库是否为空
         //if (BusinessFacade.GetFruitTopCustomerID().Tables[0].Rows.Count == 0)
         if (databaseOperation.GetFruitTopCustomerID().Tables[0].Rows.Count == 0)
         {
             this.Close();
             return;
         }
         //加工过程中:修改当前加工条目的客户信息
         //int newCustomerID = Convert.ToInt32(BusinessFacade.GetFruitTopCustomerID().Tables[0].Rows[0]["CustomerID"].ToString()); //获取最新客户信息的ID号
         int     newCustomerID = Convert.ToInt32(databaseOperation.GetFruitTopCustomerID().Tables[0].Rows[0]["CustomerID"].ToString()); //获取最新客户信息的ID号
         DataSet dst1;                                                                                                                  //统计信息时获取tb_FruitInfo
         //dst1 = BusinessFacade.GetFruitByCustomerID(newCustomerID); //获取tb_FruitInfo
         dst1 = databaseOperation.GetFruitByCustomerID(newCustomerID);                                                                  //获取tb_FruitInfo
         if (dst1.Tables[0].Rows[0]["CompletedState"].ToString().Equals("0"))
         {
             //BusinessFacade.UpdateFruitCustomerInfo(newCustomerID, strClientNameTemp, strFarmNameTemp, strFruitNameTemp);
             databaseOperation.UpdateFruitCustomerInfo(newCustomerID, strClientNameTemp, strFarmNameTemp, strFruitNameTemp);
         }
         this.Close();
     }
     catch (Exception ee)
     {
         MessageBox.Show(ee.ToString());
     }
 }