Beispiel #1
0
        private void btnRastrear_Click(object sender, EventArgs e)
        {
            string     codigo = tbCodigoAbuscar.Text;
            clsPaquete aux    = new clsPaquete();
            clsPaquete p      = new clsPaquete();

            p = aux.retornarPaquete(codigo);
            if (codigo != string.Empty)
            {
                if (p != null && p.Codigo == codigo)
                {
                    frmEstadoPaquete frmEP = new frmEstadoPaquete(codigo);
                    frmEP.ShowDialog();
                }

                else
                {
                    MessageBox.Show("codigo ingresado no es valido");
                }
            }
            else
            {
                MessageBox.Show("Debe ingresar el codigo del paquete");
            }
        }
Beispiel #2
0
        private void cargarDgv()
        {
            clsPaquete aux = new clsPaquete();

            aux = p1.retornarPaquete(codigo);
            clsFactura fac = new clsFactura();

            fac = f1.recuperarFac(codigo);
            if (aux != null && fac != null)
            {
                dgvMostrar.Rows[dgvMostrar.Rows.Count - 1].Cells["Nombre Cliente"].Value = fac.Nombrecliente;
                dgvMostrar.Rows[dgvMostrar.Rows.Count - 1].Cells["DNI"].Value            = fac.Dnicliente;
                dgvMostrar.Rows[dgvMostrar.Rows.Count - 1].Cells["Fecha Envio"].Value    = fac.Fechaenvio;
                dgvMostrar.Rows[dgvMostrar.Rows.Count - 1].Cells["Empresa"].Value        = fac.Empresa;
                dgvMostrar.Rows[dgvMostrar.Rows.Count - 1].Cells["Destino"].Value        = aux.Ciudad;
                dgvMostrar.Rows[dgvMostrar.Rows.Count - 1].Cells["Direccion"].Value      = aux.Direccion;
                dgvMostrar.Rows[dgvMostrar.Rows.Count - 1].Cells["Estado"].Value         = aux.Estado;
                dgvMostrar.Rows[dgvMostrar.Rows.Count - 1].Cells["fechallegada"].Value   = fac.Fechallegada;
            }

            else
            {
                MessageBox.Show("Codigo invalido, verifique los datos");
            }
        }
Beispiel #3
0
        private void btnRegistrarEncomienda_Click(object sender, EventArgs e)
        {
            if (tbCodpaquete.Text != string.Empty && tbdnicliente.Text != string.Empty && cbempresas.SelectedItem != null)
            {
                clsEmpresa verifica   = new clsEmpresa();
                bool       encontrado = verifica.existeCodigoPostal(cbempresas.SelectedItem.ToString(), int.Parse(tbCodPostal.Text));
                if (encontrado == true)
                {
                    clsFactura nuevo = new clsFactura();
                    nuevo.Id            = nuevo.RecuperarUltimoId() + 1;
                    nuevo.CodigoPaquete = tbCodpaquete.Text;
                    nuevo.Nombrecliente = tbnomcliente.Text;
                    nuevo.Dnicliente    = int.Parse(tbdnicliente.Text);
                    nuevo.Precio        = float.Parse(tbPrecio.Text);
                    nuevo.Fechallegada  = dtpfecha.Value;
                    nuevo.Fechaenvio    = dtOculto.Value;
                    nuevo.Empresa       = cbempresas.SelectedItem.ToString();
                    nuevo.Postal        = int.Parse(tbCodPostal.Text);
                    List <clsPaquete> lista1  = new List <clsPaquete>();
                    clsPaquete        cambiar = new clsPaquete();
                    cambiar = cambiar.retornarPaquete(nuevo.CodigoPaquete);
                    clsPaquete modi = new clsPaquete();
                    if (cambiar.Estado == "Despachado")
                    {
                        MessageBox.Show("Este paquete ya fue enviado");
                    }

                    else
                    {
                        clsPaquete p2 = new clsPaquete();

                        foreach (clsPaquete g in p2.Leer())
                        {
                            if (g.Id == cambiar.Id)
                            {
                                g.NombreDestinatario = cambiar.NombreDestinatario;
                                g.DniDestinatario    = cambiar.DniDestinatario;
                                g.Ciudad             = cambiar.Ciudad;
                                g.Direccion          = cambiar.Direccion;
                                g.Id     = cambiar.Id;
                                g.Codigo = cambiar.Codigo;
                                g.Kilos  = cambiar.Kilos;
                                g.Estado = "Despachado";
                                lista1.Add(g);
                            }
                            else
                            {
                                lista1.Add(g);
                            }
                        }



                        string res2 = string.Empty;
                        res2 = modi.ModificarPaq(lista1);
                        string res = string.Empty;
                        res = nuevo.Grabar();
                        if (res == string.Empty)
                        {
                            MessageBox.Show("encomienda enviada");
                        }

                        else
                        {
                            MessageBox.Show("ocurrio el siguiente error" + res);
                        }

                        tbCodpaquete.Clear();
                        tbdnicliente.Clear();
                        tbnomcliente.Clear();
                        tbPrecio.Clear();
                    }
                }
                else
                {
                    MessageBox.Show("No coincide el codigo postal del paquete con el de la empresa y sus sucursales, por favor verifique bien");
                }
            }
            else if (tbCodpaquete.Text != string.Empty && tbdnicliente.Text == string.Empty && tbCodPostal.Text == string.Empty)
            {
                MessageBox.Show("Seleccione el cliente");
            }
            else
            {
                MessageBox.Show("Seleccione el paquete a enviar  ");
            }
        }
Beispiel #4
0
        private void btnRecibido_Click(object sender, EventArgs e)
        {
            clsSucursal suc = new clsSucursal();
            clsSucursal aux = new clsSucursal();

            suc = aux.traerSucursal(nombre);
            if (dgvEnviosRecibidos.SelectedRows.Count != 0)
            {
                clsFactura fac = new clsFactura();

                fac.Id            = int.Parse(dgvEnviosRecibidos.CurrentRow.Cells["id"].Value.ToString());
                fac.Nombrecliente = dgvEnviosRecibidos.CurrentRow.Cells["nombrecliente"].Value.ToString();
                fac.CodigoPaquete = dgvEnviosRecibidos.CurrentRow.Cells["codigoPaquete"].Value.ToString();
                fac.Dnicliente    = int.Parse(dgvEnviosRecibidos.CurrentRow.Cells["dnicliente"].Value.ToString());
                fac.Empresa       = dgvEnviosRecibidos.CurrentRow.Cells["empresa"].Value.ToString();
                fac.Fechaenvio    = Convert.ToDateTime(dgvEnviosRecibidos.CurrentRow.Cells["fechaenvio"].Value.ToString());
                fac.Fechallegada  = Convert.ToDateTime(dgvEnviosRecibidos.CurrentRow.Cells["fechallegada"].Value.ToString());
                fac.Postal        = int.Parse(dgvEnviosRecibidos.CurrentRow.Cells["Postal"].Value.ToString());
                fac.Precio        = float.Parse(dgvEnviosRecibidos.CurrentRow.Cells["precio"].Value.ToString());


                List <clsPaquete> lista1  = new List <clsPaquete>();
                clsPaquete        cambiar = new clsPaquete();
                cambiar = cambiar.retornarPaquete(fac.CodigoPaquete);

                clsPaquete p2 = new clsPaquete();
                if (cambiar.Estado == "Despachado")
                {
                    foreach (clsPaquete g in p2.Leer())
                    {
                        if (g.Id == cambiar.Id)
                        {
                            g.NombreDestinatario = cambiar.NombreDestinatario;
                            g.DniDestinatario    = cambiar.DniDestinatario;
                            g.Ciudad             = cambiar.Ciudad;
                            g.Direccion          = cambiar.Direccion;
                            g.Id     = cambiar.Id;
                            g.Codigo = cambiar.Codigo;
                            g.Kilos  = cambiar.Kilos;
                            g.Estado = "El paquete se encuentra en la central de:" + suc.Nombre + " en " + suc.LocalidadUbicacion + " ubicada en: " + suc.Direccion + " y pronto se hara la entrega";
                            lista1.Add(g);
                        }
                        else
                        {
                            lista1.Add(g);
                        }
                    }

                    clsPaquete modi = new clsPaquete();
                    string     res  = string.Empty;
                    res = modi.ModificarPaq(lista1);

                    List <clsFactura> listafact = new List <clsFactura>();
                    clsFactura        f         = new clsFactura();

                    foreach (clsFactura facturita in f.Leer())
                    {
                        if (facturita.Id == fac.Id)
                        {
                            facturita.Id            = fac.Id;
                            facturita.CodigoPaquete = fac.CodigoPaquete;
                            facturita.Dnicliente    = fac.Dnicliente;
                            facturita.Empresa       = suc.Nombre;
                            facturita.Fechaenvio    = fac.Fechaenvio;
                            facturita.Fechallegada  = dt.Value;
                            facturita.Postal        = fac.Postal;
                            facturita.Precio        = fac.Precio;
                            facturita.Nombrecliente = fac.Nombrecliente;

                            listafact.Add(facturita);
                        }
                        else
                        {
                            listafact.Add(facturita);
                        }
                    }

                    clsFactura m      = new clsFactura();
                    string     resFac = string.Empty;
                    resFac = m.ModificarFac(listafact);

                    if (res == string.Empty && resFac == string.Empty)
                    {
                        MessageBox.Show("Operacion realizada");
                    }
                    else
                    {
                        MessageBox.Show("error:" + res + resFac);
                    }
                }
                else
                {
                    MessageBox.Show("Este paquete ya fue recibido");
                }
            }
            else
            {
                MessageBox.Show("seleccione el paquete");
            }
        }
Beispiel #5
0
        private void btnDevolver_Click(object sender, EventArgs e)
        {
            clsFactura fac = new clsFactura();

            if (dgvEnviosRecibidos.SelectedRows.Count != 0)
            {
                fac.Id            = int.Parse(dgvEnviosRecibidos.CurrentRow.Cells["id"].Value.ToString());
                fac.Nombrecliente = dgvEnviosRecibidos.CurrentRow.Cells["nombrecliente"].Value.ToString();
                fac.CodigoPaquete = dgvEnviosRecibidos.CurrentRow.Cells["codigoPaquete"].Value.ToString();
                fac.Dnicliente    = int.Parse(dgvEnviosRecibidos.CurrentRow.Cells["dnicliente"].Value.ToString());
                fac.Empresa       = dgvEnviosRecibidos.CurrentRow.Cells["empresa"].Value.ToString();
                fac.Fechaenvio    = Convert.ToDateTime(dgvEnviosRecibidos.CurrentRow.Cells["fechaenvio"].Value.ToString());
                fac.Fechallegada  = Convert.ToDateTime(dgvEnviosRecibidos.CurrentRow.Cells["fechallegada"].Value.ToString());
                fac.Postal        = int.Parse(dgvEnviosRecibidos.CurrentRow.Cells["Postal"].Value.ToString());
                fac.Precio        = float.Parse(dgvEnviosRecibidos.CurrentRow.Cells["precio"].Value.ToString());


                List <clsPaquete> lista1  = new List <clsPaquete>();
                clsPaquete        cambiar = new clsPaquete();
                cambiar = cambiar.retornarPaquete(fac.CodigoPaquete);

                clsPaquete p2 = new clsPaquete();
                if (cambiar.Estado == "Despachado")
                {
                    foreach (clsPaquete g in p2.Leer())
                    {
                        if (g.Id == cambiar.Id)
                        {
                            g.NombreDestinatario = cambiar.NombreDestinatario;
                            g.DniDestinatario    = cambiar.DniDestinatario;
                            g.Ciudad             = cambiar.Ciudad;
                            g.Direccion          = cambiar.Direccion;
                            g.Id     = cambiar.Id;
                            g.Codigo = cambiar.Codigo;
                            g.Kilos  = cambiar.Kilos;
                            g.Estado = "El paquete fue devuelto al local donde usted envio la encomienda,para mas informacion comuniquese al 0800456788";
                            lista1.Add(g);
                        }
                        else
                        {
                            lista1.Add(g);
                        }
                    }

                    clsPaquete modi = new clsPaquete();
                    string     res  = string.Empty;
                    res = modi.ModificarPaq(lista1);

                    List <clsFactura> listafact = new List <clsFactura>();
                    clsFactura        f         = new clsFactura();

                    foreach (clsFactura facturita in f.Leer())
                    {
                        if (facturita.Id == fac.Id)
                        {
                            facturita.Id            = fac.Id;
                            facturita.CodigoPaquete = fac.CodigoPaquete;
                            facturita.Dnicliente    = fac.Dnicliente;
                            facturita.Empresa       = fac.Empresa;
                            facturita.Fechaenvio    = fac.Fechaenvio;
                            facturita.Fechallegada  = dt.Value;
                            facturita.Postal        = fac.Postal;
                            facturita.Precio        = fac.Precio;
                            facturita.Nombrecliente = fac.Nombrecliente;

                            listafact.Add(facturita);
                        }
                        else
                        {
                            listafact.Add(facturita);
                        }
                    }

                    clsFactura m      = new clsFactura();
                    string     resFac = string.Empty;
                    resFac = m.ModificarFac(listafact);
                    if (res == string.Empty && resFac == string.Empty)
                    {
                        MessageBox.Show("los datos fueron actualizados");
                    }

                    else
                    {
                        MessageBox.Show("ocurrio el siguiente error:" + res + resFac);
                    }
                }
                else
                {
                    MessageBox.Show("No puede realizar esta operacion");
                }
            }
            else
            {
                MessageBox.Show("Seleccione la encomienda");
            }
        }
Beispiel #6
0
        private void btnTransferir_Click(object sender, EventArgs e)
        {
            clsFactura fac = new clsFactura();

            fac.Id            = int.Parse(dgvEnviosRecibidos.CurrentRow.Cells["id"].Value.ToString());
            fac.Nombrecliente = dgvEnviosRecibidos.CurrentRow.Cells["nombrecliente"].Value.ToString();
            fac.CodigoPaquete = dgvEnviosRecibidos.CurrentRow.Cells["codigoPaquete"].Value.ToString();
            fac.Dnicliente    = int.Parse(dgvEnviosRecibidos.CurrentRow.Cells["dnicliente"].Value.ToString());
            fac.Empresa       = dgvEnviosRecibidos.CurrentRow.Cells["empresa"].Value.ToString();
            fac.Fechaenvio    = Convert.ToDateTime(dgvEnviosRecibidos.CurrentRow.Cells["fechaenvio"].Value.ToString());
            fac.Fechallegada  = Convert.ToDateTime(dgvEnviosRecibidos.CurrentRow.Cells["fechallegada"].Value.ToString());
            fac.Postal        = int.Parse(dgvEnviosRecibidos.CurrentRow.Cells["Postal"].Value.ToString());
            fac.Precio        = float.Parse(dgvEnviosRecibidos.CurrentRow.Cells["precio"].Value.ToString());
            if (dgvSucursal.SelectedRows.Count != 0)
            {
                if (fac.Postal == int.Parse(dgvSucursal.CurrentRow.Cells["codigoPostal"].Value.ToString()))
                {
                    List <clsFactura> listafact = new List <clsFactura>();
                    clsFactura        f         = new clsFactura();

                    foreach (clsFactura facturita in f.Leer())
                    {
                        if (facturita.Id == fac.Id)
                        {
                            facturita.Id            = fac.Id;
                            facturita.CodigoPaquete = fac.CodigoPaquete;
                            facturita.Dnicliente    = fac.Dnicliente;
                            facturita.Empresa       = dgvSucursal.CurrentRow.Cells["nombre"].Value.ToString();
                            facturita.Fechaenvio    = fac.Fechaenvio;
                            facturita.Fechallegada  = dt.Value;
                            facturita.Postal        = fac.Postal;
                            facturita.Precio        = fac.Precio;
                            facturita.Nombrecliente = fac.Nombrecliente;

                            listafact.Add(facturita);
                        }
                        else
                        {
                            listafact.Add(facturita);
                        }
                    }
                    List <clsPaquete> lista1  = new List <clsPaquete>();
                    clsPaquete        cambiar = new clsPaquete();
                    cambiar = cambiar.retornarPaquete(fac.CodigoPaquete);

                    clsPaquete p2 = new clsPaquete();
                    if (cambiar.Estado == "Despachado")
                    {
                        foreach (clsPaquete g in p2.Leer())
                        {
                            if (g.Id == cambiar.Id)
                            {
                                g.NombreDestinatario = cambiar.NombreDestinatario;
                                g.DniDestinatario    = cambiar.DniDestinatario;
                                g.Ciudad             = cambiar.Ciudad;
                                g.Direccion          = cambiar.Direccion;
                                g.Id     = cambiar.Id;
                                g.Codigo = cambiar.Codigo;
                                g.Kilos  = cambiar.Kilos;
                                g.Estado = "El paquete fue tranferido a la sucursal:" + dgvSucursal.CurrentRow.Cells["nombre"].Value.ToString();
                                lista1.Add(g);
                            }
                            else
                            {
                                lista1.Add(g);
                            }
                        }
                    }
                    clsPaquete modi = new clsPaquete();
                    string     res  = string.Empty;
                    res = modi.ModificarPaq(lista1);
                    clsFactura m      = new clsFactura();
                    string     resFac = string.Empty;
                    resFac = m.ModificarFac(listafact);



                    if (resFac == string.Empty && res == string.Empty)
                    {
                        MessageBox.Show("El paquete fue transferido");
                    }

                    else
                    {
                        MessageBox.Show("error");
                    }
                }
                else
                {
                    MessageBox.Show("No coinciden el codigo postal de la sucursal con el del paquete por favor verifique bien");
                }
            }
            else
            {
                MessageBox.Show("Seleccione una sucursal");
            }
        }