/// <summary> /// 增加一条数据 /// </summary> public int Add(DNSABC.Model.ROYcms_user model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into ROYcms_user("); strSql.Append("RoleID,UgroupID,Name,PASSWORD,money,Qq,Email,Age,sex,Pic,Quanxian,Username,Guid,Ip,LoginTime)"); strSql.Append(" values ("); strSql.Append("@RoleID,@UgroupID,@Name,@PASSWORD,@money,@Qq,@Email,@Age,@sex,@Pic,@Quanxian,@Username,@Guid,@Ip,@LoginTime)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@RoleID", SqlDbType.VarChar, 50), new SqlParameter("@UgroupID", SqlDbType.VarChar, 50), new SqlParameter("@Name", SqlDbType.VarChar, 50), new SqlParameter("@PASSWORD", SqlDbType.VarChar, 50), new SqlParameter("@money", SqlDbType.Int, 4), new SqlParameter("@Qq", SqlDbType.VarChar, 50), new SqlParameter("@Email", SqlDbType.VarChar, 50), new SqlParameter("@Age", SqlDbType.Int, 4), new SqlParameter("@sex", SqlDbType.VarChar, 10), new SqlParameter("@Pic", SqlDbType.VarChar, 100), new SqlParameter("@Quanxian", SqlDbType.VarChar, 50), new SqlParameter("@Username", SqlDbType.VarChar, 50), new SqlParameter("@Guid", SqlDbType.VarChar, 50), new SqlParameter("@Ip", SqlDbType.VarChar, 20), new SqlParameter("@LoginTime", SqlDbType.DateTime) }; parameters[0].Value = model.RoleID; parameters[1].Value = model.UgroupID; parameters[2].Value = model.Name; parameters[3].Value = model.PASSWORD; parameters[4].Value = model.money; parameters[5].Value = model.Qq; parameters[6].Value = model.Email; parameters[7].Value = model.Age; parameters[8].Value = model.sex; parameters[9].Value = model.Pic; parameters[10].Value = model.Quanxian; parameters[11].Value = model.Username; parameters[12].Value = model.Guid; parameters[13].Value = model.Ip; parameters[14].Value = model.LoginTime; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
private void ShowInfo(int bh) { DNSABC.BLL.ROYcms_user bll = new DNSABC.BLL.ROYcms_user(); DNSABC.Model.ROYcms_user model = bll.GetModel(bh); this.lblbh.Text = model.bh.ToString(); this.txtRoleID.Text = model.RoleID; this.txtUgroupID.Text = model.UgroupID; this.txtName.Text = model.Name; this.txtPASSWORD.Text = model.PASSWORD; this.txtmoney.Text = model.money.ToString(); this.txtQq.Text = model.Qq; this.txtEmail.Text = model.Email; this.txtAge.Text = model.Age.ToString(); this.txtsex.Text = model.sex; this.txtPic.Text = model.Pic; this.txtQuanxian.Text = model.Quanxian; this.txtUsername.Text = model.Username; this.txtGuid.Text = model.Guid; this.txtIp.Text = model.Ip; this.txtLoginTime.Text = model.LoginTime.ToString(); }
private void ShowInfo(int bh) { DNSABC.BLL.ROYcms_user bll = new DNSABC.BLL.ROYcms_user(); DNSABC.Model.ROYcms_user model = bll.GetModel(bh); this.lblbh.Text = model.bh.ToString(); this.lblRoleID.Text = model.RoleID; this.lblUgroupID.Text = model.UgroupID; this.lblName.Text = model.Name; this.lblPASSWORD.Text = model.PASSWORD; this.lblmoney.Text = model.money.ToString(); this.lblQq.Text = model.Qq; this.lblEmail.Text = model.Email; this.lblAge.Text = model.Age.ToString(); this.lblsex.Text = model.sex; this.lblPic.Text = model.Pic; this.lblQuanxian.Text = model.Quanxian; this.lblUsername.Text = model.Username; this.lblGuid.Text = model.Guid; this.lblIp.Text = model.Ip; this.lblLoginTime.Text = model.LoginTime.ToString(); }
public void btnSave_Click(object sender, EventArgs e) { string strErr = ""; if (this.txtRoleID.Text.Trim().Length == 0) { strErr += "权限ID不能为空!\\n"; } if (this.txtUgroupID.Text.Trim().Length == 0) { strErr += "用户组ID不能为空!\\n"; } if (this.txtName.Text.Trim().Length == 0) { strErr += "用户名不能为空!\\n"; } if (this.txtPASSWORD.Text.Trim().Length == 0) { strErr += "密码不能为空!\\n"; } if (!PageValidate.IsNumber(txtmoney.Text)) { strErr += "积分格式错误!\\n"; } if (this.txtQq.Text.Trim().Length == 0) { strErr += "QQ不能为空!\\n"; } if (this.txtEmail.Text.Trim().Length == 0) { strErr += "邮件不能为空!\\n"; } if (!PageValidate.IsNumber(txtAge.Text)) { strErr += "年龄格式错误!\\n"; } if (this.txtsex.Text.Trim().Length == 0) { strErr += "性别不能为空!\\n"; } if (this.txtPic.Text.Trim().Length == 0) { strErr += "头像不能为空!\\n"; } if (this.txtQuanxian.Text.Trim().Length == 0) { strErr += "权限不能为空!\\n"; } if (this.txtUsername.Text.Trim().Length == 0) { strErr += "昵称不能为空!\\n"; } if (this.txtGuid.Text.Trim().Length == 0) { strErr += "全局ID不能为空!\\n"; } if (this.txtIp.Text.Trim().Length == 0) { strErr += "IP不能为空!\\n"; } if (!PageValidate.IsDateTime(txtLoginTime.Text)) { strErr += "注册时间格式错误!\\n"; } if (strErr != "") { MessageBox.Show(this, strErr); return; } int bh = int.Parse(this.lblbh.Text); string RoleID = this.txtRoleID.Text; string UgroupID = this.txtUgroupID.Text; string Name = this.txtName.Text; string PASSWORD = this.txtPASSWORD.Text; int money = int.Parse(this.txtmoney.Text); string Qq = this.txtQq.Text; string Email = this.txtEmail.Text; int Age = int.Parse(this.txtAge.Text); string sex = this.txtsex.Text; string Pic = this.txtPic.Text; string Quanxian = this.txtQuanxian.Text; string Username = this.txtUsername.Text; string Guid = this.txtGuid.Text; string Ip = this.txtIp.Text; DateTime LoginTime = DateTime.Parse(this.txtLoginTime.Text); DNSABC.Model.ROYcms_user model = new DNSABC.Model.ROYcms_user(); model.bh = bh; model.RoleID = RoleID; model.UgroupID = UgroupID; model.Name = Name; model.PASSWORD = PASSWORD; model.money = money; model.Qq = Qq; model.Email = Email; model.Age = Age; model.sex = sex; model.Pic = Pic; model.Quanxian = Quanxian; model.Username = Username; model.Guid = Guid; model.Ip = Ip; model.LoginTime = LoginTime; DNSABC.BLL.ROYcms_user bll = new DNSABC.BLL.ROYcms_user(); bll.Update(model); ROYcms.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx"); }
/// <summary> /// 得到一个对象实体 /// </summary> public DNSABC.Model.ROYcms_user GetModel(int bh) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 bh,RoleID,UgroupID,Name,PASSWORD,money,Qq,Email,Age,sex,Pic,Quanxian,Username,Guid,Ip,LoginTime from ROYcms_user "); strSql.Append(" where bh=@bh"); SqlParameter[] parameters = { new SqlParameter("@bh", SqlDbType.Int, 4) }; parameters[0].Value = bh; DNSABC.Model.ROYcms_user model = new DNSABC.Model.ROYcms_user(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["bh"] != null && ds.Tables[0].Rows[0]["bh"].ToString() != "") { model.bh = int.Parse(ds.Tables[0].Rows[0]["bh"].ToString()); } if (ds.Tables[0].Rows[0]["RoleID"] != null && ds.Tables[0].Rows[0]["RoleID"].ToString() != "") { model.RoleID = ds.Tables[0].Rows[0]["RoleID"].ToString(); } if (ds.Tables[0].Rows[0]["UgroupID"] != null && ds.Tables[0].Rows[0]["UgroupID"].ToString() != "") { model.UgroupID = ds.Tables[0].Rows[0]["UgroupID"].ToString(); } if (ds.Tables[0].Rows[0]["Name"] != null && ds.Tables[0].Rows[0]["Name"].ToString() != "") { model.Name = ds.Tables[0].Rows[0]["Name"].ToString(); } if (ds.Tables[0].Rows[0]["PASSWORD"] != null && ds.Tables[0].Rows[0]["PASSWORD"].ToString() != "") { model.PASSWORD = ds.Tables[0].Rows[0]["PASSWORD"].ToString(); } if (ds.Tables[0].Rows[0]["money"] != null && ds.Tables[0].Rows[0]["money"].ToString() != "") { model.money = int.Parse(ds.Tables[0].Rows[0]["money"].ToString()); } if (ds.Tables[0].Rows[0]["Qq"] != null && ds.Tables[0].Rows[0]["Qq"].ToString() != "") { model.Qq = ds.Tables[0].Rows[0]["Qq"].ToString(); } if (ds.Tables[0].Rows[0]["Email"] != null && ds.Tables[0].Rows[0]["Email"].ToString() != "") { model.Email = ds.Tables[0].Rows[0]["Email"].ToString(); } if (ds.Tables[0].Rows[0]["Age"] != null && ds.Tables[0].Rows[0]["Age"].ToString() != "") { model.Age = int.Parse(ds.Tables[0].Rows[0]["Age"].ToString()); } if (ds.Tables[0].Rows[0]["sex"] != null && ds.Tables[0].Rows[0]["sex"].ToString() != "") { model.sex = ds.Tables[0].Rows[0]["sex"].ToString(); } if (ds.Tables[0].Rows[0]["Pic"] != null && ds.Tables[0].Rows[0]["Pic"].ToString() != "") { model.Pic = ds.Tables[0].Rows[0]["Pic"].ToString(); } if (ds.Tables[0].Rows[0]["Quanxian"] != null && ds.Tables[0].Rows[0]["Quanxian"].ToString() != "") { model.Quanxian = ds.Tables[0].Rows[0]["Quanxian"].ToString(); } if (ds.Tables[0].Rows[0]["Username"] != null && ds.Tables[0].Rows[0]["Username"].ToString() != "") { model.Username = ds.Tables[0].Rows[0]["Username"].ToString(); } if (ds.Tables[0].Rows[0]["Guid"] != null && ds.Tables[0].Rows[0]["Guid"].ToString() != "") { model.Guid = ds.Tables[0].Rows[0]["Guid"].ToString(); } if (ds.Tables[0].Rows[0]["Ip"] != null && ds.Tables[0].Rows[0]["Ip"].ToString() != "") { model.Ip = ds.Tables[0].Rows[0]["Ip"].ToString(); } if (ds.Tables[0].Rows[0]["LoginTime"] != null && ds.Tables[0].Rows[0]["LoginTime"].ToString() != "") { model.LoginTime = DateTime.Parse(ds.Tables[0].Rows[0]["LoginTime"].ToString()); } return(model); } else { return(null); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(DNSABC.Model.ROYcms_user model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update ROYcms_user set "); strSql.Append("RoleID=@RoleID,"); strSql.Append("UgroupID=@UgroupID,"); strSql.Append("Name=@Name,"); strSql.Append("PASSWORD=@PASSWORD,"); strSql.Append("money=@money,"); strSql.Append("Qq=@Qq,"); strSql.Append("Email=@Email,"); strSql.Append("Age=@Age,"); strSql.Append("sex=@sex,"); strSql.Append("Pic=@Pic,"); strSql.Append("Quanxian=@Quanxian,"); strSql.Append("Username=@Username,"); strSql.Append("Guid=@Guid,"); strSql.Append("Ip=@Ip,"); strSql.Append("LoginTime=@LoginTime"); strSql.Append(" where bh=@bh"); SqlParameter[] parameters = { new SqlParameter("@RoleID", SqlDbType.VarChar, 50), new SqlParameter("@UgroupID", SqlDbType.VarChar, 50), new SqlParameter("@Name", SqlDbType.VarChar, 50), new SqlParameter("@PASSWORD", SqlDbType.VarChar, 50), new SqlParameter("@money", SqlDbType.Int, 4), new SqlParameter("@Qq", SqlDbType.VarChar, 50), new SqlParameter("@Email", SqlDbType.VarChar, 50), new SqlParameter("@Age", SqlDbType.Int, 4), new SqlParameter("@sex", SqlDbType.VarChar, 10), new SqlParameter("@Pic", SqlDbType.VarChar, 100), new SqlParameter("@Quanxian", SqlDbType.VarChar, 50), new SqlParameter("@Username", SqlDbType.VarChar, 50), new SqlParameter("@Guid", SqlDbType.VarChar, 50), new SqlParameter("@Ip", SqlDbType.VarChar, 20), new SqlParameter("@LoginTime", SqlDbType.DateTime), new SqlParameter("@bh", SqlDbType.Int, 4) }; parameters[0].Value = model.RoleID; parameters[1].Value = model.UgroupID; parameters[2].Value = model.Name; parameters[3].Value = model.PASSWORD; parameters[4].Value = model.money; parameters[5].Value = model.Qq; parameters[6].Value = model.Email; parameters[7].Value = model.Age; parameters[8].Value = model.sex; parameters[9].Value = model.Pic; parameters[10].Value = model.Quanxian; parameters[11].Value = model.Username; parameters[12].Value = model.Guid; parameters[13].Value = model.Ip; parameters[14].Value = model.LoginTime; parameters[15].Value = model.bh; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }