/// <summary> /// 增加一条数据 /// </summary> public int Add(int UserID, CUSTOMRP.Model.GROUPRIGHT model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into GROUPRIGHT("); strSql.Append("GID,COMPANY,REPORTGROUP,CATEGARY,SECURITY,QUERY,USERGROUP,USERGROUPRIGHT,USERSETUP,AUDODATE,EXTEND1,EXTEND2,EXTEND3)"); strSql.Append(" values ("); strSql.Append("@GID,@COMPANY,@REPORTGROUP,@CATEGARY,@SECURITY,@QUERY,@USERGROUP,@USERGROUPRIGHT,@USERSETUP,@AUDODATE,@EXTEND1,@EXTEND2,@EXTEND3)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@GID", SqlDbType.Int, 4), new SqlParameter("@COMPANY", SqlDbType.NVarChar, 50), new SqlParameter("@REPORTGROUP", SqlDbType.NVarChar, 50), new SqlParameter("@CATEGARY", SqlDbType.NVarChar, 50), new SqlParameter("@SECURITY", SqlDbType.NVarChar, 50), new SqlParameter("@QUERY", SqlDbType.NVarChar, 50), new SqlParameter("@USERGROUP", SqlDbType.NVarChar, 50), new SqlParameter("@USERGROUPRIGHT", SqlDbType.NVarChar, 50), new SqlParameter("@USERSETUP", SqlDbType.NVarChar, 50), new SqlParameter("@AUDODATE", SqlDbType.DateTime), new SqlParameter("@EXTEND1", SqlDbType.NVarChar, 50), new SqlParameter("@EXTEND2", SqlDbType.NVarChar, 50), new SqlParameter("@EXTEND3", SqlDbType.NVarChar, -1) }; parameters[0].Value = model.GID; parameters[1].Value = model.COMPANY; parameters[2].Value = model.REPORTGROUP; parameters[3].Value = model.CATEGARY; parameters[4].Value = model.SECURITY; parameters[5].Value = model.QUERY; parameters[6].Value = model.USERGROUP; parameters[7].Value = model.USERGROUPRIGHT; parameters[8].Value = model.USERSETUP; parameters[9].Value = model.AUDODATE; parameters[10].Value = model.EXTEND1; parameters[11].Value = model.EXTEND2; parameters[12].Value = model.EXTEND3; 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.GROUPRIGHT.Add"; auditobj.Message = String.Format(AppNum.AuditMessage.GroupRightInsertSuccess, model.ID); AUDITLOG.Add(auditobj); return(Convert.ToInt32(obj)); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(int UserID, CUSTOMRP.Model.GROUPRIGHT model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update GROUPRIGHT set "); strSql.Append("COMPANY=@COMPANY,"); strSql.Append("REPORTGROUP=@REPORTGROUP,"); strSql.Append("CATEGARY=@CATEGARY,"); strSql.Append("SECURITY=@SECURITY,"); strSql.Append("QUERY=@QUERY,"); strSql.Append("USERGROUP=@USERGROUP,"); strSql.Append("USERGROUPRIGHT=@USERGROUPRIGHT,"); strSql.Append("USERSETUP=@USERSETUP,"); strSql.Append("AUDODATE=@AUDODATE,"); strSql.Append("EXTEND1=@EXTEND1,"); strSql.Append("EXTEND2=@EXTEND2,"); strSql.Append("EXTEND3=@EXTEND3"); strSql.Append(" where ID=@ID"); SqlParameter[] parameters = { new SqlParameter("@COMPANY", SqlDbType.NVarChar, 50), new SqlParameter("@REPORTGROUP", SqlDbType.NVarChar, 50), new SqlParameter("@CATEGARY", SqlDbType.NVarChar, 50), new SqlParameter("@SECURITY", SqlDbType.NVarChar, 50), new SqlParameter("@QUERY", SqlDbType.NVarChar, 50), new SqlParameter("@USERGROUP", SqlDbType.NVarChar, 50), new SqlParameter("@USERGROUPRIGHT", SqlDbType.NVarChar, 50), new SqlParameter("@USERSETUP", SqlDbType.NVarChar, 50), new SqlParameter("@AUDODATE", SqlDbType.DateTime), new SqlParameter("@EXTEND1", SqlDbType.NVarChar, 50), new SqlParameter("@EXTEND2", SqlDbType.NVarChar, 50), new SqlParameter("@EXTEND3", SqlDbType.NVarChar, -1), new SqlParameter("@ID", SqlDbType.Int, 4), new SqlParameter("@GID", SqlDbType.Int, 4) }; parameters[0].Value = model.COMPANY; parameters[1].Value = model.REPORTGROUP; parameters[2].Value = model.CATEGARY; parameters[3].Value = model.SECURITY; parameters[4].Value = model.QUERY; parameters[5].Value = model.USERGROUP; parameters[6].Value = model.USERGROUPRIGHT; parameters[7].Value = model.USERSETUP; parameters[8].Value = model.AUDODATE; parameters[9].Value = model.EXTEND1; parameters[10].Value = model.EXTEND2; parameters[11].Value = model.EXTEND3; parameters[12].Value = model.ID; parameters[13].Value = model.GID; 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.GROUPRIGHT.Update"; auditobj.Message = String.Format(AppNum.AuditMessage.GroupRightUpdateSuccess, model.ID); AUDITLOG.Add(auditobj); return(true); } else { return(false); } }