/// <summary> /// 增加一条数据 /// </summary> public int Add(DNSABC.Model.DNSABC_UserInfo model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into DNSABC_UserInfo("); strSql.Append("UserId,AccountBalance,AvilableBalance,ConsumedAmount,Money,GradeID,State,RealName,Qq,Mobil,Tel,Address,Postcode,Website,IDcardNum,AccountType,SiteID)"); strSql.Append(" values ("); strSql.Append("@UserId,@AccountBalance,@AvilableBalance,@ConsumedAmount,@Money,@GradeID,@State,@RealName,@Qq,@Mobil,@Tel,@Address,@Postcode,@Website,@IDcardNum,@AccountType,@SiteID)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@UserId", SqlDbType.Int, 4), new SqlParameter("@AccountBalance", SqlDbType.Int, 4), new SqlParameter("@AvilableBalance", SqlDbType.Int, 4), new SqlParameter("@ConsumedAmount", SqlDbType.Int, 4), new SqlParameter("@Money", SqlDbType.Int, 4), new SqlParameter("@GradeID", SqlDbType.Int, 4), new SqlParameter("@State", SqlDbType.Int, 4), new SqlParameter("@RealName", SqlDbType.VarChar, 50), new SqlParameter("@Qq", SqlDbType.Int, 4), new SqlParameter("@Mobil", SqlDbType.VarChar, 20), new SqlParameter("@Tel", SqlDbType.VarChar, 20), new SqlParameter("@Address", SqlDbType.VarChar, 200), new SqlParameter("@Postcode", SqlDbType.VarChar, 20), new SqlParameter("@Website", SqlDbType.VarChar, 200), new SqlParameter("@IDcardNum", SqlDbType.VarChar, 20), new SqlParameter("@AccountType", SqlDbType.Int, 4), new SqlParameter("@SiteID", SqlDbType.Int, 4) }; parameters[0].Value = model.UserId; parameters[1].Value = model.AccountBalance; parameters[2].Value = model.AvilableBalance; parameters[3].Value = model.ConsumedAmount; parameters[4].Value = model.Money; parameters[5].Value = model.GradeID; parameters[6].Value = model.State; parameters[7].Value = model.RealName; parameters[8].Value = model.Qq; parameters[9].Value = model.Mobil; parameters[10].Value = model.Tel; parameters[11].Value = model.Address; parameters[12].Value = model.Postcode; parameters[13].Value = model.Website; parameters[14].Value = model.IDcardNum; parameters[15].Value = model.AccountType; parameters[16].Value = model.SiteID; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
private void ShowInfo(int Id) { DNSABC.BLL.DNSABC_UserInfo bll = new DNSABC.BLL.DNSABC_UserInfo(); DNSABC.Model.DNSABC_UserInfo model = bll.GetModel(Id); this.lblId.Text = model.Id.ToString(); this.txtUserId.Text = model.UserId.ToString(); this.txtAccountBalance.Text = model.AccountBalance.ToString(); this.txtAvilableBalance.Text = model.AvilableBalance.ToString(); this.txtConsumedAmount.Text = model.ConsumedAmount.ToString(); this.txtMoney.Text = model.Money.ToString(); this.txtGradeID.Text = model.GradeID.ToString(); this.txtState.Text = model.State.ToString(); this.txtRealName.Text = model.RealName; this.txtQq.Text = model.Qq.ToString(); this.txtMobil.Text = model.Mobil; this.txtTel.Text = model.Tel; this.txtAddress.Text = model.Address; this.txtPostcode.Text = model.Postcode; this.txtWebsite.Text = model.Website; this.txtIDcardNum.Text = model.IDcardNum; this.txtAccountType.Text = model.AccountType.ToString(); this.txtSiteID.Text = model.SiteID.ToString(); }
public void btnSave_Click(object sender, EventArgs e) { string strErr = ""; if (!PageValidate.IsNumber(txtUserId.Text)) { strErr += "用户ID格式错误!\\n"; } if (!PageValidate.IsNumber(txtAccountBalance.Text)) { strErr += "账户余额格式错误!\\n"; } if (!PageValidate.IsNumber(txtAvilableBalance.Text)) { strErr += "可用余额格式错误!\\n"; } if (!PageValidate.IsNumber(txtConsumedAmount.Text)) { strErr += "已经消费金额格式错误!\\n"; } if (!PageValidate.IsNumber(txtMoney.Text)) { strErr += "积分格式错误!\\n"; } if (!PageValidate.IsNumber(txtGradeID.Text)) { strErr += "用户等级ID 默认值1格式错误!\\n"; } if (!PageValidate.IsNumber(txtState.Text)) { strErr += "有效状态 0为停用格式错误!\\n"; } if (this.txtRealName.Text.Trim().Length == 0) { strErr += "联系人姓名不能为空!\\n"; } if (!PageValidate.IsNumber(txtQq.Text)) { strErr += "QQ号码格式错误!\\n"; } if (this.txtMobil.Text.Trim().Length == 0) { strErr += "联系人手机不能为空!\\n"; } if (this.txtTel.Text.Trim().Length == 0) { strErr += "电话不能为空!\\n"; } if (this.txtAddress.Text.Trim().Length == 0) { strErr += "地址不能为空!\\n"; } if (this.txtPostcode.Text.Trim().Length == 0) { strErr += "邮编不能为空!\\n"; } if (this.txtWebsite.Text.Trim().Length == 0) { strErr += "网站不能为空!\\n"; } if (this.txtIDcardNum.Text.Trim().Length == 0) { strErr += "身份证号码不能为空!\\n"; } if (!PageValidate.IsNumber(txtAccountType.Text)) { strErr += "账户类型 企业则对应企业信息表格式错误!\\n"; } if (!PageValidate.IsNumber(txtSiteID.Text)) { strErr += "站点ID 0为主站 大于0为站格式错误!\\n"; } if (strErr != "") { MessageBox.Show(this, strErr); return; } int Id = int.Parse(this.lblId.Text); int UserId = int.Parse(this.txtUserId.Text); int AccountBalance = int.Parse(this.txtAccountBalance.Text); int AvilableBalance = int.Parse(this.txtAvilableBalance.Text); int ConsumedAmount = int.Parse(this.txtConsumedAmount.Text); int Money = int.Parse(this.txtMoney.Text); int GradeID = int.Parse(this.txtGradeID.Text); int State = int.Parse(this.txtState.Text); string RealName = this.txtRealName.Text; int Qq = int.Parse(this.txtQq.Text); string Mobil = this.txtMobil.Text; string Tel = this.txtTel.Text; string Address = this.txtAddress.Text; string Postcode = this.txtPostcode.Text; string Website = this.txtWebsite.Text; string IDcardNum = this.txtIDcardNum.Text; int AccountType = int.Parse(this.txtAccountType.Text); int SiteID = int.Parse(this.txtSiteID.Text); DNSABC.Model.DNSABC_UserInfo model = new DNSABC.Model.DNSABC_UserInfo(); model.Id = Id; model.UserId = UserId; model.AccountBalance = AccountBalance; model.AvilableBalance = AvilableBalance; model.ConsumedAmount = ConsumedAmount; model.Money = Money; model.GradeID = GradeID; model.State = State; model.RealName = RealName; model.Qq = Qq; model.Mobil = Mobil; model.Tel = Tel; model.Address = Address; model.Postcode = Postcode; model.Website = Website; model.IDcardNum = IDcardNum; model.AccountType = AccountType; model.SiteID = SiteID; DNSABC.BLL.DNSABC_UserInfo bll = new DNSABC.BLL.DNSABC_UserInfo(); bll.Update(model); ROYcms.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx"); }
/// <summary> /// 得到一个对象实体 /// </summary> public DNSABC.Model.DNSABC_UserInfo GetModel(int Id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 Id,UserId,AccountBalance,AvilableBalance,ConsumedAmount,Money,GradeID,State,RealName,Qq,Mobil,Tel,Address,Postcode,Website,IDcardNum,AccountType,SiteID from DNSABC_UserInfo "); strSql.Append(" where Id=@Id"); SqlParameter[] parameters = { new SqlParameter("@Id", SqlDbType.Int, 4) }; parameters[0].Value = Id; DNSABC.Model.DNSABC_UserInfo model = new DNSABC.Model.DNSABC_UserInfo(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["Id"] != null && ds.Tables[0].Rows[0]["Id"].ToString() != "") { model.Id = int.Parse(ds.Tables[0].Rows[0]["Id"].ToString()); } if (ds.Tables[0].Rows[0]["UserId"] != null && ds.Tables[0].Rows[0]["UserId"].ToString() != "") { model.UserId = int.Parse(ds.Tables[0].Rows[0]["UserId"].ToString()); } if (ds.Tables[0].Rows[0]["AccountBalance"] != null && ds.Tables[0].Rows[0]["AccountBalance"].ToString() != "") { model.AccountBalance = int.Parse(ds.Tables[0].Rows[0]["AccountBalance"].ToString()); } if (ds.Tables[0].Rows[0]["AvilableBalance"] != null && ds.Tables[0].Rows[0]["AvilableBalance"].ToString() != "") { model.AvilableBalance = int.Parse(ds.Tables[0].Rows[0]["AvilableBalance"].ToString()); } if (ds.Tables[0].Rows[0]["ConsumedAmount"] != null && ds.Tables[0].Rows[0]["ConsumedAmount"].ToString() != "") { model.ConsumedAmount = int.Parse(ds.Tables[0].Rows[0]["ConsumedAmount"].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]["GradeID"] != null && ds.Tables[0].Rows[0]["GradeID"].ToString() != "") { model.GradeID = int.Parse(ds.Tables[0].Rows[0]["GradeID"].ToString()); } if (ds.Tables[0].Rows[0]["State"] != null && ds.Tables[0].Rows[0]["State"].ToString() != "") { model.State = int.Parse(ds.Tables[0].Rows[0]["State"].ToString()); } if (ds.Tables[0].Rows[0]["RealName"] != null && ds.Tables[0].Rows[0]["RealName"].ToString() != "") { model.RealName = ds.Tables[0].Rows[0]["RealName"].ToString(); } if (ds.Tables[0].Rows[0]["Qq"] != null && ds.Tables[0].Rows[0]["Qq"].ToString() != "") { model.Qq = int.Parse(ds.Tables[0].Rows[0]["Qq"].ToString()); } if (ds.Tables[0].Rows[0]["Mobil"] != null && ds.Tables[0].Rows[0]["Mobil"].ToString() != "") { model.Mobil = ds.Tables[0].Rows[0]["Mobil"].ToString(); } if (ds.Tables[0].Rows[0]["Tel"] != null && ds.Tables[0].Rows[0]["Tel"].ToString() != "") { model.Tel = ds.Tables[0].Rows[0]["Tel"].ToString(); } if (ds.Tables[0].Rows[0]["Address"] != null && ds.Tables[0].Rows[0]["Address"].ToString() != "") { model.Address = ds.Tables[0].Rows[0]["Address"].ToString(); } if (ds.Tables[0].Rows[0]["Postcode"] != null && ds.Tables[0].Rows[0]["Postcode"].ToString() != "") { model.Postcode = ds.Tables[0].Rows[0]["Postcode"].ToString(); } if (ds.Tables[0].Rows[0]["Website"] != null && ds.Tables[0].Rows[0]["Website"].ToString() != "") { model.Website = ds.Tables[0].Rows[0]["Website"].ToString(); } if (ds.Tables[0].Rows[0]["IDcardNum"] != null && ds.Tables[0].Rows[0]["IDcardNum"].ToString() != "") { model.IDcardNum = ds.Tables[0].Rows[0]["IDcardNum"].ToString(); } if (ds.Tables[0].Rows[0]["AccountType"] != null && ds.Tables[0].Rows[0]["AccountType"].ToString() != "") { model.AccountType = int.Parse(ds.Tables[0].Rows[0]["AccountType"].ToString()); } if (ds.Tables[0].Rows[0]["SiteID"] != null && ds.Tables[0].Rows[0]["SiteID"].ToString() != "") { model.SiteID = int.Parse(ds.Tables[0].Rows[0]["SiteID"].ToString()); } return(model); } else { return(null); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(DNSABC.Model.DNSABC_UserInfo model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update DNSABC_UserInfo set "); strSql.Append("UserId=@UserId,"); strSql.Append("AccountBalance=@AccountBalance,"); strSql.Append("AvilableBalance=@AvilableBalance,"); strSql.Append("ConsumedAmount=@ConsumedAmount,"); strSql.Append("Money=@Money,"); strSql.Append("GradeID=@GradeID,"); strSql.Append("State=@State,"); strSql.Append("RealName=@RealName,"); strSql.Append("Qq=@Qq,"); strSql.Append("Mobil=@Mobil,"); strSql.Append("Tel=@Tel,"); strSql.Append("Address=@Address,"); strSql.Append("Postcode=@Postcode,"); strSql.Append("Website=@Website,"); strSql.Append("IDcardNum=@IDcardNum,"); strSql.Append("AccountType=@AccountType,"); strSql.Append("SiteID=@SiteID"); strSql.Append(" where Id=@Id"); SqlParameter[] parameters = { new SqlParameter("@UserId", SqlDbType.Int, 4), new SqlParameter("@AccountBalance", SqlDbType.Int, 4), new SqlParameter("@AvilableBalance", SqlDbType.Int, 4), new SqlParameter("@ConsumedAmount", SqlDbType.Int, 4), new SqlParameter("@Money", SqlDbType.Int, 4), new SqlParameter("@GradeID", SqlDbType.Int, 4), new SqlParameter("@State", SqlDbType.Int, 4), new SqlParameter("@RealName", SqlDbType.VarChar, 50), new SqlParameter("@Qq", SqlDbType.Int, 4), new SqlParameter("@Mobil", SqlDbType.VarChar, 20), new SqlParameter("@Tel", SqlDbType.VarChar, 20), new SqlParameter("@Address", SqlDbType.VarChar, 200), new SqlParameter("@Postcode", SqlDbType.VarChar, 20), new SqlParameter("@Website", SqlDbType.VarChar, 200), new SqlParameter("@IDcardNum", SqlDbType.VarChar, 20), new SqlParameter("@AccountType", SqlDbType.Int, 4), new SqlParameter("@SiteID", SqlDbType.Int, 4), new SqlParameter("@Id", SqlDbType.Int, 4) }; parameters[0].Value = model.UserId; parameters[1].Value = model.AccountBalance; parameters[2].Value = model.AvilableBalance; parameters[3].Value = model.ConsumedAmount; parameters[4].Value = model.Money; parameters[5].Value = model.GradeID; parameters[6].Value = model.State; parameters[7].Value = model.RealName; parameters[8].Value = model.Qq; parameters[9].Value = model.Mobil; parameters[10].Value = model.Tel; parameters[11].Value = model.Address; parameters[12].Value = model.Postcode; parameters[13].Value = model.Website; parameters[14].Value = model.IDcardNum; parameters[15].Value = model.AccountType; parameters[16].Value = model.SiteID; parameters[17].Value = model.Id; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }