Esempio n. 1
0
        /// <summary>
        /// 获得实体
        /// </summary>
        /// <returns></returns>
        private SaleFlowModule EntityGet()
        {
            SaleFlowModule entity = new SaleFlowModule();

            entity.ID = HTDataID;
            return(entity);
        }
Esempio n. 2
0
        /// <summary>
        /// 删除
        /// </summary>
        public override void EntityDelete()
        {
            SaleFlowModuleRule rule   = new SaleFlowModuleRule();
            SaleFlowModule     entity = EntityGet();

            rule.RDelete(entity);
        }
        /// <summary>
        /// 保存(传入事务处理)
        /// </summary>
        /// <param name="p_Entity"></param>
        /// <param name="p_BE"></param>
        /// <param name="sqlTrans"></param>
        public void RSave(SaleFlowModule p_Entity, BaseEntity[] p_BE, IDBTransAccess sqlTrans)
        {
            try
            {
                string sql = "DELETE FROM Data_SaleFlowModuleDts 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 Data_SaleFlowModuleDts 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++)
                {
                    SaleFlowModuleDts entitydts = (SaleFlowModuleDts)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);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="p_Entity">实体类</param>
        /// <returns>操作影响的记录行数</returns>
        public override int Delete(BaseEntity p_Entity)
        {
            try
            {
                SaleFlowModule MasterEntity = (SaleFlowModule)p_Entity;
                if (MasterEntity.ID == 0)
                {
                    return(0);
                }

                //删除主表数据
                string Sql = "";
                Sql = "DELETE FROM Data_SaleFlowModule 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. 5
0
        /// <summary>
        /// 修改
        /// </summary>
        public override void EntityUpdate()
        {
            SaleFlowModuleRule rule   = new SaleFlowModuleRule();
            SaleFlowModule     entity = EntityGet();

            SaleFlowModuleDts[] entityDts = EntityDtsGet();
            rule.RUpdate(entity, entityDts);
        }
Esempio n. 6
0
        /// <summary>
        /// 新增
        /// </summary>
        public override int EntityAdd()
        {
            SaleFlowModuleRule rule   = new SaleFlowModuleRule();
            SaleFlowModule     entity = EntityGet();

            SaleFlowModuleDts[] entityDts = EntityDtsGet();
            rule.RAdd(entity, entityDts);
            return(entity.ID);
        }
Esempio n. 7
0
        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="p_Entity">实体类</param>
        /// <returns>操作影响的记录行数</returns>
        public override int AddNew(BaseEntity p_Entity)
        {
            try
            {
                SaleFlowModule MasterEntity = (SaleFlowModule)p_Entity;
                if (MasterEntity.ID == 0)
                {
                    return(0);
                }

                //新增主表数据
                StringBuilder MasterField = new StringBuilder();
                StringBuilder MasterValue = new StringBuilder();
                MasterField.Append("INSERT INTO Data_SaleFlowModule(");
                MasterValue.Append(" VALUES(");
                MasterField.Append("ID" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.ID) + ",");
                MasterField.Append("Code" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.Code) + ",");
                MasterField.Append("Name" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.Name) + ",");
                MasterField.Append("ShowDesc" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.ShowDesc) + ",");
                MasterField.Append("Remark" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.Remark) + ",");
                MasterField.Append("SaleItemTypeID" + ")");
                MasterValue.Append(SysString.ToDBString(MasterEntity.SaleItemTypeID) + ")");



                //执行
                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. 8
0
        /// <summary>
        /// 获得实体
        /// </summary>
        /// <returns></returns>
        private SaleFlowModule EntityGet()
        {
            SaleFlowModule entity = new SaleFlowModule();

            entity.ID = HTDataID;
            entity.SelectByID();
            entity.Code           = txtCode.Text.Trim();
            entity.Name           = txtName.Text.Trim();
            entity.ShowDesc       = GetProcedureDesc();
            entity.Remark         = txtRemark.Text.Trim();
            entity.SaleItemTypeID = SysConvert.ToInt32(drpSaleItemType.EditValue);

            return(entity);
        }
Esempio n. 9
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)
        {
            SaleFlowModule entity = (SaleFlowModule)p_BE;
            bool           ret    = false;
            string         sql    = string.Format(" SELECT {0} FROM {1} WHERE 1=1 AND {0}={2} AND {3}<>{4}", p_FieldName, SaleFlowModule.TableName, SysString.ToDBString(p_FieldValue), "ID", entity.ID);
            DataTable      dt     = p_sqlTrans.Fill(sql);

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

            return(ret);
        }
Esempio n. 10
0
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="p_Entity">实体类</param>
        /// <returns>操作影响的记录行数</returns>
        public override int Update(BaseEntity p_Entity)
        {
            try
            {
                SaleFlowModule MasterEntity = (SaleFlowModule)p_Entity;
                if (MasterEntity.ID == 0)
                {
                    return(0);
                }

                //更新主表数据
                StringBuilder UpdateBuilder = new StringBuilder();
                UpdateBuilder.Append("UPDATE Data_SaleFlowModule SET ");
                UpdateBuilder.Append(" ID=" + SysString.ToDBString(MasterEntity.ID) + ",");
                UpdateBuilder.Append(" Code=" + SysString.ToDBString(MasterEntity.Code) + ",");
                UpdateBuilder.Append(" Name=" + SysString.ToDBString(MasterEntity.Name) + ",");
                UpdateBuilder.Append(" ShowDesc=" + SysString.ToDBString(MasterEntity.ShowDesc) + ",");
                UpdateBuilder.Append(" Remark=" + SysString.ToDBString(MasterEntity.Remark) + ",");
                UpdateBuilder.Append(" SaleItemTypeID=" + SysString.ToDBString(MasterEntity.SaleItemTypeID));

                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. 11
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);
         SaleFlowModule    entity  = (SaleFlowModule)p_BE;
         SaleFlowModuleCtl control = new SaleFlowModuleCtl(sqlTrans);
         control.Update(entity);
     }
     catch (BaseException)
     {
         throw;
     }
     catch (Exception E)
     {
         throw new BaseException(E.Message);
     }
 }
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);
         SaleFlowModule    entity  = (SaleFlowModule)p_BE;
         SaleFlowModuleCtl control = new SaleFlowModuleCtl(sqlTrans);
         entity.ID = (int)EntityIDTable.GetID((long)SysEntity.Data_SaleFlowModule, sqlTrans);
         control.AddNew(entity);
     }
     catch (BaseException)
     {
         throw;
     }
     catch (Exception E)
     {
         throw new BaseException(E.Message);
     }
 }
Esempio n. 13
0
        /// <summary>
        /// 设置
        /// </summary>
        public override void EntitySet()
        {
            SaleFlowModule entity = new SaleFlowModule();

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

            txtCode.Text     = entity.Code.ToString();
            txtName.Text     = entity.Name.ToString();
            txtShowDesc.Text = entity.ShowDesc.ToString();
            txtRemark.Text   = entity.Remark.ToString();

            drpSaleItemType.EditValue = entity.SaleItemTypeID;

            SaleFlowModuleDtsRule dtsrule = new SaleFlowModuleDtsRule();
            DataTable             dtDts   = dtsrule.RShow(" AND MainID=" + this.HTDataID + " ORDER BY Seq");

            SetCheckProcedure(drpSaleProcedure, dtDts);

            if (!findFlag)
            {
            }
        }
Esempio n. 14
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);
                SaleFlowModule    entity  = (SaleFlowModule)p_BE;
                SaleFlowModuleCtl control = new SaleFlowModuleCtl(sqlTrans);


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

                control.Delete(entity);
            }
            catch (BaseException)
            {
                throw;
            }
            catch (Exception E)
            {
                throw new BaseException(E.Message);
            }
        }
Esempio n. 15
0
 /// <summary>
 /// 检查将要操作的数据是否符合业务规则
 /// </summary>
 /// <param name="p_BE"></param>
 private void CheckCorrect(BaseEntity p_BE)
 {
     SaleFlowModule entity = (SaleFlowModule)p_BE;
 }