Beispiel #1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(int UserID, CUSTOMRP.Model.RPCATEGORY model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into RPCATEGORY(");
            strSql.Append("NAME,DATABASEID,AUDODATE,DESCRIPTION)");
            strSql.Append(" values (");
            strSql.Append("@NAME,@DATABASEID,@AUDODATE,@DESCRIPTION)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@NAME",        SqlDbType.NVarChar,  50),
                new SqlParameter("@DATABASEID",  SqlDbType.Int,        4),
                new SqlParameter("@AUDODATE",    SqlDbType.DateTime),
                new SqlParameter("@DESCRIPTION", SqlDbType.NVarChar, -1)
            };
            parameters[0].Value = model.NAME;
            parameters[1].Value = model.DATABASEID;
            parameters[2].Value = model.AUDODATE;
            parameters[3].Value = model.DESCRIPTION;

            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.RPCATEGORY.Add";
                auditobj.Message     = String.Format(AppNum.AuditMessage.RPCategoryInsertSuccess, model.ID);

                AUDITLOG.Add(auditobj);

                return(model.ID);
            }
        }
Beispiel #2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(int UserID, CUSTOMRP.Model.RPCATEGORY model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update RPCATEGORY set ");
            strSql.Append("AUDODATE=@AUDODATE,");
            strSql.Append("DESCRIPTION=@DESCRIPTION");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@AUDODATE",    SqlDbType.DateTime),
                new SqlParameter("@DESCRIPTION", SqlDbType.NVarChar,  -1),
                new SqlParameter("@ID",          SqlDbType.Int,        4),
                new SqlParameter("@NAME",        SqlDbType.NVarChar,  50),
                new SqlParameter("@DATABASEID",  SqlDbType.Int, 4)
            };
            parameters[0].Value = model.AUDODATE;
            parameters[1].Value = model.DESCRIPTION;
            parameters[2].Value = model.ID;
            parameters[3].Value = model.NAME;
            parameters[4].Value = model.DATABASEID;

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

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

                AUDITLOG.Add(auditobj);

                return(true);
            }
            else
            {
                return(false);
            }
        }