private void dataGVKh_CellClick(object sender, DataGridViewCellEventArgs e) { if (dataGVKh.CurrentCell.ColumnIndex.Equals(10) && e.RowIndex != -1) { con.Open(); if (dataGVKh.CurrentCell != null && dataGVKh.CurrentCell.Value != null) { string del = dataGVKh.Rows[e.RowIndex].Cells[0].Value.ToString(); if (UserInfo.userName == "admin") { if ((MessageBox.Show("Xác nhận XOÁ toàn bộ thông tin của khách hàng: " + del, "Xác nhận XOÁ", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)) { KHCmd = new SqlCommand("EXECUTE dbo.IUD_KHACH '" + del + "',N'',N'','','',N'','','',N'Delete'", con); KHCmd.ExecuteNonQuery(); } } else { if ((MessageBox.Show("Xác nhận XOÁ khách hàng: " + del, "Xác nhận XOÁ", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)) { KHCmd = new SqlCommand("EXECUTE dbo.IUD_KHACH '" + del + "',N'',N'','','',N'','','',N'Hide'", con); KHCmd.ExecuteNonQuery(); } } } con.Close(); DisplayData(); } if (dataGVKh.CurrentCell.ColumnIndex.Equals(9) && e.RowIndex != -1) { con.Open(); if (dataGVKh.CurrentCell != null && dataGVKh.CurrentCell.Value != null) { if ((MessageBox.Show("Bạn có thể cập nhật các thông tin, ngoại trừ Hạn Thẻ. Để cập nhật Hạn thẻ: Khách hàng -> Gia hạn thẻ.", "Xác nhận cập nhật", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)) { SubClasses.GetDataKhach.UpdateModeOn = true; SubClasses.GetDataKhach.maKhach = dataGVKh.Rows[e.RowIndex].Cells[0].Value.ToString(); SubClasses.GetDataKhach.tenKhach = dataGVKh.Rows[e.RowIndex].Cells[1].Value.ToString(); SubClasses.GetDataKhach.GT = dataGVKh.Rows[e.RowIndex].Cells[2].Value.ToString(); SubClasses.GetDataKhach.NS = Convert.ToDateTime(dataGVKh.Rows[e.RowIndex].Cells[3].Value.ToString()); SubClasses.GetDataKhach.SDT = dataGVKh.Rows[e.RowIndex].Cells[4].Value.ToString(); SubClasses.GetDataKhach.diaChi = dataGVKh.Rows[e.RowIndex].Cells[5].Value.ToString(); SubClasses.GetDataKhach.ngayDK = Convert.ToDateTime(dataGVKh.Rows[e.RowIndex].Cells[6].Value.ToString()); SubClasses.GetDataKhach.hanThe = Convert.ToDateTime(dataGVKh.Rows[e.RowIndex].Cells[7].Value.ToString()); SubForms.ThemKhachHang themKHACH = new SubForms.ThemKhachHang(); themKHACH.ShowDialog(); con.Close(); if (SubClasses.GetDataKhach.UpdateModeOn == false) { DisplayData(); } } } con.Close(); } if (dataGVKh.CurrentCell.ColumnIndex.Equals(8) && e.RowIndex != -1) { if (dataGVKh.CurrentCell != null && dataGVKh.CurrentCell.Value != null) { if (dataGVKh.Rows[e.RowIndex].Cells[8].Value.ToString() == "True" && UserInfo.privilege == "high") { con.Close(); con.Open(); if ((MessageBox.Show("Khôi phục dữ liệu bị ẩn", "Xác nhận cập nhật", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)) { string magoitap = dataGVKh.Rows[e.RowIndex].Cells[0].Value.ToString(); KHCmd = new SqlCommand("EXECUTE dbo.IUD_KHACH '" + magoitap + "',N'',N'','','',N'','','',N'Show'", con); KHCmd.ExecuteNonQuery(); con.Close(); DisplayData(); } } } } }
private void btnInsert_Click(object sender, EventArgs e) { SubForms.ThemKhachHang themKHACH = new SubForms.ThemKhachHang(); themKHACH.ShowDialog(); DisplayData(); }