Exemplo n.º 1
0
        private async void dgvDanhSachHang_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            DataGridView dt = (DataGridView)sender;

            if (dt.Columns[e.ColumnIndex] is DataGridViewButtonColumn && e.RowIndex >= 0)
            {
                if (dt.Columns[e.ColumnIndex].Name.Equals("Sua"))
                {
                    // click sửa here
                    frmYeuCauHang f = new frmYeuCauHang(new CTHD((await balCTHD.LayID(hd.ID, Convert.ToInt32(dt.Rows[e.RowIndex].Cells["ID"].Value))).Rows[0]),
                                                        chbGiaSi.Checked,
                                                        Convert.ToInt32(dt.Rows[e.RowIndex].Cells["ID"].Value),
                                                        (dgvDanhSachHang.Rows[dgvDanhSachHang.CurrentCell.RowIndex].Cells["ThanhTien"].Value.ToString() == "") ? false : true
                                                        );

                    f.Text = dt.Rows[e.RowIndex].Cells["Ten"].Value.ToString();
                    if (f.ShowDialog() == DialogResult.OK)
                    {
                        await CapNhap();
                    }
                }
                else if (dt.Columns[e.ColumnIndex].Name.Equals("Xoa"))
                {
                    // click xoa here
                    if (MessageBox.Show("Bạn có muốn xóa hàng này đi không", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        await balCTHD.Xoa(hd.ID, Convert.ToInt32(dt.Rows[e.RowIndex].Cells["ID"].Value), (Program.UnFormatNumber(dt.Rows[e.RowIndex].Cells["ThanhTien"].Value.ToString()) == 0)?Convert.ToByte(true) : Convert.ToByte(false));
                        await CapNhap();
                    }
                }
            }
        }
Exemplo n.º 2
0
        private async Task MoChonSoLuong(int RowSelect)
        {
            CTHD c = new CTHD();

            c.IDHoaDon = hd.ID;
            c.IDHang   = Convert.ToInt32(dgvHang.Rows[RowSelect].Cells["IDHang"].Value);
            Hang          h = Program.lstHang.FirstOrDefault(p => p.ID == c.IDHang);
            frmYeuCauHang f = new frmYeuCauHang(c, chbGiaSi.Checked, h.ID);

            f.Text = h.TenHang;
            if (f.ShowDialog() == DialogResult.OK)
            {
                txtHang.Text = "";
                txtHang.Focus();
                await CapNhap();
            }
        }