private void ShowInfo(int AddressId) { NoName.NetShop.BLL.AddressModelBll bll = new NoName.NetShop.BLL.AddressModelBll(); NoName.NetShop.Model.AddressModel model = bll.GetModel(AddressId); this.lblUserId.Text = model.UserId.ToString(); this.lblProvince.Text = model.Province; this.lblCity.Text = model.City; this.lblAddressDetail.Text = model.AddressDetail; this.lblRecieverName.Text = model.RecieverName; this.lblMobile.Text = model.Mobile; this.lblTelephone.Text = model.Telephone; this.lblPostalcode.Text = model.Postalcode; this.chkIsDefault.Checked = model.IsDefault; this.lblInsertTime.Text = model.InsertTime.ToString(); this.lblModifyTime.Text = model.ModifyTime.ToString(); }
/// <summary> /// 得到一个对象实体 /// </summary> public NoName.NetShop.Model.AddressModel GetModel(int AddressId) { Database db = DatabaseFactory.CreateDatabase(); DbCommand dbCommand = db.GetStoredProcCommand("UP_umAddress_GetModel"); db.AddInParameter(dbCommand, "AddressId", DbType.Int32, AddressId); NoName.NetShop.Model.AddressModel model = null; using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { if (dataReader.Read()) { model = ReaderBind(dataReader); } } return(model); }
/// <summary> /// 更新一条数据 /// </summary> public void Update(NoName.NetShop.Model.AddressModel model) { Database db = DatabaseFactory.CreateDatabase(); DbCommand dbCommand = db.GetStoredProcCommand("UP_umAddress_Update"); db.AddInParameter(dbCommand, "UserId", DbType.Int32, model.UserId); db.AddInParameter(dbCommand, "AddressId", DbType.Int32, model.AddressId); db.AddInParameter(dbCommand, "Province", DbType.AnsiString, model.Province); db.AddInParameter(dbCommand, "City", DbType.AnsiString, model.City); db.AddInParameter(dbCommand, "AddressDetail", DbType.AnsiString, model.AddressDetail); db.AddInParameter(dbCommand, "RecieverName", DbType.AnsiString, model.RecieverName); db.AddInParameter(dbCommand, "Mobile", DbType.AnsiString, model.Mobile); db.AddInParameter(dbCommand, "Telephone", DbType.AnsiString, model.Telephone); db.AddInParameter(dbCommand, "Postalcode", DbType.AnsiString, model.Postalcode); db.AddInParameter(dbCommand, "IsDefault", DbType.Boolean, model.IsDefault); db.AddInParameter(dbCommand, "InsertTime", DbType.DateTime, model.InsertTime); db.AddInParameter(dbCommand, "ModifyTime", DbType.DateTime, model.ModifyTime); db.ExecuteNonQuery(dbCommand); }
/// <summary> /// 对象实体绑定数据 /// </summary> public NoName.NetShop.Model.AddressModel ReaderBind(IDataReader dataReader) { NoName.NetShop.Model.AddressModel model = new NoName.NetShop.Model.AddressModel(); object ojb; ojb = dataReader["UserId"]; if (ojb != null && ojb != DBNull.Value) { model.UserId = (int)ojb; } ojb = dataReader["AddressId"]; if (ojb != null && ojb != DBNull.Value) { model.AddressId = (int)ojb; } model.Province = dataReader["Province"].ToString(); model.City = dataReader["City"].ToString(); model.AddressDetail = dataReader["AddressDetail"].ToString(); model.RecieverName = dataReader["RecieverName"].ToString(); model.Mobile = dataReader["Mobile"].ToString(); model.Telephone = dataReader["Telephone"].ToString(); model.Postalcode = dataReader["Postalcode"].ToString(); ojb = dataReader["IsDefault"]; if (ojb != null && ojb != DBNull.Value) { model.IsDefault = (bool)ojb; } ojb = dataReader["InsertTime"]; if (ojb != null && ojb != DBNull.Value) { model.InsertTime = (DateTime)ojb; } ojb = dataReader["ModifyTime"]; if (ojb != null && ojb != DBNull.Value) { model.ModifyTime = (DateTime)ojb; } return(model); }
protected void btnAdd_Click(object sender, EventArgs e) { string strErr=""; if(!PageValidate.IsNumber(txtUserId.Text)) { strErr+="UserId�������֣�\\n"; } if(this.txtProvince.Text =="") { strErr+="Province����Ϊ�գ�\\n"; } if(this.txtCity.Text =="") { strErr+="City����Ϊ�գ�\\n"; } if(this.txtAddressDetail.Text =="") { strErr+="AddressDetail����Ϊ�գ�\\n"; } if(this.txtRecieverName.Text =="") { strErr+="RecieverName����Ϊ�գ�\\n"; } if(this.txtMobile.Text =="") { strErr+="Mobile����Ϊ�գ�\\n"; } if(this.txtTelephone.Text =="") { strErr+="Telephone����Ϊ�գ�\\n"; } if(this.txtPostalcode.Text =="") { strErr+="Postalcode����Ϊ�գ�\\n"; } if(!PageValidate.IsDateTime(txtInsertTime.Text)) { strErr+="InsertTime����ʱ���ʽ��\\n"; } if(!PageValidate.IsDateTime(txtModifyTime.Text)) { strErr+="ModifyTime����ʱ���ʽ��\\n"; } if(strErr!="") { MessageBox.Show(this,strErr); return; } int UserId=int.Parse(this.txtUserId.Text); string Province=this.txtProvince.Text; string City=this.txtCity.Text; string AddressDetail=this.txtAddressDetail.Text; string RecieverName=this.txtRecieverName.Text; string Mobile=this.txtMobile.Text; string Telephone=this.txtTelephone.Text; string Postalcode=this.txtPostalcode.Text; bool IsDefault=this.chkIsDefault.Checked; DateTime InsertTime=DateTime.Parse(this.txtInsertTime.Text); DateTime ModifyTime=DateTime.Parse(this.txtModifyTime.Text); NoName.NetShop.Model.AddressModel model=new NoName.NetShop.Model.AddressModel(); model.UserId=UserId; model.Province=Province; model.City=City; model.AddressDetail=AddressDetail; model.RecieverName=RecieverName; model.Mobile=Mobile; model.Telephone=Telephone; model.Postalcode=Postalcode; model.IsDefault=IsDefault; model.InsertTime=InsertTime; model.ModifyTime=ModifyTime; NoName.NetShop.BLL.AddressModelBll bll=new NoName.NetShop.BLL.AddressModelBll(); bll.Add(model); }
protected void btnAdd_Click(object sender, EventArgs e) { string strErr = ""; if (!PageValidate.IsNumber(txtUserId.Text)) { strErr += "UserId不是数字!\\n"; } if (this.txtProvince.Text == "") { strErr += "Province不能为空!\\n"; } if (this.txtCity.Text == "") { strErr += "City不能为空!\\n"; } if (this.txtAddressDetail.Text == "") { strErr += "AddressDetail不能为空!\\n"; } if (this.txtRecieverName.Text == "") { strErr += "RecieverName不能为空!\\n"; } if (this.txtMobile.Text == "") { strErr += "Mobile不能为空!\\n"; } if (this.txtTelephone.Text == "") { strErr += "Telephone不能为空!\\n"; } if (this.txtPostalcode.Text == "") { strErr += "Postalcode不能为空!\\n"; } if (!PageValidate.IsDateTime(txtInsertTime.Text)) { strErr += "InsertTime不是时间格式!\\n"; } if (!PageValidate.IsDateTime(txtModifyTime.Text)) { strErr += "ModifyTime不是时间格式!\\n"; } if (strErr != "") { MessageBox.Show(this, strErr); return; } int UserId = int.Parse(this.txtUserId.Text); string Province = this.txtProvince.Text; string City = this.txtCity.Text; string AddressDetail = this.txtAddressDetail.Text; string RecieverName = this.txtRecieverName.Text; string Mobile = this.txtMobile.Text; string Telephone = this.txtTelephone.Text; string Postalcode = this.txtPostalcode.Text; bool IsDefault = this.chkIsDefault.Checked; DateTime InsertTime = DateTime.Parse(this.txtInsertTime.Text); DateTime ModifyTime = DateTime.Parse(this.txtModifyTime.Text); NoName.NetShop.Model.AddressModel model = new NoName.NetShop.Model.AddressModel(); model.UserId = UserId; model.Province = Province; model.City = City; model.AddressDetail = AddressDetail; model.RecieverName = RecieverName; model.Mobile = Mobile; model.Telephone = Telephone; model.Postalcode = Postalcode; model.IsDefault = IsDefault; model.InsertTime = InsertTime; model.ModifyTime = ModifyTime; NoName.NetShop.BLL.AddressModelBll bll = new NoName.NetShop.BLL.AddressModelBll(); bll.Update(model); }
/// <summary> /// ����ʵ������� /// </summary> public NoName.NetShop.Model.AddressModel ReaderBind(IDataReader dataReader) { NoName.NetShop.Model.AddressModel model=new NoName.NetShop.Model.AddressModel(); object ojb; ojb = dataReader["UserId"]; if(ojb != null && ojb != DBNull.Value) { model.UserId=(int)ojb; } ojb = dataReader["AddressId"]; if(ojb != null && ojb != DBNull.Value) { model.AddressId=(int)ojb; } model.Province=dataReader["Province"].ToString(); model.City=dataReader["City"].ToString(); model.AddressDetail=dataReader["AddressDetail"].ToString(); model.RecieverName=dataReader["RecieverName"].ToString(); model.Mobile=dataReader["Mobile"].ToString(); model.Telephone=dataReader["Telephone"].ToString(); model.Postalcode=dataReader["Postalcode"].ToString(); ojb = dataReader["IsDefault"]; if(ojb != null && ojb != DBNull.Value) { model.IsDefault=(bool)ojb; } ojb = dataReader["InsertTime"]; if(ojb != null && ojb != DBNull.Value) { model.InsertTime=(DateTime)ojb; } ojb = dataReader["ModifyTime"]; if(ojb != null && ojb != DBNull.Value) { model.ModifyTime=(DateTime)ojb; } return model; }