Esempio n. 1
0
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="p_BE">要修改的实体</param>
        /// <param name="sqlTrans">事务类</param>
        public void RUpdate(BaseEntity p_BE, BaseEntity[] p_BE2, ArrayList list, IDBTransAccess sqlTrans)
        {
            try
            {
                //RCheckMDQty(p_BE, p_BE2, list);//校验码单明细和单据明细数量是否一致

                IOForm entity = (IOForm)p_BE;
                this.RUpdate(p_BE, sqlTrans);
                IOFormDtsRule ruledts = new IOFormDtsRule();
                ruledts.RSave((IOForm)p_BE, (IOFormDts[])p_BE2, sqlTrans);//保存从表

                //删除数据库中此单据类型的码单信息2011-07-12

                IOFormDtsPackRule dtsprule = new IOFormDtsPackRule();//保存码单明细
                dtsprule.RSave(entity, (IOFormDts[])p_BE2, list, sqlTrans);
            }
            catch (BaseException)
            {
                throw;
            }
            catch (Exception E)
            {
                throw new BaseException(E.Message);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 保存(传入事务处理)
        /// </summary>
        /// <param name="p_Entity"></param>
        /// <param name="p_BE"></param>
        /// <param name="sqlTrans"></param>
        public void RSaveOther(IOForm p_Entity, IOFormDts[] p_EntityDts, ArrayList list, IDBTransAccess sqlTrans)
        {
            try
            {
                string sql             = string.Empty;
                int    FormListTopType = IOFormDtsRule.GetFormListTopTypeByFormListID(p_Entity.HeadType, sqlTrans);//顶层单据类型

                sql  = "SELECT BoxNo FROM WH_IOFormDtsPack WHERE MainID=" + p_Entity.ID.ToString();
                sql += " AND ID NOT IN" + string.Format("({0})", GetIDExist(list));
                DataTable dtDelete = sqlTrans.Fill(sql); //删除表结构
                if (dtDelete.Rows.Count != 0)            //有需要删除的数据
                {
                    sql  = "DELETE FROM WH_IOFormDtsPack WHERE MainID=" + p_Entity.ID.ToString();
                    sql += " AND ID NOT IN" + string.Format("({0})", GetIDExist(list));
                    sqlTrans.ExecuteNonQuery(sql);//删除原单据里应该删除的明细数据,即数据库里有但是UI里已经删除的数据
                }
                for (int i = 0; i < list.Count; i++)
                {
                    IOFormDtsPack entitydts    = (IOFormDtsPack)list[i];
                    int           ioformdtsdex = -1;
                    for (int m = 0; m < p_EntityDts.Length; m++)
                    {
                        if (p_EntityDts[m].Seq == entitydts.Seq)//找到相同的SEQ了
                        {
                            ioformdtsdex = m;
                            break;
                        }
                    }
                    if (ioformdtsdex == -1)//未找到,异常
                    {
                        throw new Exception("码单输入异常,未找到单据明细,行号:" + entitydts.Seq);
                    }

                    if (entitydts.ID != 0)//ID不为0说明数据库中已经存在
                    {
                        this.RUpdateOther(p_EntityDts[ioformdtsdex], entitydts, sqlTrans);
                    }
                    else
                    {
                        entitydts.MainID = p_Entity.ID;
                        this.RAddOther(p_EntityDts[ioformdtsdex], entitydts, sqlTrans);
                    }
                }
            }
            catch (BaseException)
            {
                throw;
            }
            catch (Exception E)
            {
                throw new BaseException(E.Message);
            }
        }
Esempio n. 3
0
 /// <summary>
 /// 修改
 /// </summary>
 /// <param name="p_BE">要修改的实体</param>
 /// <param name="sqlTrans">事务类</param>
 public void RUpdate(BaseEntity p_BE, BaseEntity[] p_BE2, BaseEntity p_BE3, BaseEntity[] p_BE4, IDBTransAccess sqlTrans)
 {
     try
     {
         this.RUpdate(p_BE, sqlTrans);
         IOFormDtsRule ruledts = new IOFormDtsRule();
         ruledts.RSave((IOForm)p_BE, p_BE2, sqlTrans);//保存从表
     }
     catch (BaseException)
     {
         throw;
     }
     catch (Exception E)
     {
         throw new BaseException(E.Message);
     }
 }
Esempio n. 4
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);
                IOForm    entity  = (IOForm)p_BE;
                IOFormCtl control = new IOFormCtl(sqlTrans);

                string sql             = string.Empty;
                int    FormListTopType = IOFormDtsRule.GetFormListTopTypeByFormListID(entity.HeadType, sqlTrans);//顶层单据类型


                if (FormListTopType == (int)WHFormList.期初入库 || FormListTopType == (int)WHFormList.入库)//如果是入库
                {
                    sql = "DELETE FROM WH_PackBox WHERE BoxNo IN(SELECT BoxNo FROM WH_IOFormDtsPack WHERE MainID=" + entity.ID.ToString() + ")";
                    sqlTrans.ExecuteNonQuery(sql);//删除入库码单数据
                }

                sql = "DELETE FROM WH_IOFormDts WHERE MainID=" + entity.ID.ToString();
                sqlTrans.ExecuteNonQuery(sql);//删除原单据明细数据


                sql = "DELETE FROM WH_IOFormDtsPack WHERE MainID=" + entity.ID.ToString();
                sqlTrans.ExecuteNonQuery(sql);//删除原单据码单明细数据



                sql = "DELETE FROM WH_IOFormDtsInputPack WHERE MainID=" + entity.ID.ToString();
                sqlTrans.ExecuteNonQuery(sql);//删除原单据录入码单明细数据


                control.Delete(entity);
            }
            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 RAdd4(BaseEntity p_BE, BaseEntity[] p_BE2, IDBTransAccess sqlTrans)
        {
            try
            {
                this.RAdd(p_BE, sqlTrans);
                IOFormDtsRule ruledts = new IOFormDtsRule();
                ruledts.RSave((IOForm)p_BE, p_BE2, sqlTrans);//保存从表



                IOForm            entity      = (IOForm)p_BE;
                FormNoControlRule rulefn      = new FormNoControlRule();//更新单号
                int       tempFormNoControlID = 0;
                string    sql = "SELECT FormNoControlID FROM Enum_FormList WHERE ID=" + SysString.ToDBString(entity.SubType);
                DataTable dt  = sqlTrans.Fill(sql);
                if (dt.Rows.Count != 0)
                {
                    tempFormNoControlID = SysConvert.ToInt32(dt.Rows[0]["FormNoControlID"].ToString());
                    if (tempFormNoControlID == 0)//子类型没有配置 则读取主类型单号配置
                    {
                        sql = "SELECT FormNoControlID FROM Enum_FormList WHERE ID=" + SysString.ToDBString(entity.HeadType);
                        dt  = sqlTrans.Fill(sql);
                        if (dt.Rows.Count != 0)
                        {
                            tempFormNoControlID = SysConvert.ToInt32(dt.Rows[0]["FormNoControlID"].ToString());
                        }
                    }
                }
                rulefn.RAddSort(tempFormNoControlID, sqlTrans);
            }
            catch (BaseException)
            {
                throw;
            }
            catch (Exception E)
            {
                throw new BaseException(E.Message);
            }
        }
Esempio n. 6
0
        /// <summary>
        /// 新增(传入事务处理)
        /// </summary>
        /// <param name="p_BE">要新增的实体</param>
        /// <param name="sqlTrans">事务类</param>
        public void RAdd(int p_ID, string p_IDStr, IDBTransAccess sqlTrans)
        {
            try
            {
                string sql = "SELECT SectionID,JarNum,Batch FROM WH_PackBox WHERE ID IN (" + p_IDStr + ")";
                sql += " GROUP BY SectionID,JarNum,Batch";
                DataTable     dt     = sqlTrans.Fill(sql);
                int           MaxSeq = GetMaxSeq(p_ID);
                decimal       Qty    = 0;
                IOFormDtsRule rule   = new IOFormDtsRule();

                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    if (i == 0)//第一行更新
                    {
                        sql  = "SELECT * FROM WH_PackBox WHERE ID IN (" + p_IDStr + ")";
                        sql += " AND SectionID=" + SysString.ToDBString(SysConvert.ToString(dt.Rows[i]["SectionID"]));
                        sql += " AND JarNum=" + SysString.ToDBString(SysConvert.ToString(dt.Rows[i]["JarNum"]));
                        sql += " AND Batch=" + SysString.ToDBString(SysConvert.ToString(dt.Rows[i]["Batch"]));
                        DataTable dtsql = sqlTrans.Fill(sql);

                        IOFormDts entitydts = new IOFormDts(sqlTrans);
                        entitydts.ID = p_ID;
                        entitydts.SelectByID();
                        entitydts.SectionID = SysConvert.ToString(dt.Rows[i]["SectionID"]);
                        entitydts.JarNum    = SysConvert.ToString(dt.Rows[i]["JarNum"]);
                        entitydts.Batch     = SysConvert.ToString(dt.Rows[i]["Batch"]);
                        entitydts.Qty       = SysConvert.ToDecimal(dtsql.Compute("SUM(Qty)", ""));
                        entitydts.PieceQty  = dtsql.Rows.Count;
                        entitydts.PackFlag  = 1;
                        entitydts.Amount    = entitydts.Qty * entitydts.SinglePrice;

                        rule.RUpdate(entitydts, sqlTrans);

                        IOFormDtsPackRule prule = new IOFormDtsPackRule();
                        sql  = "DELETE WH_IOFormDtsPack WHERE MainID=" + SysString.ToDBString(entitydts.MainID);
                        sql += " AND Seq=" + SysString.ToDBString(entitydts.Seq);
                        sqlTrans.ExecuteNonQuery(sql);
                        for (int j = 0; j < dtsql.Rows.Count; j++)
                        {
                            IOFormDtsPack pentity = new IOFormDtsPack(sqlTrans);
                            pentity.MainID = entitydts.MainID;
                            pentity.Seq    = entitydts.Seq;
                            pentity.SubSeq = j + 1;
                            pentity.BoxNo  = SysConvert.ToString(dtsql.Rows[j]["BoxNo"]);
                            pentity.Qty    = SysConvert.ToDecimal(dtsql.Rows[j]["Qty"]);
                            pentity.DID    = entitydts.ID;
                            prule.RAdd(pentity, sqlTrans);
                        }
                    }
                    else
                    {
                        sql  = "SELECT * FROM WH_PackBox WHERE ID IN (" + p_IDStr + ")";
                        sql += " AND SectionID=" + SysString.ToDBString(SysConvert.ToString(dt.Rows[i]["SectionID"]));
                        sql += " AND JarNum=" + SysString.ToDBString(SysConvert.ToString(dt.Rows[i]["JarNum"]));
                        sql += " AND Batch=" + SysString.ToDBString(SysConvert.ToString(dt.Rows[i]["Batch"]));
                        DataTable dtsql = sqlTrans.Fill(sql);

                        IOFormDts entitydts = new IOFormDts(sqlTrans);
                        entitydts.ID = p_ID;
                        entitydts.SelectByID();
                        entitydts.Seq       = MaxSeq + i;
                        entitydts.SectionID = SysConvert.ToString(dt.Rows[i]["SectionID"]);
                        entitydts.JarNum    = SysConvert.ToString(dt.Rows[i]["JarNum"]);
                        entitydts.Batch     = SysConvert.ToString(dt.Rows[i]["Batch"]);
                        entitydts.Qty       = SysConvert.ToDecimal(dtsql.Compute("SUM(Qty)", ""));
                        entitydts.PieceQty  = dtsql.Rows.Count;
                        entitydts.PackFlag  = 1;
                        entitydts.Amount    = entitydts.Qty * entitydts.SinglePrice;

                        sql  = "SELECT ID FROM WH_IOFormDts WHERE MainID=" + SysString.ToDBString(entitydts.MainID);
                        sql += " AND Seq=" + SysString.ToDBString(entitydts.Seq);
                        if (sqlTrans.Fill(sql).Rows.Count > 0)
                        {
                            throw new BaseException("不能增行,该行已存在");
                        }
                        rule.RAdd(entitydts, sqlTrans);

                        IOFormDtsPackRule prule = new IOFormDtsPackRule();
                        sql  = "DELETE WH_IOFormDtsPack WHERE MainID=" + SysString.ToDBString(entitydts.MainID);
                        sql += " AND Seq=" + SysString.ToDBString(entitydts.Seq);
                        sqlTrans.ExecuteNonQuery(sql);
                        for (int j = 0; j < dtsql.Rows.Count; j++)
                        {
                            IOFormDtsPack pentity = new IOFormDtsPack(sqlTrans);
                            pentity.MainID = entitydts.MainID;
                            pentity.Seq    = entitydts.Seq;
                            pentity.SubSeq = j + 1;
                            pentity.BoxNo  = SysConvert.ToString(dtsql.Rows[j]["BoxNo"]);
                            pentity.Qty    = SysConvert.ToDecimal(dtsql.Rows[j]["Qty"]);
                            pentity.DID    = entitydts.ID;
                            prule.RAdd(pentity, sqlTrans);
                        }
                    }
                }
            }
            catch (BaseException)
            {
                throw;
            }
            catch (Exception E)
            {
                throw new BaseException(E.Message);
            }
        }
Esempio n. 7
0
        /// <summary>
        /// 保存(传入事务处理)
        /// </summary>
        /// <param name="p_Entity"></param>
        /// <param name="p_BE"></param>
        /// <param name="sqlTrans"></param>
        public void RSave(IOForm p_Entity, IOFormDts[] p_EntityDts, ArrayList list, IDBTransAccess sqlTrans)
        {
            try
            {
                string sql = string.Empty;

                int FormListTopType = IOFormDtsRule.GetFormListTopTypeByFormListID(p_Entity.HeadType, sqlTrans); //顶层单据类型
                if (FormListTopType != (int)WHFormList.入库 && FormListTopType != (int)WHFormList.期初入库)            //如果不是入库类型的单据
                {
                    RSaveOther(p_Entity, p_EntityDts, list, sqlTrans);
                    return;
                }


                sql  = "SELECT BoxNo FROM WH_IOFormDtsPack WHERE MainID=" + p_Entity.ID.ToString();
                sql += " AND ID NOT IN" + string.Format("({0})", GetIDExist(list));
                DataTable dtDelete = sqlTrans.Fill(sql);  //删除表结构
                if (dtDelete.Rows.Count != 0)             //有需要删除的数据
                {
                    foreach (DataRow dr in dtDelete.Rows) //校验是否可以删除
                    {
                        PackBoxRule pbrule = new PackBoxRule();
                        pbrule.RCheckDelete(dr["BoxNo"].ToString(), sqlTrans);//检测调用
                    }

                    sql  = "DELETE FROM WH_PackBox WHERE BoxNo IN(SELECT BoxNo FROM WH_IOFormDtsPack WHERE MainID=" + p_Entity.ID.ToString();
                    sql += " AND ID NOT IN" + string.Format("({0})", GetIDExist(list)) + ")";//删除码单明细数据
                    sqlTrans.ExecuteNonQuery(sql);

                    sql  = "DELETE FROM WH_IOFormDtsPack WHERE MainID=" + p_Entity.ID.ToString();
                    sql += " AND ID NOT IN" + string.Format("({0})", GetIDExist(list));
                    sqlTrans.ExecuteNonQuery(sql);//删除原单据里应该删除的明细数据,即数据库里有但是UI里已经删除的数据
                }
                for (int i = 0; i < list.Count; i++)
                {
                    IOFormDtsPack entitydts    = (IOFormDtsPack)list[i];
                    int           ioformdtsdex = -1;
                    for (int m = 0; m < p_EntityDts.Length; m++)
                    {
                        if (p_EntityDts[m].Seq == entitydts.Seq)//找到相同的SEQ了
                        {
                            ioformdtsdex = m;
                            break;
                        }
                    }
                    if (ioformdtsdex == -1)//未找到,异常
                    {
                        throw new Exception("码单输入异常,未找到单据明细,行号:" + entitydts.Seq);
                    }


                    if (entitydts.ID != 0)//ID不为0说明数据库中已经存在
                    {
                        PackBoxRule pbrule = new PackBoxRule();
                        pbrule.RCheckUpdate(entitydts.BoxNo, sqlTrans);//检测调用
                        this.RUpdate(p_EntityDts[ioformdtsdex], entitydts, sqlTrans);
                    }
                    else
                    {
                        entitydts.MainID = p_Entity.ID;
                        this.RAdd(p_Entity, p_EntityDts[ioformdtsdex], entitydts, sqlTrans);
                    }
                }
            }
            catch (BaseException)
            {
                throw;
            }
            catch (Exception E)
            {
                throw new BaseException(E.Message);
            }
        }
Esempio n. 8
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.RAdd(p_BE, sqlTrans);
                IOForm        entity  = (IOForm)p_BE;
                IOFormDtsRule ruledts = new IOFormDtsRule();
                for (int i = 0; i < p_BE2.Length; i++)
                {
                    IOFormDts entityDts = (IOFormDts)p_BE2[i];
                    entityDts.MainID = entity.ID;
                    entityDts.Seq    = i + 1;
                    ruledts.RAdd(entityDts, sqlTrans);
                }

                //ruledts.RSave((IOForm)p_BE, p_BE2, sqlTrans);//保存从表
                //FormNoControlRule rulest = new FormNoControlRule();
                //rulest.RAddSort((int)FormNoControlEnum.入库单号,sqlTrans);


                FormNoControlRule rulefn      = new FormNoControlRule();//更新单号
                int       tempFormNoControlID = 0;
                string    sql = "SELECT FormNoControlID FROM Enum_FormList WHERE ID=" + SysString.ToDBString(entity.SubType);
                DataTable dt  = sqlTrans.Fill(sql);
                if (dt.Rows.Count != 0)
                {
                    tempFormNoControlID = SysConvert.ToInt32(dt.Rows[0]["FormNoControlID"].ToString());
                    if (tempFormNoControlID == 0)//子类型没有配置 则读取主类型单号配置
                    {
                        sql = "SELECT FormNoControlID FROM Enum_FormList WHERE ID=" + SysString.ToDBString(entity.HeadType);
                        dt  = sqlTrans.Fill(sql);
                        if (dt.Rows.Count != 0)
                        {
                            tempFormNoControlID = SysConvert.ToInt32(dt.Rows[0]["FormNoControlID"].ToString());
                        }
                    }
                }
                rulefn.RAddSort(tempFormNoControlID, sqlTrans);

                #region 加载自动保存

                //sql = "SELECT * FROM Enum_FormList WHERE ID=" + SysString.ToDBString(entity.SubType);
                //dt = sqlTrans.Fill(sql);
                //if (dt.Rows.Count != 0)
                //{
                //    int saveLoadFormType = SysConvert.ToInt32(dt.Rows[0]["LoadFormTypeID"]);
                //    if (saveLoadFormType == (int)LoadFormType.送货单)
                //    {
                //        sql = "SELECT LoadDtsID,ID,Seq FROM WH_IOFormDts WHERE MainID=" + SysString.ToDBString(entity.ID);
                //        dt = sqlTrans.Fill(sql);
                //        for (int i = 0; i < dt.Rows.Count; i++)
                //        {
                //            int LoadDtsID = SysConvert.ToInt32(dt.Rows[i]["LoadDtsID"]);
                //            int Seq = SysConvert.ToInt32(dt.Rows[i]["Seq"]);
                //            int ID = SysConvert.ToInt32(dt.Rows[i]["ID"]);
                //            int SubSeq = 1;
                //            if (LoadDtsID > 0)
                //            {
                //                sql = "SELECT * FROM Sale_FHFormDtsPack 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 = entity.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);

                //                }
                //            }
                //        }

                //    }
                //}


                #endregion
            }
            catch (BaseException)
            {
                throw;
            }
            catch (Exception E)
            {
                throw new BaseException(E.Message);
            }
        }
Esempio n. 9
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;
                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);
            }
        }