/// <summary> /// 获得信息 /// </summary> void GetMessage() { m_lnqBill = new S_MusterUseBill(); m_lnqBill.DJH = txtDJH.Text; m_lnqBill.DJZT = lbDJZT.Text; m_lnqBill.StorageID = UniversalFunction.GetStorageID(cmbStorage.Text); }
private void 提交单据ToolStripMenuItem_Click(object sender, EventArgs e) { m_lnqBill = m_serverUse.GetBill(txtDJH.Text); if (m_lnqBill != null) { if (m_lnqBill.DJZT == "单据已完成" || m_lnqBill.DJZT == "单据已报废") { MessageDialog.ShowPromptMessage("请重新确认单据状态"); return; } } if (txtPurpose.Text.Trim() == "" || txtPurpose.Tag == null || txtPurpose.Tag.ToString() == "" || txtPurpose.Tag.ToString() == "-1") { MessageDialog.ShowPromptMessage("请选择用途"); return; } if (lbDJZT.Text != "新建单据" && dataGridView1.CurrentRow.Cells["申请人"].Value.ToString() != BasicInfo.LoginName) { MessageDialog.ShowPromptMessage("您不是此单据的编制人,请重新确认"); return; } if (!m_serverUse.SaveBill(txtDJH.Text, UniversalFunction.GetStorageID(cmbStorage.Text), txtPurpose.Tag.ToString(), (DataTable)dataGridView2.DataSource, out m_err)) { MessageDialog.ShowPromptMessage(m_err); return; } else { MessageDialog.ShowPromptMessage("提交成功"); m_editFlag = false; m_msgPromulgator.DestroyMessage(txtDJH.Text); m_msgPromulgator.SendNewFlowMessage(txtDJH.Text, string.Format("{0} 号样品耗用单,请主管审核", txtDJH.Text), BillFlowMessage_ReceivedUserType.角色, m_billMessageServer.GetSuperior(CE_RoleStyleType.级领导, BasicInfo.LoginID)); } m_lnqBill = m_serverUse.GetBill(txtDJH.Text); RefreshDataGirdView(m_serverUse.GetAllBill()); PositioningRecord(m_lnqBill.DJH); }
///// <summary> ///// 根据单据信息操作账务信息与库存信息 ///// </summary> ///// <param name="dataContext">数据上下文</param> ///// <param name="billInfo">单据信息</param> //void OpertaionDetailAndStock(DepotManagementDataContext dataContext, S_MusterUseBill billInfo) //{ // IFinancialDetailManagement serverDetail = // ServerModule.ServerModuleFactory.GetServerModule<IFinancialDetailManagement>(); // var varData = from a in dataContext.S_MusterUseList // where a.DJH == billInfo.DJH // select a; // foreach (S_MusterUseList item in varData) // { // if (!IsCheck(billInfo, item)) // { // throw new Exception("库存数量不足"); // } // S_FetchGoodsDetailBill detailInfo = AssignDetailInfo(dataContext, billInfo, item); // if (detailInfo == null) // { // throw new Exception("获取账务信息或者库存信息失败"); // } // serverDetail.ProcessFetchGoodsDetail(dataContext, detailInfo, null); // } //} ///// <summary> ///// 获得供应商 ///// </summary> ///// <param name="listInfo">耗用单明细信息</param> ///// <returns>返回样品信息</returns> //string GetProvider(S_MusterUseList listInfo) //{ // DepotManagementDataContext dataContext = CommentParameter.DepotDataContext; // var varData = from a in dataContext.S_MusterAffirmBill // where a.GoodsID == listInfo.GoodsID // && a.BatchNo == listInfo.BatchNo // select a; // if (varData.Count() == 1) // { // return varData.Single().Provider; // } // var varData1 = from a in dataContext.Business_Sample_ConfirmTheApplication // where a.Purchase_GoodsID == listInfo.GoodsID // && a.Purchase_BatchNo == listInfo.BatchNo // select a; // if (varData1.Count() == 1) // { // return varData1.Single().Purchase_Provider; // } // return ""; //} ///// <summary> ///// 赋值账务信息 ///// </summary> ///// <param name="context">数据上下文</param> ///// <param name="billInfo">单据信息</param> ///// <param name="item">明细信息</param> ///// <returns>返回账务信息对象</returns> //S_FetchGoodsDetailBill AssignDetailInfo(DepotManagementDataContext context, S_MusterUseBill billInfo, S_MusterUseList item) //{ // var varMusterStock = from a in context.S_MusterStock // where a.GoodsID == item.GoodsID // && a.BatchNo == item.BatchNo // && a.StrorageID == billInfo.StorageID // select a; // if (varMusterStock.Count() != 1) // { // throw new Exception( "此仓库" + UniversalFunction.GetGoodsMessage((int)item.GoodsID) + "【批次号】:" // + item.BatchNo + "库存不足"); // } // else // { // S_MusterStock lnqMusterStock = varMusterStock.Single(); // if (Convert.ToDecimal(lnqMusterStock.Count) < Convert.ToDecimal(item.Count)) // { // throw new Exception("批次号为 【" + item.BatchNo + "】的物品 库存不足,请重新确认数量!"); // } // lnqMusterStock.Count = Convert.ToDecimal(lnqMusterStock.Count) - Convert.ToDecimal(item.Count); // } // S_FetchGoodsDetailBill detailBill = new S_FetchGoodsDetailBill(); // detailBill.ID = Guid.NewGuid(); // detailBill.FetchBIllID = billInfo.DJH; // detailBill.BillTime = ServerTime.Time; // detailBill.FetchCount = item.Count; // detailBill.GoodsID = (int)item.GoodsID; // detailBill.BatchNo = item.BatchNo; // detailBill.UnitPrice = 0; // detailBill.Price = detailBill.UnitPrice * (decimal)detailBill.FetchCount; // IMusterAffirmBill serverMuster = ServerModule.ServerModuleFactory.GetServerModule<IMusterAffirmBill>(); // detailBill.Provider = GetProvider(item); // detailBill.FillInPersonnel = billInfo.SQR; // detailBill.FinanceSignatory = null; // detailBill.DepartDirector = billInfo.SHR; // detailBill.DepotManager = billInfo.KFR; // detailBill.OperationType = (int)CE_SubsidiaryOperationType.样品耗用; // detailBill.Remark = item.Remark; // detailBill.FillInDate = billInfo.SQRQ; // detailBill.StorageID = billInfo.StorageID; // return detailBill; //} ///// <summary> ///// 获得批次号的样品库库存数 ///// </summary> ///// <param name="goodsID">物品ID</param> ///// <param name="batchNo">批次号</param> ///// <returns>返回获得的库存数</returns> //decimal GetMusterBatchNoStock(int goodsID,string batchNo) //{ // DepotManagementDataContext ctx = CommentParameter.DepotDataContext; // var varStock = from a in ctx.S_MusterStock // where a.GoodsID == goodsID // && a.BatchNo == batchNo // select a; // if (varStock.Count() == 1) // { // var varData = from a in ctx.Business_Sample_ConfirmTheApplication // where a.Purchase_BatchNo == batchNo // && a.Purchase_GoodsID == goodsID // select a; // if (varData.Count() == 1) // { // if (varData.Single().Purchase_SampleType == "PPAP样件'") // { // if (varData.Single().SQE_SampleDisposeType_DisqualificationCount != null) // { // return (decimal)varStock.Single().Count - // (decimal)varData.Single().SQE_SampleDisposeType_DisqualificationCount; // } // } // else // { // if (varData.Single().Review_InspectResult_ReWork_DisqualificationCount != null) // { // return (decimal)varStock.Single().Count - // (decimal)varData.Single().Review_InspectResult_ReWork_DisqualificationCount; // } // } // } // return (decimal)varStock.Single().Count; // } // return 0; //} ///// <summary> ///// 检查是否可以出库 ///// </summary> ///// <param name="inMusterUse">单据信息</param> ///// <param name="listInfo">明细信息</param> ///// <returns>已经过检验返回True,未经过检验返回False</returns> //bool IsCheck(S_MusterUseBill inMusterUse, S_MusterUseList listInfo) //{ // try // { // DepotManagementDataContext ctx = CommentParameter.DepotDataContext; // var varStock = from a in ctx.S_MusterStock // where a.GoodsID == listInfo.GoodsID // && a.BatchNo == listInfo.BatchNo // && a.StrorageID == inMusterUse.StorageID // select a; // if (varStock.Count() != 1) // { // return false; // } // var varData = from a in ctx.S_MusterAffirmBill // where a.GoodsID == listInfo.GoodsID // && a.BatchNo == listInfo.BatchNo // && a.StorageID == inMusterUse.StorageID // select a; // if (varData.Count() == 1) // { // if ((decimal)varStock.Single().Count >= (decimal)listInfo.Count) // { // return true; // } // } // var varData1 = from a in ctx.Business_Sample_ConfirmTheApplication // join b in ctx.Flow_FlowBillData // on a.BillNo equals b.BillNo // where a.Purchase_GoodsID == listInfo.GoodsID // && a.Purchase_BatchNo == listInfo.BatchNo // && a.Purchase_StorageID == inMusterUse.StorageID // select new // { // Purchase_SampleType = a.Purchase_SampleType, // FlowID = b.FlowID, // Review_InspectResult_ReWork_QualificationCount = a.Review_InspectResult_ReWork_QualificationCount, // Review_InspectResult_ReWork_DisqualificationCount = a.Review_InspectResult_ReWork_DisqualificationCount, // SQE_SampleDisposeType_QualificationCount = a.SQE_SampleDisposeType_QualificationCount, // SQE_SampleDisposeType_DisqualificationCount = a.SQE_SampleDisposeType_DisqualificationCount // }; // if (varData1.Count() == 1) // { // if (varData1.Single().Purchase_SampleType == "PPAP样件") // { // if (varData1.Single().FlowID > 47) // { // if (varData1.Single().SQE_SampleDisposeType_QualificationCount != null) // { // if ((decimal)varStock.Single().Count - (decimal)varData1.Single().SQE_SampleDisposeType_DisqualificationCount // >= (decimal)listInfo.Count) // { // return true; // } // } // else // { // if ((decimal)varStock.Single().Count >= (decimal)listInfo.Count) // { // return true; // } // } // } // } // else // { // if (varData1.Single().FlowID > 46) // { // if (varData1.Single().Review_InspectResult_ReWork_QualificationCount != null) // { // if ((decimal)varStock.Single().Count - (decimal)varData1.Single().Review_InspectResult_ReWork_DisqualificationCount // >= (decimal)listInfo.Count) // { // return true; // } // } // else // { // if ((decimal)varStock.Single().Count >= (decimal)listInfo.Count) // { // return true; // } // } // } // } // } // return false; // } // catch (System.Exception ex) // { // throw new Exception(ex.Message); // } //} #endregion /// <summary> /// 报废单据 /// </summary> /// <param name="djh">样品耗用单单号</param> /// <param name="error">出错时返回错误信息,无错时返回null</param> /// <returns>报废成功返回True,报废失败返回False</returns> public bool ScarpBill(string djh, out string error) { try { error = null; DepotManagementDataContext dataContext = CommentParameter.DepotDataContext; var varData = from a in dataContext.S_MusterUseBill where a.DJH == djh select a; if (varData.Count() != 1) { error = "数据不唯一或者为空"; return(false); } else { S_MusterUseBill lnqbill = varData.Single(); if (lnqbill.DJZT == "单据已完成") { error = "单据已完成不能删除"; return(false); } dataContext.S_MusterUseBill.DeleteOnSubmit(lnqbill); } dataContext.SubmitChanges(); return(true); } catch (Exception ex) { error = ex.Message; return(false); } }
/// <summary> /// 保存对单据明细的修改 /// </summary> /// <param name="djh">样品耗用单号</param> /// <param name="storageID">库房ID</param> /// <param name="purposeCode">用途编码</param> /// <param name="useList">单据明细信息</param> /// <param name="error">出错时返回错误信息,无错时返回null</param> /// <returns>保存成功返回True,保存失败返回False</returns> public bool SaveBill(string djh, string storageID, string purposeCode, DataTable useList, out string error) { try { error = null; DepotManagementDataContext dataContext = CommentParameter.DepotDataContext; var varData = from a in dataContext.S_MusterUseBill where a.DJH == djh select a; if (varData.Count() == 0) { S_MusterUseBill lnqBill = new S_MusterUseBill(); lnqBill.DJH = djh; lnqBill.DJZT = "等待主管审核"; lnqBill.PurposeCode = purposeCode; lnqBill.SQR = BasicInfo.LoginName; lnqBill.SQRQ = ServerTime.Time; lnqBill.StorageID = storageID; lnqBill.SHR = null; lnqBill.SHRQ = null; lnqBill.KFR = null; lnqBill.KFRQ = null; dataContext.S_MusterUseBill.InsertOnSubmit(lnqBill); if (!AddList(dataContext, useList, out error)) { return(false); } } else if (varData.Count() == 1) { S_MusterUseBill lnqBill = varData.Single(); if (lnqBill.DJZT == "单据已完成") { error = "单据状态错误"; return(false); } lnqBill.DJZT = "等待主管审核"; lnqBill.PurposeCode = purposeCode; lnqBill.SQR = BasicInfo.LoginName; lnqBill.SQRQ = ServerTime.Time; lnqBill.StorageID = storageID; lnqBill.SHR = null; lnqBill.SHRQ = null; lnqBill.KFR = null; lnqBill.KFRQ = null; if (!DeleteList(dataContext, lnqBill.DJH, out error)) { return(false); } if (!AddList(dataContext, useList, out error)) { return(false); } } else { error = "数据不唯一或者为空"; return(false); } dataContext.SubmitChanges(); return(true); } catch (Exception ex) { error = ex.Message; return(false); } }
/// <summary> /// 更新单据状态 /// </summary> /// <param name="inMusterUse">样品耗用单信息</param> /// <param name="error">出错时返回错误信息,无错时返回null</param> /// <returns>更新成功返回True,更新失败返回False</returns> public bool UpdateBill(S_MusterUseBill inMusterUse, out string error) { try { error = null; DepotManagementDataContext dataContext = CommentParameter.DepotDataContext; var varData = from a in dataContext.S_MusterUseBill where a.DJH == inMusterUse.DJH select a; if (varData.Count() != 1) { error = "数据不唯一或者为空"; return(false); } else { S_MusterUseBill lnqBill = varData.Single(); if (inMusterUse.DJZT != lnqBill.DJZT) { error = "单据状态错误,请重新刷新单据确认单据状态"; return(false); } switch (lnqBill.DJZT) { case "等待主管审核": lnqBill.DJZT = "等待确认出库"; lnqBill.SHR = BasicInfo.LoginName; lnqBill.SHRQ = ServerTime.Time; break; case "等待确认出库": if (lnqBill.DJZT == "单据已完成") { error = "单据不能重复确认"; return(false); } lnqBill.DJZT = "单据已完成"; lnqBill.KFR = BasicInfo.LoginName; lnqBill.KFRQ = ServerTime.Time; //OpertaionDetailAndStock(dataContext, lnqBill); break; default: break; } dataContext.SubmitChanges(); } return(true); } catch (Exception ex) { error = ex.Message; return(false); } }
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e) { if (dataGridView1.Rows.Count < 1) { return; } else { if (txtDJH.Text != dataGridView1.CurrentRow.Cells["单据号"].Value.ToString() && lbDJZT.Text != "单据已完成" && m_editFlag) { m_editFlag = false; if (MessageDialog.ShowEnquiryMessage("是否要保存您已做的操作?") == DialogResult.Yes) { string tempBillNo = dataGridView1.CurrentRow.Cells["单据号"].Value.ToString(); m_lnqBill = m_serverUse.GetBill(txtDJH.Text); if (m_lnqBill != null) { if (m_lnqBill.DJZT == "单据已完成" || m_lnqBill.DJZT == "单据已报废") { MessageDialog.ShowPromptMessage("请重新确认单据状态"); return; } } if (txtPurpose.Text.Trim() == "" || txtPurpose.Tag == null || txtPurpose.Tag.ToString() == "" || txtPurpose.Tag.ToString() == "-1") { MessageDialog.ShowPromptMessage("请选择用途"); return; } if (!m_serverUse.SaveBill(txtDJH.Text, UniversalFunction.GetStorageID(cmbStorage.Text), txtPurpose.Tag.ToString(), (DataTable)dataGridView2.DataSource, out m_err)) { MessageDialog.ShowPromptMessage(m_err); return; } else { m_msgPromulgator.DestroyMessage(txtDJH.Text); m_msgPromulgator.SendNewFlowMessage(txtDJH.Text, string.Format("{0} 号样品耗用单,请主管审核", txtDJH.Text), BillFlowMessage_ReceivedUserType.角色, m_billMessageServer.GetSuperior(CE_RoleStyleType.级领导, BasicInfo.LoginID)); } RefreshDataGirdView(m_serverUse.GetAllBill()); m_lnqBill = m_serverUse.GetBill(txtDJH.Text); PositioningRecord(tempBillNo); } } if (dataGridView1.CurrentRow.Cells["单据状态"].Value.ToString() == "单据已完成") { btnAdd.Enabled = false; btnDelete.Enabled = false; } else { if (dataGridView1.CurrentRow.Cells["申请人"].Value.ToString() != BasicInfo.LoginName) { btnAdd.Enabled = false; btnDelete.Enabled = false; } else { btnAdd.Enabled = true; btnDelete.Enabled = true; } } txtDJH.Text = dataGridView1.CurrentRow.Cells["单据号"].Value.ToString(); lbDJZT.Text = dataGridView1.CurrentRow.Cells["单据状态"].Value.ToString(); dataGridView2.DataSource = m_serverUse.GetList(dataGridView1.CurrentRow.Cells["单据号"].Value.ToString()); cmbStorage.Text = dataGridView1.CurrentRow.Cells["库房名称"].Value.ToString(); txtPurpose.Text = dataGridView1.CurrentRow.Cells["用途"].Value.ToString(); txtPurpose.Tag = dataGridView1.CurrentRow.Cells["用途编码"].Value.ToString(); } }