Esempio n. 1
0
        /// <summary>
        /// 设置
        /// </summary>
        public override void EntitySet()
        {
            FabricWHOutForm entity = new FabricWHOutForm();

            entity.MainID = m_MainID;
            bool findFlag = entity.SelectByID2();

            HTDataID             = entity.ID;
            txtFormNo.Text       = entity.FormNo.ToString();
            txtFormDate.DateTime = entity.MakeDate;
            drpWHID.EditValue    = entity.WHID;
            //txtRemark.Text = entity.Remark;
            HTDataSubmitFlag = entity.SubmitFlag;
            HTDataDelFlag    = entity.DelFlag;

            txtJGFormNo.Text   = m_FormNo;
            txtJGWHFormNo.Text = entity.AutoIOFormNo;

            if (!findFlag)
            {
            }

            BindGridDts();
            //SetIOFormDetail();
            //BindPack();
        }
Esempio n. 2
0
        /// <summary>
        /// 删除
        /// </summary>
        public override void EntityDelete()
        {
            FabricWHOutFormRule rule   = new FabricWHOutFormRule();
            FabricWHOutForm     entity = EntityGet();

            rule.RDelete(entity);
        }
Esempio n. 3
0
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="p_Entity">实体类</param>
        /// <returns>操作影响的记录行数</returns>
        public override int Delete(BaseEntity p_Entity)
        {
            try
            {
                FabricWHOutForm MasterEntity = (FabricWHOutForm)p_Entity;
                if (MasterEntity.ID == 0)
                {
                    return(0);
                }

                //删除主表数据
                string Sql = "";
                Sql = "DELETE FROM WO_FabricWHOutForm WHERE " + "ID=" + SysString.ToDBString(MasterEntity.ID);
                //执行
                int AffectedRows = 0;
                if (!this.sqlTransFlag)
                {
                    AffectedRows = this.ExecuteNonQuery(Sql);
                }
                else
                {
                    AffectedRows = sqlTrans.ExecuteNonQuery(Sql);
                }

                return(AffectedRows);
            }
            catch (BaseException E)
            {
                throw new BaseException(E.Message, E);
            }
            catch (Exception E)
            {
                throw new BaseException(FrameWorkMessage.GetAlertMessage((int)Message.CommonDBDelete), E);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// 新增(传入事务处理)
        /// </summary>
        /// <param name="p_BE">要新增的实体</param>
        /// <param name="sqlTrans">事务类</param>
        public void RAdd(BaseEntity p_BE, BaseEntity[] p_BE2, IDBTransAccess sqlTrans)
        {
            try
            {
                this.CheckCorrect(p_BE);
                this.RAdd(p_BE, sqlTrans);

                FabricWHOutForm entity = (FabricWHOutForm)p_BE;
                //string sql = "DELETE WO_FabricWHOutFormDts WHERE MainID=" + SysString.ToDBString(entity.ID);
                //sqlTrans.ExecuteNonQuery(sql);

                FabricWHOutFormDtsRule rule = new FabricWHOutFormDtsRule();
                for (int i = 0; i < p_BE2.Length; i++)
                {
                    FabricWHOutFormDts entityDts = (FabricWHOutFormDts)p_BE2[i];
                    entityDts.MainID = entity.ID;
                    entityDts.Seq    = i + 1;
                    rule.RAdd(entityDts, sqlTrans);
                }

                //sql = "UPDATE WO_FabricProcess SET WHOutFormFlag=1 WHERE ID="+SysString.ToDBString(entity.MainID);
                //sqlTrans.ExecuteNonQuery(sql);
            }
            catch (BaseException)
            {
                throw;
            }
            catch (Exception E)
            {
                throw new BaseException(E.Message);
            }
        }
Esempio n. 5
0
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="p_BE">要删除的实体</param>
        /// <param name="sqlTrans">事务类</param>
        public void RDelete(BaseEntity p_BE, IDBTransAccess sqlTrans)
        {
            try
            {
                this.CheckCorrect(p_BE);
                FabricWHOutForm    entity  = (FabricWHOutForm)p_BE;
                FabricWHOutFormCtl control = new FabricWHOutFormCtl(sqlTrans);
                control.Delete(entity);
                string sql = string.Empty;

                sql = "DELETE FROM WO_FabricWHOutFormDts WHERE MainID=" + entity.ID;
                sqlTrans.ExecuteNonQuery(sql);

                sql = "DELETE FROM WO_FabricWHOutFormDtsPack WHERE MainID=" + entity.ID;
                sqlTrans.ExecuteNonQuery(sql);
            }
            catch (BaseException)
            {
                throw;
            }
            catch (Exception E)
            {
                throw new BaseException(E.Message);
            }
        }
Esempio n. 6
0
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="p_Entity">实体类</param>
        /// <returns>操作影响的记录行数</returns>
        public override int Update(BaseEntity p_Entity)
        {
            try
            {
                FabricWHOutForm MasterEntity = (FabricWHOutForm)p_Entity;
                if (MasterEntity.ID == 0)
                {
                    return(0);
                }

                //更新主表数据
                StringBuilder UpdateBuilder = new StringBuilder();
                UpdateBuilder.Append("UPDATE WO_FabricWHOutForm SET ");
                UpdateBuilder.Append(" ID=" + SysString.ToDBString(MasterEntity.ID) + ",");
                UpdateBuilder.Append(" MainID=" + SysString.ToDBString(MasterEntity.MainID) + ",");
                UpdateBuilder.Append(" FormNo=" + SysString.ToDBString(MasterEntity.FormNo) + ",");
                UpdateBuilder.Append(" WHID=" + SysString.ToDBString(MasterEntity.WHID) + ",");
                UpdateBuilder.Append(" MakeOPID=" + SysString.ToDBString(MasterEntity.MakeOPID) + ",");
                UpdateBuilder.Append(" MakeOPName=" + SysString.ToDBString(MasterEntity.MakeOPName) + ",");

                if (MasterEntity.MakeDate != SystemConfiguration.DateTimeDefaultValue)
                {
                    UpdateBuilder.Append(" MakeDate=" + SysString.ToDBString(MasterEntity.MakeDate.ToString("yyyy-MM-dd HH:mm:ss")) + ",");
                }
                else
                {
                    UpdateBuilder.Append(" MakeDate=null,");
                }

                UpdateBuilder.Append(" SubmitFlag=" + SysString.ToDBString(MasterEntity.SubmitFlag) + ",");
                UpdateBuilder.Append(" DelFlag=" + SysString.ToDBString(MasterEntity.DelFlag) + ",");
                UpdateBuilder.Append(" AutoIOFormID=" + SysString.ToDBString(MasterEntity.AutoIOFormID) + ",");
                UpdateBuilder.Append(" AutoIOFormNo=" + SysString.ToDBString(MasterEntity.AutoIOFormNo));

                UpdateBuilder.Append(" WHERE " + "ID=" + SysString.ToDBString(MasterEntity.ID));



                //执行
                int AffectedRows = 0;
                if (!this.sqlTransFlag)
                {
                    AffectedRows = this.ExecuteNonQuery(UpdateBuilder.ToString());
                }
                else
                {
                    AffectedRows = sqlTrans.ExecuteNonQuery(UpdateBuilder.ToString());
                }
                return(AffectedRows);
            }
            catch (BaseException E)
            {
                throw new BaseException(E.Message, E);
            }
            catch (Exception E)
            {
                throw new BaseException(FrameWorkMessage.GetAlertMessage((int)Message.CommonDBUpdate), E);
            }
        }
Esempio n. 7
0
        /// <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;
                FabricWHOutForm entity     = new FabricWHOutForm(sqlTrans);
                entity.ID = p_FormID;
                entity.SelectByID();


                if (entity.SubmitFlag == p_Type)//如果相同异常
                {
                    throw new Exception("单据状态重复设置,请关闭程序重新打开操作");
                }

                IOForm entitywh = new IOForm();
                if (p_Type == (int)YesOrNo.Yes)
                {
                    /*创建自动出库单并提交*/
                    entitywh = RAutoCreateWHForm(entity, sqlTrans);
                }
                else
                {
                    /*撤销提交自动出库单并删除*/
                    RAutoDeleteWHForm(entity, sqlTrans);
                }

                /* 更新扣料单据状态*/
                sql = "UPDATE WO_FabricWHOutForm 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 += ",AutoIOFormID=" + entitywh.ID;
                sql += ",AutoIOFormNo=" + SysString.ToDBString(entitywh.FormNo);
                sql += " WHERE ID=" + p_FormID.ToString();//更新单据主表审核状态
                sqlTrans.ExecuteNonQuery(sql);

                /*更新加工单据扣料状态*/
                sql  = "UPDATE WO_FabricProcess SET WHOutFormFlag=" + SysString.ToDBString(p_Type);
                sql += " WHERE ID=" + entity.MainID.ToString();//更新单据主表审核状态
                sqlTrans.ExecuteNonQuery(sql);
            }
            catch (BaseException)
            {
                throw;
            }
            catch (Exception E)
            {
                throw new BaseException(E.Message);
            }
        }
Esempio n. 8
0
        /// <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);
            }
        }
Esempio n. 9
0
        /// <summary>
        /// 获得实体
        /// </summary>
        /// <returns></returns>
        private FabricWHOutForm EntityGet()
        {
            FabricWHOutForm entity = new FabricWHOutForm();

            entity.ID = HTDataID;
            entity.SelectByID();
            entity.MainID   = m_MainID;
            entity.FormNo   = txtFormNo.Text.Trim();
            entity.MakeDate = txtFormDate.DateTime;
            //entity.VendorID = drpVendorID.EditValue.ToString();
            //entity.Remark = txtRemark.Text.Trim();
            entity.WHID       = SysConvert.ToString(drpWHID.EditValue);
            entity.MakeOPName = FParamConfig.LoginName;

            return(entity);
        }
Esempio n. 10
0
 /// <summary>
 /// 修改
 /// </summary>
 /// <param name="p_BE">要修改的实体</param>
 /// <param name="sqlTrans">事务类</param>
 public void RUpdate(BaseEntity p_BE, IDBTransAccess sqlTrans)
 {
     try
     {
         this.CheckCorrect(p_BE);
         FabricWHOutForm    entity  = (FabricWHOutForm)p_BE;
         FabricWHOutFormCtl control = new FabricWHOutFormCtl(sqlTrans);
         control.Update(entity);
     }
     catch (BaseException)
     {
         throw;
     }
     catch (Exception E)
     {
         throw new BaseException(E.Message);
     }
 }
Esempio n. 11
0
        /// <summary>
        /// 修改
        /// </summary>
        public override void EntityUpdate()
        {
            FabricWHOutFormRule rule   = new FabricWHOutFormRule();
            FabricWHOutForm     entity = EntityGet();

            FabricWHOutFormDts[] entitydts = EntityDtsGet();
            //decimal TotalQty = 0;
            //decimal TotalAmount = 0;
            //for (int i = 0; i < entitydts.Length; i++)
            //{
            //    TotalQty += SysConvert.ToDecimal(entitydts[i].Qty);
            //    TotalAmount += SysConvert.ToDecimal(entitydts[i].Amount);
            //}
            //entity.TotalQty = TotalQty;
            //entity.TotalAmount = TotalAmount;
            entity.SubmitFlag = this.HTSubmitFlagUpdateGet();

            rule.RUpdate(entity, entitydts);
        }
Esempio n. 12
0
        /// <summary>
        /// 新增(传入事务处理)
        /// </summary>
        /// <param name="p_BE">要新增的实体</param>
        /// <param name="sqlTrans">事务类</param>
        public void RAdd(BaseEntity p_BE, IDBTransAccess sqlTrans)
        {
            try
            {
                this.CheckCorrect(p_BE);

                FabricWHOutForm entity     = (FabricWHOutForm)p_BE;
                string          o_ErrorMSG = string.Empty;
                if (!RAddCheck(entity.MainID, out o_ErrorMSG, sqlTrans))
                {
                    throw new BaseException(o_ErrorMSG);
                }

                string    sql = "SELECT FormNo FROM WO_FabricWHOutForm WHERE FormNo=" + SysString.ToDBString(entity.FormNo);
                DataTable dt  = sqlTrans.Fill(sql);
                if (dt.Rows.Count > 0)
                {
                    throw new BaseException("单号已存在,请重新生成");
                }

                FabricWHOutFormCtl control = new FabricWHOutFormCtl(sqlTrans);
                entity.ID = (int)EntityIDTable.GetID((long)SysEntity.WO_FabricWHOutForm, sqlTrans);
                control.AddNew(entity);



                FormNoControlRule fnrule = new FormNoControlRule();
                fnrule.RAddSort("WO_FabricWHOutForm", "FormNo", sqlTrans);
            }
            catch (BaseException)
            {
                throw;
            }
            catch (Exception E)
            {
                throw new BaseException(E.Message);
            }
        }
Esempio n. 13
0
        /// <summary>
        /// 保存(传入事务处理)
        /// </summary>
        /// <param name="p_Entity"></param>
        /// <param name="p_BE"></param>
        /// <param name="sqlTrans"></param>
        public void RSave(FabricWHOutForm p_Entity, BaseEntity[] p_BE, IDBTransAccess sqlTrans)
        {
            try
            {
                string sql = string.Empty;

                sql = "";//删除码单明细表,代码待补充;如果是入库要删除原始码单表,需要仔细研究,因为某些情况下(先验布)原始码单还是需要保存的

                sql  = "DELETE FROM WO_FabricWHOutFormDts WHERE MainID=" + p_Entity.ID.ToString();
                sql += " AND ID NOT IN" + string.Format("({0})", GetIDExist(p_BE));
                sqlTrans.ExecuteNonQuery(sql);//删除原单据里应该删除的明细数据,即数据库里有但是UI里已经删除的数据


                for (int i = 0; i < p_BE.Length; i++)
                {
                    FabricWHOutFormDts entitydts = (FabricWHOutFormDts)p_BE[i];
                    if (entitydts.ID != 0)//ID不为0说明数据库中已经存在
                    {
                        this.RUpdate(entitydts, sqlTrans);
                    }
                    else
                    {
                        entitydts.MainID = p_Entity.ID;
                        this.RAdd(entitydts, sqlTrans);
                    }
                }
            }
            catch (BaseException)
            {
                throw;
            }
            catch (Exception E)
            {
                throw new BaseException(E.Message);
            }
        }
Esempio n. 14
0
        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="p_Entity">实体类</param>
        /// <returns>操作影响的记录行数</returns>
        public override int AddNew(BaseEntity p_Entity)
        {
            try
            {
                FabricWHOutForm MasterEntity = (FabricWHOutForm)p_Entity;
                if (MasterEntity.ID == 0)
                {
                    return(0);
                }

                //新增主表数据
                StringBuilder MasterField = new StringBuilder();
                StringBuilder MasterValue = new StringBuilder();
                MasterField.Append("INSERT INTO WO_FabricWHOutForm(");
                MasterValue.Append(" VALUES(");
                MasterField.Append("ID" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.ID) + ",");
                MasterField.Append("MainID" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.MainID) + ",");
                MasterField.Append("FormNo" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.FormNo) + ",");
                MasterField.Append("WHID" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.WHID) + ",");
                MasterField.Append("MakeOPID" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.MakeOPID) + ",");
                MasterField.Append("MakeOPName" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.MakeOPName) + ",");
                MasterField.Append("MakeDate" + ",");
                if (MasterEntity.MakeDate != SystemConfiguration.DateTimeDefaultValue)
                {
                    MasterValue.Append(SysString.ToDBString(MasterEntity.MakeDate.ToString("yyyy-MM-dd HH:mm:ss")) + ",");
                }
                else
                {
                    MasterValue.Append("null,");
                }

                MasterField.Append("SubmitFlag" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.SubmitFlag) + ",");
                MasterField.Append("DelFlag" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.DelFlag) + ",");
                MasterField.Append("AutoIOFormID" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.AutoIOFormID) + ",");
                MasterField.Append("AutoIOFormNo" + ")");
                MasterValue.Append(SysString.ToDBString(MasterEntity.AutoIOFormNo) + ")");



                //执行
                int AffectedRows = 0;
                if (!this.sqlTransFlag)
                {
                    AffectedRows = this.ExecuteNonQuery(MasterField.Append(MasterValue.ToString()).ToString());
                }
                else
                {
                    AffectedRows = sqlTrans.ExecuteNonQuery(MasterField.Append(MasterValue.ToString()).ToString());
                }
                return(AffectedRows);
            }
            catch (BaseException E)
            {
                throw new BaseException(E.Message, E);
            }
            catch (Exception E)
            {
                throw new BaseException(FrameWorkMessage.GetAlertMessage((int)Message.CommonDBInsert), E);
            }
        }
Esempio n. 15
0
 /// <summary>
 /// 检查将要操作的数据是否符合业务规则
 /// </summary>
 /// <param name="p_BE"></param>
 private void CheckCorrect(BaseEntity p_BE)
 {
     FabricWHOutForm entity = (FabricWHOutForm)p_BE;
 }
Esempio n. 16
0
        /// <summary>
        /// 创建单据
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="sqlTrans"></param>
        /// <returns></returns>
        IOForm RAutoCreateWHForm(FabricWHOutForm entity, IDBTransAccess sqlTrans)
        {
            IOForm        entitywh = new IOForm(sqlTrans);
            FabricProcess entityjg = new FabricProcess(sqlTrans);

            entityjg.ID = entity.MainID;
            entityjg.SelectByID();

            #region 赋值出入库单据主实体
            /*赋值出入库单据主实体 Begin*/
            SaleProcedureRule rulesalePro = new SaleProcedureRule();
            int    saleProcedureID        = rulesalePro.GetSaleProcedureByWOTypeID(entityjg.ProcessTypeID);//加工业务单据类型ID
            string sql = string.Empty;
            sql = "SELECT JGFormListID FROM Enum_SaleProcedure WHERE ID=" + saleProcedureID;
            DataTable dtSalePro = sqlTrans.Fill(sql);//配置表
            if (dtSalePro.Rows.Count != 0)
            {
                entitywh.SubType = SysConvert.ToInt32(dtSalePro.Rows[0]["JGFormListID"]);
                FormListRule ruleformlist = new FormListRule();
                entitywh.HeadType = ruleformlist.GetFormListIDBySubTypeID(entitywh.SubType, sqlTrans);
            }
            else
            {
                throw new Exception("业务单据类型配置异常");
            }
            entitywh.WHID      = entity.WHID;
            entitywh.WHOP      = ParamConfig.LoginName;
            entitywh.VendorID  = entityjg.DyeFactorty;//加工厂
            entitywh.FormDate  = DateTime.Now.Date;
            entitywh.WHType    = entity.WHID;
            entitywh.SpecialNo = entity.FormNo;//源单据号;自动扣料的单据号


            FormNoControlRule formconrule = new FormNoControlRule();
            entitywh.FormNo = formconrule.RGetWHFormNo(entitywh.SubType, "", sqlTrans);
            /*赋值出入库单据主实体End */
            #endregion


            #region 赋值出入库单据明细实体
            /*赋值出入库单据明细实体 Begin*/
            sql = "SELECT * FROM WO_FabricWHOutFormDts WHERE MainID=" + entity.ID;
            DataTable   dtDts       = sqlTrans.Fill(sql);
            IOFormDts[] entityDtswh = new IOFormDts[dtDts.Rows.Count];

            if (dtDts.Rows.Count == 0)
            {
                throw new Exception("没有数据明细,不应进行数据保存");
            }
            for (int i = 0; i < dtDts.Rows.Count; i++)
            {
                entityDtswh[i]           = new IOFormDts();
                entityDtswh[i].Seq       = i + 1;
                entityDtswh[i].WHID      = dtDts.Rows[i]["WHID"].ToString();
                entityDtswh[i].SectionID = dtDts.Rows[i]["SectionID"].ToString();
                entityDtswh[i].SBitID    = dtDts.Rows[i]["SBitID"].ToString();
                entityDtswh[i].ItemCode  = dtDts.Rows[i]["ItemCode"].ToString();
                entityDtswh[i].ItemName  = dtDts.Rows[i]["ItemName"].ToString();
                entityDtswh[i].ItemStd   = dtDts.Rows[i]["ItemStd"].ToString();
                entityDtswh[i].ItemModel = dtDts.Rows[i]["ItemModel"].ToString();

                entityDtswh[i].Batch       = dtDts.Rows[i]["Batch"].ToString();
                entityDtswh[i].VendorBatch = dtDts.Rows[i]["VendorBatch"].ToString();
                entityDtswh[i].ColorNum    = dtDts.Rows[i]["ColorNum"].ToString();
                entityDtswh[i].ColorName   = dtDts.Rows[i]["ColorName"].ToString();
                entityDtswh[i].JarNum      = dtDts.Rows[i]["JarNum"].ToString();
                entityDtswh[i].PieceQty    = SysConvert.ToInt32(dtDts.Rows[i]["PieceQty"]);
                entityDtswh[i].Remark      = dtDts.Rows[i]["Remark"].ToString();
                entityDtswh[i].Qty         = SysConvert.ToDecimal(dtDts.Rows[i]["Qty"]);
                entityDtswh[i].Unit        = dtDts.Rows[i]["Unit"].ToString();
                entityDtswh[i].Weight      = SysConvert.ToDecimal(dtDts.Rows[i]["Weight"]);
                entityDtswh[i].SinglePrice = SysConvert.ToDecimal(dtDts.Rows[i]["SinglePrice"]);
                entityDtswh[i].DYPrice     = SysConvert.ToDecimal(dtDts.Rows[i]["DYPrice"]);
                entityDtswh[i].Amount      = SysConvert.ToDecimal(dtDts.Rows[i]["Amount"]);
                entityDtswh[i].GoodsCode   = dtDts.Rows[i]["GoodsCode"].ToString();
                entityDtswh[i].GoodsLevel  = dtDts.Rows[i]["GoodsLevel"].ToString();

                entityDtswh[i].VColorNum  = dtDts.Rows[i]["VColorNum"].ToString();
                entityDtswh[i].VColorName = dtDts.Rows[i]["VColorName"].ToString();
                entityDtswh[i].VItemCode  = dtDts.Rows[i]["VItemCode"].ToString();
                entityDtswh[i].MWeight    = dtDts.Rows[i]["MWeight"].ToString();
                entityDtswh[i].MWidth     = dtDts.Rows[i]["MWidth"].ToString();
                entityDtswh[i].WeightUnit = dtDts.Rows[i]["WeightUnit"].ToString();
                entityDtswh[i].PackDts    = dtDts.Rows[i]["PackDts"].ToString();
                //entityDtswh[i].DtsSO = dtDts.Rows[i]["DtsSO"].ToString();
                //entityDtswh[i].DtsOrderFormNo = dtDts.Rows[i]["DtsOrderFormNo"].ToString();
                entityDtswh[i].DtsInVendorID = dtDts.Rows[i]["DtsInVendorID"].ToString();
                entityDtswh[i].InSO          = dtDts.Rows[i]["InSO"].ToString();
                entityDtswh[i].InOrderFormNo = dtDts.Rows[i]["InOrderFormNo"].ToString();
                entityDtswh[i].InSaleOPID    = dtDts.Rows[i]["InSaleOPID"].ToString();
                entityDtswh[i].MLType        = SysConvert.ToInt32(dtDts.Rows[i]["MLType"]);
                //entityDtswh[i].LoadDtsID = SysConvert.ToInt32(dtDts.Rows[i]["LoadDtsID"]);



                entityDtswh[i].LoadDtsID      = SysConvert.ToInt32(dtDts.Rows[i]["ID"]); //明细表ID
                entityDtswh[i].DtsSO          = entityjg.FormNo;                         //关联单据
                entityDtswh[i].DtsOrderFormNo = dtDts.Rows[i]["DtsSO"].ToString();       //订单号
            }

            decimal TotalQty    = 0;
            decimal TotalAmount = 0;
            for (int i = 0; i < entityDtswh.Length; i++)
            {
                TotalQty    += SysConvert.ToDecimal(entityDtswh[i].Qty);
                TotalAmount += SysConvert.ToDecimal(entityDtswh[i].Amount);
            }
            entitywh.TotalQty    = TotalQty;
            entitywh.TotalAmount = TotalAmount;
            /*赋值出入库单据明细实体 End*/
            #endregion



            IOFormRule rulewh = new IOFormRule();
            rulewh.RAdd(entitywh, entityDtswh, sqlTrans);//保存主从数据
            #region 保存孙表数据

            /*赋值出入库单据码单明细数据 Begin*/
            sql = "SELECT TOP 1 ID FROM WO_FabricWHOutFormDtsPack WHERE MainID=" + SysString.ToDBString(entity.ID);
            DataTable dtPackCheck = sqlTrans.Fill(sql);
            if (dtPackCheck.Rows.Count != 0)//如果有码单明细表示需要保存码单明细值
            {
                sql         = "SELECT LoadDtsID,ID,Seq FROM WH_IOFormDts WHERE MainID=" + SysString.ToDBString(entitywh.ID);
                dtPackCheck = sqlTrans.Fill(sql);
                for (int i = 0; i < dtPackCheck.Rows.Count; i++)
                {
                    int LoadDtsID = SysConvert.ToInt32(dtPackCheck.Rows[i]["LoadDtsID"]);
                    int Seq       = SysConvert.ToInt32(dtPackCheck.Rows[i]["Seq"]);
                    int ID        = SysConvert.ToInt32(dtPackCheck.Rows[i]["ID"]);
                    int SubSeq    = 1;
                    if (LoadDtsID > 0)
                    {
                        sql = "SELECT * FROM WO_FabricWHOutFormDtsPack WHERE DID=" + SysString.ToDBString(LoadDtsID);
                        DataTable dtfh = sqlTrans.Fill(sql);

                        for (int j = 0; j < dtfh.Rows.Count; j++)
                        {
                            IOFormDtsPackRule rulePack   = new IOFormDtsPackRule();
                            IOFormDtsPack     entityPack = new IOFormDtsPack();
                            entityPack.MainID = entitywh.ID;
                            entityPack.Seq    = Seq;
                            entityPack.DID    = ID;
                            entityPack.SubSeq = SubSeq;
                            entityPack.BoxNo  = SysConvert.ToString(dtfh.Rows[j]["BoxNo"]);
                            entityPack.Remark = SysConvert.ToString(dtfh.Rows[j]["BoxNo"]);
                            entityPack.Qty    = SysConvert.ToDecimal(dtfh.Rows[j]["Qty"]);
                            SubSeq++;
                            rulePack.RAdd(entityPack, sqlTrans);
                        }
                    }
                }
            }
            /*赋值出入库单据码单明细数据 End*/
            #endregion

            rulewh.RSubmit(entitywh.ID, (int)YesOrNo.Yes, sqlTrans);//提交

            return(entitywh);
        }