Пример #1
0
        private void griddocument_KeyDown(object sender, KeyEventArgs e)
        {
            if (griddocument.Rows.Count == 0)
            {
                return;
            }

            try
            {
                int rowactual = griddocument.Rows.Count;
                if (e.KeyCode == Keys.Insert && !globales.boolConsulta)
                {
                    if (!this.consolicitud)
                    {
                        globales.MessageBoxExclamation("No se puede insertar nuevo registor en una ampliación que no existe", "Aviso", globales.menuPrincipal);
                        return;
                    }

                    DialogResult p = globales.MessageBoxQuestion("¿Deseas registrar una nuevo registro?", "Aviso", globales.menuPrincipal);
                    if (p == DialogResult.No)
                    {
                        return;
                    }
                    this.esInsertar = true;

                    string fecha = string.Format("{0:d}", DateTime.Now);



                    griddocument.Rows.Insert(rowactual);
                    griddocument.Rows[rowactual].Cells[0].Value = "";
                    griddocument.Rows[rowactual].Cells[1].Value = "";
                    griddocument.Rows[rowactual].Cells[2].Value = false;
                    griddocument.Rows[rowactual].Cells[3].Value = false;
                    griddocument.Rows[rowactual].Cells[4].Value = false;

                    griddocument.Rows[rowactual].DefaultCellStyle.BackColor = Color.FromArgb(200, 230, 201);



                    string query = "insert into datos.h_sdocum(expediente,sec,cve_docum,original,copia,documento,ubicacion) values (" +
                                   $"{txtExpediente.Text},'{this.secuencia}','','','','','' ) returning id";
                    List <Dictionary <string, object> > resultado = globales.consulta(query);
                    griddocument.Rows[rowactual].Cells[5].Value = resultado[0]["id"];
                    griddocument.CurrentCell = griddocument.Rows[rowactual].Cells[0];
                }

                if (e.KeyCode == Keys.Delete && !globales.boolConsulta)
                {
                    DialogResult p = globales.MessageBoxQuestion("¿Desea eliminar el registro?", "Aviso", globales.menuPrincipal);
                    if (p == DialogResult.No)
                    {
                        return;
                    }



                    string id = griddocument.Rows[row].Cells[5].Value.ToString();

                    griddocument.Rows.RemoveAt(row);
                    string query = "delete from datos.h_sdocum where expediente = {0} and id = {1} and sec = '{2}' ";
                    query = string.Format(query, txtExpediente.Text, id, this.secuencia);
                    if (globales.consulta(query, true))
                    {
                        globales.MessageBoxSuccess("Registro eliminado correctamente", "Aviso", globales.menuPrincipal);
                    }
                }



                if (e.Control && e.KeyCode == Keys.D)
                {
                    if (this.row > 1)
                    {
                        griddocument.Rows[row].Cells[this.column].Value = griddocument.Rows[row - 1].Cells[this.column].Value;
                    }
                }



                if (e.KeyCode == Keys.F1)
                {
                    if (this.column == 0)
                    {
                        frmCatalogoGeneral documentos = new frmCatalogoGeneral();
                        documentos.tabla  = "documento_hipotecarios";
                        documentos.metodo = rellenarDocumentos;
                        documentos.ShowDialog();
                        SendKeys.Send("{TAB}");
                    }
                }
            }
            catch
            {
            }

            this.esInsertar = false;

            if (e.KeyCode == Keys.Enter)
            {
                e.SuppressKeyPress = true;
                try
                {
                    e.SuppressKeyPress = true;
                    int iColumn = griddocument.CurrentCell.ColumnIndex;
                    int iRow    = griddocument.CurrentCell.RowIndex;
                    if (iColumn == griddocument.ColumnCount - 1)
                    {
                        if (griddocument.RowCount > (iRow + 1))
                        {
                            griddocument.CurrentCell = griddocument[1, iRow + 1];
                        }
                        else
                        {
                            //focus next control
                        }
                    }
                    else
                    {
                        griddocument.CurrentCell = griddocument[iColumn + 1, iRow];
                    }
                }
                catch
                {
                }
            }
        }
Пример #2
0
        private void dtggrid_KeyDown(object sender, KeyEventArgs e)
        {
            if (dtggrid.Rows.Count == 0)
            {
                return;
            }

            try
            {
                int rowactual = dtggrid.Rows.Count;
                if (e.KeyCode == Keys.Insert && !globales.boolConsulta)
                {
                    DialogResult p = globales.MessageBoxQuestion("¿Deseas registrar una nuevo registro?", "Aviso", globales.menuPrincipal);
                    if (p == DialogResult.No)
                    {
                        return;
                    }
                    this.esInsertar = true;

                    string fecha = string.Format("{0:d}", DateTime.Now);



                    dtggrid.Rows.Insert(rowactual);
                    dtggrid.Rows[rowactual].Cells[0].Value             = "";
                    dtggrid.Rows[rowactual].Cells[1].Value             = fecha;
                    dtggrid.Rows[rowactual].Cells[2].Value             = "";
                    dtggrid.Rows[rowactual].Cells[3].Value             = "";
                    dtggrid.Rows[rowactual].Cells[4].Value             = "";
                    dtggrid.Rows[rowactual].Cells[5].Value             = "";
                    dtggrid.Rows[rowactual].Cells[6].Value             = "";
                    dtggrid.Rows[rowactual].Cells[7].Value             = "";
                    dtggrid.Rows[rowactual].Cells[8].Value             = "";
                    dtggrid.Rows[rowactual].Cells[9].Value             = "";
                    dtggrid.Rows[rowactual].DefaultCellStyle.BackColor = Color.FromArgb(200, 230, 201);

                    fecha = string.Format("'{0:yyyy-MM-dd}'", DateTime.Now);

                    h_solici solicitud = new h_solici();
                    solicitud.f_solicitud    = DateTime.Now;
                    solicitud.f_autorizacion = DateTime.Now;
                    solicitud.expediente     = Convert.ToInt32(txtExpediente.Text);


                    dbaseORM orm = new dbaseORM();
                    solicitud = orm.insert <h_solici>(solicitud, true);

                    dtggrid.Rows[rowactual].Cells[10].Value = solicitud.id;
                    dtggrid.CurrentCell = dtggrid.Rows[rowactual].Cells[0];
                }

                if (e.KeyCode == Keys.Delete && !globales.boolConsulta)
                {
                    DialogResult p = globales.MessageBoxQuestion("¿Desea eliminar el registro?", "Aviso", globales.menuPrincipal);
                    if (p == DialogResult.No)
                    {
                        return;
                    }



                    string id = dtggrid.Rows[row].Cells[10].Value.ToString();
                    dtggrid.Rows.RemoveAt(row);
                    string query = "delete from datos.h_solici where expediente = {0} and id = {1} ";
                    query = string.Format(query, txtExpediente.Text, id);
                    if (globales.consulta(query, true))
                    {
                        globales.MessageBoxSuccess("Registro eliminado correctamente", "Aviso", globales.menuPrincipal);
                    }
                }



                if (e.Control && e.KeyCode == Keys.D)
                {
                    if (this.row > 1)
                    {
                        dtggrid.Rows[row].Cells[this.column].Value = dtggrid.Rows[row - 1].Cells[this.column].Value;
                    }
                }

                if (e.KeyCode == Keys.F6)
                {
                    string id          = dtggrid.Rows[row].Cells[10].Value.ToString();
                    string query       = $"select sec,tot_prest,tot_prim,plazo,plazoa,tot_unit from datos.h_solici where expediente = {txtExpediente.Text} and id = {id}";
                    var    resultado   = globales.consulta(query);
                    var    diccionario = resultado[0];

                    double tot_prest = string.IsNullOrWhiteSpace(Convert.ToString(diccionario["tot_prest"])) ? 0 : Convert.ToDouble(diccionario["tot_prest"]);
                    double tot_prim  = string.IsNullOrWhiteSpace(Convert.ToString(diccionario["tot_prim"])) ? 0 : Convert.ToDouble(diccionario["tot_prim"]);
                    string plazo     = Convert.ToString(diccionario["plazo"]);
                    int    plazoa    = string.IsNullOrWhiteSpace(Convert.ToString(diccionario["plazoa"])) ? 0 : Convert.ToInt32(diccionario["plazoa"]);
                    double tot_unit  = string.IsNullOrWhiteSpace(Convert.ToString(diccionario["tot_unit"])) ? 0 : Convert.ToDouble(diccionario["tot_unit"]);

                    int tiempo = (plazo == "Q") ? ((plazoa * 24) - 1): ((plazoa * 24) - 1);

                    string cabecera  = $"{diccionario["sec"]}° Ampliación";
                    string contenido = $"TOTAL DEL PRESTAMO : {string.Format("{0:C}",tot_prest)}\nPrimer pago: {string.Format("{0:c}",tot_prim)}\n{tiempo} PAG.POR NOMINA.: {string.Format("{0:c}",tot_unit)}";
                    globales.MessageBoxInformation(contenido, cabecera, globales.menuPrincipal);
                }

                if (e.KeyCode == Keys.F1)
                {
                    if (this.column == 2)
                    {
                        frmCatalogoGeneral finalida = new frmCatalogoGeneral();
                        finalida.tabla  = "finalidad";
                        finalida.metodo = llenarFinalidad;
                        finalida.ShowDialog();
                        SendKeys.Send("{TAB}");
                    }
                }
            }
            catch
            {
            }

            this.esInsertar = false;

            if (e.KeyCode == Keys.Enter)
            {
                e.SuppressKeyPress = true;
                try
                {
                    e.SuppressKeyPress = true;
                    int iColumn = dtggrid.CurrentCell.ColumnIndex;
                    int iRow    = dtggrid.CurrentCell.RowIndex;
                    if (iColumn == dtggrid.ColumnCount - 1)
                    {
                        if (dtggrid.RowCount > (iRow + 1))
                        {
                            dtggrid.CurrentCell = dtggrid[1, iRow + 1];
                        }
                        else
                        {
                            //focus next control
                        }
                    }
                    else
                    {
                        dtggrid.CurrentCell = dtggrid[iColumn + 1, iRow];
                    }
                }
                catch
                {
                }
            }
        }