public void Operation_BudgetProject(CE_OperatorMode mode, Business_Base_Finance_Budget_ProjectItem info) { DepotManagementDataContext ctx = CommentParameter.DepotDataContext; var varData = from a in ctx.Business_Base_Finance_Budget_ProjectItem where a.ProjectID == info.ProjectID select a; switch (mode) { case CE_OperatorMode.添加: ctx.Business_Base_Finance_Budget_ProjectItem.InsertOnSubmit(info); break; case CE_OperatorMode.修改: if (varData.Count() != 1) { throw new Exception("【代码】:" + info.ProjectID + "为空或者不唯一, 无法录入"); } Business_Base_Finance_Budget_ProjectItem temp = varData.Single(); temp.ProjectName = info.ProjectName; temp.PerentProjectID = info.PerentProjectID; break; case CE_OperatorMode.除: if (varData.Count() != 1) { throw new Exception("【代码】:" + info.ProjectID + "为空或者不唯一, 无法录入"); } Business_Base_Finance_Budget_ProjectItem temp1 = varData.Single(); temp1.IsDisable = true; break; default: break; } ctx.SubmitChanges(); }
void OperationInfo(CE_OperatorMode mode, Control cl) { try { if (GlobalObject.GeneralFunction.ParentControlIsExist <TabPage>(cl, tpSubjects.Name)) { if (txtSubjects_Code.Text.Trim().Length == 0) { MessageDialog.ShowPromptMessage("请录入【科目代码】"); return; } if (txtSubjects_Name.Text.Trim().Length == 0) { MessageDialog.ShowPromptMessage("请录入【科目名称】"); return; } if (txtSubjects_Parent.Text.Trim().Length == 0) { MessageDialog.ShowPromptMessage("请选择【父级科目】"); return; } Business_Base_FinanceSubjects subjects = new Business_Base_FinanceSubjects(); subjects.SubjectsName = txtSubjects_Name.Text; subjects.SubjectsCode = txtSubjects_Code.Text; subjects.ParentCode = txtSubjects_Parent.Tag == null ? "" : txtSubjects_Parent.Tag.ToString(); _serviceParametersSetting.Operation_FinanceSubjects(mode, subjects); } else if (GlobalObject.GeneralFunction.ParentControlIsExist <TabPage>(cl, tpPurpose.Name)) { if (txtPurpose_Code.Text.Trim().Length == 0) { MessageDialog.ShowPromptMessage("请输入【用途代码】"); return; } if (txtPurpose_Name.Text.Trim().Length == 0) { MessageDialog.ShowPromptMessage("请输入【用途名称】"); return; } if (txtPurpose_ParentName.Text.Trim().Length == 0) { MessageDialog.ShowPromptMessage("请选择【父级用途】"); return; } if (txtPurpose_Parent.Text.Trim().Length >= txtPurpose_Code.Text.Trim().Length || txtPurpose_Code.Text.Trim().Substring(0, txtPurpose_Parent.Text.Trim().Length) != txtPurpose_Parent.Text.ToString()) { MessageDialog.ShowPromptMessage("【用途代码】中前面字符未包含【父级用途】代码,例如:【父级代码】:99,则【用途代码】应为:9901、 9902等等"); return; } BASE_MaterialRequisitionPurpose purpose = new BASE_MaterialRequisitionPurpose(); purpose.Inventory = chb_Inventory.Checked; purpose.Code = txtPurpose_Code.Text; purpose.IsDisable = true; purpose.IsEnd = true; purpose.Purpose = txtPurpose_Name.Text; purpose.DestructiveInspection = chb_DestructiveInspection.Checked; purpose.ThreeOutSideFit = chb_ThreeOutSideFit.Checked; purpose.ThreeOutSideRepair = chb_ThreeOutSideRepair.Checked; purpose.ApplicableDepartment = txtApplicableDepartment.Tag == null ? "" : txtApplicableDepartment.Tag.ToString(); purpose.RemindWord = txtRemindWord.Text; _serviceParametersSetting.Operation_MaterialRequisitionPurpose(mode, purpose, txtPurpose_Parent.Text.Trim()); } else if (GlobalObject.GeneralFunction.ParentControlIsExist <TabPage>(cl, tpStorage.Name)) { if (txtStorage_Code.Text.Trim().Length == 0) { MessageDialog.ShowPromptMessage("请录入【库房代码】"); return; } if (txtStorage_Name.Text.Trim().Length == 0) { MessageDialog.ShowPromptMessage("请录入【库房名称】"); return; } if (txtStorage_Subjects.Text.Trim().Length == 0) { MessageDialog.ShowPromptMessage("请选择【所属科目】"); return; } BASE_Storage storage = new BASE_Storage(); storage.Aftermarket = chbAftermarket.Checked; storage.AftermarketParts = chbAftermarketParts.Checked; storage.AssemblyWarehouse = chbAssemblyWarehouse.Checked; storage.FinancialAccountingFlag = chbFinancialAccountingFlag.Checked; storage.PartInPlanCalculation = chbPartInPlanCalculation.Checked; storage.SingleFinancialAccountingFlag = chbSingleFinancialAccountingFlag.Checked; storage.WorkShopCurrentAccount = chbWorkShopCurrentAccount.Checked; storage.ZeroCostFlag = chbZeroCostFlag.Checked; storage.StorageID = txtStorage_Code.Text; storage.StorageName = txtStorage_Name.Text; storage.StorageLv = 1; Business_Base_FinanceRelationInfo_Subjects_Storage storageSubjects = new Business_Base_FinanceRelationInfo_Subjects_Storage(); storageSubjects.StorageID = txtStorage_Code.Text; storageSubjects.SubjectsCode = txtStorage_Subjects.Tag == null ? "" : txtStorage_Subjects.Tag.ToString(); _serviceParametersSetting.Operation_StorageInfo(mode, storage, storageSubjects); } else if (GlobalObject.GeneralFunction.ParentControlIsExist <TabPage>(cl, tpSubjectsPurpose.Name)) { if (txtSubjectsPurpose_Code.Text.Trim().Length == 0) { MessageDialog.ShowPromptMessage("请选择【领料用途】"); return; } if (txtSubjectsPurpose_Subjects.Text.Trim().Length == 0) { MessageDialog.ShowPromptMessage("请选择【所属科目】"); return; } Business_Base_FinanceRelationInfo_Subjects_Purpose purposeSubjects = new Business_Base_FinanceRelationInfo_Subjects_Purpose(); purposeSubjects.PurposeCode = txtSubjectsPurpose_Code.Text; purposeSubjects.SubjectsCode = txtSubjectsPurpose_Subjects.Tag == null ? "" : txtSubjectsPurpose_Subjects.Tag.ToString(); _serviceParametersSetting.Operation_SubjectsPurpose(mode, purposeSubjects); } else if (GlobalObject.GeneralFunction.ParentControlIsExist <TabPage>(cl, tpBudgetProject.Name)) { if (txtBudgetProject.Text.Trim().Length == 0) { MessageDialog.ShowPromptMessage("请录入【科目名称】"); return; } if (txtBudgetProject_Parent.Text.Trim().Length == 0) { MessageDialog.ShowPromptMessage("请选择【父级科目】"); return; } if (txtBudgetProject_Code.Text.Trim().Length == 0) { MessageDialog.ShowPromptMessage("请录入【科目代码】"); return; } Business_Base_Finance_Budget_ProjectItem project = new Business_Base_Finance_Budget_ProjectItem(); project.PerentProjectID = txtBudgetProject_Parent.Tag == null ? "" : txtBudgetProject_Parent.Tag.ToString(); project.ProjectName = txtBudgetProject.Text; project.ProjectID = txtBudgetProject_Code.Text; _serviceParametersSetting.Operation_BudgetProject(mode, project); } MessageDialog.ShowPromptMessage("操作成功"); ShowInfo(); } catch (Exception ex) { MessageDialog.ShowPromptMessage(ex.Message); return; } }
private void customContextMenuStrip_Edit1__InputEvent(DataTable dtTemp) { DataTable dtResult = dtTemp.Clone(); foreach (DataRow dr in dtTemp.Rows) { if (dr["科目ID"] == null || GlobalObject.GeneralFunction.IsNullOrEmpty(dr["科目ID"].ToString())) { Business_Base_Finance_Budget_ProjectItem budget = _ServiceBasic.GetBudgetProjectInfo(dr["父级科目"] == null ? null : dr["父级科目"].ToString(), dr["预算科目"] == null ? null : dr["预算科目"].ToString()); if (budget != null && !GlobalObject.GeneralFunction.IsNullOrEmpty(budget.ProjectID)) { dr["科目ID"] = budget.ProjectID; } } if (dr["科目ID"] != null && !GlobalObject.GeneralFunction.IsNullOrEmpty(dr["科目ID"].ToString())) { DataRow drNew = dtResult.NewRow(); drNew["父级科目"] = dr["父级科目"]; drNew["预算科目"] = dr["预算科目"]; drNew["1月"] = dr["1月"] == null || GlobalObject.GeneralFunction.IsNullOrEmpty(dr["1月"].ToString()) ? 0 : Convert.ToDecimal(dr["1月"]); drNew["2月"] = dr["2月"] == null || GlobalObject.GeneralFunction.IsNullOrEmpty(dr["2月"].ToString()) ? 0 : Convert.ToDecimal(dr["2月"]); drNew["3月"] = dr["3月"] == null || GlobalObject.GeneralFunction.IsNullOrEmpty(dr["3月"].ToString()) ? 0 : Convert.ToDecimal(dr["3月"]); drNew["4月"] = dr["4月"] == null || GlobalObject.GeneralFunction.IsNullOrEmpty(dr["4月"].ToString()) ? 0 : Convert.ToDecimal(dr["4月"]); drNew["5月"] = dr["5月"] == null || GlobalObject.GeneralFunction.IsNullOrEmpty(dr["5月"].ToString()) ? 0 : Convert.ToDecimal(dr["5月"]); drNew["6月"] = dr["6月"] == null || GlobalObject.GeneralFunction.IsNullOrEmpty(dr["6月"].ToString()) ? 0 : Convert.ToDecimal(dr["6月"]); drNew["7月"] = dr["7月"] == null || GlobalObject.GeneralFunction.IsNullOrEmpty(dr["7月"].ToString()) ? 0 : Convert.ToDecimal(dr["7月"]); drNew["8月"] = dr["8月"] == null || GlobalObject.GeneralFunction.IsNullOrEmpty(dr["8月"].ToString()) ? 0 : Convert.ToDecimal(dr["8月"]); drNew["9月"] = dr["9月"] == null || GlobalObject.GeneralFunction.IsNullOrEmpty(dr["9月"].ToString()) ? 0 : Convert.ToDecimal(dr["9月"]); drNew["10月"] = dr["10月"] == null || GlobalObject.GeneralFunction.IsNullOrEmpty(dr["10月"].ToString()) ? 0 : Convert.ToDecimal(dr["10月"]); drNew["11月"] = dr["11月"] == null || GlobalObject.GeneralFunction.IsNullOrEmpty(dr["11月"].ToString()) ? 0 : Convert.ToDecimal(dr["11月"]); drNew["12月"] = dr["12月"] == null || GlobalObject.GeneralFunction.IsNullOrEmpty(dr["12月"].ToString()) ? 0 : Convert.ToDecimal(dr["12月"]); drNew["合计"] = Convert.ToDecimal(drNew["1月"]) + Convert.ToDecimal(drNew["2月"]) + Convert.ToDecimal(drNew["3月"]) + Convert.ToDecimal(drNew["4月"]) + Convert.ToDecimal(drNew["5月"]) + Convert.ToDecimal(drNew["6月"]) + Convert.ToDecimal(drNew["7月"]) + Convert.ToDecimal(drNew["8月"]) + Convert.ToDecimal(drNew["9月"]) + Convert.ToDecimal(drNew["10月"]) + Convert.ToDecimal(drNew["11月"]) + Convert.ToDecimal(drNew["12月"]); drNew["科目ID"] = dr["科目ID"]; dtResult.Rows.Add(drNew); } } DataRow drSum = dtResult.NewRow(); drSum["预算科目"] = "合计"; drSum["1月"] = GetSumPrice(dtResult, "1月"); drSum["2月"] = GetSumPrice(dtResult, "2月"); drSum["3月"] = GetSumPrice(dtResult, "3月"); drSum["4月"] = GetSumPrice(dtResult, "4月"); drSum["5月"] = GetSumPrice(dtResult, "5月"); drSum["6月"] = GetSumPrice(dtResult, "6月"); drSum["7月"] = GetSumPrice(dtResult, "7月"); drSum["8月"] = GetSumPrice(dtResult, "8月"); drSum["9月"] = GetSumPrice(dtResult, "9月"); drSum["10月"] = GetSumPrice(dtResult, "10月"); drSum["11月"] = GetSumPrice(dtResult, "11月"); drSum["12月"] = GetSumPrice(dtResult, "12月"); drSum["合计"] = GetSumPrice(dtResult, "合计"); dtResult.Rows.Add(drSum); RefreshDataGridView(dtResult); }