private void dgvKhach_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     if (dgvKhach.Columns[e.ColumnIndex].Name == "xem" && e.RowIndex > -1)
     {
         FormDetailKhach.state   = 1;
         FormDetailKhach.makhach = Convert.ToInt32(dgvKhach.Rows[e.RowIndex].Cells["makhach"].Value);
         FormDetailKhach frm = new FormDetailKhach();
         frm.Show();
     }
     else if (dgvKhach.Columns[e.ColumnIndex].Name == "xoa" && e.RowIndex > -1 && state != 1)
     {
         dgvKhach.Rows.RemoveAt(e.RowIndex);
         //Load lai combobox Khách đại diện
         DataTable dt = new DataTable();
         dt.Columns.Add("tenkhach", typeof(string));
         dt.Columns.Add("makhach", typeof(int));
         cboKhachThue.DisplayMember = "tenkhach";
         cboKhachThue.ValueMember   = "makhach";
         foreach (DataGridViewRow dgr in dgvKhach.Rows)
         {
             //Tải dữ liệu cho combobox Khách đại diện
             DataRow dr = dt.NewRow();
             dr["makhach"]  = Convert.ToInt32(dgr.Cells["makhach"].Value);
             dr["tenkhach"] = balK.DetailKhach(Convert.ToInt32(dgr.Cells["makhach"].Value)).tenkhach;
             dt.Rows.Add(dr);
         }
         cboKhachThue.DataSource = dt;
     }
 }
Esempio n. 2
0
        private void mniThemKhach_Click(object sender, EventArgs e)
        {
            FormDetailKhach.state   = 0;
            FormDetailKhach.makhach = -1;
            FormDetailKhach frm = new FormDetailKhach();

            frm.ShowDialog();
        }
Esempio n. 3
0
 private void dgvKhach_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     if (dgvKhach.Columns[e.ColumnIndex].Name == "xem_Khach" && e.RowIndex > -1)
     {
         FormDetailKhach.state   = 1;
         FormDetailKhach.makhach = Convert.ToInt64(dgvKhach.Rows[e.RowIndex].Cells["makhach"].Value);
         FormDetailKhach frm = new FormDetailKhach();
         frm.Show();
     }
 }
Esempio n. 4
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();
        }
Esempio n. 5
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();
            }
        }