Example #1
0
        public bool IngresarOficio(String str1, String tip, String str2, String str3, String ini, String fin, String anio)
        {
            bool fl = false;

            Conexion.Open();
            String text = "INSERT INTO oficio(numero_oficio,titulo,tipo,descripcion_oficio) " +
                          " VALUES('" + str1 + "','" + str2 + "','" + tip + "','" + str3 + "')";

            cmd = new SqlCommand(text, Conexion.sqlConexion);
            int c = cmd.ExecuteNonQuery();

            if (c > 0)
            {
                cmd = new SqlCommand("UPDATE sistema SET nro_oficio=isnull(nro_oficio,0)+1 WHERE anio=" + anio, Conexion.sqlConexion);
                c   = cmd.ExecuteNonQuery();
                if (c > 0)
                {
                    BDTal tal = new BDTal();
                    fl = (tal.IngresarOficioEn(str1, ini, fin)) ? true : false;
                }
            }
            Conexion.Close();

            return(fl);
        }
Example #2
0
        private void btnGrabar_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                int cant = Convert.ToInt32(lblCantidad.Content);

                if (cant > 0)
                {
                    int        lgNroOfi  = ((lblErrNroOfi.Content) as String).Length;
                    int        lgTitOfi  = ((lblErrTitOfi.Content) as String).Length;
                    BDPapeleta pap       = new BDPapeleta();
                    int        numPapIng = pap.isIngresado(txtRangoDel.Text, txtRangoAl.Text);
                    if (numPapIng == 0)
                    {
                        if (lgNroOfi == 0 && lgTitOfi == 0)
                        {
                            BDOficio ofi = new BDOficio();
                            if (ofi.IngresarOficio(txtNroOficio.Text, "M", txtTituloOficio.Text, txtDescripcion.Text))
                            {
                                DateTime dt    = dpFechaIngreso.SelectedDate.Value;
                                String   fecha = dt.Year + "/" + dt.Month + "/" + dt.Day;
                                BDTal    tal   = new BDTal();
                                if (tal.IngresarTal(txtRangoDel.Text, txtRangoAl.Text, fecha, codUsuario, txtNroOficio.Text, Convert.ToInt32(lblCantidad.Content)))
                                {
                                    MessageBox.Show("Se Grabo el Talonario y Oficio exitosamente");
                                }
                                else
                                {
                                    MessageBox.Show("Error: No se Guardo el Talonario");
                                }
                            }
                            else
                            {
                                MessageBox.Show("Error: No se grabo el oficio");
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show(numPapIng + " papeletas dentro del rango ya han sido ingresadas en otro talonario");
                    }
                }
                else
                {
                    MessageBox.Show("Error: La cantidad negativa");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message);
            }
        }
        private void btnGrabar_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                int cant = Convert.ToInt32(lblCantidad.Content);
                if (cant > 0)
                {
                    if (codComi != "" && txtCodCIP.Text != "")
                    {
                        DateTime   dt         = dpFechaIngreso.SelectedDate.Value;
                        String     fecha      = dt.Year + "/" + dt.Month + "/" + dt.Day;
                        BDPapeleta pap        = new BDPapeleta();
                        int        numPapAsig = pap.isReAsignado(txtRangoDel.Text, txtRangoAl.Text);
                        if (numPapAsig == cant)
                        {
                            BDTal tal = new BDTal();
                            if (tal.ReasignarTalonario(cant, txtRangoDel.Text, txtRangoAl.Text, fecha, txtCodCIP.Text, codComi, usuario))
                            {
                                DataTable dat = tal.obtenerDatos(txtRangoDel.Text, txtRangoAl.Text);
                                Reportes  rep = new Reportes();
                                rep.TalonariosAsignados(dat);

                                CargarTabPap();
                                MessageBox.Show("Se actualizacion los datos exitosamente");
                            }
                            else
                            {
                                MessageBox.Show("no se guardaron los datos...");
                            }
                        }
                        else
                        {
                            MessageBox.Show("Error: no todas las papeletas se encuentran en el estado de reasignar");
                        }
                    }
                    else
                    {
                        MessageBox.Show("No se selecciono comisaria o no se ingreso CIP");
                    }
                }
                else
                {
                    MessageBox.Show("Error: Rango de Papeletas ");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.ToString());
            }
        }
Example #4
0
        public bool DevolucionPapeleta(String num, String tip, String fec)
        {
            Conexion.Open();
            cmd = new SqlCommand("UPDATE papeleta SET fisico=1, falta=0, estado='" + tip + "', fecha_envio='" + fec + "' WHERE numero_papeleta='" + num + "'", Conexion.sqlConexion);
            bool fl = (cmd.ExecuteNonQuery() > 0) ? true : false;

            if (fl)
            {
                BDTal tal = new BDTal();
                if (tal.ActualizarTalonario(getRelTalonario(num)))
                {
                    fl = true;
                }
                else
                {
                    fl = false;
                }
            }
            Conexion.Close();
            return(fl);
        }
Example #5
0
        public bool DevolucionPapeleta(String num, String tip, String inf, String fecImp, String fec, String cond, String veh)
        {
            Conexion.Open();
            cmd = new SqlCommand("UPDATE papeleta SET fisico=1, falta=0, estado='" + tip +
                                 "', fecha_envio='" + fec + "', tipo_infraccion='" + inf + "', fecha_imposicion='" + fecImp
                                 + "', dni_conductor='" + cond + "', placa='" + veh + "' WHERE numero_papeleta='" + num + "'", Conexion.sqlConexion);
            bool fl = (cmd.ExecuteNonQuery() > 0) ? true : false;

            if (fl)
            {
                BDTal tal = new BDTal();
                if (tal.ActualizarTalonario(getRelTalonario(num)))
                {
                    fl = true;
                }
                else
                {
                    fl = false;
                }
            }
            Conexion.Close();
            return(fl);
        }
        private void dataGridTalonarios_SelectedCellsChanged(object sender, SelectedCellsChangedEventArgs e)
        {
            try
            {
                if (dataGridTalonarios.SelectedItem != null)
                {
                    string       ini = "", fin = "";
                    int          cant       = 0;
                    DataGridRow  row        = (DataGridRow)dataGridTalonarios.ItemContainerGenerator.ContainerFromIndex(dataGridTalonarios.SelectedIndex);
                    DataGridCell RowColumn1 = dataGridTalonarios.Columns[1].GetCellContent(row).Parent as DataGridCell;
                    DataGridCell RowColumn2 = dataGridTalonarios.Columns[2].GetCellContent(row).Parent as DataGridCell;
                    DataGridCell RowColumn3 = dataGridTalonarios.Columns[3].GetCellContent(row).Parent as DataGridCell;
                    ini  = ((TextBlock)RowColumn1.Content).Text;
                    fin  = ((TextBlock)RowColumn2.Content).Text;
                    cant = Convert.ToInt32(((TextBlock)RowColumn3.Content).Text);

                    BDTal            tal = new BDTal();
                    string           str = "Esta Seguro que desea eliminar los datos?. Se pederan los datos de las papeletas asignadas";
                    MessageBoxResult mes = MessageBox.Show(str, "Mensaje", MessageBoxButton.YesNo, MessageBoxImage.Question);
                    if (mes == MessageBoxResult.Yes)
                    {
                        if (tal.EliminarRelTalonario(cant, ini, fin))
                        {
                            CargarTablaTal();
                        }
                        else
                        {
                            MessageBox.Show("Error: No se guardo el Talonario");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message);
            }
        }
Example #7
0
        public void imprimirPapeletasFaltantes(String codComi, String nom, int tip)
        {
            try
            {
                BDTal     tal = new BDTal();
                DataTable ds  = tal.GetByIdAll(codComi, tip);
                if (ds != null)
                {
                    BDSistema sis = new BDSistema();
                    String    dir = sis.Directorio();
                    if (dir != null)
                    {
                        //Ubicación del reporte
                        string ubicacionReporte = @dir + "\\reportePapFaltantes_" + codComi + ".pdf";
                        //Creacion de reporte con iTextSharp
                        Document  reporte = new Document(PageSize.LETTER);
                        PdfWriter writer  = PdfWriter.GetInstance(reporte, new FileStream(ubicacionReporte, FileMode.Create));

                        //Abriendo Archivo
                        reporte.Open();

                        Font _standardFont = new Font(Font.FontFamily.TIMES_ROMAN, 8, Font.NORMAL, BaseColor.BLACK);

                        //Añadiendo titulo
                        reporte.AddTitle("Reporte de papeletas faltantes " + codComi);
                        reporte.AddAuthor("Sistema de Gestión de papeletas Poltran v1.1");

                        //Encabezado de reporte
                        reporte.Add(new iTextSharp.text.Paragraph("Reporte de Papeletas Faltantes "));
                        reporte.Add(Chunk.NEWLINE);
                        int       nrocol = 6;
                        PdfPTable tablaDatosPrincipales = new PdfPTable(nrocol);
                        tablaDatosPrincipales.WidthPercentage = 80;

                        //Configurando titulo de las columnas de datos por fila
                        PdfPCell clNroPapeleta = new PdfPCell(new Phrase("Nro. Papeleta", _standardFont));
                        clNroPapeleta.BorderWidth       = 0;
                        clNroPapeleta.BorderWidthBottom = 0.50f;

                        PdfPCell clFalta = new PdfPCell(new Phrase("Falta", _standardFont));
                        clFalta.BorderWidth       = 0;
                        clFalta.BorderWidthBottom = 0.50f;

                        PdfPCell clEstado = new PdfPCell(new Phrase("Estado", _standardFont));
                        clEstado.BorderWidth       = 0;
                        clEstado.BorderWidthBottom = 0.50f;

                        PdfPCell clid;
                        PdfPCell clnom;
                        if (tip == 1)
                        {
                            clid                   = new PdfPCell(new Phrase("Codigo CIP", _standardFont));
                            clid.BorderWidth       = 0;
                            clid.BorderWidthBottom = 0.50f;

                            clnom                   = new PdfPCell(new Phrase("Nombre de Efectivo", _standardFont));
                            clnom.BorderWidth       = 0;
                            clnom.BorderWidthBottom = 0.75f;
                        }
                        else
                        {
                            clid                   = new PdfPCell(new Phrase("Codigo", _standardFont));
                            clid.BorderWidth       = 0;
                            clid.BorderWidthBottom = 0.50f;

                            clnom                   = new PdfPCell(new Phrase("Nombre de Comisaria", _standardFont));
                            clnom.BorderWidth       = 0;
                            clnom.BorderWidthBottom = 0.75f;
                        }

                        PdfPCell clfec = new PdfPCell(new Phrase("Fecha de Envio", _standardFont));
                        clfec.BorderWidth       = 0;
                        clfec.BorderWidthBottom = 0.50f;

                        tablaDatosPrincipales.AddCell(clNroPapeleta);
                        tablaDatosPrincipales.AddCell(clFalta);
                        tablaDatosPrincipales.AddCell(clEstado);
                        tablaDatosPrincipales.AddCell(clid);
                        tablaDatosPrincipales.AddCell(clnom);
                        tablaDatosPrincipales.AddCell(clfec);

                        PdfPTable tablaDatosConsulta = new PdfPTable(nrocol);
                        tablaDatosConsulta.WidthPercentage = 80;
                        foreach (DataRow dr in ds.Rows)
                        {
                            //Recorriendo la lista y llenando el reporte
                            clNroPapeleta = new PdfPCell(new Phrase(dr["numero_papeleta"].ToString(), _standardFont));

                            String f = (dr["falta"].ToString() == "True") ? "1" : "0";
                            clFalta = new PdfPCell(new Phrase(f, _standardFont));

                            clEstado = new PdfPCell(new Phrase(dr["estado"].ToString(), _standardFont));

                            clid = new PdfPCell(new Phrase(dr["id"].ToString(), _standardFont));

                            clnom = new PdfPCell(new Phrase(dr["nombre"].ToString(), _standardFont));

                            clfec = new PdfPCell(new Phrase(dr["fecha_entrega"].ToString(), _standardFont));

                            tablaDatosConsulta.AddCell(clNroPapeleta);
                            tablaDatosConsulta.AddCell(clFalta);
                            tablaDatosConsulta.AddCell(clEstado);
                            tablaDatosConsulta.AddCell(clid);
                            tablaDatosConsulta.AddCell(clnom);
                            tablaDatosConsulta.AddCell(clfec);
                        }

                        reporte.Add(new iTextSharp.text.Paragraph("Lista de Papeletas Faltantes " + nom));
                        reporte.Add(tablaDatosPrincipales);
                        reporte.Add(tablaDatosConsulta);
                        reporte.Close();
                        writer.Close();

                        //Confirmacion de creacion de reporte y apertura automatica del reporte en pdf
                        MessageBox.Show("Reporte creado con exito");
                        System.Diagnostics.Process.Start(ubicacionReporte);
                    }
                }
                else
                {
                    String str = (tip == 1) ? " efectivo" : "a comisaria";
                    MessageBox.Show("Seleccione un" + str + "...");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message);
            }
        }
        private void btnGuardar_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                int cant = Convert.ToInt32(lblCantidad.Content);
                if (cant > 0)
                {
                    if (codEfe != "" || codEfe != null)
                    {
                        BDTal  tal    = new BDTal();
                        String codTal = tal.obtenerId(txtRangoDel.Text, txtRangoAl.Text);

                        if (codTal != null)
                        {
                            BDPapeleta pap        = new BDPapeleta();
                            int        numPapAsig = pap.isAsignado(txtRangoDel.Text, txtRangoAl.Text);
                            if (numPapAsig == 0)
                            {
                                DateTime dt    = dpFechaEnvio.SelectedDate.Value;
                                String   fecha = dt.Year + "/" + dt.Month + "/" + dt.Day;

                                if (tal.entregarPapeletas(txtRangoDel.Text, txtRangoAl.Text, fecha, codEfe, cmbCom.SelectedValue as String, codTal, usuario, cant))
                                {
                                    CargarTablaTal();
                                    if (flagArch)
                                    {
                                        DataTable dat = tal.obtenerDatos(txtRangoDel.Text, txtRangoAl.Text);
                                        Reportes  rep = new Reportes();
                                        rep.TalonariosEntregados(dat);
                                        ClearAll();
                                    }
                                    MessageBox.Show("Se Asigno correctamente las papeletas");
                                }
                                else
                                {
                                    MessageBox.Show("Error: Al asignar las papeletas");
                                }
                            }
                            else
                            {
                                MessageBox.Show(numPapAsig + " papeletas dentro del rango ya han sido asignadas");
                            }
                        }
                        else
                        {
                            MessageBox.Show("Rango de papeletas no pertenece a un talonario");
                        }
                    }
                    else
                    {
                        MessageBox.Show("No se selecciono Efectivo");
                    }
                }
                else
                {
                    MessageBox.Show("Error: Rango de Papeletas ");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error:" + ex.ToString());
            }
        }