private void btnInsert_Click(object sender, EventArgs e) { SubForms.ThemNV themNV = new SubForms.ThemNV(); themNV.ShowDialog(); con.Close(); if (SubClasses.GetNVData.UpdateModeOn == false) { DisplayData(); } }
private void dataNhanVien_CellClick(object sender, DataGridViewCellEventArgs e) { if (dataNhanVien.CurrentCell.ColumnIndex.Equals(12) && e.RowIndex != -1) { con.Open(); if (dataNhanVien.CurrentCell != null && dataNhanVien.CurrentCell.Value != null) { string del = dataNhanVien.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_NHANVIEN '" + del + "',N'','',N'','',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_NHANVIEN '" + del + "',N'','',N'','',N'',N'','','',N'',N'Hide'", con); KHCmd.ExecuteNonQuery(); } } } con.Close(); DisplayData(); } if (dataNhanVien.CurrentCell.ColumnIndex.Equals(11) && e.RowIndex != -1) { con.Open(); if (dataNhanVien.CurrentCell != null && dataNhanVien.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.GetNVData.UpdateModeOn = true; SubClasses.GetNVData.maNV = dataNhanVien.Rows[e.RowIndex].Cells[0].Value.ToString(); SubClasses.GetNVData.tenNV = dataNhanVien.Rows[e.RowIndex].Cells[1].Value.ToString(); SubClasses.GetNVData.NS = Convert.ToDateTime(dataNhanVien.Rows[e.RowIndex].Cells[2].Value.ToString()); SubClasses.GetNVData.GT = dataNhanVien.Rows[e.RowIndex].Cells[3].Value.ToString(); SubClasses.GetNVData.SDT = dataNhanVien.Rows[e.RowIndex].Cells[4].Value.ToString(); SubClasses.GetNVData.chucVu = dataNhanVien.Rows[e.RowIndex].Cells[5].Value.ToString(); SubClasses.GetNVData.caLam = dataNhanVien.Rows[e.RowIndex].Cells[6].Value.ToString(); SubClasses.GetNVData.ngayBD = Convert.ToDateTime(dataNhanVien.Rows[e.RowIndex].Cells[7].Value.ToString()); SubClasses.GetNVData.luong = dataNhanVien.Rows[e.RowIndex].Cells[8].Value.ToString(); SubClasses.GetNVData.que = dataNhanVien.Rows[e.RowIndex].Cells[9].Value.ToString(); SubForms.ThemNV themNV = new SubForms.ThemNV(); themNV.ShowDialog(); con.Close(); if (SubClasses.GetNVData.UpdateModeOn == false) { DisplayData(); } } } con.Close(); } if (dataNhanVien.CurrentCell.ColumnIndex.Equals(10) && e.RowIndex != -1) { if (dataNhanVien.CurrentCell != null && dataNhanVien.CurrentCell.Value != null) { if (dataNhanVien.Rows[e.RowIndex].Cells[10].Value.ToString() == "True" && UserInfo.privilege == "high") { 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 maNV = dataNhanVien.Rows[e.RowIndex].Cells[0].Value.ToString(); KHCmd = new SqlCommand("EXECUTE dbo.IUD_NHANVIEN '" + maNV + "',N'','',N'','',N'',N'','','',N'',N'Show'", con); KHCmd.ExecuteNonQuery(); con.Close(); DisplayData(); } } } } }