Exemplo n.º 1
0
    protected void GridView1_RowSelect(object sender, GridViewSelectEventArgs e)
    {
        DDatHangDTO ddhDTO = new DDatHangDTO();

        ddhDTO.MaHD = int.Parse(GridView1.DataKeys[e.NewSelectedIndex]["MaHD"].ToString());
        DataTable dt = DDatHangBUS.LayChiTietHoaDon(ddhDTO);

        GridView2.DataSource = dt;
        GridView2.DataBind();
    }
Exemplo n.º 2
0
    protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        try
        {
            GridView    gv  = (GridView)sender;
            GridViewRow row = GridView1.Rows[e.RowIndex];

            string      sID    = gv.DataKeys[e.RowIndex]["MaHD"].ToString();
            DDatHangDTO ddhDTO = new DDatHangDTO();
            ddhDTO.MaHD = int.Parse(sID);
            if (gv.Rows.Count == 1)
            {
                CurrentPage--;
            }
            DDatHangBUS.XoaDonDatHang(ddhDTO);

            BindItemsList();
        }
        catch (Exception ex)
        { }
    }
Exemplo n.º 3
0
 protected void btnSubmit_Click(object sender, EventArgs e)
 {
     if (Session["TenDangNhap"] == null)
     {
         Response.Write("<script type='text/javascript'>alert('Bạn phải đăng nhập mới thực hiện được chức năng này.');</script>");
     }
     else
     {
         try
         {
             DDatHangDTO ddhDTO = new DDatHangDTO();
             ddhDTO.Username = Session["TenDangNhap"].ToString();
             string sTongTien = lblTongCong.Text.Substring(0, lblTongCong.Text.Length - 1);
             ddhDTO.TongTien     = int.Parse(sTongTien);
             ddhDTO.TenNguoiNhan = txtNguoiNhan.Text;
             ddhDTO.SDT          = txtSDT.Text;
             DateTime dNgayNhapHD = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
             ddhDTO.NgapNhapHD = dNgayNhapHD;
             DateTime dNgayGiao = new DateTime(int.Parse(ddlNam.SelectedItem.Value.ToString()), int.Parse(ddlThang.SelectedItem.Value.ToString()), int.Parse(ddlNgay.SelectedItem.Value.ToString()));
             ddhDTO.NgayGiao = dNgayGiao;
             ddhDTO.DiaChi   = txtDiaChi.Text;
             DDatHangBUS.ThemDonDatHang(ddhDTO);
             DataTable dt = (DataTable)Session["GioHang"];
             ddhDTO.MaHD = int.Parse(DDatHangBUS.LayMaHoaDon().ToString());
             for (int i = 0; i < dt.Rows.Count; i++)
             {
                 ddhDTO.MaSP      = int.Parse(dt.Rows[i][0].ToString());
                 ddhDTO.SoLuongSP = int.Parse(dt.Rows[i][2].ToString());
                 ddhDTO.DonGiaSP  = int.Parse(dt.Rows[i][3].ToString());
                 DDatHangBUS.ThemChiTietHoaDon(ddhDTO);
             }
             lblThongBao.Text = "Đặt hàng thành công.";
         }
         catch (Exception ex)
         {
             lblThongBao.Text = "Đặt hàng thất bại.";
         }
     }
 }
Exemplo n.º 4
0
    protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        try
        {
            GridView    gv  = (GridView)sender;
            GridViewRow row = GridView1.Rows[e.RowIndex];

            string sID              = gv.DataKeys[e.RowIndex]["MaHD"].ToString();
            string sNewUserName     = ((TextBox)(row.Cells[1].Controls[0])).Text;
            string sNewAddress      = ((TextBox)(row.Cells[2].Controls[0])).Text;
            string sNewPhoneNumber  = ((TextBox)(row.Cells[3].Controls[0])).Text;
            string sNewRecipient    = ((TextBox)(row.Cells[4].Controls[0])).Text;
            string sNewDeliveryDate = ((TextBox)(row.Cells[5].Controls[0])).Text;
            string sNewTotal        = ((TextBox)(row.Cells[6].Controls[0])).Text;
            string sNewOrderDay     = ((TextBox)(row.Cells[7].Controls[0])).Text;


            DDatHangDTO ddhDTO = new DDatHangDTO();
            ddhDTO.MaHD         = int.Parse(sID);
            ddhDTO.Username     = sNewUserName;
            ddhDTO.DiaChi       = sNewAddress;
            ddhDTO.SDT          = sNewPhoneNumber;
            ddhDTO.TenNguoiNhan = sNewRecipient;
            ddhDTO.Newdelivery  = sNewDeliveryDate;
            ddhDTO.TongTien     = int.Parse(sNewTotal);
            ddhDTO.NewOrder     = sNewOrderDay;
            DDatHangBUS.SuaDonDatHang(ddhDTO);
            GridView1.EditIndex = -1;
            BindItemsList();
        }
        catch (Exception ex)
        {
            Response.Write("<script type='text/javascript'>"
                           + "alert('Có lỗi xảy ra. Vui Lòng điền đúng kiểu dữ liệu yêu cầu !!!');"
                           + "</script>");
        }
    }
Exemplo n.º 5
0
    /// <summary>
    /// Build DataTable to bind Main Items List
    /// </summary>
    /// <returns>DataTable</returns>
    private DataTable GetDataTable()
    {
        DataTable dt = DDatHangBUS.LayDanhSachDonDatHang();

        return(dt);
    }