/// <summary> /// 设置 /// </summary> public override void EntitySet() { JYOrder entity = new JYOrder(); entity.ID = HTDataID; bool findFlag = entity.SelectByID(); txtFormNo.Text = entity.FormNo.ToString(); txtFormDate.DateTime = entity.FormDate; txtRemark.Text = entity.Remark.ToString(); txtMakeOPName.Text = entity.MakeOPName.ToString(); txtMakeDate.DateTime = entity.MakeDate; txtTotalQty.Text = entity.TotalQty.ToString(); drpSaleOPID.EditValue = entity.SaleOPID; drpVendorID.EditValue = entity.VendorID; drpJYType.EditValue = entity.JYTypeID; HTDataSubmitFlag = entity.SubmitFlag; HTDataDelFlag = entity.DelFlag; if (!findFlag) { } BindGridDts(); }
/// <summary> /// 获得实体 /// </summary> /// <returns></returns> private JYOrder EntityGet() { JYOrder entity = new JYOrder(); entity.ID = HTDataID; entity.SelectByID(); entity.FormNo = txtFormNo.Text.Trim(); entity.FormDate = txtFormDate.DateTime.Date; entity.Remark = txtRemark.Text.Trim(); entity.MakeOPName = txtMakeOPName.Text.Trim(); entity.MakeDate = txtMakeDate.DateTime.Date; entity.TotalQty = SysConvert.ToDecimal(txtTotalQty.Text.Trim()); entity.VendorID = SysConvert.ToString(drpVendorID.EditValue); entity.SaleOPID = SysConvert.ToString(drpSaleOPID.EditValue); entity.JYTypeID = SysConvert.ToInt32(drpJYType.EditValue); return(entity); }
/// <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++) { JYOrderDtsInputPack entity = (JYOrderDtsInputPack)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 Sale_JYOrderDtsInputPack 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 Sale_JYOrderDtsInputPack WHERE DID=" + SysString.ToDBString(p_ID); DataTable dt = sqlTrans.Fill(sql); if (dt.Rows.Count > 0) { throw new BaseException("不能重复保存!"); } } JYOrder p_Main = new JYOrder(sqlTrans); p_Main.ID = p_MainID; p_Main.SelectByID(); JYOrderDts p_MainDts = new JYOrderDts(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(); JYOrderDtsInputPack entity = (JYOrderDtsInputPack)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 Sale_JYOrderDts 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); } }