//public int numeroinsertados()
        //{
        //    //DAO.FacturasDAO facturas=new EquimarFac.DAO.FacturasDAO();
        //    //return facturas.devuelveidremolcadores();
        //}


        //public string insertaremolcadores()
        //{
        //    //try
        //    //{
        //    if (lbl_rinsertados.Text == "1")
        //    {
        //        return "Correcto";
        //    }
        //    else
        //    {
        //        DAO.FacturasDAO facturas = new EquimarFac.DAO.FacturasDAO();
        //        facturas.Remolcador1 = int.Parse(id_R1.Text);

        //        if (id_R2.Text != "")
        //        {
        //            facturas.Remolcador2 = int.Parse(id_R2.Text);
        //        }

        //        if (id_R3.Text != "")
        //        {
        //            facturas.Remolcador3 = int.Parse(id_R3.Text);
        //        }

        //        return facturas.insertaRemolcadores();
        //    }
        //    //}
        //    //catch
        //    //{
        //    //    return "Error (inserta remolcadores)";
        //    //}
        //}

        public string insertafacturaparcial()
        {
            try
            {
                //(this.Fecha, this.ClienteFactura, this.Moneda, this.tipodecambio, this.FechaTipoCambio_datetime, this.metodoDePago, this.Cuenta)
                DAO.FacturasDAO facturasdao = new EquimarFac.DAO.FacturasDAO();
                facturasdao.Fecha          = Convert.ToDateTime(dateTimePicker4.Value.ToShortDateString());
                facturasdao.ClienteFactura = int.Parse(lbl_idCliente.Text);
                facturasdao.Moneda         = comboBox3.Text;
                if (textBox18.Text != "")
                {
                    facturasdao.TipoDeCambio_decimal = decimal.Parse(textBox18.Text);
                }
                else
                {
                    facturasdao.TipoDeCambio_decimal = 0;
                }
                facturasdao.FechaTipoCambio_datetime = DateTime.Now.Date;
                facturasdao.metodoDePago             = comboBox1.Text;
                facturasdao.Cuenta = textBox2.Text;
                return(facturasdao.insertaparcialfactura());
            }
            catch
            {
                return("Error, vuelva a intentarlo");
            }
        }
Beispiel #2
0
        public string insertaremolcadores()
        {
            //try
            //{
            if (lbl_rinsertados.Text == "1")
            {
                return("Correcto");
            }
            else
            {
                DAO.FacturasDAO facturas = new EquimarFac.DAO.FacturasDAO();
                facturas.Remolcador1 = int.Parse(id_R1.Text);

                if (id_R2.Text != "")
                {
                    facturas.Remolcador2 = int.Parse(id_R2.Text);
                }

                if (id_R3.Text != "")
                {
                    facturas.Remolcador3 = int.Parse(id_R3.Text);
                }

                return(facturas.insertaRemolcadores());
            }
            //}
            //catch
            //{
            //    return "Error (inserta remolcadores)";
            //}
        }
        //private void checkBox6_Click(object sender, EventArgs e)
        //{
        //    if (checkBox6.Checked)
        //    {
        //        checkBox5.CheckState = CheckState.Unchecked;
        //        checkBox3.CheckState = CheckState.Unchecked;
        //    }

        //}

        //private void checkBox5_Click(object sender, EventArgs e)
        //{
        //    if (checkBox5.Checked)
        //    {
        //        checkBox6.CheckState = CheckState.Unchecked;
        //        checkBox3.CheckState = CheckState.Unchecked;
        //    }
        //}

        private void button8_Click(object sender, EventArgs e)
        {
            DAO.FacturasDAO facturas = new EquimarFac.DAO.FacturasDAO();
            facturas.IDFServicios = Convert.ToInt32(dataGridView1.CurrentRow.Cells[0].Value);
            string resultado = facturas.eliminaserviciosfac();

            if (resultado != "Correcto")
            {
                MessageBox.Show(resultado);
            }
            else
            {
                actualizagrid();
                calculatotales();
            }
        }
Beispiel #4
0
 public string insertafacturaparcial()
 {
     try
     {
         DAO.FacturasDAO facturasdao = new EquimarFac.DAO.FacturasDAO();
         facturasdao.Fecha          = Convert.ToDateTime(dateTimePicker4.Value.ToShortDateString());
         facturasdao.ClienteFactura = int.Parse(lbl_idCliente.Text);
         facturasdao.BarcoID        = int.Parse(lb_idbarco.Text);
         facturasdao.Remolcador     = int.Parse(idrinsertados.Text);
         return(facturasdao.insertaparcialfactura());
     }
     catch
     {
         return("Error, vuelva a intentarlo");
     }
 }
        //public decimal calculaimporte()
        //{
        //    try
        //    {
        //        decimal DCB1 = decimal.Parse(CB1.Text);
        //        decimal DCB2 = decimal.Parse(CB2.Text);
        //        decimal DCB3 = decimal.Parse(CB3.Text);
        //        decimal DCB4 = decimal.Parse(CB4.Text);
        //        decimal DREP = decimal.Parse(REP.Text);
        //        decimal DREM = decimal.Parse(REM.Text);
        //        decimal DREG = decimal.Parse(REG.Text);
        //        decimal DSCA = decimal.Parse(SCA.Text);
        //        decimal DSCB = decimal.Parse(SCB.Text);
        //        decimal DSCC = decimal.Parse(SCC.Text);
        //        decimal importehoras = decimal.Truncate(Convert.ToDecimal((dateTimePicker3.Value - dateTimePicker2.Value).TotalMinutes / 60));
        //        decimal numerominutos = Convert.ToDecimal((dateTimePicker3.Value - dateTimePicker2.Value).Minutes); ;
        //        decimal cuotabasica = 0;
        //        decimal costototal = 0;
        //        decimal ServicioContinuoR1 = 0, ServicioContinuoR2 = 0, ServicioContinuoR3 = 0;
        //        int trb = int.Parse(textBox9.Text);
        //        if (importehoras < 1)
        //        {
        //            importehoras = 1;
        //            numerominutos = 0;

        //        }
        //        //if (importehoras == 1)
        //        //{
        //        //    numerominutos = 0;
        //        //}
        //        //if (importehoras > 1)
        //        //{
        //        //    //numerominutos = Convert.ToDecimal((((((dateTimePicker3.Value - dateTimePicker2.Value).TotalMinutes / 60) % 1) * 15) / 25));
        //        //    numerominutos = Convert.ToDecimal((dateTimePicker3.Value - dateTimePicker2.Value).Minutes);
        //        //}
        //        decimal importeminutos = 0;
        //        if ((numerominutos >= 1)&&(numerominutos <= 15))
        //        {
        //            importeminutos = 25;
        //        }
        //        if ((numerominutos > 15) && (numerominutos <= 30))
        //        {
        //            importeminutos = 50;
        //        }
        //        if ((numerominutos > 30) && (numerominutos <= 45))
        //        {
        //            importeminutos = 75;
        //        }
        //        if ((numerominutos > 45) && (numerominutos <= 59))
        //        {
        //            importeminutos = 100;
        //        }

        //        if (checkBox1.Checked == true)
        //        {
        //            if (lbl_tamaño1.Text == "Pequeño")
        //            {
        //                ServicioContinuoR1 = DSCA;
        //            }
        //            if (lbl_tamaño1.Text == "Mediano")
        //            {
        //                ServicioContinuoR1 = DSCB;
        //            }
        //            if (lbl_tamaño1.Text == "Grande")
        //            {
        //                ServicioContinuoR1 = DSCC;
        //            }

        //            if (id_R2.Text != "")
        //            {
        //                if (lbl_tamaño2.Text == "Pequeño")
        //                {
        //                    ServicioContinuoR2 = DSCA;
        //                }
        //                if (lbl_tamaño2.Text == "Mediano")
        //                {
        //                    ServicioContinuoR2 = DSCB;
        //                }
        //                if (lbl_tamaño2.Text == "Grande")
        //                {
        //                    ServicioContinuoR2 = DSCC;
        //                }
        //            }

        //            if (id_R3.Text != "")
        //            {
        //                if (lbl_tamaño3.Text == "Pequeño")
        //                {
        //                    ServicioContinuoR3 = DSCA;
        //                }
        //                if (lbl_tamaño3.Text == "Mediano")
        //                {
        //                    ServicioContinuoR3 = DSCB;
        //                }
        //                if (lbl_tamaño3.Text == "Grande")
        //                {
        //                    ServicioContinuoR3 = DSCC;
        //                }
        //            }

        //            if (checkBox2.Checked == true)
        //            {
        //                cuotabasica = (ServicioContinuoR1 + ServicioContinuoR2 + ServicioContinuoR3) * Convert.ToDecimal(1.5);
        //            }
        //            else
        //            {
        //                cuotabasica = ServicioContinuoR1 + ServicioContinuoR2 + ServicioContinuoR3;
        //            }

        //            costototal = (cuotabasica * importehoras) + (cuotabasica * (importeminutos / 100));

        //        }
        //        else
        //        {


        //            if ((trb >= 1501) && (trb <= 4500))
        //            {
        //                cuotabasica = DCB1;
        //            }

        //            if ((trb >= 4501) && (trb <= 10000))
        //            {
        //                cuotabasica = DCB2;
        //            }

        //            if ((trb >= 10001) && (trb <= 15000))
        //            {
        //                cuotabasica = DCB3;
        //            }

        //            if ((trb > 15000))
        //            {
        //                cuotabasica = DCB4;
        //            }


        //            if ((trb <= 500) | ((trb >= 501) && (trb <= 1500)))
        //            {
        //                if (checkBox2.Checked == true)
        //                {
        //                    cuotabasica = Convert.ToDecimal(DCB1 * Convert.ToDecimal(1.5));
        //                }
        //                else
        //                {
        //                    cuotabasica = DCB1;
        //                }

        //                ////if ((id_R1.Text != "") && (id_R2.Text == "") && (id_R3.Text == ""))
        //                ////{
        //                ////    descuentot += " 10% descuento sobre Cuota basica por 1 remolcador";
        //                ////    descuento += cuotabasica * Convert.ToDecimal(.10);
        //                ////    cuotabasica = cuotabasica * Convert.ToDecimal(.90);

        //                ////}
        //                if (trb <= 500)
        //                {
        //                    descuentot += " 30% Descuento sobre total por TRB Menor a 500 Ton";

        //                    costototal = ((cuotabasica * importehoras) + (cuotabasica * (importeminutos / 100))) * Convert.ToDecimal(.70);
        //                    descuento += ((cuotabasica * importehoras) + (cuotabasica * (importeminutos / 100))) * Convert.ToDecimal(.30);
        //                }
        //                if ((trb >= 501) && (trb <= 1500))
        //                {
        //                    descuentot += " 5% Descuento sobre total por TRB Menor a 1500 Ton";
        //                    costototal = ((cuotabasica * importehoras) + (cuotabasica * (importeminutos / 100))) * Convert.ToDecimal(.95);
        //                    descuento += ((cuotabasica * importehoras) + (cuotabasica * (importeminutos / 100))) * Convert.ToDecimal(.05);

        //                }
        //            }
        //            else
        //            {


        //                if (checkBox2.Checked == true)
        //                {
        //                    cuotabasica = cuotabasica * Convert.ToDecimal(1.5);
        //                }

        //                //if ((id_R1.Text != "") && (id_R2.Text == "") && (id_R3.Text == ""))
        //                //{
        //                //    descuentot += " 10% descuento sobre Cuota basica por 1 remolcador";
        //                //    descuento += cuotabasica * Convert.ToDecimal(.10);
        //                //    cuotabasica = cuotabasica * Convert.ToDecimal(.90);
        //                //}
        //            }

        //            if (id_R3.Text == "")
        //            {
        //                costototal = (cuotabasica * importehoras) + (cuotabasica * (importeminutos / 100));
        //            }
        //            else
        //            {
        //                if (lbl_tamaño3.Text == "Pequeño")
        //                {
        //                    cuotabasica = cuotabasica + DREP;
        //                    costototal = (cuotabasica * importehoras) + (cuotabasica * (importeminutos / 100));
        //                }
        //                if (lbl_tamaño3.Text == "Mediano")
        //                {
        //                    cuotabasica = cuotabasica + DREM;
        //                    costototal = (cuotabasica * importehoras) + (cuotabasica * (importeminutos / 100));
        //                }
        //                if (lbl_tamaño3.Text == "Grande")
        //                {
        //                    cuotabasica = cuotabasica + DREG;
        //                    costototal = (cuotabasica * importehoras) + (cuotabasica * (importeminutos / 100));
        //                }
        //            }



        //        }

        //        if (textBox16.Text != "")
        //        {
        //            descuentot += " " +textBox16.Text +"% de descuento";
        //            descuento += costototal * ((decimal.Parse(textBox16.Text)) / 100);
        //            costototal = costototal * ((100 - decimal.Parse(textBox16.Text)) / 100);
        //        }

        //        if (comboBox3.Text == "USD")
        //        {
        //            if (checkBox4.Checked)
        //            {
        //                return costototal;
        //            }
        //            else
        //            {
        //                if (textBox18.Text != "")
        //                {
        //                    return costototal / decimal.Parse(textBox18.Text);
        //                }
        //                else
        //                {
        //                    MessageBox.Show("Es necesario que especifique el tipo de cambio");
        //                    return -1;
        //                }
        //            }
        //        }
        //        else
        //        {
        //            return costototal;
        //        }


        //    }
        //    catch
        //    {
        //        return -1;
        //    }
        //}

        public void actualizagrid()
        {
            DAO.FacturasDAO facturasdao = new EquimarFac.DAO.FacturasDAO();
            facturasdao.IDFactura    = int.Parse(lbl_idfactura.Text);
            dataGridView1.DataSource = facturasdao.devuelveserviciosfac();
        }
 public int numerofactura()
 {
     DAO.FacturasDAO facturas = new EquimarFac.DAO.FacturasDAO();
     return(facturas.devuelveidfacturas());
 }
Beispiel #7
0
 public int numeroinsertados()
 {
     DAO.FacturasDAO facturas = new EquimarFac.DAO.FacturasDAO();
     return(facturas.devuelveidremolcadores());
 }
Beispiel #8
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");
            }
        }