/// <summary> /// 更新一条数据 /// </summary> public void Update(TravelAgent.Model.Supplier model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update Supplier set "); strSql.Append("supplyName=@supplyName,"); strSql.Append("contactName=@contactName,"); strSql.Append("telephone=@telephone,"); strSql.Append("mobilephone=@mobilephone,"); strSql.Append("email=@email,"); strSql.Append("remark=@remark,"); strSql.Append("isLock=@isLock"); strSql.Append(" where Id=@Id "); SqlParameter[] parameters = { new SqlParameter("@supplyName", SqlDbType.NVarChar, 50), new SqlParameter("@contactName", SqlDbType.VarChar, 250), new SqlParameter("@telephone", SqlDbType.VarChar, 250), new SqlParameter("@mobilephone", SqlDbType.VarChar, 250), new SqlParameter("@email", SqlDbType.VarChar, 250), new SqlParameter("@remark", SqlDbType.Text, 500), new SqlParameter("@isLock", SqlDbType.Int), new SqlParameter("@Id", SqlDbType.Int, 4) }; parameters[0].Value = model.supplyName; parameters[1].Value = model.contactName; parameters[2].Value = model.telephone; parameters[3].Value = model.mobilephone; parameters[4].Value = model.email; parameters[5].Value = model.remark; parameters[6].Value = model.isLock; parameters[7].Value = model.Id; DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); }
/// <summary> /// 编辑 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSave_Click(object sender, EventArgs e) { TravelAgent.Model.Supplier model = new TravelAgent.Model.Supplier(); model.supplyName = this.txtSupplyName.Text.Trim(); model.contactName = this.txtContactName.Text.Trim(); model.telephone = this.txtTelephone.Text.Trim(); model.mobilephone = this.txtMobilephone.Text.Trim(); model.email = this.txtEmail.Text.Trim(); model.remark = this.txtRemark.Text.Trim(); model.isLock = this.chkIsLock.Checked?1:0; var stringUrl = Request.Url.ToString(); try { if (Request.QueryString["supplyid"] != null) { model.Id = Convert.ToInt32(Request.QueryString["supplyid"]); SupplyBll.Update(model); JscriptPrint("保存成功!", "SupplyList.aspx", "Success"); } else { SupplyBll.Add(model); JscriptPrint("添加成功!", "SupplyList.aspx", "Success"); } } catch { JscriptPrint("保存失败!", stringUrl, "Error"); } }
/// <summary> /// 增加一条数据 /// </summary> public void Add(TravelAgent.Model.Supplier model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into Supplier("); strSql.Append("supplyName,contactName,telephone,mobilephone,email,remark,isLock)"); strSql.Append(" values ("); strSql.Append("@supplyName,@contactName,@telephone,@mobilephone,@email,@remark,@isLock)"); SqlParameter[] parameters = { new SqlParameter("@supplyName", SqlDbType.NVarChar, 50), new SqlParameter("@contactName", SqlDbType.VarChar, 250), new SqlParameter("@telephone", SqlDbType.VarChar, 250), new SqlParameter("@mobilephone", SqlDbType.VarChar, 250), new SqlParameter("@email", SqlDbType.VarChar, 250), new SqlParameter("@remark", SqlDbType.Text, 500), new SqlParameter("@isLock", SqlDbType.Int, 4) }; parameters[0].Value = model.supplyName; parameters[1].Value = model.contactName; parameters[2].Value = model.telephone; parameters[3].Value = model.mobilephone; parameters[4].Value = model.email; parameters[5].Value = model.remark; parameters[6].Value = model.isLock; DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); }
/// <summary> /// 得到一个对象实体 /// </summary> public TravelAgent.Model.Supplier GetModel(int Id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 Id,supplyName,contactName,telephone,mobilephone,email,remark,isLock from Supplier "); strSql.Append(" where Id=@Id "); SqlParameter[] parameters = { new SqlParameter("@Id", SqlDbType.Int, 4) }; parameters[0].Value = Id; TravelAgent.Model.Supplier model = new TravelAgent.Model.Supplier(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["Id"].ToString() != "") { model.Id = int.Parse(ds.Tables[0].Rows[0]["Id"].ToString()); } model.supplyName = ds.Tables[0].Rows[0]["supplyName"].ToString(); model.contactName = ds.Tables[0].Rows[0]["contactName"].ToString(); model.telephone = ds.Tables[0].Rows[0]["telephone"].ToString(); model.mobilephone = ds.Tables[0].Rows[0]["mobilephone"].ToString(); model.email = ds.Tables[0].Rows[0]["email"].ToString(); model.remark = ds.Tables[0].Rows[0]["remark"].ToString(); model.isLock = int.Parse(ds.Tables[0].Rows[0]["isLock"].ToString()); return(model); } else { return(null); } }
protected void Page_Load(object sender, EventArgs e) { if (!this.IsPostBack) { if (Request.QueryString["supplyid"] != null) { TravelAgent.Model.Supplier model = SupplyBll.GetModel(Convert.ToInt32(Request.QueryString["supplyid"])); if (model != null) { this.txtSupplyName.Text = model.supplyName; this.txtContactName.Text = model.contactName; this.txtTelephone.Text = model.telephone; this.txtMobilephone.Text = model.mobilephone; this.txtEmail.Text = model.email; this.txtRemark.Text = model.remark; this.chkIsLock.Checked = model.isLock == 1; } } } }
/// <summary> /// 更新一条数据 /// </summary> public void Update(TravelAgent.Model.Supplier model) { SupplyDAL.Update(model); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(TravelAgent.Model.Supplier model) { SupplyDAL.Add(model); return(SupplyDAL.GetMaxID("Id")); }