Exemplo n.º 1
0
        private void mniThemKhach_Click(object sender, EventArgs e)
        {
            FormDetailKhach.state   = 0;
            FormDetailKhach.makhach = -1;
            FormDetailKhach frm = new FormDetailKhach();

            frm.ShowDialog();
        }
Exemplo n.º 2
0
        private void btnThem_Click(object sender, EventArgs e)
        {
            FormDetailKhach.state   = 0;
            FormDetailKhach.makhach = -1;
            FormDetailKhach frm = new FormDetailKhach();

            frm.ShowDialog();

            dgvKhach.DataSource = balK.GetAll();
            BindingGridView();
        }
Exemplo n.º 3
0
        private void dgvKhach_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (dgvKhach.Columns[e.ColumnIndex].Name == "xem" && e.RowIndex > -1)
            {
                FormDetailKhach.state   = 1;
                FormDetailKhach.makhach = Convert.ToInt64(dgvKhach.Rows[e.RowIndex].Cells["makhach"].Value);
                FormDetailKhach frm = new FormDetailKhach();
                frm.ShowDialog();
            }
            else if (dgvKhach.Columns[e.ColumnIndex].Name == "sua" && e.RowIndex > -1)
            {
                FormDetailKhach.state   = -1;
                FormDetailKhach.makhach = Convert.ToInt64(dgvKhach.Rows[e.RowIndex].Cells["makhach"].Value);
                FormDetailKhach frm = new FormDetailKhach();
                frm.ShowDialog();
            }
            else if (dgvKhach.Columns[e.ColumnIndex].Name == "xoa" && e.RowIndex > -1)
            {
                string UserPic = balK.DetailKhach(Convert.ToInt64(dgvKhach.CurrentRow.Cells["makhach"].Value)).hinh;
                try
                {
                    balK.XoaKhach(Convert.ToInt64(dgvKhach.CurrentRow.Cells["makhach"].Value));
                    //Xóa ảnh
                    //try
                    //{
                    //    Image img = Image.FromFile(UserPic);
                    //    img.Dispose();
                    //    System.IO.File.Delete(UserPic);
                    //}
                    //catch(Exception ex) { MessageBox.Show("Không thể xóa ảnh.\n"+ex.ToString(),"Thông báo",MessageBoxButtons.OK, MessageBoxIcon.Error); }
                    MessageBox.Show("Xóa dữ liệu thành công!", "Thông báo");
                }
                catch (Exception ex) { MessageBox.Show("Xóa dữ liệu thất bại!\n" + ex.ToString(), "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); }

                //Load lại dữ liệu
                dgvKhach.DataSource = balK.GetAll();
                BindingGridView();
            }
        }