示例#1
0
        private void cuentasContablesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmCuentas Cuentas = new frmCuentas();

            Cuentas.MdiParent = this;
            Cuentas.Show();
        }
示例#2
0
        private void dtgGrid_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (dtgGrid.Rows[this.row].Cells[0].Selected == true)
            {
                frmCuentas cuenta = new frmCuentas(false);
                cuenta.enviar = rellenar;
                cuenta.ShowDialog();
            }


            if (dtgGrid.Rows[this.row].Cells[5].Selected == true)
            {
                p1.Visible = true;
                limpiaP1();

                string doctipo       = Convert.ToString(dtgGrid.Rows[this.row].Cells[5].Value);
                string doccomentario = Convert.ToString(dtgGrid.Rows[this.row].Cells[8].Value);
                string docfecha      = Convert.ToString(dtgGrid.Rows[this.row].Cells[7].Value);
                string docnumero     = Convert.ToString(dtgGrid.Rows[this.row].Cells[6].Value);
                if (!string.IsNullOrWhiteSpace(doctipo))
                {
                    switch (doctipo)
                    {
                    case "CLC":
                        auxtipo.SelectedIndex = 0;
                        break;

                    case "CH":
                        auxtipo.SelectedIndex = 1;
                        break;

                    case "EO":
                        auxtipo.SelectedIndex = 2;
                        break;

                    case "FACT":
                        auxtipo.SelectedIndex = 3;
                        break;

                    case "FD":
                        auxtipo.SelectedIndex = 4;
                        break;

                    case "REM":
                        auxtipo.SelectedIndex = 5;
                        break;

                    case "NOTA":
                        auxtipo.SelectedIndex = 6;
                        break;

                    case "OTB":
                        auxtipo.SelectedIndex = 7;
                        break;

                    case "OTRO":
                        auxtipo.SelectedIndex = 8;
                        break;

                    case "RBO":
                        auxtipo.SelectedIndex = 9;
                        break;

                    case "SPEI":
                        auxtipo.SelectedIndex = 10;
                        break;
                    }

                    auxgrupo.Text      = "NORMAL";
                    auxcomentario.Text = doccomentario;
                    auxfecha.Text      = docfecha;
                    auxnumero.Text     = docnumero;
                }
            }
        }
示例#3
0
        private void dataGridView1_KeyDown(object sender, KeyEventArgs e)
        {
            if (string.IsNullOrWhiteSpace(comboPoliza.Text) || string.IsNullOrWhiteSpace(comboPrefijo.Text) || string.IsNullOrWhiteSpace(txtDescripcion.Text))
            {
                DialogResult dialogo2 = globales.MessageBoxError("NO SE PUEDE INGRESAR UN DETALLE HASTA QUE SE CEPTURE EL ENCABEZADO", "VIOLACIÓN DE NORMAS", globales.menuPrincipal);
                return;
            }
            if (e.KeyCode == Keys.Insert)
            {
                dtgGrid.Rows.Insert(contador);
                contador++;
            }

            if (e.KeyCode == Keys.Delete)
            {
                //dtgGrid.Rows.Insert(contador);
                contador--;
                SacaSumas();
            }

            if (e.KeyCode == Keys.F1)
            {
                frmCuentas cuenta = new frmCuentas(false);
                cuenta.enviar = rellenar;
                cuenta.ShowDialog();
            }

            if (e.KeyCode == Keys.F12)
            {
                string fechas = maskedTextBox1.Text;
                string anioS  = fechas.Substring(6, 4);
                string meSS   = fechas.Substring(3, 2);

                int m = Convert.ToInt32(meSS) + 1;

                string verifica = $"SELECT substr( mes , {m},1) as status FROM cg_fondos.cierremeses where anio= {anioS};";
                List <Dictionary <string, object> > resu = globales.consulta(verifica);
                int digito = Convert.ToInt32(resu[0]["status"]);

                if (digito != 0)
                {
                    DialogResult dialogo = globales.MessageBoxError("EL MES QUE DESEA AGREGAR LA POLIZA SE ENCUENTRA CERRADO", "", globales.menuPrincipal);
                }

                if (this.sumaDebe == this.sumaHaber)
                {
                    string prefijo = string.Empty;
                    if (comboPrefijo.SelectedIndex == 0)
                    {
                        prefijo = "B";
                    }
                    if (comboPrefijo.SelectedIndex == 1)
                    {
                        prefijo = "P";
                    }
                    if (comboPrefijo.SelectedIndex == 2)
                    {
                        prefijo = "R";
                    }
                    if (comboPrefijo.SelectedIndex == 3)
                    {
                        prefijo = "X";
                    }

                    //TIPO
                    string tipoPol = string.Empty;

                    if (comboPoliza.SelectedIndex == 0)
                    {
                        tipoPol = "D";
                    }
                    if (comboPoliza.SelectedIndex == 1)
                    {
                        tipoPol = "I";
                    }
                    if (comboPoliza.SelectedIndex == 2)
                    {
                        tipoPol = "E";
                    }
                    string polnumero = string.Empty;


                    string numero = txtNumero.Text;


                    if (numero.Length == 1)
                    {
                        numero = "000000" + numero;
                    }
                    if (numero.Length == 2)
                    {
                        numero = "00000" + numero;
                    }
                    if (numero.Length == 3)
                    {
                        numero = "0000" + numero;
                    }



                    try
                    {
                        string cuenta = string.Empty;
                        string query  = $"insert into  cg_fondos.des values ('801', 'P' , '{meSS}' , '{tipoPol}', '{numero}' ,'{maskedTextBox1.Text}' , {this.sumaDebe} , {this.sumaHaber} , '{txtDescripcion.Text}' ,'000' , '{prefijo}' , '{globales.id_usuario}' , {0} ,'{anioS}' ) ";
                        globales.consulta(query, true);

                        int contador = 0;
                        foreach (DataGridViewRow item in dtgGrid.Rows)
                        {
                            if (contador == dtgGrid.Rows.Count)
                            {
                                break;
                            }

                            string debe  = Convert.ToString(item.Cells[3].Value);
                            string haber = Convert.ToString(item.Cells[4].Value);
                            cuenta = Convert.ToString(item.Cells[1].Value);
                            string descripcion = Convert.ToString(item.Cells[2].Value);

                            string doc = Convert.ToString(item.Cells[5].Value);


                            contador++;



                            if (debe == "0.00" || string.IsNullOrWhiteSpace(debe))
                            {
                                string debehaber = "H";
                                string inserta   = $"insert into cg_fondos.pol values  ('801' , 'P' , '{meSS}' ,'{tipoPol}' , '{numero}' , '{maskedTextBox1.Text}' , '{cuenta}' , '{debehaber}' , '{double.Parse(haber, System.Globalization.NumberStyles.Currency)}' , '00' , '{prefijo}' ,'CH', '{doc}' , '{maskedTextBox1.Text}' ,'', '{descripcion}' ,'0' , 0 , 0 , '{anioS}' )";

                                globales.consulta(inserta);
                            }
                            else
                            {
                                string debehaber = "D";
                                string inserta   = $"insert into cg_fondos.pol values ('801' , 'P' , '{meSS}' ,'{tipoPol}' , '{numero}' , '{maskedTextBox1.Text}' , '{cuenta}' , '{debehaber}' , '{double.Parse(debe, System.Globalization.NumberStyles.Currency)}' , '00' , '{prefijo}' ,'CH', '{doc}' , '{maskedTextBox1.Text}' ,'', '{descripcion}' ,'0' , 0 , 0  , '{anioS}' )";
                                globales.consulta(inserta);
                            }
                        }
                        DialogResult dialogo = globales.MessageBoxSuccess("POLIZA GUARDADA EXITOSAMENTE", "PROCESO TERMINADO", globales.menuPrincipal);
                    }
                    catch
                    {
                        DialogResult dialogo = globales.MessageBoxSuccess("ERROR AL GUARDAR SU PÓLIZA", "PROCESO TERMINADO", globales.menuPrincipal);
                    }
                }
                else
                {
                    DialogResult dialogo = globales.MessageBoxExclamation("LOS IMPORTES DEBE Y HABER NO COINCIDEN", "PROCESO ABORTADO", globales.menuPrincipal);
                }
            }



            if (e.KeyCode == Keys.Enter)
            {
                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];
                }
            }
        }
        private void dtggrid_KeyDown(object sender, KeyEventArgs e)
        {
            if (dtggrid.Rows.Count == 0)
            {
                return;
            }

            if (!this.abierto)
            {
                dtggrid.AllowUserToDeleteRows = false;
                return;
            }
            ;



            if (this.esConsulta)
            {
                return;
            }

            try
            {
                if (e.KeyCode == Keys.Insert)
                {
                    DialogResult p = globales.MessageBoxQuestion("¿Deseas registrar una nueva poliza?", "Aviso", globales.menuPrincipal);
                    if (p == DialogResult.No)
                    {
                        return;
                    }
                    this.esInsertar = true;
                    string cuenta      = "";
                    string descripcion = "";
                    string debe        = "0.00";
                    string haber       = "0.00";
                    string grupo       = "";
                    string docto       = "";

                    int rowfinal = row + 1;



                    dtggrid.Rows.Insert(rowfinal);
                    dtggrid.Rows[rowfinal].Cells[0].Value             = cuenta;
                    dtggrid.Rows[rowfinal].Cells[1].Value             = descripcion;
                    dtggrid.Rows[rowfinal].Cells[2].Value             = debe;
                    dtggrid.Rows[rowfinal].Cells[3].Value             = haber;
                    dtggrid.Rows[rowfinal].Cells[4].Value             = grupo;
                    dtggrid.Rows[rowfinal].Cells[5].Value             = docto;
                    dtggrid.Rows[rowfinal].DefaultCellStyle.BackColor = Color.FromArgb(200, 230, 201);


                    codigo.repositorios.cg_fondos.pol pol = new codigo.repositorios.cg_fondos.pol {
                        entidad    = "801",
                        subsistema = "P",
                        polmes     = this.polmes,
                        poltipo    = this.poltipo,
                        polnumero  = this.polnumero,
                        fecha      = DateTime.Parse(txtFecha.Text),
                        cuenta     = "",
                        naturaleza = "",
                        grupo      = "000",
                        anio       = this.polanio,
                        prefijo    = this.prefijo
                    };

                    dbaseORM orm = new dbaseORM();
                    pol = orm.insert <codigo.repositorios.cg_fondos.pol>(pol, true);

                    //query = string.Format(query, txtrfc.Text, string.Format("{0:yyyy-MM-dd}", DateTime.Parse(inicio)), string.Format("{0:yyyy-MM-dd}", DateTime.Parse(final)), cuenta, string.Format("{0:yyyy-MM-dd}", DateTime.Parse(fecha)), globales.id_usuario);


                    dtggrid.Rows[row + 1].Cells[6].Value = pol.id;
                    dtggrid.CurrentCell = dtggrid.Rows[row + 1].Cells[0];
                }

                if (e.KeyCode == Keys.Delete)
                {
                    DialogResult p = globales.MessageBoxQuestion("¿Desea eliminar la poliza?", "Aviso", globales.menuPrincipal);
                    if (p == DialogResult.No)
                    {
                        return;
                    }
                    string id = dtggrid.Rows[row].Cells[6].Value.ToString();
                    dtggrid.Rows.RemoveAt(row);
                    string query = "delete from cg_fondos.pol where id={0}";
                    query = string.Format(query, id);
                    if (globales.consulta(query, true))
                    {
                        globales.MessageBoxSuccess("Poliza eliminada correctamente", "Aviso", globales.menuPrincipal);
                    }
                }

                if (e.KeyCode == Keys.F1)
                {
                    frmCuentas cuenta = new frmCuentas(true);
                    cuenta.enviar = rellenar;
                    cuenta.ShowDialog();
                }
            }
            catch (Exception ee)
            {
            }

            this.esInsertar = false;
            if (e.KeyCode == Keys.Enter)
            {
                if (this.columna == 5)
                {
                    this.ejecutarMetodo();
                }
                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
                {
                }
            }
        }