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

                //删除主表数据
                string Sql = "";
                Sql = "DELETE FROM Sys_FiledSet 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. 2
0
        /// <summary>
        /// 删除
        /// </summary>
        public override void EntityDelete()
        {
            FiledSetRule rule   = new FiledSetRule();
            FiledSet     entity = EntityGet();

            rule.RDelete(entity);
        }
Esempio n. 3
0
        /// <summary>
        /// 获得实体
        /// </summary>
        /// <returns></returns>
        private FiledSet EntityGet()
        {
            FiledSet entity = new FiledSet();

            entity.ID = HTDataID;
            return(entity);
        }
Esempio n. 4
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);
                FiledSet    entity  = (FiledSet)p_BE;
                FiledSetCtl control = new FiledSetCtl(sqlTrans);

                string sql = "SELECT Name FROM Sys_FiledSet WHERE Name=" + SysString.ToDBString(entity.Name);
                sql += " AND FormID=" + SysString.ToDBString(entity.FormID);
                sql += " AND FAID=" + SysString.ToDBString(entity.FAID);
                sql += " AND FBID=" + SysString.ToDBString(entity.FBID);
                sql += " AND ID<>" + entity.ID;
                DataTable dt = sqlTrans.Fill(sql);
                if (dt.Rows.Count > 0)
                {
                    throw new BaseException("名称已存在,请检查");
                }

                control.Update(entity);
            }
            catch (BaseException)
            {
                throw;
            }
            catch (Exception E)
            {
                throw new BaseException(E.Message);
            }
        }
Esempio n. 5
0
        /// <summary>
        /// 设置
        /// </summary>
        public override void EntitySet()
        {
            FiledSet entity = new FiledSet();

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

            txtFormID.Text        = entity.FormID.ToString();
            txtFAID.Text          = entity.FAID.ToString();
            txtFBID.Text          = entity.FBID.ToString();
            txtSort.Text          = entity.Sort.ToString();
            txtCode.Text          = entity.Code.ToString();
            txtName.Text          = entity.Name.ToString();
            txtFiledName.Text     = entity.FiledName.ToString();
            txtFiledType.Text     = entity.FiledType.ToString();
            drpBindType.EditValue = SysConvert.ToInt32(entity.BindType);
            txtLength.Text        = entity.Length.ToString();
            txtRemark.Text        = entity.Remark.ToString();

            drpUseableFlag.EditValue = entity.UseableFlag;
            drpUpDateFlag.EditValue  = entity.UpDateFlag;
            txtMainTable.Text        = entity.MainTable;


            if (!findFlag)
            {
            }
        }
Esempio n. 6
0
        /// <summary>
        /// 新增
        /// </summary>
        public override int EntityAdd()
        {
            FiledSetRule rule   = new FiledSetRule();
            FiledSet     entity = EntityGet();

            rule.RAdd(entity);
            return(entity.ID);
        }
Esempio n. 7
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)
        {
            FiledSet  entity = (FiledSet)p_BE;
            bool      ret    = false;
            string    sql    = string.Format(" SELECT {0} FROM {1} WHERE 1=1 AND {0}={2} AND {3}<>{4}", p_FieldName, FiledSet.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. 8
0
 /// <summary>
 /// 更新表单设置的值
 /// </summary>
 /// <param name="p_ID"></param>
 /// <param name="p_TableName"></param>
 /// <param name="p_FiledName"></param>
 /// <param name="p_Value"></param>
 /// <param name="sqlTrans"></param>
 public void UpdateFiledSet(int p_ID, int p_FiledSetID, string p_Value, IDBTransAccess sqlTrans)
 {
     try
     {
         FiledSet entity = new FiledSet(sqlTrans);
         entity.ID = p_FiledSetID;
         entity.SelectByID();
         string sql = "";
         if (entity.UpDateFlag == 1) //更新标志
         {
             if (entity.FiledType == "string")
             {
                 sql  = "Update " + entity.MainTable;
                 sql += " Set " + entity.FiledName + "=" + SysString.ToDBString(SysConvert.ToString(p_Value));
                 sql += " where ID=" + p_ID;
                 sqlTrans.ExecuteNonQuery(sql);
             }
             if (entity.FiledType == "decimal")
             {
                 sql  = "Update " + entity.MainTable;
                 sql += " Set " + entity.FiledName + "=" + SysString.ToDBString(SysConvert.ToDecimal(p_Value));
                 sql += " where ID=" + p_ID;
                 sqlTrans.ExecuteNonQuery(sql);
             }
             if (entity.FiledType == "int")
             {
                 sql  = "Update " + entity.MainTable;
                 sql += " Set " + entity.FiledName + "=" + SysString.ToDBString(SysConvert.ToInt32(p_Value));
                 sql += " where ID=" + p_ID;
                 sqlTrans.ExecuteNonQuery(sql);
             }
             if (entity.FiledType == "datetime")
             {
                 sql  = "Update " + entity.MainTable;
                 sql += " Set " + entity.FiledName + "=" + SysString.ToDBString(SysConvert.ToDateTime(p_Value));
                 sql += " where ID=" + p_ID;
                 sqlTrans.ExecuteNonQuery(sql);
             }
         }
     }
     catch (BaseException)
     {
         throw;
     }
     catch (Exception E)
     {
         throw new BaseException(E.Message);
     }
 }
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);
         FiledSet    entity  = (FiledSet)p_BE;
         FiledSetCtl control = new FiledSetCtl(sqlTrans);
         control.Delete(entity);
     }
     catch (BaseException)
     {
         throw;
     }
     catch (Exception E)
     {
         throw new BaseException(E.Message);
     }
 }
Esempio n. 10
0
        /// <summary>
        /// 获得实体
        /// </summary>
        /// <returns></returns>
        private FiledSet EntityGet()
        {
            FiledSet entity = new FiledSet();

            entity.ID = HTDataID;
            entity.SelectByID();
            entity.FormID    = SysConvert.ToInt32(txtFormID.Text.Trim());
            entity.FAID      = SysConvert.ToInt32(txtFAID.Text.Trim());
            entity.FBID      = SysConvert.ToInt32(txtFBID.Text.Trim());
            entity.Sort      = SysConvert.ToInt32(txtSort.Text.Trim());
            entity.Code      = SysConvert.ToInt32(txtCode.Text.Trim());
            entity.Name      = txtName.Text.Trim();
            entity.FiledName = txtFiledName.Text.Trim();
            entity.FiledType = txtFiledType.Text.Trim();
            entity.BindType  = SysConvert.ToString(drpBindType.EditValue);
            entity.Length    = SysConvert.ToInt32(txtLength.Text.Trim());
            entity.Remark    = txtRemark.Text.Trim();

            entity.UseableFlag = SysConvert.ToInt32(drpUseableFlag.EditValue);
            entity.UpDateFlag  = SysConvert.ToInt32(drpUpDateFlag.EditValue);
            entity.MainTable   = txtMainTable.Text.Trim();

            return(entity);
        }
Esempio n. 11
0
        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="p_Entity">实体类</param>
        /// <returns>操作影响的记录行数</returns>
        public override int AddNew(BaseEntity p_Entity)
        {
            try
            {
                FiledSet MasterEntity = (FiledSet)p_Entity;
                if (MasterEntity.ID == 0)
                {
                    return(0);
                }

                //新增主表数据
                StringBuilder MasterField = new StringBuilder();
                StringBuilder MasterValue = new StringBuilder();
                MasterField.Append("INSERT INTO Sys_FiledSet(");
                MasterValue.Append(" VALUES(");
                MasterField.Append("ID" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.ID) + ",");
                MasterField.Append("FormID" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.FormID) + ",");
                MasterField.Append("FAID" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.FAID) + ",");
                MasterField.Append("FBID" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.FBID) + ",");
                MasterField.Append("Sort" + ",");
                if (MasterEntity.Sort != 0)
                {
                    MasterValue.Append(SysString.ToDBString(MasterEntity.Sort) + ",");
                }
                else
                {
                    MasterValue.Append("null,");
                }

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

                MasterField.Append("Name" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.Name) + ",");
                MasterField.Append("FiledName" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.FiledName) + ",");
                MasterField.Append("FiledType" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.FiledType) + ",");
                MasterField.Append("BindType" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.BindType) + ",");
                MasterField.Append("Length" + ",");
                if (MasterEntity.Length != 0)
                {
                    MasterValue.Append(SysString.ToDBString(MasterEntity.Length) + ",");
                }
                else
                {
                    MasterValue.Append("null,");
                }

                MasterField.Append("Remark" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.Remark) + ",");
                MasterField.Append("UseableFlag" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.UseableFlag) + ",");
                MasterField.Append("UpDateFlag" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.UpDateFlag) + ",");
                MasterField.Append("MainTable" + ")");
                MasterValue.Append(SysString.ToDBString(MasterEntity.MainTable) + ")");



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

                //更新主表数据
                StringBuilder UpdateBuilder = new StringBuilder();
                UpdateBuilder.Append("UPDATE Sys_FiledSet SET ");
                UpdateBuilder.Append(" ID=" + SysString.ToDBString(MasterEntity.ID) + ",");
                UpdateBuilder.Append(" FormID=" + SysString.ToDBString(MasterEntity.FormID) + ",");
                UpdateBuilder.Append(" FAID=" + SysString.ToDBString(MasterEntity.FAID) + ",");
                UpdateBuilder.Append(" FBID=" + SysString.ToDBString(MasterEntity.FBID) + ",");

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


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

                UpdateBuilder.Append(" Name=" + SysString.ToDBString(MasterEntity.Name) + ",");
                UpdateBuilder.Append(" FiledName=" + SysString.ToDBString(MasterEntity.FiledName) + ",");
                UpdateBuilder.Append(" FiledType=" + SysString.ToDBString(MasterEntity.FiledType) + ",");
                UpdateBuilder.Append(" BindType=" + SysString.ToDBString(MasterEntity.BindType) + ",");

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

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

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