Esempio n. 1
0
 private void btnOK_Click(object sender, EventArgs e)
 {
     if (CustomerId != 0)
     {
         var result = service.Update(new Customers()
         {
             Id      = CustomerId,
             IsDel   = 0,
             Name    = txtName.Text.Trim(),
             Phone   = txtPhone.Text.Trim(),
             Remarks = txtRemarks.Text
         });
         if (result.Code == 0)
         {
             MessageBox.Show("更新客户信息成功", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.None);
             this.DialogResult = System.Windows.Forms.DialogResult.OK;
         }
         else
         {
             MessageBox.Show("更新客户信息失败", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     else
     {
         var result = service.Add(new Customers()
         {
             IsDel   = 0,
             Name    = txtName.Text.Trim(),
             Phone   = txtPhone.Text.Trim(),
             Remarks = txtRemarks.Text
         });
         if (result.Code == 0)
         {
             MessageBox.Show("新增客户信息成功", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.None);
             this.DialogResult = System.Windows.Forms.DialogResult.OK;
         }
         else
         {
             MessageBox.Show("新增客户信息失败", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
Esempio n. 2
0
        protected void btSubmit_Click(object sender, EventArgs e)
        {
            if (!UserRightImpl.CheckRightAdminnistrator().UserEdit)
            {
                Response.Redirect(Utility.UrlRoot + Config.PathNotRight, false);
                return;
            }

            try
            {
                int userID = 0;

                var obj = new CustomerImpl();
                if (Request.QueryString["ID"] != null && Request.QueryString["ID"] != string.Empty)
                {
                    try
                    {
                        userID = int.Parse(Request.QueryString["ID"]);
                        CustomerInfo item = obj.GetInfo(userID);

                        if (item == null)
                        {
                            Response.Redirect(Utility.UrlRoot + Config.PathError, false);
                            return;
                        }
                        var objAdmin = (AdminInfo)Session[Constant.SessionNameAccountAdmin];

                        //string imgName = IMGName();

                        item.s_CustomerName = txtName.Text;
                        item.s_Email        = txtEmail.Text;
                        item.s_Address      = txtAddress.Text;
                        item.s_Mobile       = txtMobile.Text;
                        item.s_Homepage     = txtHomepage.Text;
                        item.s_Logo         = UntilityFunction.StringForNull(HD_IMG.Value);

                        obj.Update(item);
                        //Delete cache
                        CacheController.GetListCus_Delete();
                    }
                    catch
                    {
                        Response.Redirect(Utility.UrlRoot + Config.PathError, false);
                        return;
                    }
                }
                else
                {
                    var item = new CustomerInfo();
                    item.s_CustomerName = txtName.Text;
                    item.s_Email        = txtEmail.Text;
                    item.s_Address      = txtAddress.Text;
                    item.s_Mobile       = txtMobile.Text;
                    item.s_Homepage     = txtHomepage.Text;
                    item.s_Logo         = UntilityFunction.StringForNull(HD_IMG.Value);// IMGName();

                    obj.Insert(item);
                    //Delete cache
                    CacheController.GetListCus_Delete();
                }
                Response.Redirect("customer_manager.aspx", false);
            }
            catch
            {
                lblMsg.Text = "Tên khách hàng. Bạn chạy chọn một tên khác";
            }
        }