private void ms_function_click(object sender, EventArgs e) { MyMenuItem item = sender as MyMenuItem; ModulInterface modul = this.modules[item.moduleId]; FunctionInterface function = modul.getFunctions()[item.functionId]; UIBuilderInterface builder = new UIBuilder(); function.buildUI(builder); EingabeManager em = new EingabeManager(); UserDataInterface data = em.getUserData(builder); if (data == null) { return; } try { lb_Ergebnis.Items.Add(function.calculate(data)); } catch (Exception err) { lb_Ergebnis.Items.Add(err.Message + err.StackTrace); Console.Write(err.StackTrace); } }
public static bool AddFunction <A0, A1, A2, A3, R>(this CFlat self, string functionName, System.Func <A0, A1, A2, A3, R> function) where A0 : struct, IMarshalable where A1 : struct, IMarshalable where A2 : struct, IMarshalable where A3 : struct, IMarshalable where R : struct, IMarshalable { var builder = new FunctionTypeBuilder(self.chunk); builder.WithParam(Marshal.TypeOf <A0>(self.chunk)); builder.WithParam(Marshal.TypeOf <A1>(self.chunk)); builder.WithParam(Marshal.TypeOf <A2>(self.chunk)); builder.WithParam(Marshal.TypeOf <A3>(self.chunk)); builder.returnType = Marshal.TypeOf <R>(self.chunk); return(FinishAddFunction(self, builder, functionName, (vm, top) => { var functionInterface = new FunctionInterface(vm, top); FunctionInterface.Return(vm, function( functionInterface.Arg <A0>(), functionInterface.Arg <A1>(), functionInterface.Arg <A2>(), functionInterface.Arg <A3>() )); })); }
/// <summary> /// Diese Methode fügt eine Funktion zu dem Modul hinzu /// </summary> /// <param name="name">Der Name der Funktion</param> /// <param name="description">Die Beschreibung der Funktion</param> /// <param name="function">Die Funktion selbst</param> protected void addFunction(string name, string description, FunctionInterface function) { this.functions.Add(function); FunctionDescription desc = new FunctionDescription(this.functionDescs.Count, name, description); this.functionDescs.Add(desc); }
public static bool AddFunction <R>(this CFlat self, string functionName, System.Func <R> function) where R : struct, IMarshalable { var builder = new FunctionTypeBuilder(self.chunk); builder.returnType = Marshal.TypeOf <R>(self.chunk); return(FinishAddFunction(self, builder, functionName, (vm, top) => { FunctionInterface.Return(vm, function()); })); }
private void ms_function_click(object sender, EventArgs e) { MyMenuItem item = sender as MyMenuItem; ModulInterface modul = this.modules[item.moduleId]; FunctionInterface function = modul.getFunctions()[item.functionId]; UIBuilderInterface builder = new UIBuilder(); function.buildUI(builder); var uem = new universelleseingabemodul(); uem.buildUi(builder); uem.ShowDialog(); try { lb_Ergebnis.Items.Add(function.calculate(uem.getData())); } catch (DatenNichtValideFehler) { } }
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()); } }
/// <summary> /// 填充表格信息 /// </summary> /// <param name="m_Sheet"></param> /// <param name="startrow"></param> public static void FillTableData(Excel._Worksheet m_Sheet, DataInterface dataInterfaceExcel, int startrow, bool IsQaulity, bool IsSize) { try { //客户信息 #region m_Sheet.Cells[4, 2] = dataInterfaceExcel.CustomerName; //客户名称 m_Sheet.Cells[4, 5] = dataInterfaceExcel.FarmName; //农场名称 m_Sheet.Cells[4, 8] = dataInterfaceExcel.FruitName; //水果品种 m_Sheet.Cells[5, 2] = dataInterfaceExcel.IoStStatistics.nTotalCount; //个数汇总 m_Sheet.Cells[5, 5] = ((double)dataInterfaceExcel.IoStStatistics.nWeightCount / 1000000).ToString(); //重量汇总 //Modify by ChengSk - 20180305 int sumBoxNum = FunctionInterface.GetSumValue(dataInterfaceExcel.IoStStatistics.nBoxGradeCount); //总箱数 m_Sheet.Cells[5, 8] = sumBoxNum; //箱数汇总 //平均果重 if (dataInterfaceExcel.IoStStatistics.nTotalCount == 0) { m_Sheet.Cells[6, 2] = 0.000; } else { m_Sheet.Cells[6, 2] = ((double)dataInterfaceExcel.IoStStatistics.nWeightCount / dataInterfaceExcel.IoStStatistics.nTotalCount).ToString("0.000"); } m_Sheet.Cells[6, 5] = dataInterfaceExcel.ProgramName; //分选程序 m_Sheet.Cells[6, 8] = GlobalDataInterface.SerialNum; //序列号 //add by xcw 20200701 //开始时间 Excel.Range range = m_Sheet.Range[m_Sheet.Cells[7, 2], m_Sheet.Cells[7, 3]]; //取得单元格范围 range.MergeCells = true; //合并单元格 range.Value2 = dataInterfaceExcel.StartTime; //结束时间 range = m_Sheet.Range[m_Sheet.Cells[7, 5], m_Sheet.Cells[7, 6]]; //取得单元格范围 range.MergeCells = true; //合并单元格 range.Value2 = dataInterfaceExcel.EndTime; #endregion //等级信息 #region int startrowex;//等级个数 UInt64 uSumValue, uSumWeightValue; int uSumBoxValue; //if(IsSize) uSumValue = FunctionInterface.GetSumValue(dataInterfaceExcel.IoStStatistics.nGradeCount); //获取总个数 //else uSumWeightValue = FunctionInterface.GetSumValue(dataInterfaceExcel.IoStStatistics.nWeightGradeCount); //获取总重量 uSumBoxValue = FunctionInterface.GetSumValue(dataInterfaceExcel.IoStStatistics.nBoxGradeCount); //获取总箱数 if (!IsQaulity) { startrowex = dataInterfaceExcel.WeightOrSizeGradeSum; for (int j = 0; j < dataInterfaceExcel.WeightOrSizeGradeSum; j++) { if (dataInterfaceExcel.QualityGradeSum == 0) { m_Sheet.Cells[j + startrow, 1] = Encoding.Default.GetString(dataInterfaceExcel.IoStStGradeInfo.strSizeGradeName, j * ConstPreDefine.MAX_TEXT_LENGTH, ConstPreDefine.MAX_TEXT_LENGTH); //等级名称 m_Sheet.Cells[j + startrow, 2] = dataInterfaceExcel.IoStStGradeInfo.grades[j].nMinSize.ToString(); //尺寸/重量 m_Sheet.Cells[j + startrow, 3] = dataInterfaceExcel.IoStStatistics.nGradeCount[j].ToString(); //等级个数 //个数百分比 if (uSumValue == 0) { m_Sheet.Cells[j + startrow, 4] = "0.00%"; } else { m_Sheet.Cells[j + startrow, 4] = ((double)dataInterfaceExcel.IoStStatistics.nGradeCount[j] / uSumValue).ToString("0.00%"); } m_Sheet.Cells[j + startrow, 5] = (dataInterfaceExcel.IoStStatistics.nWeightGradeCount[j] / 1000.0).ToString("#0.0"); //等级重量 //重量百分比 if (uSumWeightValue == 0) { m_Sheet.Cells[j + startrow, 6] = "0.00%"; } else { m_Sheet.Cells[j + startrow, 6] = ((double)dataInterfaceExcel.IoStStatistics.nWeightGradeCount[j] / uSumWeightValue).ToString("0.00%"); } m_Sheet.Cells[j + startrow, 7] = dataInterfaceExcel.IoStStatistics.nBoxGradeCount[j].ToString(); //箱数 //箱数百分比 if (uSumWeightValue == 0) { m_Sheet.Cells[j + startrow, 8] = "0.00%"; } else { m_Sheet.Cells[j + startrow, 8] = ((double)dataInterfaceExcel.IoStStatistics.nBoxGradeCount[j] / uSumBoxValue).ToString("0.00%"); } } else { ulong GradeCount = 0;//add by xcw 20201104 double CountPer = 0.0; double GradeWeight = 0.0; double WeightPer = 0.0; int BoxSumValue = 0; double BoxSumPer = 0.0; for (int i = 0; i < dataInterfaceExcel.QualityGradeSum; i++) { GradeCount += dataInterfaceExcel.IoStStatistics.nGradeCount[i * ConstPreDefine.MAX_SIZE_GRADE_NUM + j]; if (uSumValue != 0) { CountPer += ((double)dataInterfaceExcel.IoStStatistics.nGradeCount[i * ConstPreDefine.MAX_SIZE_GRADE_NUM + j] / uSumValue); } GradeWeight += (dataInterfaceExcel.IoStStatistics.nWeightGradeCount[i * ConstPreDefine.MAX_SIZE_GRADE_NUM + j] / 1000.0); if (uSumWeightValue != 0) { WeightPer += ((double)dataInterfaceExcel.IoStStatistics.nWeightGradeCount[i * ConstPreDefine.MAX_SIZE_GRADE_NUM + j] / uSumWeightValue); } BoxSumValue += dataInterfaceExcel.IoStStatistics.nBoxGradeCount[i * ConstPreDefine.MAX_SIZE_GRADE_NUM + j]; if (uSumBoxValue != 0) { BoxSumPer += ((double)dataInterfaceExcel.IoStStatistics.nBoxGradeCount[i * ConstPreDefine.MAX_SIZE_GRADE_NUM + j] / uSumBoxValue); } } m_Sheet.Cells[j + startrow, 1] = Encoding.Default.GetString(dataInterfaceExcel.IoStStGradeInfo.strSizeGradeName, j * ConstPreDefine.MAX_TEXT_LENGTH, ConstPreDefine.MAX_TEXT_LENGTH); //等级名称 m_Sheet.Cells[j + startrow, 2] = dataInterfaceExcel.IoStStGradeInfo.grades[j].nMinSize.ToString(); //尺寸/重量 m_Sheet.Cells[j + startrow, 3] = GradeCount.ToString(); //等级个数 //个数百分比 m_Sheet.Cells[j + startrow, 4] = CountPer.ToString("0.00%"); m_Sheet.Cells[j + startrow, 5] = GradeWeight.ToString("#0.0"); //等级重量 //重量百分比 j m_Sheet.Cells[j + startrow, 6] = WeightPer.ToString("0.00%"); m_Sheet.Cells[j + startrow, 7] = BoxSumValue.ToString(); //箱数 //箱数百分比 m_Sheet.Cells[j + startrow, 8] = BoxSumPer.ToString("0.00%"); //m_Sheet.Cells[j + startrow, 8] =((double)BoxSumValue/ uSumBoxValue).ToString("0.00%"); } } } else { string strSizeName; string strQualityName; string strMixName; int qualSum = 1; if (dataInterfaceExcel.QualityGradeSum > qualSum) { qualSum = dataInterfaceExcel.QualityGradeSum; } int sizeSum = 1; if (dataInterfaceExcel.WeightOrSizeGradeSum > sizeSum) { sizeSum = dataInterfaceExcel.WeightOrSizeGradeSum; } startrowex = qualSum * sizeSum; for (int i = 0; i < qualSum; i++) { for (int j = 0; j < sizeSum; j++) { strSizeName = Encoding.Default.GetString(dataInterfaceExcel.IoStStGradeInfo.strSizeGradeName, j * ConstPreDefine.MAX_TEXT_LENGTH, ConstPreDefine.MAX_TEXT_LENGTH); strQualityName = Encoding.Default.GetString(dataInterfaceExcel.IoStStGradeInfo.strQualityGradeName, i * ConstPreDefine.MAX_TEXT_LENGTH, ConstPreDefine.MAX_TEXT_LENGTH); int QualityGradeNameLength = strQualityName.IndexOf("\0"); //add by xcw 20201102 if (QualityGradeNameLength == -1) { QualityGradeNameLength = strQualityName.Length; } strMixName = strSizeName.Substring(0, strSizeName.IndexOf("\0")) + "." + strQualityName.Substring(0, QualityGradeNameLength); m_Sheet.Cells[i * dataInterfaceExcel.WeightOrSizeGradeSum + j + startrow, 1] = strMixName; //等级名称 m_Sheet.Cells[i * dataInterfaceExcel.WeightOrSizeGradeSum + j + startrow, 2] = dataInterfaceExcel.IoStStGradeInfo.grades[i * ConstPreDefine.MAX_SIZE_GRADE_NUM + j].nMinSize.ToString(); //尺寸/重量 m_Sheet.Cells[i * dataInterfaceExcel.WeightOrSizeGradeSum + j + startrow, 3] = dataInterfaceExcel.IoStStatistics.nGradeCount[i * ConstPreDefine.MAX_SIZE_GRADE_NUM + j].ToString(); //等级个数 //个数百分比 if (uSumValue == 0) { m_Sheet.Cells[i * dataInterfaceExcel.WeightOrSizeGradeSum + j + startrow, 4] = "0.00%"; } else { m_Sheet.Cells[i * dataInterfaceExcel.WeightOrSizeGradeSum + j + startrow, 4] = ((double)dataInterfaceExcel.IoStStatistics.nGradeCount[i * ConstPreDefine.MAX_SIZE_GRADE_NUM + j] / uSumValue).ToString("0.00%"); } m_Sheet.Cells[i * dataInterfaceExcel.WeightOrSizeGradeSum + j + startrow, 5] = (dataInterfaceExcel.IoStStatistics.nWeightGradeCount[i * ConstPreDefine.MAX_SIZE_GRADE_NUM + j] / 1000.0).ToString("#0.0").ToString();//等级重量 //重量百分比 if (uSumWeightValue == 0) { m_Sheet.Cells[i * dataInterfaceExcel.WeightOrSizeGradeSum + j + startrow, 6] = "0.00%"; } else { m_Sheet.Cells[i * dataInterfaceExcel.WeightOrSizeGradeSum + j + startrow, 6] = ((double)dataInterfaceExcel.IoStStatistics.nWeightGradeCount[i * ConstPreDefine.MAX_SIZE_GRADE_NUM + j] / uSumWeightValue).ToString("0.00%"); } m_Sheet.Cells[i * dataInterfaceExcel.WeightOrSizeGradeSum + j + startrow, 7] = dataInterfaceExcel.IoStStatistics.nBoxGradeCount[i * ConstPreDefine.MAX_SIZE_GRADE_NUM + j].ToString();//箱数 //箱数百分比 if (uSumBoxValue == 0) { m_Sheet.Cells[i * dataInterfaceExcel.WeightOrSizeGradeSum + j + startrow, 8] = "0.00%"; } else { m_Sheet.Cells[i * dataInterfaceExcel.WeightOrSizeGradeSum + j + startrow, 8] = ((double)dataInterfaceExcel.IoStStatistics.nBoxGradeCount[i * ConstPreDefine.MAX_SIZE_GRADE_NUM + j] / uSumBoxValue).ToString("0.00%"); } } } } #endregion } catch (Exception ex) { Trace.WriteLine("ExcelReportFunc中函数备份设置FillTableData出错" + ex); #if REALEASE GlobalDataInterface.WriteErrorInfo("ExcelReportFunc中函数备份设置FillTableData出错" + ex); #endif } }
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()); } }