protected void btnSave_Click(object sender, EventArgs e) { //实例化一个控件数据映射对象 ControlDataMap cdm = new ControlDataMap(); //收集数据到实体对象 CustomerContactInfo info = cdm.CollectDataToObject<CustomerContactInfo>( MyWebForm.GetIBControls(this.tbCustomerInfo.Controls) ); //调用业务类,保存数据 bool result = false; CustomerManageBIZ biz = new CustomerManageBIZ(); if (dbtCID.ReadOnly) { //这里规定主键对应的控件是只读状态,表示当前表单是修改状态,否则是新增状态 result= biz.UpdateContactInfo(info); } else { info.Integral = 10;//新建客户默认送10个积分 result= biz.AddContactInfo(info); dbtCID.ReadOnly = true; } lblMsg.Text = result ? "保存成功!" : "保存失败"; bindGrid(); }
private void bindGrid() { CustomerManageBIZ biz = new CustomerManageBIZ(); this.ProPageToolBar1.AllCount = biz.GetContactInfoCount(); this.GridView1.DataSource = biz.GetContactInfoList(this.ProPageToolBar1.PageSize, 1, this.ProPageToolBar1.AllCount); this.GridView1.DataBind(); }
/// <summary> /// 指定的客户是否还需要继续等待 /// </summary> /// <param name="customer"></param> /// <param name="salePriceVM">销售价格单</param> /// <returns></returns> public bool Waite(Customer customer) { if (this.processingCustomer == customer) { //是当前用户,开始收银 //如果客户同意付款 //对客户所购物品的售价进行实际的计算 List <GoodsSalePriceVM> salesPriceInfo = new List <GoodsSalePriceVM>(); GoodsManageBIZ biz = new GoodsManageBIZ(); CustomerManageBIZ cbiz = new CustomerManageBIZ(); bool isCustomer = (cbiz.GetCustomerContactInfo(customer.CustomerID) != null); foreach (Goods goods in customer.Goodss) { GoodsSalePriceVM vm = new GoodsSalePriceVM(goods); int integral; decimal sellPrice = biz.GoodsSellPrice(goods.GoodsID, goods.SerialNumber, goods.GoodsNumber, isCustomer, out integral); if (sellPrice == 0) { vm.GoodsNumber = 0; goods.GoodsNumber = 0; } vm.DiscountPrice = sellPrice; //goods.GoodsPrice = sellPrice; goods.Integral = integral; salesPriceInfo.Add(vm); } this.CurrCRManchines.ReSet(); this.CurrCRManchines.GoodsSalePriceList = salesPriceInfo; return(false); } else { if (this.processingCustomer == null) { if (customerQueue.Count > 0) { //准备进行下一个客户的处理 this.processingCustomer = customerQueue.Dequeue(); this.lastProcessTime = DateTime.Now; } } else { //当前客户可能已经离开,放弃购物了,需要强行清除,否则后面的客户将会一直等待 if (DateTime.Now.Subtract(lastProcessTime).Minutes > 5) { this.processingCustomer = null; } } return(true); } }
protected void ProPageToolBar1_PageChangeIndex(object sender, EventArgs e) { CustomerManageBIZ biz = new CustomerManageBIZ(); this.ProPageToolBar1.AllCount = biz.GetContactInfoCount(); this.GridView1.DataSource = biz.GetContactInfoList( this.ProPageToolBar1.PageSize, this.ProPageToolBar1.CurrentPage, this.ProPageToolBar1.AllCount); this.GridView1.DataBind(); }
/// <summary> /// 指定的客户是否还需要继续等待 /// </summary> /// <param name="customer"></param> /// <param name="salePriceVM">销售价格单</param> /// <returns></returns> public bool Waite(Customer customer) { if (this.processingCustomer == customer) { //是当前用户,开始收银 //如果客户同意付款 //对客户所购物品的售价进行实际的计算 List<GoodsSalePriceVM> salesPriceInfo = new List<GoodsSalePriceVM>(); GoodsManageBIZ biz = new GoodsManageBIZ(); CustomerManageBIZ cbiz = new CustomerManageBIZ(); bool isCustomer = (cbiz.GetCustomerContactInfo(customer.CustomerID) != null); foreach (Goods goods in customer.Goodss) { GoodsSalePriceVM vm = new GoodsSalePriceVM(goods); int integral; decimal sellPrice = biz.GoodsSellPrice(goods.GoodsID, goods.SerialNumber, goods.GoodsNumber, isCustomer, out integral); if (sellPrice == 0) { vm.GoodsNumber = 0; goods.GoodsNumber = 0; } vm.DiscountPrice = sellPrice; //goods.GoodsPrice = sellPrice; goods.Integral = integral; salesPriceInfo.Add(vm); } this.CurrCRManchines.ReSet(); this.CurrCRManchines.GoodsSalePriceList = salesPriceInfo; return false; } else { if (this.processingCustomer == null) { if (customerQueue.Count > 0) { //准备进行下一个客户的处理 this.processingCustomer = customerQueue.Dequeue(); this.lastProcessTime = DateTime.Now; } } else { //当前客户可能已经离开,放弃购物了,需要强行清除,否则后面的客户将会一直等待 if (DateTime.Now.Subtract(lastProcessTime).Minutes > 5) this.processingCustomer = null; } return true; } }
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e) { lblMsg.Text = "Selected id=" + GridView1.SelectedRow.Cells[1].Text; string customerId = GridView1.SelectedRow.Cells[1].Text; //调用业务层方法获取实体 CustomerManageBIZ biz = new CustomerManageBIZ(); CustomerContactInfo info = biz.GetCustomerContactInfo (customerId); //将实体与页面控件绑定 WebControlDataMap.FillDataFromEntityClass(info, MyWebForm.GetIBControls(this.tbCustomerInfo.Controls) ); //标记当前表单为编辑状态,主键控件不可编辑 dbtCID.ReadOnly = true; this.tbCustomerInfo.Visible = true ; lblMsg.Text = "编辑客户联系信息后请保存!"; }
protected void btnComeIn_Click(object sender, EventArgs e) { string customerID = txtComeIn.Text; CustomerManageBIZ biz = new CustomerManageBIZ(); Customer customer = biz.GetRegistedCustomer(customerID); if (customer != null) { Session["Curr_Customer"] = customer; Response.Redirect("Index.aspx"); } else { lblMsg.Text = "对不起,您输入的客户号不存在,您也可以使用该客户号注册一个会员账号。"; } }
protected void btnDelete_Click(object sender, EventArgs e) { if (GridView1.SelectedIndex >= 0) { string customerId = GridView1.SelectedRow.Cells[1].Text; CustomerContactInfo info = new CustomerContactInfo() { CustomerID = customerId }; CustomerManageBIZ biz = new CustomerManageBIZ(); if (biz.RemoveContactInfo(info)) { this.tbCustomerInfo.Visible = false; lblMsg.Text = "删除成功!"; bindGrid(); } } else { lblMsg.Text = "请先选择一行有效的记录!"; } }