public void DeleteSelectedRows(DevExpress.XtraGrid.Views.Grid.GridView view) { if (view == null || view.SelectedRowsCount == 0) return; DataRow[] rows = new DataRow[view.SelectedRowsCount]; for (int i = 0; i < view.SelectedRowsCount; i++) rows[i] = view.GetDataRow(view.GetSelectedRows()[i]); view.BeginSort(); try { foreach (DataRow row in rows) row.Delete(); } finally { view.EndSort(); } }
private static byte[] UpData(DevExpress.XtraGrid.Views.BandedGrid.AdvBandedGridView view) { string path = null; OpenFileDialog openFile = new OpenFileDialog(); openFile.Title = "Chọn file để cập nhật tài liệu:"; DialogResult value = openFile.ShowDialog(); if (value == DialogResult.OK) { path = openFile.FileName; //Kiểm tra độ lớn của file if (!HelpFile.CheckFileSize(path, 20)) { //Độ lớn của file lớn hơn độ lớn qui định HelpMsgBox.ShowNotificationMessage("Bạn không được chọn file lớn hơn 20 MB."); path = null; UpData(view); } } else if (value == DialogResult.Cancel) { path = null; return null; } if (path != null) { byte[] bytes = null; bytes = HelpFile.FileToBytes(path); DataRow row = view.GetDataRow(view.FocusedRowHandle); if (row == null) HelpMsgBox.ShowNotificationMessage("Bạn chưa chọn nhân sự, vui lòng vào thông tin nhân sự!"); else { row["TEN_TAI_LIEU"] = Path.GetFileName(path); row["NGAY_NOP"] = DateTime.Now; return bytes; } } return null; }
private void focus_new_row_created(DevExpress.XtraGrid.Views.Grid.GridView ip_grv) { int v_row_index = 0; decimal v_id_gd_hd_f340 = 0; string v_da_xoa_f340 = "N"; v_id_gd_hd_f340 = find_id_hd(CIPConvert.ToDecimal(m_sle_chon_nhan_vien.EditValue)); if (ip_grv == m_grv_hs_lns) { US_V_F340_DAT_HS_LNS v_us = new US_V_F340_DAT_HS_LNS(); DS_V_F340_DAT_HS_LNS v_ds = new DS_V_F340_DAT_HS_LNS(); v_us.FillDataset(v_ds); for (v_row_index = 0; v_row_index < v_ds.Tables[0].Rows.Count; v_row_index++) { var v_id_gd_hd = CIPConvert.ToDecimal(ip_grv.GetDataRow(v_row_index)["ID_HOP_DONG"].ToString()); var v_da_xoa = ip_grv.GetDataRow(v_row_index)["DA_XOA_LNS"].ToString(); if (v_id_gd_hd == v_id_gd_hd_f340 && v_da_xoa == v_da_xoa_f340) { break; } } ip_grv.FocusedRowHandle = v_row_index; } else if (ip_grv == m_grv_lcd) { US_V_F340_DAT_LCD v_us = new US_V_F340_DAT_LCD(); DS_V_F340_DAT_LCD v_ds = new DS_V_F340_DAT_LCD(); v_us.FillDataset(v_ds); for (v_row_index = 0; v_row_index < v_ds.Tables[0].Rows.Count; v_row_index++) { var v_id_gd_hd = CIPConvert.ToDecimal(ip_grv.GetDataRow(v_row_index)["ID_HOP_DONG"].ToString()); var v_da_xoa = ip_grv.GetDataRow(v_row_index)["DA_XOA_LCD"].ToString(); if (v_id_gd_hd == v_id_gd_hd_f340 && v_da_xoa == v_da_xoa_f340) { break; } } ip_grv.FocusedRowHandle = v_row_index; } }
public static bool deleteSelectedRows(DevExpress.XtraGrid.Views.Grid.GridView xgv) { if (xgv == null) return false; int[] nSelectedRows = xgv.GetSelectedRows(); if (nSelectedRows.Length == 0) return false; try { DataRow drRow = null; foreach(int nRowHandle in nSelectedRows) { drRow = xgv.GetDataRow(nRowHandle); if (drRow != null) drRow.Delete(); } } catch(Exception ex) { throw(ex); } return true; }
public static bool deleteSelectedRow(DevExpress.XtraGrid.Views.Grid.GridView xgv, int nRowHandle) { if (xgv == null || nRowHandle < 0) return false; DataRow drDeleteRow = xgv.GetDataRow(nRowHandle); if (drDeleteRow == null) return false; // delete row: drDeleteRow.Delete(); return true; }
public static bool deleteSelectedRow(DevExpress.XtraGrid.GridControl xgc,DevExpress.XtraGrid.Views.Grid.GridView xgv, object objMessageID) { if (xgv == null) return false; DataRow dr=null; try { dr = (DataRow)xgv.GetDataRow(xgv.FocusedRowHandle); if (dr != null) { dr.Delete(); } else { UIMessage.ShowMessage(objMessageID ,System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation ); xgc.Focus(); } } catch(Exception e) { throw new Exception(e.Message ); } return true; }
public static bool DelMainBurtgel(DevExpress.XtraGrid.Views.Grid.GridView grd) { bool ReturnValue = false; try { if (Services.Security.checkForm("DELETE_CARD", Variables.UserInfo)) { if (grd.SelectedRowsCount > 0) { if (MessageBox.Show("Мэдээллийг устгах уу?", "Анхааруулга", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { DataRow Row = grd.GetDataRow(grd.FocusedRowHandle); if (Row["BNoHistory_ID"] != null && Row["BNoHistory_ID"].ToString() != "") { string SQL = "Update MainBurtgel.T_BNoHistory Set Archive = 'Y' Where ID = '" + Row["BNoHistory_ID"].ToString() + "'"; if (Services.Database.ExecuteNonQueryStr(SQL)) ReturnValue = true; else ReturnValue = false; } } } else { MessageBox.Show("Мэдээлэл сонгоно уу!", "Алдаа", MessageBoxButtons.OK, MessageBoxIcon.Error); ReturnValue = false; } } else MessageBox.Show("Уучлаарай! Та хандах эрхгүй байна.", "Анхааруулга", MessageBoxButtons.OK, MessageBoxIcon.Warning); } catch (Exception Err) { MessageBox.Show("Дараахи алдаа гарлаа : " + Err.Message.ToString(), "Алдаа", MessageBoxButtons.OK, MessageBoxIcon.Error); ReturnValue = false; } return ReturnValue; }