protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (isexist == false) { System.Data.DataTable MYDT = bllsensitivitylevel.GetList(me.ID, 1000, " DATABASEID='" + me.DatabaseID + "'", "SLEVEL").Tables[0]; if (MYDT.Rows.Count <= 0) { this.DropDownList1.Items.Clear(); this.DropDownList1.Items.Add(new ListItem("N/A", "0")); } else { this.DropDownList1.Items.Clear(); this.DropDownList1.DataSource = MYDT; this.DropDownList1.DataTextField = "NAME"; this.DropDownList1.DataValueField = "SLEVEL"; this.DropDownList1.DataBind(); this.DropDownList1.SelectedIndex = MYDT.Rows.Count - 1; } } else { CUSTOMRP.Model.SensitivityLevel mylevel = bllsensitivitylevel.GetModel(me.ID, id); this.TextBox1.Text = mylevel.NAME; this.TextBox2.Text = mylevel.DESCRIPTION; this.DropDownList1.Items.Add(new ListItem(mylevel.NAME, mylevel.SLEVEL.Value.ToString())); this.DropDownList1.Visible = false; } } }
protected void Page_Init(object sender, EventArgs e) { if (string.IsNullOrEmpty(Request.QueryString["id"])) { if (me.checkUserGroupRight(CUSTOMRP.Model.APPModuleID.usergroupright_securitylevel, "Add", me.LoginID) == false) { Common.JScript.AlertAndRedirect(AppNum.ErrorMsg.accesserror, "Slevel.aspx"); Response.End(); } isexist = false; id = 0; this.Button2.Visible = false; } else { if (me.checkUserGroupRight(CUSTOMRP.Model.APPModuleID.usergroupright_securitylevel, "Modify", me.LoginID) == false) { Common.JScript.AlertAndRedirect(AppNum.ErrorMsg.accesserror, "Slevel.aspx"); Response.End(); } isexist = true; id = Int32.Parse(Request.QueryString["id"]); myviewLevel = bllsensitivitylevel.GetModel(me.ID, id); if (myviewLevel == null) { Common.JScript.AlertAndRedirect(AppNum.ErrorMsg.parameter_error, "Slevel.aspx"); Response.End(); } } }
/// <summary> /// 得到一个对象实体 /// </summary> public CUSTOMRP.Model.SensitivityLevel DataRowToModel(DataRow row) { CUSTOMRP.Model.SensitivityLevel model = new CUSTOMRP.Model.SensitivityLevel(); if (row != null) { if (row["ID"] != null && row["ID"].ToString() != "") { model.ID = Int32.Parse(row["ID"].ToString()); } if (row["DATABASEID"] != null && row["DATABASEID"].ToString() != "") { model.DATABASEID = Int32.Parse(row["DATABASEID"].ToString()); } if (row["NAME"] != null) { model.NAME = row["NAME"].ToString(); } if (row["SLEVEL"] != null && row["SLEVEL"].ToString() != "") { model.SLEVEL = Decimal.Parse(row["SLEVEL"].ToString()); } if (row["DESCRIPTION"] != null) { model.DESCRIPTION = row["DESCRIPTION"].ToString(); } if (row["AUDOTIME"] != null && row["AUDOTIME"].ToString() != "") { model.AUDOTIME = DateTime.Parse(row["AUDOTIME"].ToString()); } } return(model); }
protected void Button1_Click(object sender, EventArgs e) { string name = this.TextBox1.Text.Trim(); string description = this.TextBox2.Text.Trim(); if (isexist == false) { if (bllsensitivitylevel.GetList(me.ID, "NAME='" + name + "'").Tables[0].Rows.Count > 0) { //Common.JScript.Alert(AppNum.Commonexits); //Common.JScript.GoHistory(-1); Common.JScript.AlertAndRedirect(AppNum.ErrorMsg.Commonexits, "Slevel.aspx"); Response.End(); } CUSTOMRP.Model.SensitivityLevel mylevel = new CUSTOMRP.Model.SensitivityLevel(); mylevel.DATABASEID = me.DatabaseID; mylevel.DESCRIPTION = description; mylevel.NAME = name; decimal slevel; if (this.DropDownList1.SelectedIndex == this.DropDownList1.Items.Count - 1)//Last option { slevel = Decimal.Parse(this.DropDownList1.SelectedValue) + 16; } else { decimal d1 = Decimal.Parse(this.DropDownList1.SelectedValue); decimal d2 = Decimal.Parse(this.DropDownList1.Items[this.DropDownList1.SelectedIndex + 1].Value); slevel = (d1 + d2) / 2; } mylevel.SLEVEL = slevel; bllsensitivitylevel.Add(me.ID, mylevel); } else { CUSTOMRP.Model.SensitivityLevel mylevel = bllsensitivitylevel.GetModel(me.ID, id); mylevel.DESCRIPTION = description; mylevel.NAME = name; bllsensitivitylevel.Update(me.ID, mylevel); } Common.JScript.AlertAndRedirect(AppNum.ErrorMsg.success, "Slevel.aspx"); Response.End(); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(int UserID, CUSTOMRP.Model.SensitivityLevel model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update SensitivityLevel set "); strSql.Append("DATABASEID=@DATABASEID,"); strSql.Append("NAME=@NAME,"); strSql.Append("SLEVEL=@SLEVEL,"); strSql.Append("DESCRIPTION=@DESCRIPTION,"); strSql.Append("AUDOTIME=@AUDOTIME"); strSql.Append(" where ID=@ID"); SqlParameter[] parameters = { new SqlParameter("@DATABASEID", SqlDbType.Int, 4), new SqlParameter("@NAME", SqlDbType.NVarChar, 50), new SqlParameter("@SLEVEL", SqlDbType.Decimal, 9), new SqlParameter("@DESCRIPTION", SqlDbType.NVarChar, -1), new SqlParameter("@AUDOTIME", SqlDbType.DateTime), new SqlParameter("@ID", SqlDbType.Int, 4) }; parameters[0].Value = model.DATABASEID; parameters[1].Value = model.NAME; parameters[2].Value = model.SLEVEL; parameters[3].Value = model.DESCRIPTION; parameters[4].Value = model.AUDOTIME; parameters[5].Value = model.ID; 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.SENSITIVITYLEVEL.Update"; auditobj.Message = String.Format(AppNum.AuditMessage.SensitivityLevelUpdateSuccess, model.ID); AUDITLOG.Add(auditobj); return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(int UserID, CUSTOMRP.Model.SensitivityLevel model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into SensitivityLevel("); strSql.Append("DATABASEID,NAME,SLEVEL,DESCRIPTION,AUDOTIME)"); strSql.Append(" values ("); strSql.Append("@DATABASEID,@NAME,@SLEVEL,@DESCRIPTION,@AUDOTIME)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@DATABASEID", SqlDbType.Int, 4), new SqlParameter("@NAME", SqlDbType.NVarChar, 50), new SqlParameter("@SLEVEL", SqlDbType.Decimal, 9), new SqlParameter("@DESCRIPTION", SqlDbType.NVarChar, -1), new SqlParameter("@AUDOTIME", SqlDbType.DateTime) }; parameters[0].Value = model.DATABASEID; parameters[1].Value = model.NAME; parameters[2].Value = model.SLEVEL; parameters[3].Value = model.DESCRIPTION; parameters[4].Value = model.AUDOTIME; 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.SENSITIVITYLEVEL.Add"; auditobj.Message = String.Format(AppNum.AuditMessage.SensitivityLevelInsertSuccess, model.ID); AUDITLOG.Add(auditobj); return(Convert.ToInt32(obj)); } }
/// <summary> /// 批量删除数据 /// </summary> //public bool DeleteList(int UserID, string IDlist) //{ // StringBuilder strSql=new StringBuilder(); // strSql.Append("delete from SensitivityLevel "); // strSql.Append(" where ID in ("+IDlist + ") "); // int rows=DbHelperSQL.ExecuteSql(UserID, strSql.ToString()); // if (rows > 0) // { // return true; // } // else // { // return false; // } //} /// <summary> /// 得到一个对象实体 /// </summary> public CUSTOMRP.Model.SensitivityLevel GetModel(int UserID, int ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 ID,DATABASEID,NAME,SLEVEL,DESCRIPTION,AUDOTIME from SensitivityLevel "); strSql.Append(" where ID=@ID"); SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.Int, 4) }; parameters[0].Value = ID; CUSTOMRP.Model.SensitivityLevel model = new CUSTOMRP.Model.SensitivityLevel(); DataSet ds = DbHelperSQL.Query(UserID, strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }