示例#1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(int UserID, CUSTOMRP.Model.SOURCEVIEW model)
        {
            Model.SOURCEVIEW original = GetModel(UserID, model.ID);

            StringBuilder strSql = new StringBuilder();

            strSql.Append("update SOURCEVIEW set ");
            strSql.Append("SOURCEVIEWNAME=@SOURCEVIEWNAME,");
            strSql.Append("DATABASEID=@DATABASEID,");
            strSql.Append("SOURCETYPE=@SOURCETYPE,");
            strSql.Append("TBLVIEWNAME=@TBLVIEWNAME,");
            strSql.Append("AUDODATE=@AUDODATE,");
            strSql.Append("VIEWLEVEL=@VIEWLEVEL,");
            strSql.Append("[DESC]=@DESC,");
            strSql.Append("FORMATTYPE=@FORMATTYPE");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@SOURCEVIEWNAME", SqlDbType.NVarChar,   50),
                new SqlParameter("@DATABASEID",     SqlDbType.Int,         4),
                new SqlParameter("@SOURCETYPE",     SqlDbType.Int,         4),
                new SqlParameter("@TBLVIEWNAME",    SqlDbType.NVarChar,  128),
                new SqlParameter("@AUDODATE",       SqlDbType.DateTime),
                new SqlParameter("@VIEWLEVEL",      SqlDbType.Decimal,     9),
                new SqlParameter("@DESC",           SqlDbType.NVarChar,   50),
                new SqlParameter("@FORMATTYPE",     SqlDbType.Int,         4),
                new SqlParameter("@ID",             SqlDbType.Int, 4)
            };
            parameters[0].Value = model.SOURCEVIEWNAME;
            parameters[1].Value = model.DATABASEID;
            parameters[2].Value = model.SOURCETYPE;
            parameters[3].Value = model.TBLVIEWNAME;
            parameters[4].Value = model.AUDODATE;
            parameters[5].Value = model.VIEWLEVEL;
            parameters[6].Value = model.DESC;
            parameters[7].Value = model.FORMATTYPE;
            parameters[8].Value = model.ID;

            int rows = DbHelperSQL.ExecuteSql(UserID, strSql.ToString(), parameters);

            if (rows > 0)
            {
                Model.AUDITLOG auditobj = model.GetAuditLogObject(original);
                auditobj.UserID      = UserID;
                auditobj.CreateDate  = DateTime.Now;
                auditobj.MessageType = Model.AUDITLOG.Severity.Audit;
                auditobj.ModuleName  = "DAL.SOURCEVIEW.Update";
                auditobj.Message     = String.Format(AppNum.AuditMessage.SourceViewUpdateSuccess, model.ID);

                AUDITLOG.Add(auditobj);

                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(int UserID, CUSTOMRP.Model.SOURCEVIEW model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into SOURCEVIEW(");
            strSql.Append("SOURCEVIEWNAME,DATABASEID,SOURCETYPE,TBLVIEWNAME,AUDODATE,VIEWLEVEL,[DESC],FORMATTYPE)");
            strSql.Append(" values (");
            strSql.Append("@SOURCEVIEWNAME,@DATABASEID,@SOURCETYPE,@TBLVIEWNAME,@AUDODATE,@VIEWLEVEL,@DESC,@FORMATTYPE)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@SOURCEVIEWNAME", SqlDbType.NVarChar,   50),
                new SqlParameter("@DATABASEID",     SqlDbType.Int,         4),
                new SqlParameter("@SOURCETYPE",     SqlDbType.Int,         4),
                new SqlParameter("@TBLVIEWNAME",    SqlDbType.NVarChar,  128),
                new SqlParameter("@AUDODATE",       SqlDbType.DateTime),
                new SqlParameter("@VIEWLEVEL",      SqlDbType.Decimal,     9),
                new SqlParameter("@DESC",           SqlDbType.NVarChar,   50),
                new SqlParameter("@FORMATTYPE",     SqlDbType.Int, 4)
            };
            parameters[0].Value = model.SOURCEVIEWNAME;
            parameters[1].Value = model.DATABASEID;
            parameters[2].Value = model.SOURCETYPE;
            parameters[3].Value = model.TBLVIEWNAME;
            parameters[4].Value = model.AUDODATE;
            parameters[5].Value = model.VIEWLEVEL;
            parameters[6].Value = model.DESC;
            parameters[7].Value = model.FORMATTYPE;

            object obj = DbHelperSQL.GetSingle(UserID, strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                model.ID = Convert.ToInt32(obj);

                Model.AUDITLOG auditobj = model.GetAuditLogObject(null);
                auditobj.UserID      = UserID;
                auditobj.CreateDate  = DateTime.Now;
                auditobj.MessageType = Model.AUDITLOG.Severity.Audit;
                auditobj.ModuleName  = "DAL.SOURCEVIEW.Add";
                auditobj.Message     = String.Format(AppNum.AuditMessage.SourceViewInsertSuccess, model.ID);

                AUDITLOG.Add(auditobj);

                return(model.ID);
            }
        }