/// <summary> /// 保存事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSave_Click(object sender, EventArgs e) { try { if (m_strDJZTFlag == "已确认") { return; } BASE_Storage storageInfo_Out = UniversalFunction.GetStorageInfo(cmbOutStorage.Text); BASE_Storage storageInfo_In = UniversalFunction.GetStorageInfo(cmbInStorage.Text); if (storageInfo_In.StorageID == storageInfo_Out.StorageID) { throw new Exception("【入库库房】与【出库库房】是同一库房,无法操作"); } if (storageInfo_In.ZeroCostFlag != storageInfo_Out.ZeroCostFlag) { throw new Exception("【入库库房】与【出库库房】财务结算属性不一致,不能相互调拨"); } DataTable dt = (DataTable)dgv_Main.DataSource; m_billInfoLnq.ID = m_intDJID; m_billInfoLnq.DJH = txtSellID.Text; m_billInfoLnq.LRRY = BasicInfo.LoginID; m_billInfoLnq.LRRQ = ServerTime.Time; m_billInfoLnq.Price = Convert.ToDecimal(txtPrice.Text); m_billInfoLnq.Remark = txtRemarkAll.Text; m_billInfoLnq.OutStoreRoom = storageInfo_Out.StorageID; m_billInfoLnq.InStoreRoom = storageInfo_In.StorageID; m_serverCannibalize.SaveBill(dt, m_billInfoLnq); m_billMessageServer.DestroyMessage(txtSellID.Text); m_billMessageServer.SendNewFlowMessage(txtSellID.Text, string.Format("{0} 号库房调拨单,请主管审核", txtSellID.Text), BillFlowMessage_ReceivedUserType.角色, m_billMessageServer.GetSuperior(CE_RoleStyleType.级领导, BasicInfo.LoginID)); MessageBox.Show("保存成功", "提示"); txtSellID.Tag = null; this.Close(); } catch (Exception ex) { MessageDialog.ShowErrorMessage(ex.Message); return; } }
/// <summary> /// 添加库房信息 /// </summary> /// <param name="stroageID">库房ID</param> /// <param name="stroageName">库房名称</param> /// <param name="error">出错时返回错误信息,无错时返回null</param> /// <returns>添加成功返回True,添加失败返回False</returns> public bool AddStorage(string stroageID, string stroageName, out string error) { try { DepotManagementDataContext dataContxt = CommentParameter.DepotDataContext; error = null; BASE_Storage lnqStroage = new BASE_Storage(); lnqStroage.StorageID = stroageID; lnqStroage.StorageName = stroageName; lnqStroage.StorageLv = 1; dataContxt.BASE_Storage.InsertOnSubmit(lnqStroage); dataContxt.SubmitChanges(); return(true); } catch (Exception ex) { error = ex.Message; return(false); } }
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; } }
/// <summary> /// 仓管确认事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnAffirm_Click(object sender, EventArgs e) { if (m_intDJID != 0 && m_strDJZTFlag == "已批准") { DataTable dtTemp = (DataTable)dgv_Main.DataSource; BASE_Storage storageInfo_Out = UniversalFunction.GetStorageInfo(cmbOutStorage.Text); BASE_Storage storageInfo_In = UniversalFunction.GetStorageInfo(cmbInStorage.Text); if (storageInfo_In.StorageID == storageInfo_Out.StorageID) { throw new Exception("【入库库房】与【出库库房】是同一库房,无法操作"); } if (storageInfo_In.ZeroCostFlag != storageInfo_Out.ZeroCostFlag) { throw new Exception("【入库库房】与【出库库房】财务结算属性不一致,不能相互调拨"); } for (int i = 0; i < dtTemp.Rows.Count; i++) { if (!m_serverProductCode.IsFitCount(Convert.ToInt32(dtTemp.Rows[i]["GoodsID"]), Convert.ToInt32(dtTemp.Rows[i]["Count"]), m_strDJH)) { MessageBox.Show("请对产品设置流水号,并保证产品数量与流水号数一致", "提示"); return; } } if (m_serverCannibalize.AffirmBill(m_intDJID, out m_err)) { #region 发送知会消息 List <string> noticeRoles = new List <string>(); string strDept = m_serverDepartment.GetDeptInfoFromPersonnelInfo( m_serverCannibalize.GetBill(m_intDJID).LRRY).Rows[0]["DepartmentCode"].ToString(); noticeRoles.AddRange(m_billMessageServer.GetDeptDirectorRoleName(strDept)); noticeRoles.Add(m_billMessageServer.GetRoleStringForStorage(cmbOutStorage.Text).ToString()); noticeRoles.Add(m_billMessageServer.GetRoleStringForStorage(cmbInStorage.Text).ToString()); noticeRoles.Add(CE_RoleEnum.财务主管.ToString()); noticeRoles.Add(CE_RoleEnum.会计.ToString()); m_billMessageServer.EndFlowMessage(txtSellID.Text, string.Format("{0} 号库房调拨单已经处理完毕", txtSellID.Text), noticeRoles, null); #endregion 发送知会消息 MessageBox.Show("确认完毕!", "提示"); m_billNoControl.UseBill(txtSellID.Text); this.Close(); } else { MessageDialog.ShowErrorMessage(m_err); return; } } else if (m_intDJID != 0) { MessageBox.Show("请重新确认单据状态!", "提示"); return; } else { MessageBox.Show("单据ID无效,请重新确认!", "提示"); return; } }
/// <summary> /// 变更金额_入库明细 /// </summary> /// <param name="dataContxt">数据上下文</param> /// <param name="detailInfo">结算单明细</param> void ChangePrice_S_InDepotDetailBill(DepotManagementDataContext dataContxt, View_Business_Settlement_ProcurementStatementDetail detailInfo) { DateTime dtStart = new DateTime(); DateTime dtEnd = new DateTime(); Business_Settlement_ProcurementStatement statement = GetSingleBillInfo(detailInfo.单据号); //获得当前日期的月结起始日期与结束日期 ServerTime.GetMonthlyBalance(ServerTime.Time, out dtStart, out dtEnd); var varInDepotBill = from b in dataContxt.S_InDepotDetailBill where b.GoodsID == detailInfo.物品ID && b.InDepotBillID == detailInfo.入库单号 && b.BatchNo == detailInfo.批次号 select b; if (varInDepotBill.Count() == 1) { S_InDepotDetailBill lnqInDepotBill = varInDepotBill.Single(); var varData1 = from a in dataContxt.BASE_Storage where a.StorageID == lnqInDepotBill.StorageID select a; if (varData1.Count() == 1) { BASE_Storage storageInfo = varData1.Single(); if (!storageInfo.FinancialAccountingFlag) { throw new Exception("单据号【" + lnqInDepotBill.InDepotBillID + "】的入库库房不在财务核算范围之内"); } } else { throw new Exception("单据号【" + lnqInDepotBill.InDepotBillID + "】的入库库房不存在或者重复"); } if (statement.BillType == CE_ProcurementStatementBillTypeEnum.委托加工物资.ToString()) { lnqInDepotBill.InvoiceUnitPrice = detailInfo.发票单价 + (decimal)detailInfo.单件委托材料; lnqInDepotBill.InvoicePrice = Math.Round((decimal)lnqInDepotBill.InvoiceUnitPrice * (decimal)lnqInDepotBill.InDepotCount, 2); } else { lnqInDepotBill.InvoiceUnitPrice = detailInfo.发票单价; lnqInDepotBill.InvoicePrice = detailInfo.发票金额; } if (lnqInDepotBill.FactPrice != detailInfo.发票金额) { //当查询的记录不在当月的结算日期范围内,插入红冲单据与对冲单据 if (lnqInDepotBill.BillTime < dtStart || lnqInDepotBill.BillTime > dtEnd) { var varDetail = from d in dataContxt.S_InDepotDetailBill where d.GoodsID == detailInfo.物品ID && d.InDepotBillID.Contains(detailInfo.入库单号) && d.BatchNo == detailInfo.批次号 && d.BillTime >= dtStart && d.BillTime <= dtEnd select d; //判断是否已经在当前结算日期范围内插入了红冲与对冲数据 if (varDetail.Count() != 0) { foreach (var item in varDetail) { //针对已经插入的对冲数据进行修改 if (item.InDepotBillID.Contains("(对冲单据)")) { if (statement.BillType == CE_ProcurementStatementBillTypeEnum.委托加工物资.ToString()) { item.FactUnitPrice = detailInfo.发票单价 + (decimal)detailInfo.单件委托材料; item.FactPrice = Math.Round((decimal)item.FactUnitPrice * (decimal)item.InDepotCount, 2); } else { item.FactUnitPrice = detailInfo.发票单价; item.FactPrice = detailInfo.发票金额; } } } }//对没有插入的红冲与对冲的记录进行插入 else { //插一条原始的负记录(红冲单据) S_InDepotDetailBill lnqOldInDepotBill = new S_InDepotDetailBill(); lnqOldInDepotBill.ID = Guid.NewGuid(); lnqOldInDepotBill.InDepotBillID = lnqInDepotBill.InDepotBillID + "(红冲单据)"; lnqOldInDepotBill.BatchNo = lnqInDepotBill.BatchNo; lnqOldInDepotBill.BillTime = ServerTime.Time; lnqOldInDepotBill.Department = lnqInDepotBill.Department; lnqOldInDepotBill.FactUnitPrice = lnqInDepotBill.FactUnitPrice; lnqOldInDepotBill.FactPrice = -lnqInDepotBill.FactPrice; lnqOldInDepotBill.FillInPersonnel = lnqInDepotBill.FillInPersonnel; lnqOldInDepotBill.GoodsID = lnqInDepotBill.GoodsID; lnqOldInDepotBill.InDepotCount = -lnqInDepotBill.InDepotCount; lnqOldInDepotBill.Price = -lnqInDepotBill.Price; lnqOldInDepotBill.OperationType = (int)GlobalObject.CE_SubsidiaryOperationType.财务红冲; lnqOldInDepotBill.Provider = lnqInDepotBill.Provider; lnqOldInDepotBill.Remark = lnqInDepotBill.Remark; lnqOldInDepotBill.StorageID = lnqInDepotBill.StorageID; lnqOldInDepotBill.UnitPrice = lnqInDepotBill.UnitPrice; lnqOldInDepotBill.FillInDate = lnqInDepotBill.FillInDate; lnqOldInDepotBill.AffrimPersonnel = lnqInDepotBill.AffrimPersonnel; IFinancialDetailManagement serverDetail = ServerModule.ServerModuleFactory.GetServerModule <IFinancialDetailManagement>(); serverDetail.ProcessInDepotDetail(dataContxt, lnqOldInDepotBill, null); //插一条新的正记录(对冲单据) S_InDepotDetailBill lnqNewInDepotBill = new S_InDepotDetailBill(); lnqNewInDepotBill.ID = Guid.NewGuid(); lnqNewInDepotBill.InDepotBillID = lnqInDepotBill.InDepotBillID + "(对冲单据)"; lnqNewInDepotBill.BatchNo = lnqInDepotBill.BatchNo; lnqNewInDepotBill.BillTime = ServerTime.Time; lnqNewInDepotBill.Department = lnqInDepotBill.Department; lnqNewInDepotBill.InDepotCount = lnqInDepotBill.InDepotCount; if (statement.BillType == CE_ProcurementStatementBillTypeEnum.委托加工物资.ToString()) { lnqNewInDepotBill.FactUnitPrice = detailInfo.发票单价 + (decimal)detailInfo.单件委托材料; lnqNewInDepotBill.FactPrice = Math.Round((decimal)lnqNewInDepotBill.FactUnitPrice * (decimal)lnqNewInDepotBill.InDepotCount, 2); } else { lnqNewInDepotBill.FactUnitPrice = detailInfo.发票单价; lnqNewInDepotBill.FactPrice = detailInfo.发票金额; } lnqNewInDepotBill.FillInPersonnel = lnqInDepotBill.FillInPersonnel; lnqNewInDepotBill.GoodsID = lnqInDepotBill.GoodsID; lnqNewInDepotBill.Price = lnqInDepotBill.Price; lnqNewInDepotBill.OperationType = (int)GlobalObject.CE_SubsidiaryOperationType.财务对冲; lnqNewInDepotBill.Provider = lnqInDepotBill.Provider; lnqNewInDepotBill.Remark = lnqInDepotBill.Remark; lnqNewInDepotBill.StorageID = lnqInDepotBill.StorageID; lnqNewInDepotBill.UnitPrice = lnqInDepotBill.UnitPrice; lnqNewInDepotBill.FillInDate = lnqInDepotBill.FillInDate; lnqNewInDepotBill.AffrimPersonnel = lnqInDepotBill.AffrimPersonnel; serverDetail.ProcessInDepotDetail(dataContxt, lnqNewInDepotBill, null); } } else { if (statement.BillType == CE_ProcurementStatementBillTypeEnum.委托加工物资.ToString()) { lnqInDepotBill.FactUnitPrice = detailInfo.发票单价 + (decimal)detailInfo.单件委托材料; lnqInDepotBill.FactPrice = Math.Round((decimal)lnqInDepotBill.InvoiceUnitPrice * (decimal)lnqInDepotBill.InDepotCount, 2); } else { lnqInDepotBill.FactUnitPrice = detailInfo.发票单价; lnqInDepotBill.FactPrice = detailInfo.发票金额; } } } dataContxt.SubmitChanges(); } }
public void Operation_StorageInfo(CE_OperatorMode mode, BASE_Storage info, Business_Base_FinanceRelationInfo_Subjects_Storage info_Relation) { DepotManagementDataContext ctx = CommentParameter.DepotDataContext; var varData = from a in ctx.BASE_Storage where a.StorageID == info.StorageID select a; switch (mode) { case CE_OperatorMode.添加: if (varData.Count() > 0) { throw new Exception("【代码】:" + info.StorageID + "重复, 无法录入"); } ctx.BASE_Storage.InsertOnSubmit(info); ctx.Business_Base_FinanceRelationInfo_Subjects_Storage.InsertOnSubmit(info_Relation); break; case CE_OperatorMode.修改: if (varData.Count() != 1) { throw new Exception("【代码】:" + info.StorageID + "为空或者不唯一, 无法录入"); } BASE_Storage temp = varData.Single(); temp.StorageName = info.StorageName; temp.StorageLv = 1; temp.Aftermarket = info.Aftermarket; temp.AftermarketParts = info.AftermarketParts; temp.AssemblyWarehouse = info.AssemblyWarehouse; temp.FinancialAccountingFlag = info.FinancialAccountingFlag; temp.PartInPlanCalculation = info.PartInPlanCalculation; temp.SingleFinancialAccountingFlag = info.SingleFinancialAccountingFlag; temp.WorkShopCurrentAccount = temp.WorkShopCurrentAccount; temp.ZeroCostFlag = temp.ZeroCostFlag; var varDataX = from a in ctx.Business_Base_FinanceRelationInfo_Subjects_Storage where a.StorageID == info.StorageID select a; ctx.Business_Base_FinanceRelationInfo_Subjects_Storage.DeleteAllOnSubmit(varDataX); ctx.Business_Base_FinanceRelationInfo_Subjects_Storage.InsertOnSubmit(info_Relation); break; case CE_OperatorMode.除: var varData1 = from a in ctx.S_Stock where a.StorageID == info.StorageID select a; var varData2 = from a in ctx.S_InDepotDetailBill where a.StorageID == info.StorageID select a; var varData3 = from a in ctx.S_FetchGoodsDetailBill where a.StorageID == info.StorageID select a; if (varData1.Count() > 0 || varData2.Count() > 0 || varData3.Count() > 0) { throw new Exception("已产生业务,无法删除"); } ctx.BASE_Storage.DeleteAllOnSubmit(varData); varDataX = from a in ctx.Business_Base_FinanceRelationInfo_Subjects_Storage where a.StorageID == info.StorageID select a; ctx.Business_Base_FinanceRelationInfo_Subjects_Storage.DeleteAllOnSubmit(varDataX); break; default: break; } ctx.SubmitChanges(); }