/// <summary> /// Método para llenar la cuadricula donde se visualizan los registros /// </summary> public void LlenarGrilla() { GvGeneral.Columns.Clear(); GvGeneral.OptionsView.ColumnAutoWidth = false; DataViewManager dvm = new DataViewManager(dsGeneral); DataView dvMain = dvm.CreateDataView(dsGeneral.Tables[0]); GridColumn[] col = new GridColumn[PerfilShow.Visibles.Length]; int index = 0; for (int i = 0; i < PerfilShow.Visibles.Length; i++) { index = Convert.ToInt32(PerfilShow.Indices[i]); col[index] = GvGeneral.Columns.AddField(dsGeneral.Tables[0].Columns[PerfilShow.CamposId[i]].Caption); col[index].VisibleIndex = index; //col[index].BestFit(); col[index].Width = PerfilShow.Tamaños[i].ToInt(); col[index].Caption = PerfilShow.Cabeceras[i]; col[index].AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; } GctrlGeneral.DataSource = dvMain; if (GvGeneral.RowCount > 0) { GvGeneral.Focus(); GvGeneral.SelectRow(0); } }
public void Editar() { FrmAñadirEditarPerfiles frm = new FrmAñadirEditarPerfiles(); frm.Dbase = null; frm.Perfil = GvGeneral.GetFocusedRowCellValue("Id").ToString(); if (frm.ShowDialog() == DialogResult.OK) { LlenarGrid(); } }
private void GctrlGeneral_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter && !DesdeMenu) { if (GvGeneral.GetFocusedDataSourceRowIndex() > -1) { Seleccion = dsGeneral.Tables[0].Rows[GvGeneral.GetFocusedDataSourceRowIndex()][PerfilShow.Llave].ToString(); DescripcionSeleccion = dsGeneral.Tables[0].Rows[GvGeneral.GetFocusedDataSourceRowIndex()][PerfilShow.CampoNombre].ToString(); IdentificacionSeleccion = dsGeneral.Tables[0].Rows[GvGeneral.GetFocusedDataSourceRowIndex()][PerfilShow.CampoCodigo].ToString(); DialogResult = System.Windows.Forms.DialogResult.OK; } } if (e.KeyCode == Keys.Escape) { DialogResult = System.Windows.Forms.DialogResult.Cancel; } }
/// <summary> /// Método para eliminar el registro seleccionado /// </summary> public void Eliminar() { if (permisoEliminar) { try { if (GvGeneral.GetFocusedDataSourceRowIndex() > -1) { if (XtraMessageBox.Show("¿Esta seguro que desea anular el registro ?", GLReferences.Properties.Resources.AppName, MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { Seleccion = dsGeneral.Tables[0].Rows[GvGeneral.GetFocusedDataSourceRowIndex()][PerfilShow.Llave].ToString(); String sql = String.Format("UPDATE {0} SET delmrk = 0 WHERE {1} = '{2}'", PerfilShow.Tabla, PerfilShow.Llave, Seleccion); bool IsDone = DataBase.ExecuteNonQuery(sql, CommandType.Text, null, ConexionDB.getInstancia().Conexion(database, null)); if (IsDone) { //AlertInfo info = new AlertInfo(Resources.SystemMessage, "Registro Eliminado Satisfactoriamente", Resources.Check); //alertControl1.Show(this, info); LlenarDataSet(); LlenarGrilla(); } } } else { XtraMessageBox.Show("Debe seleccionar un registro", GLReferences.Properties.Resources.AppName, MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button2); } } catch (Exception t) { XtraMessageBox.Show(t.Message); } } else { XtraMessageBox.Show("El usuario " + Usuario + " no tiene permiso para realizar esta operación.", GLReferences.Properties.Resources.AppName, MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Método para llamar al formulario de Edición /// </summary> public void Editar() { if (permisoEditar) { System.Reflection.Assembly myDllAssembly = System.Reflection.Assembly.LoadFile(@"" + PerfilShow.Proyecto); Type t = myDllAssembly.GetType(PerfilShow.Formulario); object o = Activator.CreateInstance(t); if (GvGeneral.GetFocusedDataSourceRowIndex() > -1) { try { int hver = GvGeneral.GetFocusedDataSourceRowIndex(); Seleccion = dsGeneral.Tables[0].Rows[GvGeneral.GetFocusedDataSourceRowIndex()][PerfilShow.Llave].ToString(); //DescripcionSeleccion = dsGeneral.Tables[0].Rows[GvGeneral.GetFocusedDataSourceRowIndex()][PerfilShow.CampoNombre].ToString(); //IdentificacionSeleccion = dsGeneral.Tables[0].Rows[GvGeneral.GetFocusedDataSourceRowIndex()][PerfilShow.CampoCodigo].ToString(); PropertyInfo desdeShow = o.GetType().GetProperty("DesdeMenu"); desdeShow.SetValue(o, DesdeMenu, null); PropertyInfo modo = o.GetType().GetProperty("Modo"); modo.SetValue(o, "E", null); if (OpGet) { PropertyInfo Get = o.GetType().GetProperty("OpcionGet"); Get.SetValue(o, OpcionGet, null); } PropertyInfo perfil = o.GetType().GetProperty("PerfilAct"); perfil.SetValue(o, PerfilShow, null); PropertyInfo codigo = o.GetType().GetProperty("ID"); codigo.SetValue(o, Seleccion, null); PropertyInfo db = o.GetType().GetProperty("Database"); db.SetValue(o, database, null); if (PasarUsuario) { PropertyInfo Get = o.GetType().GetProperty("Usuario"); Get.SetValue(o, Usuario, null); } if (PerfilShow.Formulario.Equals("GLUserControls.FrmGetCodeName")) { PropertyInfo ponerCeros = o.GetType().GetProperty("PonerCeros"); ponerCeros.SetValue(o, PonerCeros, null); } } catch (Exception ex) { XtraMessageBox.Show(ex.Message, GLReferences.Properties.Resources.AppName, MessageBoxButtons.OK, MessageBoxIcon.Information); } XtraForm frm = (XtraForm)o; frm.ShowDialog(); if (frm.DialogResult == DialogResult.OK && DesdeMenu) { LlenarDataSet(); LlenarGrilla(); } if (frm.DialogResult == DialogResult.OK && !DesdeMenu) { Seleccion = frm.GetType().GetProperty("ID").GetValue(frm, null).ToString(); DialogResult = System.Windows.Forms.DialogResult.OK; } } else { XtraMessageBox.Show("Debe seleccionar un registro", GLReferences.Properties.Resources.AppName, MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button2); } } else { XtraMessageBox.Show("El usuario " + Usuario + " no tiene permiso para realizar esta operación.", GLReferences.Properties.Resources.AppName, MessageBoxButtons.OK, MessageBoxIcon.Information); } }