/// <summary> /// 快递数据 /// </summary> protected void ExpressBind() { ShowShop.BLL.Product.Express bll = new ShowShop.BLL.Product.Express(); List<ShowShop.Model.Product.Express> model = bll.GetAll(); ddlExpressCompany.DataSource = model; ddlExpressCompany.DataTextField = "Name"; ddlExpressCompany.DataValueField = "ID"; ddlExpressCompany.DataBind(); }
/// <summary> /// 显示编辑信息 /// </summary> /// <param name="id"></param> protected void BandInfo(int id) { ShowShop.BLL.Product.Express bll = new ShowShop.BLL.Product.Express(); ShowShop.Model.Product.Express model = bll.GetModelByID(id); this.txtName.Text = model.Name; this.txtFullName.Text = model.FullName; this.txtAddress.Text = model.Address; this.txtPhone.Text = model.Phone; this.txtPerson.Text = model.Person; this.txtSort.Text = model.Sort.ToString(); ViewState["ID"] = model.ID.ToString(); ViewState["NumStr"] = model.Numstr; }
protected void lbtnSave_Click(object sender, EventArgs e) { try { ShowShop.BLL.Product.Express bll = new ShowShop.BLL.Product.Express(); ShowShop.Model.Product.Express model = new ShowShop.Model.Product.Express(); model.Name = this.txtName.Text.Trim(); model.FullName = this.txtFullName.Text.Trim(); model.Address = this.txtAddress.Text.Trim(); if (txtPhone.Text!="") { if(!ChangeHope.Common.ValidateHelper.IsPhone(txtPhone.Text.Trim())) { this.ltlMsg.Text = "操作失败,请输入正确的电话号码。"; this.pnlMsg.Visible = true; this.pnlMsg.CssClass = "actionErr"; return; } } model.Phone = this.txtPhone.Text.Trim(); model.Person = this.txtPerson.Text.Trim(); model.Sort = Convert.ToInt32(this.txtSort.Text.Trim()); if (ViewState["ID"] != null)//更新 { model.ID = Convert.ToInt32(ViewState["ID"].ToString()); model.Numstr = ViewState["NumStr"].ToString(); bll.Amend(model); } else//添加 { string str = DateTime.Now.ToFileTime().ToString(); Random rand = new Random(); model.Numstr = String.Format("YX{0}Ram{1}", str, rand.Next(10000, 99999)); bll.Add(model); } this.ltlMsg.Text = "操作成功,已保存该信息"; this.pnlMsg.Visible = true; this.pnlMsg.CssClass = "actionOk"; } catch { this.ltlMsg.Text = "操作失败,请查看数据格式是否符合要求"; this.pnlMsg.Visible = true; this.pnlMsg.CssClass = "actionErr"; } }
/// <summary> /// 列表 /// </summary> /// <returns></returns> protected string GetList() { ChangeHope.WebPage.Table table = new ChangeHope.WebPage.Table(); ShowShop.BLL.Product.Express bll = new ShowShop.BLL.Product.Express(); ChangeHope.DataBase.DataByPage dataPage = bll.GetList(); //第一步先添加表头 table.AddHeadCol("", "序号"); table.AddHeadCol("", "名称"); table.AddHeadCol("", "联系人"); table.AddHeadCol("", "电话"); table.AddHeadCol("", "优先级"); table.AddHeadCol("", "操作"); table.AddRow(); //添加表的内容 if (dataPage.DataReader != null) { int curpage = ChangeHope.WebPage.PageRequest.GetInt("pageindex"); if (curpage < 0) { curpage = 1; } int count = 0; while (dataPage.DataReader.Read()) { count++; string No = (15 * (curpage - 1) + count).ToString(); table.AddCol(No); table.AddCol(dataPage.DataReader["name"].ToString()); table.AddCol(dataPage.DataReader["person"].ToString()); table.AddCol(dataPage.DataReader["phone"].ToString()); table.AddCol(string.Format("<input id='txtSort{0}' value='{1}' size='5' onblur='SetSort({0})'/>", dataPage.DataReader["id"].ToString(), dataPage.DataReader["sort"].ToString())); table.AddCol(string.Format("<a href=express_edite.aspx?id={0}>编辑</a> <a href='javascript:void(0)' onclick='Del({0})'>删除</a>", dataPage.DataReader["id"].ToString())); table.AddRow(); } } string view = table.GetTable() + dataPage.PageToolBar; dataPage.Dispose(); dataPage = null; return view; }
/// <summary> /// 修改优先级 /// </summary> /// <param name="id"></param> /// <param name="sort"></param> private void SetSort(int id, int sort) { ShowShop.BLL.Product.Express bll = new ShowShop.BLL.Product.Express(); bll.Amend(id, "sort", sort); Response.Write("ok"); }
/// <summary> /// 删除 /// </summary> /// <param name="id"></param> private void Del(string id) { ShowShop.BLL.Product.Express bll = new ShowShop.BLL.Product.Express(); bll.Delete(id); Response.Write("ok"); }