Ejemplo n.º 1
0
 public void insertaviaje()
 {
     try
     {
         DAO.FacturasDAO fac = new FacturasDAO();
         fac.IDFactura = int.Parse(lbl_idfactura.Text);
         fac.viaje     = textBox20.Text;
         fac.insertaviaje();
     }
     catch
     {
         MessageBox.Show("Error insertaviaje");
     }
 }
Ejemplo n.º 2
0
        //public void insertaviaje()
        //{
        //    try
        //    {
        //        DAO.FacturasDAO fac = new FacturasDAO();
        //        fac.IDFactura = int.Parse(lbl_idfactura.Text);
        //        fac.viaje = textBox20.Text;
        //        fac.insertaviaje();
        //    }
        //    catch
        //    {
        //        MessageBox.Show("Error insertaviaje");
        //    }
        //}

        private void button7_Click(object sender, EventArgs e)
        {
            try
            {
                if (textBox5.Text != "")
                {
                    //(this.IDFactura, this.IDFServicios, this.Cantidad, this.Importe)
                    DAO.FacturasDAO facturasdao = new FacturasDAO();
                    facturasdao.IDFactura    = int.Parse(lbl_idfactura.Text);
                    facturasdao.IDFServicios = int.Parse(dataGridView2.CurrentRow.Cells[0].Value.ToString());
                    facturasdao.Cantidad     = int.Parse(textBox5.Text);
                    facturasdao.Importe      = (decimal.Parse(dataGridView2.CurrentRow.Cells[4].Value.ToString()) * decimal.Parse(textBox5.Text));
                    string resultado = facturasdao.insertaserviciosfactura();
                    if (resultado != "Correcto")
                    {
                        MessageBox.Show(resultado);
                    }
                    else
                    {
                        actualizagrid();
                        calculatotales();
                    }
                }
                else
                {
                    DAO.FacturasDAO facturasdao = new FacturasDAO();
                    facturasdao.IDFactura    = int.Parse(lbl_idfactura.Text);
                    facturasdao.IDFServicios = int.Parse(dataGridView2.CurrentRow.Cells[0].Value.ToString());
                    facturasdao.Cantidad     = 1;
                    facturasdao.Importe      = decimal.Parse(dataGridView2.CurrentRow.Cells[4].Value.ToString());
                    string resultado = facturasdao.insertaserviciosfactura();
                    if (resultado != "Correcto")
                    {
                        MessageBox.Show(resultado);
                    }
                    else
                    {
                        actualizagrid();
                        calculatotales();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Ejemplo n.º 3
0
        private void button9_Click(object sender, EventArgs e)
        {
            try
            {
                DAO.FacturasDAO facturasdao = new FacturasDAO();
                facturasdao.IDFactura = int.Parse(lbl_idfactura.Text);

                Numalet let = new Numalet();
                if (comboBox3.Text == "USD")
                {
                    let.MascaraSalidaDecimal   = "00'/100 USD'";
                    let.SeparadorDecimalSalida = "Dolares";
                    //observar que sin esta propiedad queda "veintiuno pesos" en vez de "veintiún pesos":
                    let.ApocoparUnoParteEntera = true;
                    facturasdao.TotalLetras    = ("Son: " + let.ToCustomCardinal(textBox15.Text));
                    //Son: un mil ciento veintiún pesos 24/100 M.N.
                }
                else
                {
                    let.MascaraSalidaDecimal   = "00'/100 MXN'";
                    let.SeparadorDecimalSalida = "Pesos";
                    //observar que sin esta propiedad queda "veintiuno pesos" en vez de "veintiún pesos":
                    let.ApocoparUnoParteEntera = true;
                    facturasdao.TotalLetras    = ("Son: " + let.ToCustomCardinal(textBox15.Text));
                    //Son: un mil ciento veintiún pesos 24/100 M.N.
                }
                //this.ClaveCFDI, this.formaDePago, this.metodoDePago, this.descuento, this.porcentajeDescuento, this.motivodescuento, this.tipodecambio,
                //this.fechatipodecambio, this.totalImpuestosretenidos, this.totalimpuestostrasladados, this.LugarExpedicion);


                facturasdao.formaDePago = "Pago en una sola exhibición";
                if (textBox16.Text != "")
                {
                    facturasdao.Descuento_decimal           = ((decimal.Parse(textBox16.Text) * decimal.Parse(textBox13.Text)) / ((decimal.Parse("100"))));
                    facturasdao.PorcentajeDescuento_decimal = int.Parse(textBox16.Text);
                    facturasdao.Subtotal = decimal.Parse(textBox13.Text);
                    decimal ivadespuesdescuento      = (decimal.Parse(textBox13.Text) - ((decimal.Parse(textBox16.Text) * decimal.Parse(textBox13.Text)) / ((decimal.Parse("100"))))) * decimal.Parse("0.16");
                    decimal subtotaldespuesdescuento = decimal.Parse(textBox13.Text) - ((decimal.Parse(textBox16.Text) * decimal.Parse(textBox13.Text)) / ((decimal.Parse("100"))));
                    facturasdao.Iva   = ivadespuesdescuento;
                    facturasdao.Total = subtotaldespuesdescuento + ivadespuesdescuento;
                }
                else
                {
                    facturasdao.descuento = "";
                    //facturasdao.PorcentajeDescuento_decimal = int.Parse(textBox16.Text);
                    facturasdao.Subtotal = decimal.Parse(textBox13.Text);
                    facturasdao.Iva      = decimal.Parse(textBox14.Text);
                    facturasdao.Total    = decimal.Parse(textBox15.Text);
                }

                facturasdao.motivodescuento = textBox17.Text;

                facturasdao.totalImpuestosretenidos   = "";
                facturasdao.totalimpuestostrasladados = textBox14.Text;
                facturasdao.LugarExpedicion           = "Merida, Yucatan";
                string resultado = facturasdao.actualizafacturatermina();
                if (resultado != "Correcto")
                {
                    MessageBox.Show(resultado);
                }
                else
                {
                    facturasdao.facturaimpresa = "";
                    facturasdao.ClaveCFDI      = "";
                    resultado = facturasdao.insertanumfacturaimpresa();
                    if (resultado != "Correcto")
                    {
                        MessageBox.Show(resultado);
                    }
                    else
                    {
                        string resultado2 = descargainventarios();
                        if (resultado2 == "Correcto")
                        {
                            MessageBox.Show("Correcto");
                            GUI.CatalogosForms.Facturas facturasgui = new Facturas();
                            facturasgui.MdiParent = this.MdiParent;
                            facturasgui.Show();

                            this.Close();
                        }
                        else
                        {
                            MessageBox.Show(resultado2);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Hubo algun error en la informacion " + ex);
            }
        }
Ejemplo n.º 4
0
        private void button9_Click(object sender, EventArgs e)
        {
            //(this.IDFactura, this.Remolcadores, this.Moneda, this.Subtotal, this.Iva, this.Total, this.TotalLetras);
            try
            {
                DAO.FacturasDAO facturasdao = new FacturasDAO();
                facturasdao.IDFactura = int.Parse(lbl_idfactura.Text);
                if (textBox7.Text != "")
                {
                    facturasdao.Remolcadores = textBox5.Text + "/" + textBox6.Text + "/" + textBox7.Text;
                }
                else
                {
                    if (textBox6.Text != "")
                    {
                        facturasdao.Remolcadores = textBox5.Text + "/" + textBox6.Text;
                    }
                    else
                    {
                        facturasdao.Remolcadores = textBox5.Text;
                    }
                }
                facturasdao.Moneda   = comboBox3.Text;
                facturasdao.Subtotal = decimal.Parse(textBox13.Text);
                facturasdao.Iva      = decimal.Parse(textBox14.Text);
                facturasdao.Total    = decimal.Parse(textBox15.Text);
                Numalet let = new Numalet();
                if (comboBox3.Text == "USD")
                {
                    let.MascaraSalidaDecimal   = "00'/100 USD'";
                    let.SeparadorDecimalSalida = "Dolares";
                    //observar que sin esta propiedad queda "veintiuno pesos" en vez de "veintiún pesos":
                    let.ApocoparUnoParteEntera = true;
                    facturasdao.TotalLetras    = ("Son: " + let.ToCustomCardinal(textBox15.Text));
                    //Son: un mil ciento veintiún pesos 24/100 M.N.
                }
                else
                {
                    let.MascaraSalidaDecimal   = "00'/100 MXN'";
                    let.SeparadorDecimalSalida = "Pesos";
                    //observar que sin esta propiedad queda "veintiuno pesos" en vez de "veintiún pesos":
                    let.ApocoparUnoParteEntera = true;
                    facturasdao.TotalLetras    = ("Son: " + let.ToCustomCardinal(textBox15.Text));
                    //Son: un mil ciento veintiún pesos 24/100 M.N.
                }
                //this.ClaveCFDI, this.formaDePago, this.metodoDePago, this.descuento, this.porcentajeDescuento, this.motivodescuento, this.tipodecambio,
                //this.fechatipodecambio, this.totalImpuestosretenidos, this.totalimpuestostrasladados, this.LugarExpedicion);
                facturasdao.ClaveCFDI    = "";
                facturasdao.metodoDePago = comboBox1.Text;
                facturasdao.formaDePago  = "Pago en una sola exhibición";
                if (((checkBox7.Checked) | (checkBox8.Checked)) && textBox16.Text != "")
                {
                    if (checkBox7.Checked)
                    {
                        facturasdao.descuento           = ((decimal.Parse(textBox13.Text) * decimal.Parse(textBox16.Text)) / (100 - (decimal.Parse(textBox16.Text)))).ToString();
                        facturasdao.porcentajeDescuento = textBox16.Text;
                        facturasdao.motivodescuento     = textBox17.Text;
                    }
                    else
                    {
                        decimal descuentosuma = 0;
                        foreach (DataGridViewRow row in dataGridView1.Rows)
                        {
                            descuentosuma += decimal.Parse(row.Cells["Descuento"].Value.ToString());
                        }
                        facturasdao.descuento           = descuentosuma.ToString();
                        facturasdao.porcentajeDescuento = ((descuentosuma / 100) * (decimal.Parse(textBox13.Text) + descuentosuma)).ToString();
                        facturasdao.motivodescuento     = textBox17.Text;
                    }

                    //foreach (DataGridViewRow row in dataGridView1.Rows)
                    //{
                    //    facturasdao.descuento += decimal.Parse(row.Cells["Descuento"].Value.ToString());
                    //}
                }
                else
                {
                    facturasdao.descuento           = "";
                    facturasdao.porcentajeDescuento = "";
                    facturasdao.motivodescuento     = "";
                }
                //facturasdao.porcentajeDescuento = textBox16.Text;
                //facturasdao.motivodescuento = textBox17.Text;
                facturasdao.tipodecambio              = textBox18.Text;
                facturasdao.fechatipodecambio         = dateTimePicker5.Value.ToShortDateString();
                facturasdao.totalImpuestosretenidos   = "";
                facturasdao.totalimpuestostrasladados = textBox14.Text;
                facturasdao.LugarExpedicion           = "Progreso, Yucatan";
                facturasdao.Agencia   = textBox2.Text;
                facturasdao.NumCuenta = textBox21.Text;
                string resultado = facturasdao.actualizafacturatermina();
                if (resultado != "Correcto")
                {
                    MessageBox.Show(resultado);
                }
                else
                {
                    resultado = facturasdao.insertanumfacturaimpresa();
                    if (resultado != "Correcto")
                    {
                        MessageBox.Show(resultado);
                    }
                    else
                    {
                        resultado = facturasdao.creanota();
                        if (resultado != "Correcto")
                        {
                            MessageBox.Show(resultado);
                        }
                        else
                        {
                            MessageBox.Show("Correcto");
                            GUI.CatalogosForms.Facturas facturasgui = new Facturas();
                            facturasgui.MdiParent = this.MdiParent;
                            facturasgui.Show();

                            this.Close();
                        }
                    }
                }
            }
            catch
            {
                MessageBox.Show("Hubo algun error en la informacion");
            }
        }
Ejemplo n.º 5
0
        private void button7_Click(object sender, EventArgs e)
        {
            try
            {
                if ((lb_idbarco.Text != "") && (lbl_idCliente.Text != "") && (id_R1.Text != "") && (textBox11.Text != "") && (textBox19.Text != "") && (textBox20.Text != "") && (comboBox1.SelectedIndex != -1) && (((comboBox3.SelectedIndex == 1) && (textBox21.Text != "")) | comboBox3.SelectedIndex != -1))
                {
                    string resultado = insertaremolcadores();
                    if (resultado != "Correcto")
                    {
                        MessageBox.Show(resultado);
                    }
                    else
                    {
                        lbl_rinsertados.Text = "1";
                        if (idrinsertados.Text == "")
                        {
                            idrinsertados.Text = numeroinsertados().ToString();
                        }
                        if (lbl_idfactura.Text == "")
                        {
                            string resultado2 = insertafacturaparcial();
                            if (resultado2 != "Correcto")
                            {
                                MessageBox.Show(resultado2);
                            }
                            else
                            {
                                lbl_idfactura.Text = numerofactura().ToString();
                                insertaviaje();
                            }
                        }
                        else
                        {
                            bool descuentoresultado;
                            //if (textBox16.Text != "")
                            //{
                            //    descuentoresultado = ((int.Parse(textBox16.Text) < 0) | (int.Parse(textBox16.Text) > 99));
                            //}
                            //else
                            //{
                            //    descuentoresultado = false;
                            //}
                            if (((checkBox7.Checked) | (checkBox8.Checked)) && textBox16.Text != "")
                            {
                                //descuentot += " " + textBox16.Text + "% de descuento";
                                if (checkBox7.Checked)
                                {
                                    descuentoresultado = ((int.Parse(textBox16.Text) < 0) | (int.Parse(textBox16.Text) > 99));
                                }
                                else
                                {
                                    descuentoresultado = false;
                                }
                            }
                            else
                            {
                                descuentoresultado = false;
                            }

                            if ((descuentoresultado == false))
                            {
                                //(this.IDFactura, this.Servicio, this.BarcoT, this.TRB, this.Muelles, this.FechaT, this.Horario, this.TiempoTrancurrido, this.Importe);
                                DAO.FacturasDAO facturas = new EquimarFac.DAO.FacturasDAO();
                                facturas.IDFactura = int.Parse(lbl_idfactura.Text);
                                string service;
                                service = textBox11.Text;
                                if (checkBox1.Checked)
                                {
                                    service = service + " SERVICIO CONTINUO";
                                }

                                if (checkBox3.Checked)
                                {
                                    service = service + " Recargo extra 60%";
                                }
                                if (((checkBox9.Checked) | (checkBox10.Checked)) && textBox22.Text != "")
                                {
                                    service += " SobreCuota : " + textBox22.Text;
                                }
                                facturas.Servicio = service;
                                facturas.BarcoT   = textBox8.Text;
                                facturas.TRB      = textBox9.Text;
                                facturas.Muelles  = textBox12.Text;
                                facturas.FechaT   = dateTimePicker1.Value.ToShortDateString();
                                if ((checkBox5.Checked) | (checkBox6.Checked))
                                {
                                    facturas.Horario = "Solicitado a " + dateTimePicker2.Text + " Cancelado a " + dateTimePicker3.Text;
                                }
                                else
                                {
                                    facturas.Horario = "De " + dateTimePicker2.Text + " a " + dateTimePicker3.Text;
                                }
                                decimal redondeado = decimal.Truncate(Convert.ToDecimal((dateTimePicker3.Value - dateTimePicker2.Value).TotalMinutes / 60));
                                if (((redondeado < 1) && (redondeado > 0)) | (redondeado == 0))
                                {
                                    redondeado = 1;
                                }
                                else
                                {
                                    decimal numerominutos = Convert.ToDecimal((dateTimePicker3.Value - dateTimePicker2.Value).Minutes);;
                                    if ((numerominutos >= 1) && (numerominutos <= 15))
                                    {
                                        redondeado += Convert.ToDecimal(0.25);
                                    }
                                    if ((numerominutos > 15) && (numerominutos <= 30))
                                    {
                                        redondeado += Convert.ToDecimal(.50);
                                    }
                                    if ((numerominutos > 30) && (numerominutos <= 45))
                                    {
                                        redondeado += Convert.ToDecimal(.75);
                                    }
                                    if ((numerominutos > 45) && (numerominutos <= 59))
                                    {
                                        redondeado += 1;
                                    }
                                }


                                facturas.TiempoTrancurrido = redondeado.ToString() + " Hrs.";
                                decimal import;
                                if (checkBox1.Checked)
                                {
                                    double horas = ((dateTimePicker3.Value - dateTimePicker2.Value).TotalMinutes / 60);
                                    if (horas < 2)
                                    {
                                        MessageBox.Show("Para uso Servicio Continuo es un minimo de dos horas");
                                    }
                                    else
                                    {
                                        import = calculaimporte();
                                        if (import == -1)
                                        {
                                            MessageBox.Show("Error en el calculo del importe, verifique sus datos");
                                        }
                                        else
                                        {
                                            if (checkBox6.Checked)
                                            {
                                                descuento += import * Convert.ToDecimal(0.75);
                                                import     = import * Convert.ToDecimal(0.25);
                                            }
                                            if (checkBox5.Checked)
                                            {
                                                descuento += import * Convert.ToDecimal(0.5);
                                                import     = import * Convert.ToDecimal(0.5);
                                            }
                                            if (checkBox3.Checked)
                                            {
                                                import = import * Convert.ToDecimal(1.6);
                                            }

                                            if (((checkBox9.Checked) | (checkBox10.Checked)) && textBox22.Text != "")
                                            {
                                                //descuentot += " " + textBox16.Text + "% de descuento";
                                                if (checkBox9.Checked)
                                                {
                                                    facturas.Importe = import + (import * ((decimal.Parse(textBox23.Text)) / 100));
                                                }
                                                else
                                                {
                                                    facturas.Importe = (import + decimal.Parse(textBox23.Text));
                                                }
                                            }
                                            else
                                            {
                                                facturas.Importe = import;
                                            }
                                            resultado = facturas.insertaserviciosfactura();
                                            if (resultado != "Correcto")
                                            {
                                                MessageBox.Show(resultado);
                                            }
                                            else
                                            {
                                                DAO.FacturasDAO facturasdao = new FacturasDAO();
                                                facturasdao.IDFServicios = facturasdao.devuelveiddetallefac();
                                                if (checkBox6.Checked)
                                                {
                                                    descuentot = descuentot + " Cargo total del 25% por cancelacion";
                                                }
                                                if (checkBox5.Checked)
                                                {
                                                    descuentot = descuentot + " Cargo total del 50% por cancelacion";
                                                }
                                                facturasdao.DescuentoT = this.descuentot;
                                                if (descuento == 0)
                                                {
                                                }
                                                else
                                                {
                                                    facturasdao.Importe = this.descuento;
                                                }

                                                string resultado3 = facturasdao.insertaserviciosdescuento();
                                                if (resultado3 != "Correcto")
                                                {
                                                    MessageBox.Show(resultado3);
                                                }
                                                else
                                                {
                                                    descuento  = 0;
                                                    descuentot = "";
                                                    actualizagrid();
                                                    calculatotales();
                                                    textBox18.ReadOnly = true;
                                                    textBox16.ReadOnly = true;
                                                    textBox17.ReadOnly = true;
                                                    textBox20.ReadOnly = true;
                                                }
                                            }
                                        }
                                    }
                                }
                                else
                                {
                                    import = calculaimporte();
                                    if (import == -1)
                                    {
                                        MessageBox.Show("Error en el calculo del importe, verifique sus datos");
                                    }
                                    else
                                    {
                                        if (checkBox6.Checked)
                                        {
                                            descuento += import * Convert.ToDecimal(0.75);
                                            import     = import * Convert.ToDecimal(0.25);
                                        }
                                        if (checkBox5.Checked)
                                        {
                                            descuento += import * Convert.ToDecimal(0.5);
                                            import     = import * Convert.ToDecimal(0.5);
                                        }
                                        if (checkBox3.Checked)
                                        {
                                            import = import * Convert.ToDecimal(1.6);
                                        }
                                        if (((checkBox9.Checked) | (checkBox10.Checked)) && textBox22.Text != "")
                                        {
                                            //descuentot += " " + textBox16.Text + "% de descuento";
                                            if (checkBox9.Checked)
                                            {
                                                facturas.Importe = import + (import * ((decimal.Parse(textBox23.Text)) / 100));
                                            }
                                            else
                                            {
                                                facturas.Importe = (import + decimal.Parse(textBox23.Text));
                                            }
                                        }
                                        else
                                        {
                                            facturas.Importe = import;
                                        }
                                        resultado = facturas.insertaserviciosfactura();
                                        if (resultado != "Correcto")
                                        {
                                            MessageBox.Show(resultado);
                                        }
                                        else
                                        {
                                            DAO.FacturasDAO facturasdao = new FacturasDAO();
                                            facturasdao.IDFServicios = facturasdao.devuelveiddetallefac();
                                            if (checkBox6.Checked)
                                            {
                                                descuentot = descuentot + " Descuento del 75% por cancelacion";
                                            }
                                            if (checkBox5.Checked)
                                            {
                                                descuentot = descuentot + " Descuento del 50% por cancelacion";
                                            }
                                            facturasdao.DescuentoT = this.descuentot;
                                            if (descuento == 0)
                                            {
                                            }
                                            else
                                            {
                                                facturasdao.Importe = this.descuento;
                                            }
                                            string resultado3 = facturasdao.insertaserviciosdescuento();
                                            if (resultado3 != "Correcto")
                                            {
                                                MessageBox.Show(resultado3);
                                            }
                                            else
                                            {
                                                descuento  = 0;
                                                descuentot = "";
                                                actualizagrid();
                                                calculatotales();
                                                textBox18.ReadOnly = true;
                                                textBox16.ReadOnly = true;
                                                textBox17.ReadOnly = true;
                                            }
                                        }
                                    }
                                }
                            }
                            else
                            {
                                MessageBox.Show("Descuento fuera de los limites permitidos");
                            }
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Es necesario ingresar todos los datos");
                }
            }
            catch
            {
                MessageBox.Show("Ha habido algun error, verifique sus datos");
            }
        }