Exemplo n.º 1
0
        protected void gvHoaDon_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
        {
            int mahd = int.Parse(gvHoaDon.DataKeys[e.NewSelectedIndex].Value.ToString());

            Session["MaHoaDon"] = mahd;
            HoaDon     hd  = new HoaDon();
            BUS_HoaDon bus = new BUS_HoaDon();

            hd = bus.LayThongTinHD(mahd);

            txtMaHD.Text               = hd.MAHD.ToString();
            txtTenKH.Text              = hd.HOTEN;
            txtNgayLapHD.Text          = hd.NGAYLAPHD;
            txtNgayGiaoHang.Text       = hd.NGAYGIAOHANG;
            txtDiaChi.Text             = hd.DIACHIGIAOHANG;
            ddlTrangThai.SelectedValue = hd.TRANGTHAI.ToString();

            //load chi tiet hoa don
            DataTable dt      = new DataTable();
            BUS_CTHD  busCTHD = new BUS_CTHD();

            dt = busCTHD.LoadCTHD(mahd);
            gvCTHD.DataSource = dt.DefaultView;
            gvCTHD.DataBind();

            lblThongBao.Text = "";
        }
Exemplo n.º 2
0
        protected void gvCTHD_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            int         mahd   = int.Parse(Session["MaHoaDon"].ToString());
            GridViewRow row    = gvCTHD.Rows[e.RowIndex];
            BUS_SanPham busSp  = new BUS_SanPham();
            int         masp   = int.Parse(row.Cells[1].Text);
            int         masize = 0;
            string      s      = row.Cells[3].Text;

            switch (row.Cells[3].Text)
            {
            case "s":
                masize = 0;
                break;

            case "m":
                masize = 1;
                break;

            case "l":
                masize = 2;
                break;

            case "xl ":
                masize = 3;
                break;

            case "xxl":
                masize = 4;
                break;
            }
            TextBox txtSoLuong = row.FindControl("txtSoLuong") as TextBox;
            string  soluong    = txtSoLuong.Text.Trim();

            CTHD ct = new CTHD();

            ct.MAHD    = mahd;
            ct.MASP    = masp;
            ct.MASIZE  = masize;
            ct.SOLUONG = int.Parse(soluong);

            BUS_CTHD bus = new BUS_CTHD();

            bus.CapNhatCTHD(ct);



            gvCTHD.EditIndex = -1;
            DataTable dt      = new DataTable();
            BUS_CTHD  busCTHD = new BUS_CTHD();

            dt = busCTHD.LoadCTHD(mahd);
            gvCTHD.DataSource = dt.DefaultView;
            gvCTHD.PageIndex  = int.Parse(Session["cthdPage"].ToString());
            gvCTHD.DataBind();
        }
Exemplo n.º 3
0
        protected void gvCTHD_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
        {
            gvCTHD.EditIndex = -1;
            int       mahd    = int.Parse(Session["MaHoaDon"].ToString());
            DataTable dt      = new DataTable();
            BUS_CTHD  busCTHD = new BUS_CTHD();

            dt = busCTHD.LoadCTHD(mahd);
            gvCTHD.DataSource = dt.DefaultView;
            gvCTHD.PageIndex  = int.Parse(Session["cthdPage"].ToString());
            gvCTHD.DataBind();
        }
Exemplo n.º 4
0
        protected void gvCTHD_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            //load chi tiet hoa don
            DataTable dt      = new DataTable();
            BUS_CTHD  busCTHD = new BUS_CTHD();
            int       mahd    = int.Parse(Session["MaHoaDon"].ToString());

            Session["cthdPage"] = e.NewPageIndex;
            dt = busCTHD.LoadCTHD(mahd);
            gvCTHD.DataSource = dt.DefaultView;
            gvCTHD.PageIndex  = e.NewPageIndex;
            gvCTHD.DataBind();
        }
Exemplo n.º 5
0
        protected void gvCTHD_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            int      mahd = int.Parse(gvCTHD.DataKeys[e.RowIndex].Value.ToString());
            BUS_CTHD bus  = new BUS_CTHD();

            bus.XoaCTHD(mahd);

            gvCTHD.EditIndex = -1;
            DataTable dt      = new DataTable();
            BUS_CTHD  busCTHD = new BUS_CTHD();

            dt = busCTHD.LoadCTHD(mahd);
            gvCTHD.DataSource = dt.DefaultView;
            gvCTHD.PageIndex  = int.Parse(Session["cthdPage"].ToString());
            gvCTHD.DataBind();
        }