Пример #1
0
        protected void btDelete_Click(object sender, EventArgs e)
        {
            if (!UserRightImpl.CheckRightAdminnistrator().UserDelete)
            {
                Response.Redirect(Utility.UrlRoot + Config.PathNotRight, false);
                return;
            }
            try
            {
                int          i   = 0;
                CustomerImpl obj = new CustomerImpl();
                foreach (GridViewRow row in grvView.Rows)
                {
                    var status = (CheckBox)row.Cells[2].FindControl("StatusCheck");

                    if (status.Checked)
                    {
                        int ID = int.Parse(grvView.DataKeys[i].Value.ToString());
                        obj.Delete(ID);
                        //delete cache
                        CacheController.GetListCus_Delete();
                    }

                    i++;
                }
            }
            catch
            {
                Response.Redirect(Utility.UrlRoot + Config.PathError, false);
                return;
            }
            BindGird();
        }
Пример #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";
            }
        }