コード例 #1
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.CheckCorrect(p_BE);
                InfoMain    entity  = (InfoMain)p_BE;
                InfoMainCtl control = new InfoMainCtl(sqlTrans);
                entity.DSYSID = (int)EntityIDTable.GetID((long)SysEntity.BBS_InfoMain, sqlTrans);
                control.AddNew(entity);

                for (int i = 0; i < p_BE2.Length; i++)
                {
                    InfoMainShareDtsRule rule      = new InfoMainShareDtsRule();
                    InfoMainShareDts     entityDts = (InfoMainShareDts)p_BE2[i];
                    entityDts.MainID = entity.DSYSID;
                    entityDts.Seq    = i + 1;
                    rule.RAdd(entityDts, sqlTrans);
                }
            }
            catch (BaseException)
            {
                throw;
            }
            catch (Exception E)
            {
                throw new BaseException(E.Message);
            }
        }
コード例 #2
0
ファイル: InfoMainCtl.cs プロジェクト: zhp-apeng/HTMLTERP
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="p_Entity">实体类</param>
        /// <returns>操作影响的记录行数</returns>
        public override int Delete(BaseEntity p_Entity)
        {
            try
            {
                InfoMain MasterEntity = (InfoMain)p_Entity;
                if (MasterEntity.DSYSID == 0)
                {
                    return(0);
                }

                //删除主表数据
                string Sql = "";
                Sql = "DELETE FROM BBS_InfoMain WHERE " + "DSYSID=" + SysString.ToDBString(MasterEntity.DSYSID);
                //执行
                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);
            }
        }
コード例 #3
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)
        {
            InfoMain  entity = (InfoMain)p_BE;
            bool      ret    = false;
            string    sql    = string.Format(" SELECT {0} FROM {1} WHERE 1=1 AND {0}={2} AND {3}<>{4}", p_FieldName, InfoMain.TableName, SysString.ToDBString(p_FieldValue), "ID", entity.DSYSID);
            DataTable dt     = p_sqlTrans.Fill(sql);

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

            return(ret);
        }
コード例 #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);
         InfoMain    entity  = (InfoMain)p_BE;
         InfoMainCtl control = new InfoMainCtl(sqlTrans);
         control.Delete(entity);
     }
     catch (BaseException)
     {
         throw;
     }
     catch (Exception E)
     {
         throw new BaseException(E.Message);
     }
 }
コード例 #5
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);
         InfoMain    entity  = (InfoMain)p_BE;
         InfoMainCtl control = new InfoMainCtl(sqlTrans);
         entity.DSYSID = (int)EntityIDTable.GetID((long)SysEntity.BBS_InfoMain, sqlTrans);
         control.AddNew(entity);
     }
     catch (BaseException)
     {
         throw;
     }
     catch (Exception E)
     {
         throw new BaseException(E.Message);
     }
 }
コード例 #6
0
 /// <summary>
 /// 检查将要操作的数据是否符合业务规则
 /// </summary>
 /// <param name="p_BE"></param>
 private void CheckCorrect(BaseEntity p_BE)
 {
     InfoMain entity = (InfoMain)p_BE;
 }
コード例 #7
0
ファイル: InfoMainCtl.cs プロジェクト: zhp-apeng/HTMLTERP
        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="p_Entity">实体类</param>
        /// <returns>操作影响的记录行数</returns>
        public override int AddNew(BaseEntity p_Entity)
        {
            try
            {
                InfoMain MasterEntity = (InfoMain)p_Entity;
                if (MasterEntity.DSYSID == 0)
                {
                    return(0);
                }

                //新增主表数据
                StringBuilder MasterField = new StringBuilder();
                StringBuilder MasterValue = new StringBuilder();
                MasterField.Append("INSERT INTO BBS_InfoMain(");
                MasterValue.Append(" VALUES(");
                MasterField.Append("DSYSID" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.DSYSID) + ",");
                MasterField.Append("Code" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.Code) + ",");
                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("DTitle" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.DTitle) + ",");
                MasterField.Append("DContext" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.DContext) + ",");
                MasterField.Append("DRemark" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.DRemark) + ",");
                MasterField.Append("SubmitFlag" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.SubmitFlag) + ",");
                MasterField.Append("SubmitOPID" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.SubmitOPID) + ",");
                MasterField.Append("SubmitTime" + ",");
                if (MasterEntity.SubmitTime != SystemConfiguration.DateTimeDefaultValue)
                {
                    MasterValue.Append(SysString.ToDBString(MasterEntity.SubmitTime.ToString("yyyy-MM-dd HH:mm:ss")) + ",");
                }
                else
                {
                    MasterValue.Append("null,");
                }

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

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

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

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

                MasterField.Append("InfoType" + ")");
                MasterValue.Append(SysString.ToDBString(MasterEntity.InfoType) + ")");



                //执行
                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);
            }
        }
コード例 #8
0
ファイル: InfoMainCtl.cs プロジェクト: zhp-apeng/HTMLTERP
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="p_Entity">实体类</param>
        /// <returns>操作影响的记录行数</returns>
        public override int Update(BaseEntity p_Entity)
        {
            try
            {
                InfoMain MasterEntity = (InfoMain)p_Entity;
                if (MasterEntity.DSYSID == 0)
                {
                    return(0);
                }

                //更新主表数据
                StringBuilder UpdateBuilder = new StringBuilder();
                UpdateBuilder.Append("UPDATE BBS_InfoMain SET ");
                UpdateBuilder.Append(" DSYSID=" + SysString.ToDBString(MasterEntity.DSYSID) + ",");
                UpdateBuilder.Append(" Code=" + SysString.ToDBString(MasterEntity.Code) + ",");

                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(" DTitle=" + SysString.ToDBString(MasterEntity.DTitle) + ",");
                UpdateBuilder.Append(" DContext=" + SysString.ToDBString(MasterEntity.DContext) + ",");
                UpdateBuilder.Append(" DRemark=" + SysString.ToDBString(MasterEntity.DRemark) + ",");
                UpdateBuilder.Append(" SubmitFlag=" + SysString.ToDBString(MasterEntity.SubmitFlag) + ",");
                UpdateBuilder.Append(" SubmitOPID=" + SysString.ToDBString(MasterEntity.SubmitOPID) + ",");

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

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

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


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

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

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

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

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

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

                UpdateBuilder.Append(" WHERE " + "DSYSID=" + SysString.ToDBString(MasterEntity.DSYSID));



                //执行
                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);
            }
        }