protected void btnSave_Click(object sender, EventArgs e) { string strErr = ""; if (!PageValidate.IsNumber(txtR_UserID.Text)) { strErr += "角角所属用户ID格式错误!\\n"; } if (this.txtR_RoleName.Text.Trim().Length == 0) { strErr += "角色名称不能为空!\\n"; } if (this.txtR_Description.Text.Trim().Length == 0) { strErr += "角色介绍不能为空!\\n"; } if (strErr != "") { MessageBox.Show(this, strErr); return; } int R_UserID = int.Parse(this.txtR_UserID.Text); string R_RoleName = this.txtR_RoleName.Text; string R_Description = this.txtR_Description.Text; Maticsoft.Model.sys_Roles model = new Maticsoft.Model.sys_Roles(); model.R_UserID = R_UserID; model.R_RoleName = R_RoleName; model.R_Description = R_Description; Maticsoft.BLL.sys_Roles bll = new Maticsoft.BLL.sys_Roles(); bll.Add(model); Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "add.aspx"); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Maticsoft.Model.sys_Roles model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update sys_Roles set "); strSql.Append("R_UserID=@R_UserID,"); strSql.Append("R_RoleName=@R_RoleName,"); strSql.Append("R_Description=@R_Description"); strSql.Append(" where RoleID=@RoleID"); SqlParameter[] parameters = { new SqlParameter("@R_UserID", SqlDbType.Int, 4), new SqlParameter("@R_RoleName", SqlDbType.NVarChar, 50), new SqlParameter("@R_Description", SqlDbType.NVarChar, 255), new SqlParameter("@RoleID", SqlDbType.Int, 4) }; parameters[0].Value = model.R_UserID; parameters[1].Value = model.R_RoleName; parameters[2].Value = model.R_Description; parameters[3].Value = model.RoleID; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
protected void btnSave_Click(object sender, EventArgs e) { string strErr=""; if(!PageValidate.IsNumber(txtR_UserID.Text)) { strErr+="角角所属用户ID格式错误!\\n"; } if(this.txtR_RoleName.Text.Trim().Length==0) { strErr+="角色名称不能为空!\\n"; } if(this.txtR_Description.Text.Trim().Length==0) { strErr+="角色介绍不能为空!\\n"; } if(strErr!="") { MessageBox.Show(this,strErr); return; } int R_UserID=int.Parse(this.txtR_UserID.Text); string R_RoleName=this.txtR_RoleName.Text; string R_Description=this.txtR_Description.Text; Maticsoft.Model.sys_Roles model=new Maticsoft.Model.sys_Roles(); model.R_UserID=R_UserID; model.R_RoleName=R_RoleName; model.R_Description=R_Description; Maticsoft.BLL.sys_Roles bll=new Maticsoft.BLL.sys_Roles(); bll.Add(model); Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功!","add.aspx"); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Maticsoft.Model.sys_Roles model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into sys_Roles("); strSql.Append("R_UserID,R_RoleName,R_Description)"); strSql.Append(" values ("); strSql.Append("@R_UserID,@R_RoleName,@R_Description)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@R_UserID", SqlDbType.Int, 4), new SqlParameter("@R_RoleName", SqlDbType.NVarChar, 50), new SqlParameter("@R_Description", SqlDbType.NVarChar, 255) }; parameters[0].Value = model.R_UserID; parameters[1].Value = model.R_RoleName; parameters[2].Value = model.R_Description; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
private void ShowInfo(int RoleID) { Maticsoft.BLL.sys_Roles bll = new Maticsoft.BLL.sys_Roles(); Maticsoft.Model.sys_Roles model = bll.GetModel(RoleID); this.lblRoleID.Text = model.RoleID.ToString(); this.txtR_UserID.Text = model.R_UserID.ToString(); this.txtR_RoleName.Text = model.R_RoleName; this.txtR_Description.Text = model.R_Description; }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.sys_Roles DataRowToModel(DataRow row) { Maticsoft.Model.sys_Roles model=new Maticsoft.Model.sys_Roles(); if (row != null) { if(row["RoleID"]!=null && row["RoleID"].ToString()!="") { model.RoleID=int.Parse(row["RoleID"].ToString()); } if(row["R_UserID"]!=null && row["R_UserID"].ToString()!="") { model.R_UserID=int.Parse(row["R_UserID"].ToString()); } if(row["R_RoleName"]!=null) { model.R_RoleName=row["R_RoleName"].ToString(); } if(row["R_Description"]!=null) { model.R_Description=row["R_Description"].ToString(); } } return model; }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.sys_Roles DataRowToModel(DataRow row) { Maticsoft.Model.sys_Roles model = new Maticsoft.Model.sys_Roles(); if (row != null) { if (row["RoleID"] != null && row["RoleID"].ToString() != "") { model.RoleID = int.Parse(row["RoleID"].ToString()); } if (row["R_UserID"] != null && row["R_UserID"].ToString() != "") { model.R_UserID = int.Parse(row["R_UserID"].ToString()); } if (row["R_RoleName"] != null) { model.R_RoleName = row["R_RoleName"].ToString(); } if (row["R_Description"] != null) { model.R_Description = row["R_Description"].ToString(); } } return(model); }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.sys_Roles GetModel(int RoleID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 RoleID,R_UserID,R_RoleName,R_Description from sys_Roles "); strSql.Append(" where RoleID=@RoleID"); SqlParameter[] parameters = { new SqlParameter("@RoleID", SqlDbType.Int, 4) }; parameters[0].Value = RoleID; Maticsoft.Model.sys_Roles model = new Maticsoft.Model.sys_Roles(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.sys_Roles GetModel(int RoleID) { StringBuilder strSql=new StringBuilder(); strSql.Append("select top 1 RoleID,R_UserID,R_RoleName,R_Description from sys_Roles "); strSql.Append(" where RoleID=@RoleID"); SqlParameter[] parameters = { new SqlParameter("@RoleID", SqlDbType.Int,4) }; parameters[0].Value = RoleID; Maticsoft.Model.sys_Roles model=new Maticsoft.Model.sys_Roles(); DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters); if(ds.Tables[0].Rows.Count>0) { return DataRowToModel(ds.Tables[0].Rows[0]); } else { return null; } }