Example #1
0
        private void cmdGuardar_Click(object sender, EventArgs e)
        {
            if (IsValidEmail(this.txtID.Text) == true)
            {
                try
                {
                    objDatos.Conectar();
                    string sql = "exec inserta_actualiza_notificacion_correos " + this.textBox2.Text + ",'" + this.txtID.Text + "'";
                    if (objDatos.Insertar(sql))
                    {
                        objDatos.Desconectar();
                        MessageBox.Show("Registro Insertado");
                    }
                    else
                    {
                        MessageBox.Show("Registro no pudo ser insertado");
                    }
                }
                catch (System.Data.SqlClient.SqlException ex)
                {
                    MessageBox.Show(ex.Message.ToString());
                }
            }

            else
            {
                MessageBox.Show("Correo invalido");
            }
        }
Example #2
0
 public bool insertar(string nom, string email, string pass,
                      string apellidos, string dni, string telefono, string calle, string calle2, string codpos,
                      string puebloID, string provinciaID, string nacido)
 {
     return(dat.Insertar(nom, email, pass, apellidos, dni,
                         telefono, calle, calle2, codpos, puebloID, provinciaID, nacido));
 }
Example #3
0
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                obDatos.Conectar();
                for (int i = 0; i < listBox1.Items.Count; i++)
                {
                    //MessageBox.Show(listBox1.Items[i].ToString());
                    string sql = "insert into NCF (ncf_ncf,codigo_tncf,estado) values ('" + listBox1.Items[i].ToString() + "','" + this.cmbTCF.SelectedValue.ToString() + "','TRUE')";

                    if (obDatos.Insertar(sql))
                    {
                        //MessageBox.Show("Registro Insertado");
                    }
                    else
                    {
                        //MessageBox.Show("Registro Insertado");
                    }
                }
            }
            catch (System.Data.SqlClient.SqlException ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
            MessageBox.Show("NCF Insertados");
            obDatos.Desconectar();
        }
Example #4
0
        private void cmdAgregarArticuloaFactura_Click(object sender, EventArgs e)
        {
            try
            {
                if (this.txtCodigoArticulo.Text != "")
                {
                    string buscarCantidad = ("select cantidad from facturatemporal where codigo_art = '" + this.txtCodigoArticulo.Text.ToString() + "'");
                    obDatos.Consulta_llenar_datos(buscarCantidad);

                    //int cantidad = Convert.ToInt16(obDatos.ds.Tables[0].Rows[0][0].ToString());
                    //string buscarCantidad = ("select cantidad from facturatemporal where codigo_art = '" + this.txtCodigoArticulo.Text.ToString() + "'");
                    //obDatos.Consulta_llenar_datos(buscarCantidad);

                    if (obDatos.ds.Tables[0].Rows.Count > 0)
                    {
                        cantidad = Convert.ToInt32(obDatos.ds.Tables[0].Rows[0][0].ToString());
                    }
                    else
                    {
                        cantidad = 0;
                    }

                    cantidad = Convert.ToInt32(cantidad) + Convert.ToInt32(this.txtCantidad.Text);

                    string sql = "exec inserta_actualiza_detalle_factura_temporal " + this.codigoArticulo.ToString() + "," + linea + ",'" + descripcion + "'," + cantidad + ",0" + "," + importe + "," + precioUnidad.ToString() + "";
                    if (obDatos.Insertar(sql))
                    {
                        cantidad = 0;
                    }
                    else
                    {
                        MessageBox.Show("Error al insertar registro");
                    }
                    actualizarDatosFactura();
                }
                else
                {
                    MessageBox.Show("Debe especificar el codigo de barra del articulo");
                }
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            for (int a = 0; a < this.dataGridView1.Rows.Count; a++)
            {
                subTotal = (Convert.ToDouble(subTotal)) + Convert.ToDouble(this.dataGridView1.Rows[a].Cells["importe"].Value.ToString());
            }
            subTotal2        = subTotal.ToString();
            subTotal3        = subTotal.ToString("C");
            lblSubTotal.Text = subTotal3;
            totalITBIS       = (Convert.ToDouble(subTotal2)) * ITBIS;
            lblItbis.Text    = totalITBIS.ToString("C");
            total            = totalITBIS + subTotal;
            lblTotal.Text    = total.ToString("C");
            subTotal         = 0;
        }
Example #5
0
        public virtual void eliminarRegistro()
        {
            DialogResult respuesta;

            respuesta = MessageBox.Show("Desea elmininar el vendedor: " + this.txtnombre.Text, "Pregunta", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
            if (respuesta == DialogResult.OK)
            {
                if (this.txtID.Text == "" || this.txtID.Text == "Nuevo")
                {
                    MessageBox.Show("Favor de seleccionar un vendedor para borrar");
                }
                else
                {
                    try
                    {
                        objDatos.Conectar();
                        string sql = "exec elimina_vendedores " + this.txtID.Text;
                        if (objDatos.Insertar(sql))
                        {
                            MessageBox.Show("Vendedor Eliminado", "Informacion", MessageBoxButtons.OK, MessageBoxIcon.None);
                            cargarMarcas();
                        }
                        else
                        {
                            MessageBox.Show("No se pudo eliminar el registro");
                        }
                        objDatos.Cn.Close();
                        cargarMarcas();
                    }
                    catch (System.Data.SqlClient.SqlException ex)
                    {
                        MessageBox.Show(ex.Message.ToString());
                    }
                    cargarMarcas();
                }
            }
            else
            {
                cargarMarcas();
            }
        }
Example #6
0
        private void cmdProcesar_Click(object sender, EventArgs e)
        {
            if (this.txtCamion.Text != "Nuevo" || this.txtCamion.Text != "")
            {
                if (this.radioButton1.Checked == true)
                {
                    Heridos = true;
                }

                if (this.radioButton6.Checked == true)
                {
                    Muertos = true;
                }

                if (this.radioButton4.Checked == true)
                {
                    casaConductor = true;
                }

                //try
                //{
                objDatos.Conectar();
                string sql = "exec inserta_registro_accidentes " + this.txtCamion.Text + "," + this.cmbTipoAccidente.SelectedValue + ",'" + this.txtNombre.Text + "','" + this.txtLicencia.Text + "','" + this.txtSeguro.Text + "','" + this.txtDetalles.Text + "','" + casaConductor + "','" + Muertos + "','" + Heridos + "'," + this.txtCodigoCliente.Text + ",'" + this.txtTelefonoChofer.Text + "'";
                if (objDatos.Insertar(sql))
                {
                    objDatos.Desconectar();
                    MessageBox.Show("Registro Insertado");
                }
                else
                {
                    MessageBox.Show("Registro no pudo ser insertado");
                }
                //}
                //catch (System.Data.SqlClient.SqlException ex)
                //{
                //    MessageBox.Show("Confirme que no haya campos vacios");
                //    MessageBox.Show(ex.Message.ToString());
                //}
            }
            limpiarPantalla();
        }
Example #7
0
        private void cmdProcesar_Click(object sender, EventArgs e)
        {
            if (this.txtPersonaEntrega.Text == "")
            {
                MessageBox.Show("Especifique quien entrega el vehiculo");
                this.txtPersonaEntrega.Focus();
            }
            if (this.txtPersonaEntrega.Text == "")
            {
                this.txtCedula.Text = "N/A";
            }
            if (this.txtKilometraje.Text == "")
            {
                MessageBox.Show("Especifique el kilometraje al recibir el camion");
                this.txtPersonaEntrega.Focus();
            }


            if (this.txtKilometraje.Text == "")
            {
                this.txtCombustibleEntrada.Text = "N/A";
            }

            if (this.txtReferencia.Text == "")
            {
                txtCombustibleEntrada.Text = "N/A";
            }

            if (this.txtCodigoCamion.Text != "Nuevo")
            {
                try
                {
                    //Calcular la cantidad de dias
                    txtFechaEntrada.Format       = DateTimePickerFormat.Custom;
                    txtFechaEntrada.CustomFormat = "dd/MM/yyyy";
                    salida = DateTime.ParseExact(this.txtFechaSalida.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture);
                    string   date       = txtFechaEntrada.Text;
                    DateTime entrada    = DateTime.ParseExact(date, "dd/MM/yyyy", CultureInfo.InvariantCulture);
                    TimeSpan difference = entrada - salida;

                    //Calcular la cantidad de horas
                    txtFechaEntrada.Format       = DateTimePickerFormat.Custom;
                    txtFechaEntrada.CustomFormat = "MM/dd/yyyy HH:mm:ss";

                    var src = HoraFechaSalida;
                    var hm  = new DateTime(src.Year, src.Month, src.Day, src.Hour, src.Minute, 0);

                    DateTime src2 = txtFechaEntrada.Value;
                    var      hm2  = new DateTime(src2.Year, src2.Month, src2.Day, src2.Hour, src2.Minute, 0);

                    int dias  = hm2.Day - hm.Day;
                    int horas = hm2.Hour - hm.Hour;
                    int minutos;


                    if (hm2.Hour > hm.Hour)
                    {
                        minutos = hm2.Minute - hm.Minute;
                    }
                    else
                    {
                        minutos = hm.Minute - hm2.Minute;
                    }



                    objDatos.Conectar();
                    string sql = "exec inserta_entrada_camiones " + this.txtCodigoCamion.Text + ",'" + entrada + "','" + this.txtPersonaEntrega.Text + "','" + this.txtCedula.Text + "','" + this.horaEntrada.Text.Substring(0, 8) + "','" + this.txtKilometraje.Text + "','" + this.txtReferencia.Text + "','" + this.txtCombustible.Text + "'," + difference.TotalDays + "," + horas;
                    if (objDatos.Insertar(sql))
                    {
                        string ActualizarAlquiler = "update vehiculo set alquilado = 'False', kilome_veh= " + txtKilometraje.Text + " where codveh_veh = " + this.txtCodigoCamion.Text;
                        if (objDatos.Insertar(ActualizarAlquiler))
                        {
                            MessageBox.Show("Registro Insertado");
                        }

                        NuevoKilometraje    = Convert.ToInt32(txtKilometraje.Text) - Convert.ToInt32(txtKmSalida.Text);
                        KilometrajeInsertar = NuevoKilometraje + kilometrajeActualCambioAceite();
                        //MessageBox.Show("El nuevo kilometraje es:" + NuevoKilometraje);
                        objDatos.Desconectar();
                        objDatos.Conectar();
                        string sql3 = "exec actualizar_kilometraje_aceite " + this.txtCodigoCamion.Text + "," + KilometrajeInsertar;
                        if (objDatos.Insertar(sql3))
                        {
                            objDatos.Desconectar();
                            //MessageBox.Show("Se actualizó la cantidad de KM para el cambio de aceite");
                        }

                        objDatos.Conectar();
                        string sql5 = "exec desactiva_salida_camion " + codigoSalidaCamion + "," + "'False'";
                        if (objDatos.Insertar(sql5))
                        {
                            objDatos.Desconectar();
                            //MessageBox.Show("se deactivo la salida de camion");
                        }
                        objDatos.Desconectar();
                        limpiarPantalla();
                    }
                    else
                    {
                        MessageBox.Show("Registro no pudo ser insertado");
                    }
                }
                catch (System.Data.SqlClient.SqlException ex)
                {
                    MessageBox.Show(ex.Message.ToString());
                }
            }
        }
Example #8
0
        public override void guardarRegistros()
        {
            if (this.txtMarca.Text != "")
            {
                if (validadCampo() == false)
                {
                    MessageBox.Show("La Marca debe ser mayor a 2 caracteres.", "Favor verifique", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                else
                {
                    //Verificar si ya la marca insertada estaba insertada
                    marcaEncontrada = "";
                    if (txtID.Text == "Nuevo")
                    {
                        codigo_marca = 0;
                    }
                    else
                    {
                        codigo_marca = int.Parse(this.txtID.Text);
                    }

                    //Busco en el gridview
                    foreach (DataGridViewRow Row in dataGridView1.Rows)
                    {
                        int    fila  = Row.Index;
                        String valor = Row.Cells[1].Value.ToString();

                        //compara lo que se escribe con lo que esta en el grid
                        if (this.txtMarca.Text == valor)
                        {
                            marcaEncontrada = valor;
                            dataGridView1.Rows[fila].Selected = true;
                        }
                    }
                    //validamos la variable valor
                    if (marcaEncontrada != "")
                    {
                        DialogResult respuesta;
                        respuesta = MessageBox.Show("La marca encontrada, " + marcaEncontrada + ", existe. ¿Desea actualizar?", "Pregunta", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
                        if (respuesta == DialogResult.OK)
                        {
                            MessageBox.Show("Procedemos a guardar");
                            cargarMarcas();
                        }
                        else
                        {
                            cargarMarcas();
                        }
                    }
                    else
                    {
                        try
                        {
                            objDatos.Conectar();
                            string sql = "exec inserta_actualiza_modelos " + codigo_marca + ",'" + this.txtMarca.Text + "'";
                            if (objDatos.Insertar(sql))
                            {
                                MessageBox.Show("Registro Insertado");
                                //cargarMarcas();
                            }
                            else
                            {
                                MessageBox.Show("Registro no pudo ser insertado");
                            }
                            objDatos.Cn.Close();
                            cargarMarcas();
                        }
                        catch (System.Data.SqlClient.SqlException ex)
                        {
                            MessageBox.Show(ex.Message.ToString());
                        }
                    }
                }
            }
        }
Example #9
0
        private void cmdProcesar_Click(object sender, EventArgs e)
        {
            if (this.txtCamion.Text == "")
            {
                errorProvider1.SetError(txtCamion, "Seleccione un camion");
            }
            else
            {
                errorProvider1.Clear();
            }

            if (this.txtCodigoCliente.Text == "")
            {
                errorProvider1.SetError(txtCodigoCliente, "Seleccione un camion");
            }
            //if (this.txtFechaEntrada.Text == this.fechaSalida.Text)
            //{
            //    MessageBox.Show("La fecha de Salida no puede ser la misma fecha de Entrada", "Error", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            //}
            else
            {
                if (this.txtCamion.Text != "" && this.txtCamion.Text != "")
                {
                    if (this.txtCamion.Text != "Nuevo")
                    {
                        try
                        {
                            if (txtPersonaRecibe.Text == "")
                            {
                                personaRecibe = "NULL";
                            }
                            else
                            {
                                personaRecibe = txtPersonaRecibe.Text;
                            }
                            if (this.txtCedula.Text == "")
                            {
                                Cedula = "NULL";
                            }
                            else
                            {
                                Cedula = txtCedula.Text;
                            }
                            if (this.txtReferencia.Text == "")
                            {
                                Referencia = "NULL";
                            }
                            else
                            {
                                Referencia = txtReferencia.Text;
                            }
                            if (this.txtKilometraje.Text == "")
                            {
                                Km = "NULL";
                            }
                            else
                            {
                                Km = txtKilometraje.Text;
                            }
                            if (this.txtConcepto.Text == "")
                            {
                                Concepto = "NULL";
                            }
                            else
                            {
                                Concepto = txtConcepto.Text;
                            }
                            if (this.txtCombustible.Text == "")
                            {
                                Combustible = "NULL";
                            }
                            else
                            {
                                Combustible = txtCombustible.Text;
                            }
                            if (this.txtSucursal.Text == "")
                            {
                                Sucursal = "NULL";
                            }
                            else
                            {
                                Sucursal = txtSucursal.Text;
                            }
                            if (this.txtTelefonoChofer.Text == "")
                            {
                                TelefonoChofer = "NULL";
                            }
                            else
                            {
                                TelefonoChofer = txtTelefonoChofer.Text;
                            }
                            fecha_salida = Convert.ToDateTime(this.fechaSalida.Text);
                            for (int i = 0; i < +chBoxListTables.Items.Count; i++)
                            {
                                if (chBoxListTables.GetItemChecked(i))
                                {
                                    miscelaneos[i] = "True";
                                }
                            }

                            objDatos.Conectar();
                            string sql = "exec inserta_salida_camiones " + this.txtCamion.Text + "," + this.txtCodigoCliente.Text + ",'" + personaRecibe + "','" + Cedula + "','" + fecha_salida.ToString("yyyy-MM-dd") + "','" + this.horaSalida.Value.ToString("HH:mm:ss") + "','" + this.txtFechaEntrada.Text + "','" + this.horaSalida.Value.ToString("HH:mm:ss") + "'," + Km + ",'" + Referencia + "','" + Concepto + "','" + Sucursal + "','" + Combustible + "','" + TelefonoChofer + "'," + codigoEmpleado + ",'" + miscelaneos[0] + "','" + miscelaneos[1] + "','" + miscelaneos[2] + "','" + miscelaneos[3] + "','" + miscelaneos[4] + "','" + miscelaneos[5] + "','" + miscelaneos[6] + "','" + miscelaneos[7] + "','" + miscelaneos[8] + "','" + miscelaneos[9] + "','" + miscelaneos[10] + "','" + miscelaneos[11] + "','" + miscelaneos[12] + "','" + miscelaneos[13] + "','" + miscelaneos[14] + "','" + miscelaneos[15] + "','" + miscelaneos[16] + "','" + miscelaneos[17] + "','" + miscelaneos[18] + "','" + miscelaneos[19] + "','" + miscelaneos[20] + "','" + miscelaneos[21] + "','" + miscelaneos[22] + "','" + miscelaneos[23] + "','" + miscelaneos[24] + "','" + miscelaneos[25] + "','" + miscelaneos[26] + "','" + miscelaneos[27] + "','" + miscelaneos[28] + "'";
                            if (objDatos.Insertar(sql))
                            {
                                objDatos.Desconectar();
                                objDatos.Conectar();
                                objDatos.Consulta_llenar_datos("exec setAlquilarVehiculo1 " + this.txtCamion.Text);
                                objDatos.Desconectar();
                                MessageBox.Show("Registro Insertado");

                                Reportes.ReporteSalida.Form1 Reporte_Salida = new Reportes.ReporteSalida.Form1();
                                Reporte_Salida.ShowDialog();
                            }
                            else
                            {
                                MessageBox.Show("Registro no pudo ser insertado");
                            }
                        }
                        catch (System.Data.SqlClient.SqlException ex)
                        {
                            MessageBox.Show(ex.Message.ToString());
                        }
                    }
                }
                limpiarPantalla();
            }
        }
Example #10
0
        private void cmdNuevo_Click(object sender, EventArgs e)
        {
            //if (txtID.Text == "Nuevo")
            //{
            //    MessageBox.Show("Seleccione un camion");
            //}
            //else
            //{
            string selectDateAsString = dateTimePicker1.Value.ToString("yyyyMMdd");

            if (this.txtAceite.Text == "")
            {
                aceite = "NULL";
            }
            else
            {
                aceite = txtAceite.Text;
            }
            if (this.checkBox1.Checked == false)
            {
                selectDateAsString = "19900101";
            }
            if (this.txtCorreaTiempo.Text == "")
            {
                correa_tiempo = "NULL";
            }
            else
            {
                correa_tiempo = this.txtCorreaTiempo.Text;
            }
            if (this.txtFrenos.Text == "")
            {
                frenos = "NULL";
            }
            else
            {
                frenos = this.txtFrenos.Text;
            }
            if (this.txtID.Text == "Nuevo")
            {
                codigoMantenimiento = 0;
            }
            else
            {
                codigoMantenimiento = Convert.ToInt32(txtID.Text);
            }


            try
            {
                objDatos.Conectar();
                string sql = "exec inserta_actualiza_mantenimiento_vehiculos " + codigoMantenimiento + "," + this.txtCamion.Text + "," + aceite + ",'" + selectDateAsString + "'," + correa_tiempo + "," + frenos + "";
                if (objDatos.Insertar(sql))
                {
                    objDatos.Desconectar();
                    MessageBox.Show("Registro Insertado");
                }
                else
                {
                    MessageBox.Show("Registro no pudo ser insertado");
                }
            }
            catch (System.Data.SqlClient.SqlException ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
            limpiarPantalla();
            //}
        }