public void loadListArray() { System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor; try { sql.ToString(); } catch { sql = F_DangNhap.SQL_con_object as SQLConnect; nguoi = F_DangNhap.person_object as NguoiDung; } listBox_DanhSach.Items.Clear(); string s = "SELECT MaID,TenDangNhap,HoTen,Cap FROM Taikhoan"; mang_ID = sql.GetDataArray(s, 0); mang_TenDangNhap = sql.GetDataArray(s, 1); mang_TenNguoiDung = sql.GetDataArray(s, 2); mang_NhomQuanLy = sql.GetDataArray(s, 3); int i = 0; while (!string.IsNullOrEmpty(mang_TenDangNhap[i])) { listBox_DanhSach.Items.Add(i + ". " + mang_TenDangNhap[i]); i++; } Cursor = Cursors.Default; }
private void toolStripMenuItem_Delete_Click(object sender, EventArgs e) { if (nguoi.Cap > 1) { DevExpress.XtraEditors.XtraMessageBox.Show("Bạn không đủ quyền !"); return; } int rowSel = -1; int[] selectedRows = gridView1.GetSelectedRows(); foreach (int r in selectedRows) { rowSel = r; } DialogResult re = DialogResult.No; re = DevExpress.XtraEditors.XtraMessageBox.Show("Bạn thực sự muốn xóa tổ chức '" + table_DSTenToChuc.Rows[rowSel].ItemArray[2].ToString() + "' ?", "Cảnh Báo", MessageBoxButtons.YesNo); if (re == DialogResult.Yes) { System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor; if (int.Parse(table_DSTenToChuc.Rows[rowSel].ItemArray[3].ToString()) > 0) { string s = "SELECT [IDGD] FROM [GIAODAT].[dbo].[Giaodat] WHERE MaTochuc = '" + table_DSTenToChuc.Rows[rowSel].ItemArray[1].ToString() + "' "; string[] mangIDGD = sql.GetDataArray(s, 0); int i = 0; while (!string.IsNullOrEmpty(mangIDGD[i])) { s = "DELETE FROM LDTruocGiao WHERE IDGD=" + mangIDGD[i] + ""; sql.ExecuteData(s); s = "DELETE FROM LDDuocGiao WHERE IDGD=" + mangIDGD[i] + ""; sql.ExecuteData(s); i++; } s = "DELETE FROM Giaodat WHERE MaTochuc='" + table_DSTenToChuc.Rows[rowSel].ItemArray[1].ToString() + "'"; sql.ExecuteData(s); } string s1 = "DELETE FROM TenTochuc WHERE MaTochuc='" + table_DSTenToChuc.Rows[rowSel].ItemArray[1].ToString() + "'"; sql.ExecuteData(s1); DevExpress.XtraEditors.XtraMessageBox.Show("Xóa thành công !"); this.RefeshDS(); Cursor = Cursors.Default; } }