Esempio n. 1
0
        /// <summary>
        /// 修改
        /// </summary>
        public override void EntityUpdate()
        {
            CLSRule rule   = new CLSRule();
            CLS     entity = EntityGet();

            rule.RUpdate(entity);
        }
Esempio n. 2
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);
         CLS    entity  = (CLS)p_BE;
         CLSCtl control = new CLSCtl(sqlTrans);
         string sql     = string.Empty;
         //string sql="SELECT CLSIDC FROM Data_CLS WHERE CLSIDC="+SysString.ToDBString(entity.CLSIDC);
         //sql+=" AND CLSListID="+SysString.ToDBString(entity.CLSListID);
         //sql+=" AND ID<>"+SysString.ToDBString(entity.ID);
         //DataTable dt=SysUtils.Fill(sql);
         //if(dt.Rows.Count!=0)
         //{
         //    throw new Exception("该编码已经存在,请重新输入!");
         //}
         sql  = "SELECT CLSNM FROM Data_CLS WHERE CLSNM=" + SysString.ToDBString(entity.CLSNM);
         sql += " AND CLSListID=" + SysString.ToDBString(entity.CLSListID);
         sql += " AND ID<>" + SysString.ToDBString(entity.ID);
         DataTable dt = SysUtils.Fill(sql);
         if (dt.Rows.Count != 0)
         {
             throw new Exception("该内容已经存在,请重新输入!");
         }
         control.Update(entity);
     }
     catch (BaseException)
     {
         throw;
     }
     catch (Exception E)
     {
         throw new BaseException(E.Message);
     }
 }
Esempio n. 3
0
        /// <summary>
        /// 获得实体
        /// </summary>
        /// <returns></returns>
        private CLS EntityGet()
        {
            CLS entity = new CLS();

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

                //删除主表数据
                string Sql = "";
                Sql = "DELETE FROM Data_CLS 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 int EntityAdd()
        {
            CLSRule rule   = new CLSRule();
            CLS     entity = EntityGet();

            rule.RAdd(entity);
            return(entity.ID);
        }
Esempio n. 6
0
        /// <summary>
        /// 获得实体
        /// </summary>
        /// <returns></returns>
        private CLS EntityGet()
        {
            CLS entity = new CLS();

            entity.ID = HTDataID;
            entity.SelectByID();
            entity.CLSIDC = txtCLSIDC.Text.Trim();
            entity.CLSNM  = txtCLSNM.Text.Trim();
            //entity.CLSNMEn = txtCLSNMEn.Text.Trim();
            entity.Remark    = txtRemark.Text.Trim();
            entity.CLSListID = SysConvert.ToInt32(drpCLSList.EditValue);
            //entity.FCode = txtFCode.Text.Trim();
            return(entity);
        }
Esempio n. 7
0
        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="p_Entity">实体类</param>
        /// <returns>操作影响的记录行数</returns>
        public override int AddNew(BaseEntity p_Entity)
        {
            try
            {
                CLS MasterEntity = (CLS)p_Entity;
                if (MasterEntity.ID == 0)
                {
                    return(0);
                }

                //新增主表数据
                StringBuilder MasterField = new StringBuilder();
                StringBuilder MasterValue = new StringBuilder();
                MasterField.Append("INSERT INTO Data_CLS(");
                MasterValue.Append(" VALUES(");
                MasterField.Append("ID" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.ID) + ",");
                MasterField.Append("CLSIDC" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.CLSIDC) + ",");
                MasterField.Append("CLSNM" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.CLSNM) + ",");
                MasterField.Append("CLSListID" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.CLSListID) + ",");
                MasterField.Append("Remark" + ")");
                MasterValue.Append(SysString.ToDBString(MasterEntity.Remark) + ")");



                //执行
                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>
        public override void EntitySet()
        {
            CLS entity = new CLS();

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

            txtCLSIDC.Text       = entity.CLSIDC.ToString();
            txtCLSNM.Text        = entity.CLSNM.ToString();
            txtRemark.Text       = entity.Remark.ToString();
            drpCLSList.EditValue = entity.CLSListID;
            //txtFCode.Text = entity.FCode;
            if (!findFlag)//处理默认值
            {
            }
        }
Esempio n. 9
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);
         CLS    entity  = (CLS)p_BE;
         CLSCtl control = new CLSCtl(sqlTrans);
         control.Delete(entity);
     }
     catch (BaseException)
     {
         throw;
     }
     catch (Exception E)
     {
         throw new BaseException(E.Message);
     }
 }
Esempio n. 10
0
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="p_Entity">实体类</param>
        /// <returns>操作影响的记录行数</returns>
        public override int Update(BaseEntity p_Entity)
        {
            try
            {
                CLS MasterEntity = (CLS)p_Entity;
                if (MasterEntity.ID == 0)
                {
                    return(0);
                }

                //更新主表数据
                StringBuilder UpdateBuilder = new StringBuilder();
                UpdateBuilder.Append("UPDATE Data_CLS SET ");
                UpdateBuilder.Append(" ID=" + SysString.ToDBString(MasterEntity.ID) + ",");
                UpdateBuilder.Append(" CLSIDC=" + SysString.ToDBString(MasterEntity.CLSIDC) + ",");
                UpdateBuilder.Append(" CLSNM=" + SysString.ToDBString(MasterEntity.CLSNM) + ",");
                UpdateBuilder.Append(" CLSListID=" + SysString.ToDBString(MasterEntity.CLSListID) + ",");
                UpdateBuilder.Append(" Remark=" + SysString.ToDBString(MasterEntity.Remark));

                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>
 private void CheckCorrect(BaseEntity p_BE)
 {
     CLS entity = (CLS)p_BE;
 }