Пример #1
0
        private void frmMostrarVentas_Load(object sender, EventArgs e)
        {
            clsEmpresa nueva = new clsEmpresa();

            foreach (clsEmpresa a in nueva.Leer())
            {
                if (a != null)
                {
                    cbEmpresa.Items.Add(a.NombreEmpresa);
                }
            }

            cbEmpresa.Items.Add("Todas");
            cbEmpresa.SelectedItem = "Todas";

            dgvMostrar.DataSource = null;
            lista = new List <clsFactura>();
            foreach (clsFactura a in en.Leer())
            {
                lista.Add(a);
            }
            dgvMostrar.DataSource = lista;

            organizarDGV();

            dtpFiltroFechaEnvioDesde.Enabled = ckbFiltroFechaEnvioDesde.Checked;
            dtpFiltroFechaEnvioHasta.Enabled = ckbFiltroFechaEnvioHasta.Checked;
        }
Пример #2
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");
            }
        }
Пример #3
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");
            }
        }
Пример #4
0
        public void filtros()
        {
            lista = new List <clsFactura>();
            foreach (clsFactura f in aux.Leer())
            {
                lista.Add(f);
            }
            dgvEnviosRecibidos.DataSource = lista;


            if (tbFiltroCodigoPaquete.Text != string.Empty)
            {
                for (int i = 0; i < dgvEnviosRecibidos.Rows.Count; i++)
                {
                    if (tbFiltroCodigoPaquete.Text.Length > Convert.ToString(dgvEnviosRecibidos.Rows[i].Cells["CodigoPaquete"].Value).Length || Convert.ToString(dgvEnviosRecibidos.Rows[i].Cells["CodigoPaquete"].Value).Substring(0, tbFiltroCodigoPaquete.Text.Length).ToLower().CompareTo(tbFiltroCodigoPaquete.Text.ToLower()) != 0)
                    {
                        dgvEnviosRecibidos.CurrentCell     = null;
                        dgvEnviosRecibidos.Rows[i].Visible = false;
                    }
                }
            }

            dtpFiltroFechaEnvioDesde.Enabled = ckbFiltroFechaEnvioDesde.Checked;
            dtpFiltroFechaEnvioHasta.Enabled = ckbFiltroFechaEnvioHasta.Checked;

            if ((ckbFiltroFechaEnvioDesde.Checked) && (ckbFiltroFechaEnvioHasta.Checked))
            {
                for (int i = 0; i < dgvEnviosRecibidos.Rows.Count; i++)
                {
                    if ((Convert.ToDateTime(dgvEnviosRecibidos.Rows[i].Cells["Fechaenvio"].Value).Date < Convert.ToDateTime(dtpFiltroFechaEnvioDesde.Value).Date) || (Convert.ToDateTime(dgvEnviosRecibidos.Rows[i].Cells["Fechaenvio"].Value).Date > Convert.ToDateTime(dtpFiltroFechaEnvioHasta.Value).Date))
                    {
                        dgvEnviosRecibidos.CurrentCell     = null;
                        dgvEnviosRecibidos.Rows[i].Visible = false;
                    }
                }
            }
            else if ((ckbFiltroFechaEnvioDesde.Checked) && (!ckbFiltroFechaEnvioHasta.Checked))
            {
                for (int i = 0; i < dgvEnviosRecibidos.Rows.Count; i++)
                {
                    if ((Convert.ToDateTime(dgvEnviosRecibidos.Rows[i].Cells["Fechaenvio"].Value).Date < Convert.ToDateTime(dtpFiltroFechaEnvioDesde.Value).Date))
                    {
                        dgvEnviosRecibidos.CurrentCell     = null;
                        dgvEnviosRecibidos.Rows[i].Visible = false;
                    }
                }
            }
            else if ((!ckbFiltroFechaEnvioDesde.Checked) && (ckbFiltroFechaEnvioHasta.Checked))
            {
                for (int i = 0; i < dgvEnviosRecibidos.Rows.Count; i++)
                {
                    if ((Convert.ToDateTime(dgvEnviosRecibidos.Rows[i].Cells["Fechaenvio"].Value).Date > Convert.ToDateTime(dtpFiltroFechaEnvioHasta.Value).Date))
                    {
                        dgvEnviosRecibidos.CurrentCell     = null;
                        dgvEnviosRecibidos.Rows[i].Visible = false;
                    }
                }
            }

            int  indice    = 0;
            bool continuar = false;

            while (indice < dgvEnviosRecibidos.Rows.Count && !continuar)
            {
                if (dgvEnviosRecibidos.Rows[indice].Visible)
                {
                    dgvEnviosRecibidos.Rows[indice].Selected = true;
                    continuar = true;
                }
                indice++;
            }
        }
Пример #5
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");
            }
        }