Beispiel #1
0
        public frmConsultarMantenimiento()
        {
            InitializeComponent();
            fillDocumento();

            ent_configuracion = new Ent_Configuracion();
            ent_configuracion = BL_Configuracion.getConfiguracion();
            prog = new Ent_Prog_Mantenimiento();

            Dictionary <string, string> lista_tipo = new Dictionary <string, string>();

            lista_tipo.Add("RE", "REALIZADO");
            lista_tipo.Add("NR", "NO REALIZADO");
            lista_tipo.Add("RP", "EN REPARACIÓN");
            cboEstado.DataSource    = new BindingSource(lista_tipo, null);
            cboEstado.DisplayMember = "Value";
            cboEstado.ValueMember   = "Key";
        }
Beispiel #2
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            Ent_Prog_Mantenimiento mant = new Ent_Prog_Mantenimiento();

            mant.documento = Convert.ToInt32(nro_doc);
            mant.estado    = cboEstado.SelectedValue.ToString();
            String result = BL_Mantenimiento.updMantenimiento(mant);

            if (result.Equals("1"))
            {
                fillDocumento();
                MessageBox.Show("¡Mantenimiento modificado!.", "Consulta Mantenimiento", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show(result, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #3
0
        private void btnPagar_Click(object sender, EventArgs e)
        {
            Ent_Prog_Mantenimiento prog = new Ent_Prog_Mantenimiento();

            prog.documento        = correlativo == "" ? 0 : int.Parse(correlativo);
            prog.documento_des    = lblSerie.Text;
            prog.tienda           = cod_tienda;
            prog.usuario          = usuario;
            prog.tipo_persona     = rdbEmpresa.Checked == true ? "N" : "E";
            prog.numero_documento = txtDesRuc.Text;
            prog.cliente_des      = txtDesCliente.Text;
            prog.cliente          = cliente;
            prog.estado           = cboEstado.SelectedValue.ToString();
            prog.fecha_salida     = dtpFechaSalida.Value.ToShortDateString();

            List <Ent_Tipo_Mantenimiento> lista_mant = new List <Ent_Tipo_Mantenimiento>();

            foreach (DataGridViewRow row in dgvMantenimiento.Rows)
            {
                Ent_Tipo_Mantenimiento prd = new Ent_Tipo_Mantenimiento();
                prd.id          = int.Parse(row.Cells["ID"].Value.ToString());
                prd.descripcion = row.Cells["DESCRIPCION"].Value.ToString();

                lista_mant.Add(prd);
            }
            prog.mantenimiento = lista_mant;
            string request = BL_Mantenimiento.setProg_Mantenimiento(prog);

            if (request == "1")
            {
                MessageBox.Show("Se agregó correctamente");
                InvoicePDF pdf = new InvoicePDF();
                pdf.createServicioTecnico(ent_configuracion, prog);
            }
            else
            {
                MessageBox.Show(request);
            }
        }
Beispiel #4
0
        public void createServicioTecnico(Ent_Configuracion ent_configuracion, Ent_Prog_Mantenimiento prog)
        {
            PdfDocument document = new PdfDocument();
            PdfPage     page     = document.AddPage();
            XGraphics   gfx      = XGraphics.FromPdfPage(page);

            //XImage image = XImage.FromFile(logo);
            //gfx.DrawImage(image, 0, marginTop, 256, 80);

            XFont font    = new XFont(fontName, 10);
            XFont fontBox = new XFont(fontName, 15);

            int yPosHeader1 = marginTop + 20;

            gfx.DrawString(ent_configuracion.RAZON_SOCIAL, font, XBrushes.Black, marginLeft, yPosHeader1);
            yPosHeader1 = yPosHeader1 + 15;
            gfx.DrawString(ent_configuracion.DIRECCION, font, XBrushes.Black, marginLeft, yPosHeader1);
            yPosHeader1 = yPosHeader1 + 15;
            gfx.DrawString("Cel. " + ent_configuracion.TELEFONO, font, XBrushes.Black, marginLeft, yPosHeader1);
            yPosHeader1 = yPosHeader1 + 15;
            gfx.DrawString("[email protected] / www.osmosisperu.com", font, XBrushes.Black, marginLeft, yPosHeader1);

            int yPosHeader2 = marginTop;

            drawBox(gfx, Convert.ToInt32(page.Width / 1.5), marginTop, Convert.ToInt32(page.Width / 2.9 - marginRight * 2), 80);
            yPosHeader2 = yPosHeader2 + 20;
            gfx.DrawString("R.U.C. " + ent_configuracion.RUC, fontBox, XBrushes.Black, Convert.ToInt32(page.Width / 1.5) + 15, yPosHeader2);
            gfx.DrawRectangle(XBrushes.Black, Convert.ToInt32(page.Width / 1.5), 40, Convert.ToInt32(page.Width / 2.9 - marginRight * 2), 20);
            yPosHeader2 = yPosHeader2 + 25;
            gfx.DrawString("SERVICIO TÉCNICO", fontBox, XBrushes.White, Convert.ToInt32(page.Width / 1.5) + 15, yPosHeader2);
            yPosHeader2 = yPosHeader2 + 25;
            gfx.DrawString(prog.documento_des, fontBox, XBrushes.Black, Convert.ToInt32(page.Width / 1.5) + 15, yPosHeader2);

            int yPosCustomerDetails = yPosHeader2 + 40;

            gfx.DrawString("Lima, " + DateTime.Now.ToString("d 'de' MMMM 'del' yyyy"), font, XBrushes.Black, marginLeft, yPosCustomerDetails);
            yPosCustomerDetails = yPosCustomerDetails + 20;
            gfx.DrawString("Cliente: " + prog.cliente_des, font, XBrushes.Black, marginLeft, yPosCustomerDetails);
            gfx.DrawString("Solicitante: _______________________________", font, XBrushes.Black, page.Width / 2, yPosCustomerDetails);
            yPosCustomerDetails = yPosCustomerDetails + 20;
            gfx.DrawString("Dirección: " + prog.cliente.direccion, font, XBrushes.Black, marginLeft, yPosCustomerDetails);
            gfx.DrawString("RUC: " + prog.cliente.dni, font, XBrushes.Black, page.Width / 1.35, yPosCustomerDetails);

            int yPosBoxMoreDetails = yPosCustomerDetails + 10;

            drawBox(gfx, marginLeft, yPosBoxMoreDetails, Convert.ToInt32(page.Width - marginRight * 2), 75);

            int yPosBoxMoreDetailsContent = yPosBoxMoreDetails + 20;

            gfx.DrawString("Llamada:  Fecha: ___/___/____    Hora: ___/___", font, XBrushes.Black, marginLeft + 10, yPosBoxMoreDetailsContent);
            yPosBoxMoreDetailsContent = yPosBoxMoreDetailsContent + 20;
            gfx.DrawString("Servicio:  Fecha: ___/___/____    Hora: ___/___", font, XBrushes.Black, marginLeft + 10, yPosBoxMoreDetailsContent);
            yPosBoxMoreDetailsContent = yPosBoxMoreDetailsContent + 20;
            gfx.DrawString("Persona Contacto:  ________________________________________    Teléfono Contacto: _____________", font, XBrushes.Black, marginLeft + 10, yPosBoxMoreDetailsContent);

            int totalItems = prog.mantenimiento.Count;

            int yPosBoxItems = yPosBoxMoreDetailsContent + 25;
            int yPosBoxTitle = yPosBoxItems + 15;
            int boxHeight    = yPosBoxTitle + 20 * totalItems - yPosBoxItems + 10;

            //ITEMS BOX
            drawBox(gfx, marginLeft, yPosBoxItems, Convert.ToInt32(page.Width - marginRight * 2), boxHeight);

            //TITLE BOX
            drawBox(gfx, marginLeft, yPosBoxItems, Convert.ToInt32(page.Width - marginRight * 2), 20);

            int xPosDesc = marginLeft + 10;

            gfx.DrawString("DESCRIPCIÓN", font, XBrushes.Black, xPosDesc, yPosBoxTitle);

            int yPosBoxTitleWMargin = yPosBoxTitle + 20;
            int yPosLastItem        = 0;
            int i = 0;

            prog.mantenimiento.ForEach(delegate(Ent_Tipo_Mantenimiento m) {
                yPosLastItem = yPosBoxTitleWMargin + 20 * i;
                gfx.DrawString(m.descripcion, font, XBrushes.Black, xPosDesc, yPosLastItem);
                i++;
            });

            String filename = "invoices\\serviciotecnico_" + prog.documento + ".pdf";

            document.Save(filename);
            Process.Start(filename);
        }
Beispiel #5
0
        public static string updMantenimiento(Ent_Prog_Mantenimiento mant)
        {
            MySqlTransaction tr = null;

            con = Conexion.getConnection();

            string retval = "1";

            try
            {
                con.Open();

                tr = con.BeginTransaction();

                MySqlCommand cmd = new MySqlCommand();

                cmd.Connection  = con;
                cmd.Transaction = tr;

                cmd.CommandText = "sp_sys_upd_mantenimiento";
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.AddWithValue("@RETVAL", MySqlDbType.VarChar);
                cmd.Parameters["@RETVAL"].Direction = ParameterDirection.Output;

                cmd.Parameters.AddWithValue("@PSTR_ID", mant.documento);
                cmd.Parameters["@PSTR_ID"].Direction = ParameterDirection.Input;

                cmd.Parameters.AddWithValue("@PSTR_ESTADO", mant.estado);
                cmd.Parameters["@PSTR_ESTADO"].Direction = ParameterDirection.Input;

                cmd.ExecuteNonQuery();

                retval = cmd.Parameters["@RETVAL"].Value.ToString();

                if (retval != "1")
                {
                    tr.Rollback();
                    return(retval);
                }

                tr.Commit();
            }
            catch (MySqlException ex)
            {
                try
                {
                    tr.Rollback();
                }
                catch (MySqlException ex1)
                {
                    return(ex1.ToString());
                }

                return(ex.ToString());
            }
            finally
            {
                con.Close();
            }

            return(retval);
        }
Beispiel #6
0
        public static string setProg_Mantenimiento(Ent_Prog_Mantenimiento cabecera_mant)
        {
            MySqlTransaction tr = null;

            con = Conexion.getConnection();

            string retval = "1";

            try
            {
                con.Open();

                tr = con.BeginTransaction();

                MySqlCommand cmd = new MySqlCommand();

                cmd.Connection  = con;
                cmd.Transaction = tr;

                cmd.CommandText = "SP_SET_GUARDARPROG_MANTENIMIENTO_CAB";
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.AddWithValue("@RETVAL", MySqlDbType.VarChar);
                cmd.Parameters["@RETVAL"].Direction = ParameterDirection.Output;

                cmd.Parameters.AddWithValue("@RETID", MySqlDbType.VarChar);
                cmd.Parameters["@RETID"].Direction = ParameterDirection.Output;

                cmd.Parameters.AddWithValue("@PSTR_NUM_DOC", cabecera_mant.documento);
                cmd.Parameters["@PSTR_NUM_DOC"].Direction = ParameterDirection.Input;

                cmd.Parameters.AddWithValue("@PSTR_TIENDA", cabecera_mant.tienda);
                cmd.Parameters["@PSTR_TIENDA"].Direction = ParameterDirection.Input;

                cmd.Parameters.AddWithValue("@PSTR_TIPO_PERSONA", cabecera_mant.tipo_persona);
                cmd.Parameters["@PSTR_TIPO_PERSONA"].Direction = ParameterDirection.Input;

                cmd.Parameters.AddWithValue("@PSTR_CLIENTE", cabecera_mant.numero_documento);
                cmd.Parameters["@PSTR_CLIENTE"].Direction = ParameterDirection.Input;

                cmd.Parameters.AddWithValue("@PSTR_USUARIO", cabecera_mant.usuario);
                cmd.Parameters["@PSTR_USUARIO"].Direction = ParameterDirection.Input;

                cmd.Parameters.AddWithValue("@PSTR_ESTADO", cabecera_mant.estado);
                cmd.Parameters["@PSTR_ESTADO"].Direction = ParameterDirection.Input;

                cmd.Parameters.AddWithValue("@PSTR_FECHA_SALIDA", cabecera_mant.fecha_salida);
                cmd.Parameters["@PSTR_FECHA_SALIDA"].Direction = ParameterDirection.Input;

                cmd.ExecuteNonQuery();

                retval = cmd.Parameters["@RETVAL"].Value.ToString();
                string id_cab = cmd.Parameters["@RETID"].Value.ToString();

                if (retval == "1")
                {
                    string retval_det;

                    cmd.CommandText = "SP_SET_GUARDARPROG_MANTENIMIENTO_DET";
                    cmd.CommandType = CommandType.StoredProcedure;

                    foreach (Ent_Tipo_Mantenimiento prog in cabecera_mant.mantenimiento)
                    {
                        cmd.Parameters.Clear();

                        cmd.Parameters.AddWithValue("@RETVAL", MySqlDbType.VarChar);
                        cmd.Parameters["@RETVAL"].Direction = ParameterDirection.Output;

                        cmd.Parameters.AddWithValue("@PSTR_NUM_DOC", id_cab);
                        cmd.Parameters["@PSTR_NUM_DOC"].Direction = ParameterDirection.Input;

                        cmd.Parameters.AddWithValue("@PSTR_TIPO_MANTENIMIENTO", prog.id);
                        cmd.Parameters["@PSTR_TIPO_MANTENIMIENTO"].Direction = ParameterDirection.Input;

                        cmd.ExecuteNonQuery();

                        retval_det = cmd.Parameters["@RETVAL"].Value.ToString();

                        if (retval_det != "1")
                        {
                            tr.Rollback();
                            return(retval_det);
                        }
                    }
                }
                else
                {
                    tr.Rollback();
                    return(retval);
                }

                tr.Commit();
            }
            catch (MySqlException ex)
            {
                try
                {
                    tr.Rollback();
                }
                catch (MySqlException ex1)
                {
                    return(ex1.ToString());
                }

                return(ex.ToString());
            }
            finally
            {
                con.Close();
            }

            return(retval);
        }
Beispiel #7
0
 public static string updMantenimiento(Ent_Prog_Mantenimiento mant)
 {
     return(DAO_Mantenimiento.updMantenimiento(mant));
 }
Beispiel #8
0
 public static string setProg_Mantenimiento(Ent_Prog_Mantenimiento mantenimiento)
 {
     return(DAO_Mantenimiento.setProg_Mantenimiento(mantenimiento));
 }