Exemplo n.º 1
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            string   ma   = TextBox1.Text;
            DateTime date = Calendar1.SelectedDate;

            CouponBUS.UpdateDate(ma, date);
        }
Exemplo n.º 2
0
        protected void btnSale_Click(object sender, EventArgs e)
        {
            int typePrice;

            int.TryParse(drPrice.SelectedValue, out typePrice);
            string macp  = hdfCouponId.Value;
            string error = "";

            try
            {
                int result = CouponBUS.AcceptOrdersCoupon(macp, typePrice, ref error);
                GridExCouponDataBind();
                if (result == 1)
                {
                    if (error != "")
                    {
                        lbresult.Text = "Đã xử lý thành công! Nhưng webservice của " + error + " chưa kết nối được";
                    }
                    else
                    {
                        lbresult.Text = "Đã xử lý thành công!";
                    }
                    lbresult.ForeColor = Color.Green;
                    btnSale.Visible    = false;
                    drPrice.Visible    = false;
                }
                else
                {
                    if (error != "")
                    {
                        lbresult.Text = "Đã xảy ra lỗi, vui lòng thử lại sau! Nhưng webservice của " + error + " chưa kết nối được";
                    }
                    else
                    {
                        lbresult.Text = "Đã xảy ra lỗi, vui lòng thử lại sau!";
                    }
                    lbresult.ForeColor = Color.Red;
                }
            }
            catch (Exception ex)
            {
                if (error != "")
                {
                    lbresult.Text = "Đã xảy ra lỗi, vui lòng thử lại sau! Nhưng webservice của " + error + " chưa kết nối được";
                }
                else
                {
                    lbresult.Text = "Đã xảy ra lỗi, vui lòng thử lại sau!";
                }
                lbresult.ForeColor = Color.Red;
            }
            lbresult.Visible = true;
        }
Exemplo n.º 3
0
 private void GridExCouponDataBind()
 {
     GridView1.DataSource = CouponBUS.GetExCoupons();
     GridView1.DataBind();
     if (GridView1.Rows.Count <= 0 && grDetail.Rows.Count > 0 && btnSale.Visible == false)
     {
         cph3.InnerHtml = "Chúc mừng bạn đã hoàn thành công việc";
     }
     if (GridView1.Rows.Count == 0 && grDetail.Rows.Count == 0)
     {
         cph3.InnerHtml = "Không có Coupon nào hết hạn cần xử lý cả";
     }
 }
Exemplo n.º 4
0
        protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            string macp = GridView1.DataKeys[e.RowIndex].Value.ToString();

            try
            {
                CouponBUS.DeleteCoupon(macp);
                GridCouponDataBind();
            }
            catch (Exception ex)
            {
            }
        }
Exemplo n.º 5
0
        protected void bttDangSP_Click(object sender, EventArgs e)
        {
            if (DateTimePicker1.getDate() == "" && DateTimePicker2.getDate() == "")
            {
                lbResultInfo.Text = "Chưa điền ngày";
                return;
            }
            DateTime batdau;
            DateTime ketthuc;

            if (!DateTime.TryParse(DateTimePicker1.getDate(), out batdau))
            {
                lbResultInfo.Text = "Trường ngày bắt đầu không đúng dịnh dạng ngày";
                return;
            }
            if (!DateTime.TryParse(DateTimePicker2.getDate(), out ketthuc))
            {
                lbResultInfo.Text = "Trường ngày kết thúc không đúng dịnh dạng ngày";
                return;
            }
            COUPON_DTO couDTO = new COUPON_DTO();

            couDTO.MaCoupon          = txtMaCP.Text;
            couDTO.MaSanPham         = ddlTenSP.SelectedValue.ToString();
            couDTO.GiaSauGiam        = float.Parse(txtGiaSauKhiGiam.Text);
            couDTO.ThoiGianBD        = batdau;
            couDTO.ThoiGianKT        = ketthuc;
            couDTO.SoLuongSanPhamMin = int.Parse(txtSLSPmin.Text);
            couDTO.TinhTrangCoupon   = "1";
            couDTO.DieuKienSuDung    = txtRreaDKSU.Value.ToString();
            couDTO.GiaGoc            = float.Parse(txtGiaGoc.Text);
            couDTO.DonViTienTe       = ddlDVTienTe.Text;
            couDTO.SoLuongCouponMin  = int.Parse(txtSLCPMinGiamGia.Text);
            try
            {
                CouponBUS.CreateCoupon(couDTO);
                lbResultInfo.Text = "Đã tạo thành công";
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Exemplo n.º 6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int isLogIn;

            int.TryParse(Session["IsLogin"].ToString(), out isLogIn);
            if (isLogIn == 1)
            {
                string typeUser = Session["LoaiUser"].ToString();
                if (typeUser == "Manager" && Request.QueryString["macp"] != "")
                {
                    if (!IsPostBack)
                    {
                        string     macp = Request.QueryString["macp"];
                        COUPON_DTO cp   = CouponBUS.GetCouponInfor1(macp);
                        txtGiaGoc.Text         = cp.GiaGoc.ToString();
                        txtGiaSauKhiGiam.Text  = cp.GiaSauGiam.ToString();
                        txtMaCP.Text           = cp.MaCoupon;
                        txtRreaDKSU.Value      = cp.DieuKienSuDung;
                        txtSLCPMinGiamGia.Text = cp.SoLuongCouponMin.ToString();
                        txtSLSPmin.Text        = cp.SoLuongSanPhamMin.ToString();
                        DateTimePicker1.setDate(cp.ThoiGianBD.ToShortDateString());
                        DateTimePicker2.setDate(cp.ThoiGianKT.ToShortDateString());
                        TextBox1.Text = cp.TenSanPham;

                        /*
                         * List<Coupon> list = CouponBUS.GetCouponInfor(macp);
                         * txtGiaGoc.Text = list[0].GiaHangKhiChuaGiam.ToString();
                         * txtGiaSauKhiGiam.Text = list[0].GiaHangSauKhiGiam.ToString();
                         * txtMaCP.Text = list[0].MaCoupon;
                         * txtRreaDKSU.Value = list[0].DieuKienSuDung;
                         * txtSLCPMinGiamGia.Text=list[0].s*/
                    }
                }
                else
                {
                    Response.Redirect("../Shared/Default.aspx");
                }
            }
            else
            {
                Response.Redirect("../Shared/Default.aspx");
            }
        }
Exemplo n.º 7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string macp = Request.QueryString["macp"];
                if (macp != "")
                {
                    List <Coupon> coupons = CouponBUS.GetCouponInfor(macp);
                    FormView1.DataSource = coupons;
                    FormView1.DataBind();


                    int numberOrder = 0;
                    int numberWS    = 0;

                    GridView grDetail = (GridView)FormView1.FindControl("grDetail");
                    grDetail.DataSource = CouponBUS.GetOrderExCoupons(macp, ref numberOrder, ref numberWS);
                    grDetail.DataBind();
                }
            }
        }
Exemplo n.º 8
0
        protected void LinkButton1_Click(object sender, EventArgs e)
        {
            string macp = ((LinkButton)sender).CommandArgument;

            hdfSLCP.Value     = ((LinkButton)sender).CommandName;
            hdfCouponId.Value = macp;
            h3.InnerText      = "Thông tin chi tiết coupon " + macp;
            int numberOrder = 0;
            int numberWS    = 0;

            grDetail.DataSource = CouponBUS.GetOrderExCoupons(macp, ref numberOrder, ref numberWS);
            grDetail.DataBind();
            int mincp;

            int.TryParse(hdfSLCP.Value, out mincp);

            h41.InnerHtml = "<b style='color:green'>Đã có tổng cộng " + numberOrder.ToString() + " Coupon được đặt từ " + numberWS.ToString() + " hệ thống mua chung</b>";
            if (numberOrder >= mincp)
            {
                h42.InnerHtml = "<b style='color:blue'>Số lượng coupon cần thỏa để giảm giá là " + hdfSLCP.Value + " Coupons</b>";
            }
            else
            {
                h42.InnerHtml = "<b style='color:red'>Số lượng coupon cần thỏa để giảm giá là " + hdfSLCP.Value + " Coupons</b>";
            }
            if (numberOrder <= 0)
            {
                btnSale.Text    = "Đánh dấu Coupon hết hạn";
                btnSale.Visible = true;
                drPrice.Visible = false;
            }
            else
            {
                btnSale.Text    = "Đồng ý bán";
                drPrice.Visible = true;
                btnSale.Visible = false;
            }
            lbresult.Visible  = false;
            divDetail.Visible = true;
        }
Exemplo n.º 9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int isLogIn;

            int.TryParse(Session["IsLogin"].ToString(), out isLogIn);
            if (isLogIn == 1)
            {
                string typeUser = Session["LoaiUser"].ToString();
                if (typeUser == "Consumer")
                {
                    if (!IsPostBack)
                    {
                        GridView1.DataSource = DonHangBUS.GetAllOrderKH(Session["User"].ToString());
                        GridView1.DataBind();

                        if (Session["mc"] != null)
                        {
                            muachung.Visible = true;
                            string username = Session["User"].ToString();
                            GridView2.DataSource = CouponBUS.GetDHCoupon(username);
                            GridView2.DataBind();
                            if (GridView2.Rows.Count <= 0)
                            {
                                muachung.Visible = false;
                            }
                        }
                    }
                }
                else
                {
                    Response.Redirect("../Shared/Default.aspx");
                }
            }
            else
            {
                Response.Redirect("../Shared/Default.aspx");
            }
        }
Exemplo n.º 10
0
 private void GridCouponDataBind()
 {
     GridView1.DataSource = CouponBUS.SelectAnyCoupon();
     GridView1.DataBind();
 }