Example #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(CUSTOMRP.Model.APPLICATION model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update APPLICATION set ");
            strSql.Append("NAME=@NAME,");
            strSql.Append("DESC=@DESC,");
            strSql.Append("CONFIG_VIEW1=@CONFIG_VIEW1,");
            strSql.Append("CONFIG_VIEW2=@CONFIG_VIEW2,");
            strSql.Append("CONFIG_VIEW3=@CONFIG_VIEW3,");
            strSql.Append("LASTMODIFYDATE=@LASTMODIFYDATE,");
            strSql.Append("LASTMODIFYUSER=@LASTMODIFYUSER,");
            strSql.Append("AUDODATE=@AUDODATE");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@NAME",           SqlDbType.NVarChar,  50),
                new SqlParameter("@DESC",           SqlDbType.NVarChar,  -1),
                new SqlParameter("@CONFIG_VIEW1",   SqlDbType.NVarChar,  -1),
                new SqlParameter("@CONFIG_VIEW2",   SqlDbType.NVarChar,  -1),
                new SqlParameter("@CONFIG_VIEW3",   SqlDbType.NVarChar,  -1),
                new SqlParameter("@LASTMODIFYDATE", SqlDbType.DateTime),
                new SqlParameter("@LASTMODIFYUSER", SqlDbType.Int,        4),
                new SqlParameter("@AUDODATE",       SqlDbType.DateTime),
                new SqlParameter("@ID",             SqlDbType.Int, 4)
            };
            parameters[0].Value = model.NAME;
            parameters[1].Value = model.DESC;
            parameters[2].Value = model.CONFIG_VIEW1;
            parameters[3].Value = model.CONFIG_VIEW2;
            parameters[4].Value = model.CONFIG_VIEW3;
            parameters[5].Value = model.LASTMODIFYDATE;
            parameters[6].Value = model.LASTMODIFYUSER;
            parameters[7].Value = model.AUDODATE;
            parameters[8].Value = model.ID;

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

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

                AUDITLOG.Add(auditobj);

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

            strSql.Append("insert into APPLICATION(");
            strSql.Append("NAME,[DESC],CONFIG_VIEW1,CONFIG_VIEW2,CONFIG_VIEW3,LASTMODIFYDATE,LASTMODIFYUSER,AUDODATE)");
            strSql.Append(" values (");
            strSql.Append("@NAME,@DESC,@CONFIG_VIEW1,@CONFIG_VIEW2,@CONFIG_VIEW3,@LASTMODIFYDATE,@LASTMODIFYUSER,@AUDODATE)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@NAME",           SqlDbType.NVarChar,  50),
                new SqlParameter("@DESC",           SqlDbType.NVarChar,  -1),
                new SqlParameter("@CONFIG_VIEW1",   SqlDbType.NVarChar,  -1),
                new SqlParameter("@CONFIG_VIEW2",   SqlDbType.NVarChar,  -1),
                new SqlParameter("@CONFIG_VIEW3",   SqlDbType.NVarChar,  -1),
                new SqlParameter("@LASTMODIFYDATE", SqlDbType.DateTime),
                new SqlParameter("@LASTMODIFYUSER", SqlDbType.Int,        4),
                new SqlParameter("@AUDODATE",       SqlDbType.DateTime)
            };
            parameters[0].Value = model.NAME;
            parameters[1].Value = model.DESC;
            parameters[2].Value = model.CONFIG_VIEW1;
            parameters[3].Value = model.CONFIG_VIEW2;
            parameters[4].Value = model.CONFIG_VIEW3;
            parameters[5].Value = model.LASTMODIFYDATE;
            parameters[6].Value = model.LASTMODIFYUSER;
            parameters[7].Value = model.AUDODATE;

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

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

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

                AUDITLOG.Add(auditobj);

                return(model.ID);
            }
        }