Ejemplo n.º 1
0
        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
            {
                result          = biz.AddContactInfo(info);
                dbtCID.ReadOnly = true;
                txtComeIn.Text  = dbtCID.Text;
            }
            lblMsg.Text = result ? "保存成功!请进入本超市!(也可以继续修改你的个人信息)" : "保存失败";
        }
Ejemplo n.º 2
0
        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();
        }
Ejemplo n.º 3
0
        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();
        }
Ejemplo n.º 4
0
        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 = "对不起,您输入的客户号不存在,您也可以使用该客户号注册一个会员账号。";
            }
        }
Ejemplo n.º 5
0
        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 = "编辑客户联系信息后请保存!";
        }
Ejemplo n.º 6
0
        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 = "请先选择一行有效的记录!";
            }
        }