예제 #1
0
        /// <summary>
        /// 获得实体
        /// </summary>
        /// <returns></returns>
        private TowelProductionPlan EntityGet()
        {
            TowelProductionPlan entity = new TowelProductionPlan();

            entity.ID = HTDataID;
            return(entity);
        }
예제 #2
0
        /// <summary>
        /// 删除
        /// </summary>
        public override void EntityDelete()
        {
            TowelProductionPlanRule rule   = new TowelProductionPlanRule();
            TowelProductionPlan     entity = EntityGet();

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

                //删除主表数据
                string Sql = "";
                Sql = "DELETE FROM WO_TowelProductionPlan 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);
            }
        }
        /// <summary>
        /// 设置
        /// </summary>
        public override void EntitySet()
        {
            TowelProductionPlan entity = new TowelProductionPlan();

            entity.ID = HTDataID;
            bool findFlag = entity.SelectByID();

            txtFormNo.Text        = entity.FormNo.ToString();
            txtFormDate.DateTime  = entity.FormDate;
            txtMakeOPID.Text      = entity.MakeOPID.ToString();
            txtMakeOPName.Text    = entity.MakeOPName.ToString();
            drpVendorID.EditValue = entity.VendorID.ToString();
            drpSaleOPID.EditValue = entity.SaleOPID.ToString();
            txtTotalQty.Text      = entity.TotalQty.ToString();
            txtTotalAmount.Text   = entity.TotalAmount.ToString();
            txtRemark.Text        = entity.Remark.ToString();
            txtMakeDate.DateTime  = entity.MakeDate;
            txtSpecialReq.Text    = entity.SpecialReq.ToString();


            HTDataSubmitFlag = entity.SubmitFlag;
            HTDataDelFlag    = entity.DelFlag;
            if (!findFlag)
            {
            }

            BindGridDts();
        }
예제 #5
0
        /// <summary>
        /// 保存(传入事务处理)
        /// </summary>
        /// <param name="p_Entity"></param>
        /// <param name="p_BE"></param>
        /// <param name="sqlTrans"></param>
        public void RSave(TowelProductionPlan p_Entity, BaseEntity[] p_BE, IDBTransAccess sqlTrans)
        {
            try
            {
                string sql = "DELETE FROM WO_TowelProductionPlanDts WHERE MainID=" + p_Entity.ID.ToString();
                sql += " AND ID NOT IN" + string.Format("({0})", GetIDExist(p_BE));
                sqlTrans.ExecuteNonQuery(sql);                                                                                     //删除原单据里应该删除的明细数据,即数据库里有但是UI里已经删除的数据
                sql = "SELECT ISNULL(MAX(Seq),0)+1 As MSEQ FROM WO_TowelProductionPlanDts WHERE MainID=" + p_Entity.ID.ToString(); ////找到最大的Seq    将获得最大Seq的语句放到循环外更高效(多人操作时会有问题吗?)
                int MSEQ = SysConvert.ToInt32(sqlTrans.Fill(sql).Rows[0][0].ToString());
                for (int i = 0; i < p_BE.Length; i++)
                {
                    TowelProductionPlanDts entitydts = (TowelProductionPlanDts)p_BE[i];
                    if (entitydts.ID != 0)//ID不为0说明数据库中已经存在
                    {
                        this.RUpdate(entitydts, sqlTrans);
                    }
                    else
                    {
                        entitydts.Seq    = MSEQ;
                        entitydts.MainID = p_Entity.ID;
                        this.RAdd(entitydts, sqlTrans);

                        MSEQ++;//最大值加1
                    }
                }
            }
            catch (BaseException)
            {
                throw;
            }
            catch (Exception E)
            {
                throw new BaseException(E.Message);
            }
        }
예제 #6
0
        /// <summary>
        /// 检验字段值是否已存在
        /// </summary>
        /// <param name="p_TableName">表名</param>
        /// <param name="p_FieldName">字段名</param>
        /// <param name="p_FieldValue">字段值</param>
        /// <param name="p_KeyField">主键(只考虑主键为ID的情况)</param>
        /// <param name="p_KeyValue">主键值</param>
        /// <param name="p_sqlTrans"></param>
        /// <returns></returns>
        private bool CheckFieldValueIsExist(BaseEntity p_BE, string p_FieldName, string p_FieldValue, IDBTransAccess p_sqlTrans)
        {
            TowelProductionPlan entity = (TowelProductionPlan)p_BE;
            bool      ret = false;
            string    sql = string.Format(" SELECT {0} FROM {1} WHERE 1=1 AND {0}={2} AND {3}<>{4}", p_FieldName, TowelProductionPlan.TableName, SysString.ToDBString(p_FieldValue), "ID", entity.ID);
            DataTable dt  = p_sqlTrans.Fill(sql);

            if (dt.Rows.Count != 0)
            {
                ret = true;
            }

            return(ret);
        }
예제 #7
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);
         TowelProductionPlan    entity  = (TowelProductionPlan)p_BE;
         TowelProductionPlanCtl control = new TowelProductionPlanCtl(sqlTrans);
         control.Update(entity);
     }
     catch (BaseException)
     {
         throw;
     }
     catch (Exception E)
     {
         throw new BaseException(E.Message);
     }
 }
예제 #8
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);
         TowelProductionPlan    entity  = (TowelProductionPlan)p_BE;
         TowelProductionPlanCtl control = new TowelProductionPlanCtl(sqlTrans);
         entity.ID = (int)EntityIDTable.GetID((long)SysEntity.WO_TowelProductionPlan, sqlTrans);
         control.AddNew(entity);
     }
     catch (BaseException)
     {
         throw;
     }
     catch (Exception E)
     {
         throw new BaseException(E.Message);
     }
 }
        /// <summary>
        /// 修改
        /// </summary>
        public override void EntityUpdate()
        {
            TowelProductionPlanRule rule   = new TowelProductionPlanRule();
            TowelProductionPlan     entity = EntityGet();

            TowelProductionPlanDts[] entitydts = EntityDtsGet();

            decimal TotalAmount = 0;
            decimal TotalQty    = 0;

            for (int i = 0; i < entitydts.Length; i++)
            {
                TotalAmount += entitydts[i].Amount;
                TotalQty    += entitydts[i].Qty;
            }
            entity.TotalAmount = TotalAmount;
            entity.TotalQty    = TotalQty;

            entity.SubmitFlag = this.HTSubmitFlagUpdateGet();
            rule.RUpdate(entity, entitydts);
        }
        /// <summary>
        /// 获得实体
        /// </summary>
        /// <returns></returns>
        private TowelProductionPlan EntityGet()
        {
            TowelProductionPlan entity = new TowelProductionPlan();

            entity.ID = HTDataID;
            entity.SelectByID();

            entity.FormNo      = txtFormNo.Text.Trim();
            entity.FormDate    = txtFormDate.DateTime.Date;
            entity.MakeOPID    = txtMakeOPID.Text.Trim();
            entity.MakeOPName  = txtMakeOPName.Text.Trim();
            entity.VendorID    = SysConvert.ToString(drpVendorID.EditValue);
            entity.SaleOPID    = SysConvert.ToString(drpSaleOPID.EditValue);
            entity.TotalQty    = SysConvert.ToDecimal(txtTotalQty.Text.Trim());
            entity.TotalAmount = SysConvert.ToDecimal(txtTotalAmount.Text.Trim());
            entity.Remark      = txtRemark.Text.Trim();
            entity.MakeDate    = txtMakeDate.DateTime.Date;
            entity.SpecialReq  = txtSpecialReq.Text.Trim();


            return(entity);
        }
예제 #11
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);
                TowelProductionPlan    entity  = (TowelProductionPlan)p_BE;
                TowelProductionPlanCtl control = new TowelProductionPlanCtl(sqlTrans);


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

                control.Delete(entity);
            }
            catch (BaseException)
            {
                throw;
            }
            catch (Exception E)
            {
                throw new BaseException(E.Message);
            }
        }
        /// <summary>
        /// 新增
        /// </summary>
        public override int EntityAdd()
        {
            TowelProductionPlanRule rule   = new TowelProductionPlanRule();
            TowelProductionPlan     entity = EntityGet();

            TowelProductionPlanDts[] entitydts = EntityDtsGet();


            decimal TotalAmount = 0;
            decimal TotalQty    = 0;

            for (int i = 0; i < entitydts.Length; i++)
            {
                TotalAmount += entitydts[i].Amount;
                TotalQty    += entitydts[i].Qty;
            }
            entity.TotalAmount = TotalAmount;
            entity.TotalQty    = TotalQty;


            entity.SubmitFlag = this.HTSubmitFlagInsertGet();
            rule.RAdd(entity, entitydts);
            return(entity.ID);
        }
예제 #13
0
        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="p_Entity">实体类</param>
        /// <returns>操作影响的记录行数</returns>
        public override int AddNew(BaseEntity p_Entity)
        {
            try
            {
                TowelProductionPlan MasterEntity = (TowelProductionPlan)p_Entity;
                if (MasterEntity.ID == 0)
                {
                    return(0);
                }

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

                MasterField.Append("MakeOPID" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.MakeOPID) + ",");
                MasterField.Append("MakeOPName" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.MakeOPName) + ",");
                MasterField.Append("VendorID" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.VendorID) + ",");
                MasterField.Append("SaleOPID" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.SaleOPID) + ",");
                MasterField.Append("TotalQty" + ",");
                if (MasterEntity.TotalQty != 0)
                {
                    MasterValue.Append(SysString.ToDBString(MasterEntity.TotalQty) + ",");
                }
                else
                {
                    MasterValue.Append("null,");
                }

                MasterField.Append("TotalAmount" + ",");
                if (MasterEntity.TotalAmount != 0)
                {
                    MasterValue.Append(SysString.ToDBString(MasterEntity.TotalAmount) + ",");
                }
                else
                {
                    MasterValue.Append("null,");
                }

                MasterField.Append("Remark" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.Remark) + ",");
                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("SpecialReq" + ")");
                MasterValue.Append(SysString.ToDBString(MasterEntity.SpecialReq) + ")");



                //执行
                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);
            }
        }
예제 #14
0
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="p_Entity">实体类</param>
        /// <returns>操作影响的记录行数</returns>
        public override int Update(BaseEntity p_Entity)
        {
            try
            {
                TowelProductionPlan MasterEntity = (TowelProductionPlan)p_Entity;
                if (MasterEntity.ID == 0)
                {
                    return(0);
                }

                //更新主表数据
                StringBuilder UpdateBuilder = new StringBuilder();
                UpdateBuilder.Append("UPDATE WO_TowelProductionPlan SET ");
                UpdateBuilder.Append(" ID=" + SysString.ToDBString(MasterEntity.ID) + ",");
                UpdateBuilder.Append(" SubmitFlag=" + SysString.ToDBString(MasterEntity.SubmitFlag) + ",");
                UpdateBuilder.Append(" DelFlag=" + SysString.ToDBString(MasterEntity.DelFlag) + ",");
                UpdateBuilder.Append(" FormNo=" + SysString.ToDBString(MasterEntity.FormNo) + ",");

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

                UpdateBuilder.Append(" MakeOPID=" + SysString.ToDBString(MasterEntity.MakeOPID) + ",");
                UpdateBuilder.Append(" MakeOPName=" + SysString.ToDBString(MasterEntity.MakeOPName) + ",");
                UpdateBuilder.Append(" VendorID=" + SysString.ToDBString(MasterEntity.VendorID) + ",");
                UpdateBuilder.Append(" SaleOPID=" + SysString.ToDBString(MasterEntity.SaleOPID) + ",");

                if (MasterEntity.TotalQty != 0)
                {
                    UpdateBuilder.Append(" TotalQty=" + SysString.ToDBString(MasterEntity.TotalQty) + ",");
                }
                else
                {
                    UpdateBuilder.Append(" TotalQty=null,");
                }


                if (MasterEntity.TotalAmount != 0)
                {
                    UpdateBuilder.Append(" TotalAmount=" + SysString.ToDBString(MasterEntity.TotalAmount) + ",");
                }
                else
                {
                    UpdateBuilder.Append(" TotalAmount=null,");
                }

                UpdateBuilder.Append(" Remark=" + SysString.ToDBString(MasterEntity.Remark) + ",");

                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(" SpecialReq=" + SysString.ToDBString(MasterEntity.SpecialReq));

                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);
            }
        }
예제 #15
0
 /// <summary>
 /// 检查将要操作的数据是否符合业务规则
 /// </summary>
 /// <param name="p_BE"></param>
 private void CheckCorrect(BaseEntity p_BE)
 {
     TowelProductionPlan entity = (TowelProductionPlan)p_BE;
 }