public void Operation_SubjectsPurpose(CE_OperatorMode mode, Business_Base_FinanceRelationInfo_Subjects_Purpose info) { DepotManagementDataContext ctx = CommentParameter.DepotDataContext; var varData = from a in ctx.Business_Base_FinanceRelationInfo_Subjects_Purpose where a.SubjectsCode == info.SubjectsCode && a.PurposeCode == info.PurposeCode select a; switch (mode) { case CE_OperatorMode.添加: if (varData.Count() > 0) { throw new Exception("【代码】:" + info.SubjectsCode + "重复, 无法录入"); } ctx.Business_Base_FinanceRelationInfo_Subjects_Purpose.InsertOnSubmit(info); break; case CE_OperatorMode.除: ctx.Business_Base_FinanceRelationInfo_Subjects_Purpose.DeleteAllOnSubmit(varData); 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; } }