/// <summary> /// 获得实体 /// </summary> /// <returns></returns> private IOForm EntityGet() { IOForm entity = new IOForm(); entity.ID = HTDataID; entity.SelectByID(); entity.FromIOFormID = SysConvert.ToInt32(txtFormIOFormID.Text.Trim()); entity.CompanyTypeID = SysConvert.ToInt32(drpCompanyTypeID.EditValue); entity.FormNo = txtFormNo.Text.Trim(); entity.HeadType = SysConvert.ToInt32(txtHeadType.Text.Trim()); entity.HeadType = this.HeadType; entity.SubType = SysConvert.ToInt32(drpSubType.EditValue); entity.VendorID = SysConvert.ToString(drpVendorID.EditValue); entity.FormDate = txtFormDate.DateTime.Date; entity.WHID = SysConvert.ToString(drpWHID.EditValue); entity.WHTypeID = SysConvert.ToInt32(drpWHTypeID.EditValue); entity.OutDep = txtOutDep.Text.Trim(); //entity.InDep = txtInDep.Text.Trim(); entity.WHOP = txtWHOP.Text.Trim(); entity.PassOP = txtPassOP.Text.Trim(); entity.DutyOP = SysConvert.ToString(drpDutyOP.EditValue); entity.Remark = txtRemark.Text.Trim(); if (HTFormStatus == FormStatus.新增) { // entity.MakeOPID = FParamConfig.LoginID; // entity.MakeDate = DateTime.Now.Date; } return(entity); }
/// <summary> /// 审核通过和审核拒绝 /// </summary> /// <param name="p_FormID">单据ID</param> /// <param name="p_Type">1/0 审核通过/审核拒绝</param> /// <param name="drFormList">单据小类的属性值行</param> /// <returns></returns> public void RSubmit(int p_FormID, int p_Type, DataRow drFormList, IDBTransAccess sqlTrans) { try { IOForm entity = new IOForm(sqlTrans); entity.ID = p_FormID; entity.SelectByID(); int FormListTopType = GetFormListTopTypeByFormListID(entity.HeadType, sqlTrans);//顶层单据类型 IOFormDts[] entitydts = this.RGetFormDts(p_FormID, sqlTrans); for (int i = 0; i < entitydts.Length; i++) { StorgeRule rulest = new StorgeRule();//结算库存 rulest.RSubmit(FormListTopType, entity, entitydts[i], p_Type, sqlTrans); } PackBoxProc(FormListTopType, entity, entitydts, p_Type, sqlTrans); //处理装箱单数据 RFillDataType(entity, entitydts, p_Type, SysConvert.ToInt32(drFormList["FillDataTypeID"]), drFormList, sqlTrans); //回填数据处理 } catch (BaseException) { throw; } catch (Exception E) { throw new BaseException(E.Message); } }
/// <summary> /// 设置 /// </summary> public override void EntitySet() { IOForm entity = new IOForm(); entity.ID = HTDataID; bool findFlag = entity.SelectByID(); HTDataFormNo = entity.FormNo; txtFormNo.Text = entity.FormNo.ToString(); txtFormDate.DateTime = entity.FormDate; drpVendorID.EditValue = entity.VendorID.ToString(); drpXZ.EditValue = entity.XZ.ToString(); drpWHID.EditValue = entity.WHID.ToString(); drpSubType.EditValue = entity.SubType; txtWHDM.Text = entity.DM.ToString(); drpSaleOPID.EditValue = entity.SaleOPID.ToString(); txtWHInvoiceNo.Text = entity.InvoiceNo.ToString(); txtTotalQty.Text = entity.TotalQty.ToString(); txtRemark.Text = entity.Remark; txtMakeOPName.Text = entity.MakeOPName; HTDataSubmitFlag = entity.SubmitFlag; HTDataDelFlag = entity.DelFlag; if (!findFlag) { } BindGridDts(); SetIOFormDetail(); }
/// <summary> /// 获得实体 /// </summary> /// <returns></returns> private IOForm EntityGet() { IOForm entity = new IOForm(); entity.ID = HTDataID; entity.SelectByID(); entity.FormNo = txtFormNo.Text.Trim(); entity.FormDate = txtFormDate.DateTime; entity.XZ = drpXZ.Text.Trim(); entity.VendorID = drpVendorID.EditValue.ToString(); //entity.WHType = drpWHID.EditValue.ToString(); entity.SubType = SysConvert.ToInt32(drpSubType.EditValue.ToString()); entity.SaleOPID = drpSaleOPID.EditValue.ToString(); //entity.WHTypeID = SysConvert.ToInt32(drpWHID.EditValue); //entity.WHID = SysConvert.ToString(drpWHID.EditValue); //entity.DM = txtWHDM.Text.Trim(); //entity.InvoiceNo = txtWHInvoiceNo.Text.Trim(); //entity.InvoiceNo = txtInvoiceNo.Text.Trim(); entity.Remark = txtRemark.Text.Trim(); entity.HeadType = this.FormListAID; entity.MakeDate = DateTime.Now.Date; entity.MakeOPName = txtMakeOPName.Text.Trim(); return(entity); }
/// <summary> /// 获得实体 /// </summary> /// <returns></returns> private IOForm EntityGet() { IOForm entity = new IOForm(); entity.ID = HTDataID; entity.SelectByID(); entity.FormNo = txtFormNo.Text.Trim(); entity.FormDate = txtFormDate.DateTime; entity.VendorID = drpVendorID.EditValue.ToString(); entity.WHTypeID = SysConvert.ToInt32(Common.GetWHTypeByFormListID(this.FormListAID)); entity.SubType = SysConvert.ToInt32(drpSubType.EditValue.ToString()); entity.SaleOPID = drpSaleOPID.EditValue.ToString(); entity.VendorOPID = SysConvert.ToString(drpVendorOPID.EditValue); entity.VendorTel = txtVendorTel.Text.Trim(); entity.Remark = txtRemark.Text.Trim(); entity.HeadType = this.FormListAID; entity.Address = SysConvert.ToString(drpAddress.EditValue); if (HTFormStatus == FormStatus.新增) { entity.MakeDate = DateTime.Now; entity.MakeOPID = FParamConfig.LoginID; entity.MakeOPName = FParamConfig.LoginName; } return(entity); }
/// <summary> /// 设置 /// </summary> public override void EntitySet() { IOForm entity = new IOForm(); entity.ID = HTDataID; bool findFlag = entity.SelectByID(); HTDataFormNo = entity.FormNo; txtFormNo.Text = entity.FormNo.ToString(); txtFormDate.DateTime = entity.FormDate; drpVendorID.EditValue = entity.VendorID.ToString(); drpSubType.EditValue = entity.SubType; drpSaleOPID.EditValue = entity.SaleOPID.ToString(); txtTotalQty.Text = entity.TotalQty.ToString(); txtRemark.Text = entity.Remark; txtMakeOPName.Text = entity.MakeOPName; drpAddress.EditValue = entity.Address; drpVendorOPID.EditValue = entity.VendorOPID; txtVendorTel.Text = entity.VendorTel; HTDataSubmitFlag = entity.SubmitFlag; HTDataDelFlag = entity.DelFlag; if (!findFlag) { } BindGridDts(); }
//public override void IniData() //{ // Common.BindOP(drpOPID1, (int)EnumOPDep.仓库, true); // Common.BindOP(drpOPID2, (int)EnumOPDep.仓库, true); //} /// <summary> /// 窗体加载 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void frmWait_Load(object sender, EventArgs e) { try { Common.BindOP(drpOPID1, (int)EnumOPDep.布员, true); Common.BindOP(drpOPID2, (int)EnumOPDep.布员, true); Common.BindOP(drpOPID3, (int)EnumOPDep.布员, true); Common.BindOP(drpOPID4, (int)EnumOPDep.布员, true); Common.BindOP(drpOPID5, (int)EnumOPDep.布员, true); Common.BindOP(drpOPID6, (int)EnumOPDep.运输员, true); IOForm entity = new IOForm(); entity.ID = m_ID; entity.SelectByID(); drpOPID1.EditValue = entity.RecordSBOPID1; drpOPID2.EditValue = entity.RecordSBOPID2; drpOPID3.EditValue = entity.RecordSBOPID3; drpOPID4.EditValue = entity.RecordSBOPID4; drpOPID5.EditValue = entity.RecordSBOPID5; drpOPID6.EditValue = entity.RecordYSOPID1; } catch (Exception E) { this.ShowMessage(E.Message); } }
/// <summary> /// 撤销提交 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public override void btnSubmitCancel_Click(object sender, EventArgs e) { try { if (!FCommon.RightCheck(this.FormID, this.RightFormID, this.FormListAID, this.FormListBID, RightSub.新增)) { this.ShowMessage("你没有此操作权限"); return; } if (HTDataID == 0) { this.ShowMessage("请选择要操作的记录"); return; } IOForm entity = new IOForm(); entity.ID = HTDataID; entity.SelectByID(); if (entity.ReadFlag == 1) { this.ShowMessage("该单据已阅不能撤销提交"); return; } IOFormRule rule = new IOFormRule(); rule.RSubmit(HTDataID, (int)ConfirmFlag.未提交); FCommon.AddDBLog(this.Text, FormStatus.撤消提交.ToString(), "ID:" + HTDataID, ""); this.SetPosStatus(HTDataID); } catch (Exception E) { this.ShowMessage(E.Message); } }
/// <summary> /// 修改销售合同站别 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnLoad_Click(object sender, EventArgs e) { try { if (m_ID == 0 || m_DtsID == 0) { this.ShowMessage("单据有误,请查看"); return; } if (SysConvert.ToString(txtOldSinglePrice.Text.Trim()) == string.Empty) { this.ShowMessage("旧单价为空,请检查"); return; } if (SysConvert.ToString(txtNewSinglePrice.Text.Trim()) == string.Empty) { this.ShowMessage("新单价为空,请检查"); return; } if (SysConvert.ToString(txtOldSinglePrice.Text.Trim()) == SysConvert.ToString(txtNewSinglePrice.Text.Trim())) { this.ShowMessage("新旧单价相同,请检查"); return; } IOForm entity = new IOForm(); entity.ID = m_ID; entity.SelectByID(); IOFormDts entityDts = new IOFormDts(); entityDts.ID = m_DtsID; entityDts.SelectByID(); UpdateWHSinglePriceRule rule = new UpdateWHSinglePriceRule(); UpdateWHSinglePrice entityWH = new UpdateWHSinglePrice(); entityWH.FormNo = entity.FormNo; entityWH.DtsID = entityDts.ID; entityWH.ItemCode = entityDts.ItemCode; entityWH.ColorNum = entityDts.ColorNum; entityWH.ColorName = entityDts.ColorName; entityWH.NewSinglePrice = SysConvert.ToDecimal(txtNewSinglePrice.Text.Trim()); entityWH.OldSinglePrice = SysConvert.ToDecimal(txtOldSinglePrice.Text.Trim()); entityWH.UpdateDate = DateTime.Now; entityWH.UpdateOPName = FParamConfig.LoginName; rule.RAdd(entityWH); string sql = "UPDATE WH_IOFormDts SET SinglePrice=" + SysString.ToDBString(SysConvert.ToDecimal(txtNewSinglePrice.Text.Trim())); sql += ",Amount=ISNULL(DYPrice,0)+ISNULL(Qty,0)*" + SysString.ToDBString(SysConvert.ToDecimal(txtNewSinglePrice.Text.Trim())); sql += " WHERE ID=" + SysString.ToDBString(m_DtsID); SysUtils.ExecuteNonQuery(sql); this.ShowInfoMessage("修改成功"); this.Close(); } catch (Exception E) { } }
/// <summary> /// 撤销提交及删除单据 /// </summary> /// <param name="entity"></param> /// <param name="sqlTrans"></param> void RAutoDeleteWHForm(FabricWHOutForm entity, IDBTransAccess sqlTrans) { string sql = string.Empty; IOForm entitywh = new IOForm(sqlTrans); entitywh.ID = entity.AutoIOFormID; if (entitywh.SelectByID()) { IOFormRule rulewh = new IOFormRule(); rulewh.RSubmit(entitywh.ID, (int)YesOrNo.No, sqlTrans); rulewh.RDelete(entitywh, sqlTrans); } }
/// <summary> /// 窗体加载 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void frmWait_Load(object sender, EventArgs e) { try { IOForm entity = new IOForm(); entity.ID = m_ID; entity.SelectByID(); IOFormDts entityDts = new IOFormDts(); entityDts.ID = m_DtsID; entityDts.SelectByID(); lbShow.Text = "出入库单号:" + entity.FormNo + ",产品编码:" + entityDts.ItemCode + ",颜色:" + entityDts.ColorNum + " " + entityDts.ColorName; txtOldSinglePrice.Text = entityDts.SinglePrice.ToString(); txtNewSinglePrice.Text = entityDts.SinglePrice.ToString(); } catch (Exception E) { } }
/// <summary> /// 设置 /// </summary> public override void EntitySet() { IOForm entity = new IOForm(); entity.ID = HTDataID; bool findFlag = entity.SelectByID(); HTDataFormNo = entity.FormNo; txtFormIOFormID.Text = entity.FromIOFormID.ToString(); drpCompanyTypeID.EditValue = SysConvert.ToInt32(entity.CompanyTypeID); txtFormNo.Text = entity.FormNo.ToString(); //txtHeadType.Text = entity.HeadType.ToString(); txtHeadType.Text = this.HeadType.ToString(); drpSubType.EditValue = SysConvert.ToInt32(entity.SubType); drpVendorID.EditValue = entity.VendorID.ToString(); txtFormDate.DateTime = entity.FormDate; drpWHID.EditValue = entity.WHID.ToString(); drpWHTypeID.EditValue = SysConvert.ToInt32(entity.WHTypeID); txtOutDep.Text = entity.OutDep.ToString(); //txtInDep.Text = entity.InDep.ToString(); txtWHOP.Text = entity.WHOP.ToString(); txtPassOP.Text = entity.PassOP.ToString(); drpDutyOP.EditValue = entity.DutyOP.ToString(); txtRemark.Text = entity.Remark.ToString(); HTDataSubmitFlag = entity.SubmitFlag; HTDataDelFlag = entity.DelFlag; if (!findFlag) { } BindGridDts(); }
public void btnLoadYY_Click(object sender, EventArgs e) { if (!FCommon.RightCheck(this.FormID, this.RightFormID, this.FormListAID, this.FormListBID, RightSub.权限0)) { this.ShowMessage("没有此权限,请联系管理员"); return; } int row = gridView1.FocusedRowHandle; ButtonItem btn = (ButtonItem)sender; IOFormRule rule = new IOFormRule(); IOForm entity = new IOForm(); entity.ID = HTDataID; entity.SelectByID(); if (btn.Text == "撤销已阅") { if (entity.ReadFlag == 0) { this.ShowMessage("该出库单还未阅,无需撤销"); return; } entity.ReadFlag = 0; rule.RUpdate(entity); } if (btn.Text == "已阅") { if (entity.ReadFlag == 1) { this.ShowMessage("该出库单已阅,无需再阅"); return; } entity.ReadFlag = 1; rule.RUpdate(entity); } ID = entity.ID; btnQuery_Click(null, null); }
/// <summary> /// 审核 /// </summary> /// <param name="p_FormID">单据ID</param> /// <param name="p_Type">0/1/2/3:弃审/审核</param> public void RSubmit(int p_FormID, int p_Type, IDBTransAccess sqlTrans) { try { int p_TempType = p_Type;//处理状态 string sql = string.Empty; IOForm entity = new IOForm(sqlTrans); entity.ID = p_FormID; entity.SelectByID(); //if (!RSubmitCheckJS(entity.FormDate, sqlTrans)) //{ // throw new Exception("不允许操作,此单据日期之后已经有结算数据"); //} if (entity.SubmitFlag == p_Type)//如果相同异常 { throw new Exception("单据状态重复设置,请关闭程序重新打开操作"); } int p_AuditFlag = -1; sql = "SELECT FillDataTypeID,AuditFlag,WHQtyPosID,CheckQtyPer1,CheckQtyFrom,CheckQtyPer2,DZFlag FROM Enum_FormList WHERE ID=" + SysString.ToDBString(entity.SubType); DataTable dtFormList = sqlTrans.Fill(sql); if (dtFormList.Rows.Count != 0) { p_AuditFlag = SysConvert.ToInt32(dtFormList.Rows[0]["AuditFlag"]); if (p_AuditFlag == 0)//不需要审核 { switch (p_Type) { case (int)ConfirmFlag.未提交: //p_Type=(int)ConfirmFlag.未提交; break; case (int)ConfirmFlag.已提交: p_Type = (int)ConfirmFlag.审核通过; break; case (int)ConfirmFlag.审核通过: // p_Type=(int)ConfirmFlag.审核通过; break; case (int)ConfirmFlag.审核拒绝: p_Type = (int)ConfirmFlag.未提交; break; } } #region 提交 sql = "UPDATE WH_IOForm SET SubmitFlag=" + SysString.ToDBString(p_Type); if (p_Type == (int)ConfirmFlag.审核通过 || p_Type == (int)ConfirmFlag.审核拒绝) { sql += ",SubmitOPID=" + SysString.ToDBString(ParamConfig.LoginName) + ",SubmitTime=" + SysString.ToDBString(DateTime.Now); } sql += " WHERE ID=" + p_FormID.ToString();//更新单据主表审核状态 sqlTrans.ExecuteNonQuery(sql); //更新转换后单据的状态 sql = "UPDATE WH_IOForm SET SubmitFlag=" + SysString.ToDBString(p_Type); if (p_Type == (int)ConfirmFlag.审核通过 || p_Type == (int)ConfirmFlag.审核拒绝) { sql += ",SubmitOPID=" + SysString.ToDBString(ParamConfig.LoginName) + ",SubmitTime=" + SysString.ToDBString(DateTime.Now); } sql += " WHERE FromIOFormID=" + p_FormID.ToString(); sqlTrans.ExecuteNonQuery(sql); //开始检验和判断是否需要提交 int TempSubmitType = 0; //提交和撤销提交状态 bool SubmitFlag = false; //是否需要提交 if (p_AuditFlag == 0) //不需要审核 { switch (p_TempType) { case (int)ConfirmFlag.审核通过: SubmitFlag = true; TempSubmitType = 1; break; case (int)ConfirmFlag.审核拒绝: TempSubmitType = 0; break; case (int)ConfirmFlag.已提交: SubmitFlag = true; TempSubmitType = 1; break; case (int)ConfirmFlag.未提交: SubmitFlag = true; TempSubmitType = 0; break; } } else//需要审核 { switch (p_TempType) { case (int)ConfirmFlag.审核通过: TempSubmitType = 1; SubmitFlag = true; break; case (int)ConfirmFlag.审核拒绝: if (entity.SubmitFlag == (int)ConfirmFlag.审核通过) //如果之前的状态是审核通过的才执行 { TempSubmitType = 0; SubmitFlag = true; } break; case (int)ConfirmFlag.已提交: break; case (int)ConfirmFlag.未提交: break; } } if (SubmitFlag)//需要执行提交操作 { IOFormDtsRule ruledts = new IOFormDtsRule(); ruledts.RSubmit(p_FormID, TempSubmitType, dtFormList.Rows[0], sqlTrans);//操作子表库存 } #endregion } if (entity.SubmitFlag == p_Type)//如果相同异常 { throw new Exception("单据状态重复设置,请关闭程序重新打开操作"); } } catch (BaseException) { throw; } catch (Exception E) { throw new BaseException(E.Message); } }
/// <summary> /// 处理对账回填数据 /// </summary> /// <param name="p_FormID"></param> /// <param name="p_Type"></param> /// <param name="sqlTrans"></param> private void SetCheckOperationTotal(int p_FormID, int p_Type, IDBTransAccess sqlTrans) { string sql = "SELECT ID,MainID,Seq FROM Finance_CheckOperationDts WHERE MainID=" + SysString.ToDBString(p_FormID); sql += " ORDER BY Seq"; DataTable dt = sqlTrans.Fill(sql); if (dt.Rows.Count > 0) { foreach (DataRow dr in dt.Rows) { //对账单 CheckOperation entity = new CheckOperation(); entity.ID = p_FormID; ///对账单明细 CheckOperationDts entityDts = new CheckOperationDts(); entityDts.ID = SysConvert.ToInt32(dr["ID"]); entityDts.SelectByID(); ///仓库单据明细 IOForm entityIOF = new IOForm(sqlTrans); entityIOF.ID = entityDts.DLOADID; entityIOF.SelectByID(); if (entityDts.DLOADID > 0) ///回填仓库出入库数据 { if (entityIOF.SelectByID()) { } else { throw new Exception("操作异常,没有找到出入库记录 ID:" + entityDts.DLOADID); } if (p_Type == (int)YesOrNo.Yes)//提交 { //if (entityIOF.DZFlag == (int)YesOrNo.Yes && entityIOF.Qty == entityDts.DCheckQty) //{ // throw new Exception("不能操作,数据已对账 ID:" + entityDts.DLOADDtsID + " " + entityIOF.ItemCode + " " + entityIOF.ColorNum); //} ///回填数据到出库明细表中:对账数量、对账金额、对账单价、对账标志、对账单、对账日期、对账单号 /// sql = "UPDATE WH_IOForm SET DZQty=ISNULL(DZQty,0)+(" + SysString.ToDBString(entityDts.DCheckQty) + ")"; sql += ",DZAmount=ISNULL(DZAmount,0)+(" + SysString.ToDBString(entityDts.DCheckAmount) + ")"; sql += ",DZSinglePrice=" + SysString.ToDBString(entityDts.DCheckSinglePrice); sql += ",DZFlag=1"; sql += ",DZOPID=" + SysString.ToDBString(entity.SaleOPID); sql += ",DZTime=GetDate()"; sql += ",DZNo=" + SysString.ToDBString(entity.FormNo); sql += " WHERE ID=" + SysString.ToDBString(entityIOF.ID); sqlTrans.ExecuteNonQuery(sql); } else//撤销提交 { //if (entityIOF.InvoiceQty != 0 && entityIOF.Qty == entityDts.DCheckQty) //{ // throw new Exception("不能操作,数据已有开票数据 ID:" + entityDts.DLOADDtsID + " " + entityIOF.ItemCode + " " + entityIOF.ColorNum); //} sql = "UPDATE WH_IOForm SET DZQty=ISNULL(DZQty,0)-(" + SysString.ToDBString(entityDts.DCheckQty) + ")"; sql += ",DZAmount=ISNULL(DZAmount,0)-(" + SysString.ToDBString(entityDts.DCheckAmount) + ")"; sql += ",DZSinglePrice=NULL"; if (entityIOF.DZQty == entityDts.DCheckQty) { sql += ",DZFlag=0"; } sql += ",DZOPID=''"; sql += ",DZTime=NULL"; sql += ",DZNo=''"; sql += " WHERE ID=" + SysString.ToDBString(entityIOF.ID); sqlTrans.ExecuteNonQuery(sql); } } } } }
/// <summary> /// 保存(传入事务处理) /// </summary> /// <param name="p_BE">要新增的实体</param> /// <param name="sqlTrans">事务类</param> public void RSave(int p_ID, int p_MainID, int p_Seq, BaseEntity[] p_BE, bool p_UpdateFlag, IDBTransAccess sqlTrans) { try { string sql = ""; if (p_UpdateFlag) //修改状态下首先清除被删除的码单明细 { string idStr = string.Empty; //ID字符串 idStr = "0"; for (int i = 0; i < p_BE.Length; i++) { IOFormDtsInputPack entity = (IOFormDtsInputPack)p_BE[i]; if (entity.ID != 0)//有ID { if (idStr != string.Empty) { idStr += ","; } idStr += entity.ID.ToString(); } } if (idStr != string.Empty) { sql = "DELETE FROM WH_PackBox WHERE BoxNo IN (SELECT BoxNo FROM WH_IOFormDtsInputPack WHERE DID=" + SysString.ToDBString(p_ID) + " AND ID NOT IN(" + idStr + ") )"; sqlTrans.ExecuteNonQuery(sql); //执行条形码删除 sql = "DELETE FROM WH_IOFormDtsInputPack WHERE DID=" + SysString.ToDBString(p_ID) + " AND ID NOT IN(" + idStr + ")"; //WH_IOFormDtsPack WH_PackBox sqlTrans.ExecuteNonQuery(sql); } } else//新增状态 { sql = "SELECT TOP 1 ID FROM WH_IOFormDtsInputPack WHERE DID=" + SysString.ToDBString(p_ID); DataTable dt = sqlTrans.Fill(sql); if (dt.Rows.Count > 0) { throw new BaseException("不能重复保存!"); } } IOForm p_Main = new IOForm(sqlTrans); p_Main.ID = p_MainID; p_Main.SelectByID(); IOFormDts p_MainDts = new IOFormDts(sqlTrans); p_MainDts.ID = p_ID; p_MainDts.SelectByID(); //IOFormDtsPackRule rule = new IOFormDtsPackRule(); //PackBoxRule Brule = new PackBoxRule(); decimal Qty = 0; decimal PieceQty = 0; decimal inputQty = 0; for (int i = 0; i < p_BE.Length; i++) { //FormNoControlRule frule = new FormNoControlRule(); IOFormDtsInputPack entity = (IOFormDtsInputPack)p_BE[i]; if (SysConvert.ToBoolean(ProductParamSet.GetIntValueByID(5405)))//转换为默认单位模式开启,目前支持转换为公斤模式 { //开始换算单位 entity.InputUnit = p_MainDts.InputUnit; entity.Unit = p_MainDts.Unit; entity.InputConvertXS = p_MainDts.InputConvertXS; entity.InputQty = entity.Qty;// ProductCommon.UnitConvertValueAnyUnit(entitydts[index].Unit, entitydts[index].Qty, entitydts[index].InputUnit, entitydts[index].InputConvertXS); if (entity.InputConvertXS != 0) { entity.InputQty = SysConvert.ToDecimal(entity.Qty / entity.InputConvertXS, 2); } } if (entity.ID == 0) { //entity.BoxNo = frule.RGetFormNo((int)FormNoControlEnum.码单箱号, sqlTrans); this.RAdd(entity, sqlTrans); //frule.RAddSort((int)FormNoControlEnum.码单箱号, sqlTrans); } else { this.RUpdate(entity, sqlTrans); } inputQty += entity.InputQty; Qty += entity.Qty; PieceQty++; } //if (PieceQty == 0) //{ // throw new BaseException("请填写细码后点击保存"); //} sql = "UPDATE WH_IOFormDts SET Qty=" + SysString.ToDBString(Qty); sql += ",PieceQty=" + SysString.ToDBString(PieceQty); sql += ",InputQty=" + SysString.ToDBString(inputQty); sql += ",PackFlag=1 "; sql += ",InputAmount= " + SysString.ToDBString(inputQty * p_MainDts.InputSinglePrice + p_MainDts.DYPrice); sql += ",Amount= " + SysString.ToDBString(Qty * p_MainDts.SinglePrice + p_MainDts.DYPrice); sql += " WHERE ID=" + SysString.ToDBString(p_ID); sqlTrans.ExecuteNonQuery(sql); } catch (BaseException) { throw; } catch (Exception E) { throw new BaseException(E.Message); } }
/// <summary> /// 保存(传入事务处理) /// </summary> /// <param name="p_BE">要新增的实体</param> /// <param name="sqlTrans">事务类</param> public void RSave(int p_ID, int p_MainID, int p_Seq, BaseEntity[] p_BE, bool p_UpdateFlag, IDBTransAccess sqlTrans) { try { string sql = ""; if (p_UpdateFlag) //修改状态下首先清除被删除的码单明细 { string idStr = string.Empty; //ID字符串 idStr = "0"; for (int i = 0; i < p_BE.Length; i++) { IOFormDtsPack entity = (IOFormDtsPack)p_BE[i]; if (entity.ID != 0)//有ID { if (idStr != string.Empty) { idStr += ","; } idStr += entity.ID.ToString(); } } if (idStr != string.Empty) { sql = "DELETE FROM WH_PackBox WHERE BoxNo IN (SELECT BoxNo FROM WH_IOFormDtsPack WHERE DID=" + SysString.ToDBString(p_ID) + " AND ID NOT IN(" + idStr + ") )"; sqlTrans.ExecuteNonQuery(sql); //执行条形码删除 sql = "DELETE FROM WH_IOFormDtsPack WHERE DID=" + SysString.ToDBString(p_ID) + " AND ID NOT IN(" + idStr + ")"; //WH_IOFormDtsPack WH_PackBox sqlTrans.ExecuteNonQuery(sql); } } else//新增状态 { sql = "SELECT TOP 1 ID FROM WH_IOFormDtsPack WHERE DID=" + SysString.ToDBString(p_ID); DataTable dt = sqlTrans.Fill(sql); if (dt.Rows.Count > 0) { throw new BaseException("不能重复保存!"); } } IOForm p_Main = new IOForm(sqlTrans); p_Main.ID = p_MainID; p_Main.SelectByID(); IOFormDts p_MainDts = new IOFormDts(sqlTrans); p_MainDts.ID = p_ID; p_MainDts.SelectByID(); IOFormDtsPackRule rule = new IOFormDtsPackRule(); PackBoxRule Brule = new PackBoxRule(); decimal Qty = 0; decimal PieceQty = 0; for (int i = 0; i < p_BE.Length; i++) { FormNoControlRule frule = new FormNoControlRule(); IOFormDtsPack entity = (IOFormDtsPack)p_BE[i]; int boxNoCreateTypeID = 0;//箱号条码来源 if (entity.ID == 0) { if (entity.BoxNo == string.Empty)//没有箱号条码 { entity.BoxNo = frule.RGetFormNo((int)FormNoControlEnum.码单箱号, sqlTrans); rule.RAdd(entity, sqlTrans); frule.RAddSort((int)FormNoControlEnum.码单箱号, sqlTrans); } else//有箱号条码说明是验布产生的条码 { boxNoCreateTypeID = 1;//验布来源 } } else { rule.RUpdate(entity, sqlTrans); } PackBox entityBox = new PackBox(); if (entity.ID != 0)//仓库明细已生成,则寻找箱号ID 此处判断其实无意义,经过上面的代码肯定有ID值了 { sql = "SELECT ID FROM WH_PackBox WHERE BoxNo=" + SysString.ToDBString(entity.BoxNo); DataTable dtPackBox = sqlTrans.Fill(sql); if (dtPackBox.Rows.Count != 0)//如果找到条码 { entityBox.ID = SysConvert.ToInt32(dtPackBox.Rows[0]["ID"]); } else//如果未找到条码 { entityBox.CreateSourceID = boxNoCreateTypeID;////原始条码表加个字段表示来源 0:表示入库录入 } } entityBox.BoxNo = entity.BoxNo; entityBox.WHID = p_MainDts.WHID; entityBox.SectionID = p_MainDts.SectionID; entityBox.SBitID = p_MainDts.SBitID; entityBox.ColorName = p_MainDts.ColorName; entityBox.ColorNum = p_MainDts.ColorNum; entityBox.CompanyTypeID = p_MainDts.CompanyTypeID; entityBox.GoodsCode = p_MainDts.GoodsCode; entityBox.GoodsLevel = p_MainDts.GoodsLevel; entityBox.ItemCode = p_MainDts.ItemCode; entityBox.ItemName = p_MainDts.ItemName; entityBox.ItemStd = p_MainDts.ItemStd; entityBox.JarNum = p_MainDts.JarNum; entityBox.Batch = p_MainDts.Batch; entityBox.VendorBatch = p_MainDts.VendorBatch; entityBox.MWeight = p_MainDts.MWeight; entityBox.MWidth = p_MainDts.MWidth; entityBox.Qty = entity.Qty; entityBox.Unit = p_MainDts.Unit; entityBox.BoxStatusID = (int)EnumBoxStatus.未入库; entityBox.DID = p_ID; entityBox.InFormNo = p_Main.FormNo; entityBox.OrderFormNo = p_MainDts.DtsOrderFormNo;//合同号明细 if (entityBox.ID == 0)//没有ID则新增 { Brule.RAdd(entityBox, sqlTrans); } else//有ID则修改 { Brule.RUpdate(entityBox, sqlTrans); } Qty += entity.Qty; PieceQty++; } //if (PieceQty == 0) //{ // throw new BaseException("请填写细码后点击保存"); //} sql = "UPDATE WH_IOFormDts SET Qty=" + SysString.ToDBString(Qty); sql += ",PieceQty=" + SysString.ToDBString(PieceQty); sql += ",PackFlag=1 "; sql += " WHERE ID=" + SysString.ToDBString(p_ID); sqlTrans.ExecuteNonQuery(sql); } catch (BaseException) { throw; } catch (Exception E) { throw new BaseException(E.Message); } }
/// <summary> /// 提交 /// </summary> /// <param name="p_FormID"></param> /// <param name="p_Type"></param> /// <param name="sqlTrans"></param> private void SetInvoiceOperation(int p_FormID, int p_Type, IDBTransAccess sqlTrans) { string sql = "SELECT ID,MainID,Seq FROM Finance_InvoiceOperationDts WHERE MainID=" + SysString.ToDBString(p_FormID); sql += " ORDER BY Seq"; DataTable dt = sqlTrans.Fill(sql); if (dt.Rows.Count > 0) { foreach (DataRow dr in dt.Rows) { //对账单 InvoiceOperation entity = new InvoiceOperation(sqlTrans); entity.ID = p_FormID; entity.SelectByID(); ///对账单明细 InvoiceOperationDts entityDts = new InvoiceOperationDts(sqlTrans); entityDts.ID = SysConvert.ToInt32(dr["ID"]); entityDts.SelectByID(); ///仓库单据明细 IOFormDts entityIOF = new IOFormDts(sqlTrans); if (entityDts.MergeFlage == 1) { if (entityDts.DLOADID > 0) { IOForm entityNoDts = new IOForm(sqlTrans); entityNoDts.ID = entityDts.DLOADID; entityNoDts.SelectByID(); if (entityNoDts.SelectByID()) { } else { throw new Exception("操作异常,没有找到出入库记录 ID:" + entityDts.DLOADID); } if (p_Type == (int)YesOrNo.Yes)//提交 { //if (entityDts.DInvoiceQty + entityIOF.InvoiceQty > entityIOF.DZQty || entityDts.DInvoiceAmount + entityIOF.InvoiceAmount > entityIOF.DZAmount)//开票溢出 //{ // throw new Exception("不能操作,开票数超过对账数 或 开票金额超过对账金额 ID:" + entityDts.DLOADDtsID + " " + entityIOF.ItemCode + " " + entityIOF.ColorNum); //} if (entityNoDts.InvoiceDelFlag == (int)YesOrNo.Yes && entityNoDts.TotalQty == entityNoDts.InvoiceQty) { throw new Exception("不能操作,数据已开票结束 ID:" + entityDts.DLOADID); //+ " " + SysConvert.ToString(drs["ItemCode"]) + " " + SysConvert.ToString(drs["ColorNum"]) } sql = "UPDATE WH_IOForm SET InvoiceQty=ISNULL(InvoiceQty,0)+" + "(" + SysString.ToDBString(entityDts.DInvoiceQty) + ")"; sql += ",InvoiceAmount=ISNULL(InvoiceAmount,0)+" + "(" + SysString.ToDBString(SysConvert.ToDecimal(entityDts.DInvoiceAmount)) + ")"; sql += ",InvoiceDelOPID=" + SysString.ToDBString(entity.SaleOPID); sql += ",InvoiceDelTime=" + SysString.ToDBString(entity.FormDate.ToString("yyyy-MM-dd")); sql += ",InvoiceNo=" + SysString.ToDBString(entity.InvoiceNO); if (entityDts.DInvoiceAmount + entityNoDts.InvoiceAmount >= entityNoDts.DZAmount) //开票完成 { sql += ",InvoiceDelFlag=1"; } else { sql += ",InvoiceDelFlag=0"; } sql += " WHERE ID=" + SysString.ToDBString(entityNoDts.ID); sqlTrans.ExecuteNonQuery(sql); if (entityDts.DLoadCheckDtsID > 0) { sql = "UPDATE Finance_CheckOperationDts SET InvoiceFlag=1 WHERE ID=" + SysString.ToDBString(entityDts.DLoadCheckDtsID); sqlTrans.ExecuteNonQuery(sql); } } else//撤销提交 { if (entityNoDts.PayAmount != 0) { throw new Exception("不能操作,数据已有收付款数据 ID:" + entityDts.DLOADID); } sql = "UPDATE WH_IOForm SET InvoiceQty=ISNULL(InvoiceQty,0)-" + "(" + SysString.ToDBString(entityDts.DInvoiceQty) + ")"; sql += ",InvoiceAmount=ISNULL(InvoiceAmount,0)-" + "(" + SysString.ToDBString(entityDts.DInvoiceAmount) + ")"; sql += ",InvoiceDelOPID=" + SysString.ToDBString(entity.SaleOPID); sql += ",InvoiceDelTime=null"; sql += ",InvoiceNo=''"; if (entityNoDts.InvoiceQty == entityDts.DInvoiceQty) { sql += ",InvoiceDelFlag=0";//开票完成标志 } sql += " WHERE ID=" + SysString.ToDBString(entityNoDts.ID); sqlTrans.ExecuteNonQuery(sql); if (entityDts.DLoadCheckDtsID > 0) { sql = "UPDATE Finance_CheckOperationDts SET InvoiceFlag=0 WHERE ID=" + SysString.ToDBString(entityDts.DLoadCheckDtsID); sqlTrans.ExecuteNonQuery(sql); } } } else { if (p_Type == (int)YesOrNo.Yes)//提交 { if (entityDts.DLoadCheckDtsID > 0) { sql = "UPDATE Finance_CheckOperationDts SET InvoiceFlag=1 WHERE ID=" + SysString.ToDBString(entityDts.DLoadCheckDtsID); sqlTrans.ExecuteNonQuery(sql); } } else { if (entityDts.DLoadCheckDtsID > 0) { sql = "UPDATE Finance_CheckOperationDts SET InvoiceFlag=0 WHERE ID=" + SysString.ToDBString(entityDts.DLoadCheckDtsID); sqlTrans.ExecuteNonQuery(sql); } } } } else { entityIOF.ID = entityDts.DLOADDtsID; if (entityDts.DLOADDtsID > 0) { if (entityIOF.SelectByID()) { } else { throw new Exception("操作异常,没有找到出入库记录 ID:" + entityDts.DLOADDtsID); } if (p_Type == (int)YesOrNo.Yes)//提交 { if (entityIOF.DtsInvoiceDelFlag == (int)YesOrNo.Yes && entityIOF.Qty == entityIOF.InvoiceQty) { throw new Exception("不能操作,数据已开票结束 ID:" + entityDts.DLOADDtsID + " " + entityIOF.ItemCode + " " + entityIOF.ColorNum); } //if (entityDts.DInvoiceQty + entityIOF.InvoiceQty > entityIOF.DZQty || entityDts.DInvoiceAmount + entityIOF.InvoiceAmount > entityIOF.DZAmount)//开票溢出 //{ // throw new Exception("不能操作,开票数超过对账数 或 开票金额超过对账金额 ID:" + entityDts.DLOADDtsID + " " + entityIOF.ItemCode + " " + entityIOF.ColorNum); //} sql = "UPDATE WH_IOFormDts SET InvoiceQty=ISNULL(InvoiceQty,0)+" + "(" + SysString.ToDBString(entityDts.DInvoiceQty) + ")"; sql += ",InvoiceAmount=ISNULL(InvoiceAmount,0)+" + "(" + SysString.ToDBString(entityDts.DInvoiceAmount) + ")"; sql += ",DtsInvoiceDelOPID=" + SysString.ToDBString(entity.SaleOPID); sql += ",DtsInvoiceDelTime=" + SysString.ToDBString(entity.FormDate.ToString("yyyy-MM-dd")); sql += ",DtsInvoiceNo=" + SysString.ToDBString(entity.InvoiceNO); if (entityDts.DInvoiceAmount + entityIOF.InvoiceAmount >= entityIOF.DZAmount)//开票完成 { sql += ",DtsInvoiceDelFlag=1"; } else { sql += ",DtsInvoiceDelFlag=0"; } sql += " WHERE ID=" + SysString.ToDBString(entityDts.DLOADDtsID); sqlTrans.ExecuteNonQuery(sql); if (entityDts.DLoadCheckDtsID > 0) { sql = "UPDATE Finance_CheckOperationDts SET InvoiceFlag=1 WHERE ID=" + SysString.ToDBString(entityDts.DLoadCheckDtsID); sqlTrans.ExecuteNonQuery(sql); } } else//撤销提交 { if (entityIOF.PayAmount != 0) { throw new Exception("不能操作,数据已有收付款数据 ID:" + entityDts.DLOADDtsID + " " + entityIOF.ItemCode + " " + entityIOF.ColorNum); } sql = "UPDATE WH_IOFormDts SET InvoiceQty=ISNULL(InvoiceQty,0)-" + "(" + SysString.ToDBString(entityDts.DInvoiceQty) + ")"; sql += ",InvoiceAmount=ISNULL(InvoiceAmount,0)-" + "(" + SysString.ToDBString(entityDts.DInvoiceAmount) + ")"; sql += ",DtsInvoiceDelOPID=" + SysString.ToDBString(entity.SaleOPID); sql += ",DtsInvoiceDelTime=null"; sql += ",DtsInvoiceNo=''"; if (entityIOF.InvoiceQty == entityDts.DInvoiceQty) { sql += ",DtsInvoiceDelFlag=0";//开票完成标志 } sql += " WHERE ID=" + SysString.ToDBString(entityDts.DLOADDtsID); sqlTrans.ExecuteNonQuery(sql); if (entityDts.DLoadCheckDtsID > 0) { sql = "UPDATE Finance_CheckOperationDts SET InvoiceFlag=0 WHERE ID=" + SysString.ToDBString(entityDts.DLoadCheckDtsID); sqlTrans.ExecuteNonQuery(sql); } } } else { if (p_Type == (int)YesOrNo.Yes)//提交 { if (entityDts.DLoadCheckDtsID > 0) { sql = "UPDATE Finance_CheckOperationDts SET InvoiceFlag=1 WHERE ID=" + SysString.ToDBString(entityDts.DLoadCheckDtsID); sqlTrans.ExecuteNonQuery(sql); } } else { if (entityDts.DLoadCheckDtsID > 0) { sql = "UPDATE Finance_CheckOperationDts SET InvoiceFlag=0 WHERE ID=" + SysString.ToDBString(entityDts.DLoadCheckDtsID); sqlTrans.ExecuteNonQuery(sql); } } } } } } }