Exemple #1
0
        private void dgvDanhSachHoaDon_RowEnter(object sender, DataGridViewCellEventArgs e)
        {
            txtMaHoaDon.Text     = dgvDanhSachHoaDon.Rows[e.RowIndex].Cells[0].FormattedValue.ToString();
            txtTenKhachHang.Text = dgvDanhSachHoaDon.Rows[e.RowIndex].Cells[1].FormattedValue.ToString();
            txtSoDienThoai.Text  = dgvDanhSachHoaDon.Rows[e.RowIndex].Cells[4].FormattedValue.ToString();
            txtDiaChi.Text       = dgvDanhSachHoaDon.Rows[e.RowIndex].Cells[3].FormattedValue.ToString();
            txtNgayXuat.Text     = dgvDanhSachHoaDon.Rows[e.RowIndex].Cells[2].FormattedValue.ToString();

            chiTietHoaDon               = hoadonController.GetChiTietHoaDon(int.Parse(dgvDanhSachHoaDon.Rows[e.RowIndex].Cells[0].FormattedValue.ToString()));
            cbbTenSanPham.DataSource    = chiTietHoaDon;
            cbbTenSanPham.ValueMember   = "masanpham";
            cbbTenSanPham.DisplayMember = "tensanpham";
            maHoaDon = int.Parse(dgvDanhSachHoaDon.Rows[e.RowIndex].Cells[0].FormattedValue.ToString());
            txtSoLuongConLai.Text = (int.Parse(chiTietHoaDon.Rows[cbbTenSanPham.SelectedIndex]["soluongsanpham"].ToString()) - int.Parse(chiTietHoaDon.Rows[cbbTenSanPham.SelectedIndex]["soluongsanphamdaxuat"].ToString())).ToString();
            btnThem.Enabled       = true;
            btnSuaSp.Enabled      = true;
            btnXoa.Enabled        = true;
        }