Beispiel #1
0
        private void btnMostrarClientes_Click(object sender, EventArgs e)
        {
            List <clsPaquete> lista = new List <clsPaquete>();
            clsPaquete        aux   = new clsPaquete();

            foreach (clsPaquete p in aux.Leer())
            {
                if (p.Estado == "Para enviar")
                {
                    lista.Add(p);
                }
            }

            if (lista != null)
            {
                dgvAgregarPaquete.DataSource = null;
                dgvAgregarPaquete.DataSource = lista;
            }

            else
            {
                MessageBox.Show("vacio");
            }
            tbciudadCliente.Clear();
            tbdirecDest.Clear();
            tbDniDestinatario.Clear();
            tbNomdestinatario.Clear();
            tbKg.Clear();
            tbCodigoPostal.Clear();
            tbBultos.Clear();
        }
Beispiel #2
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 #3
0
        private void toolStripMenuItem1_Click(object sender, EventArgs e)
        {
            ContextMenuStrip cnx = (ContextMenuStrip)(sender as ToolStripMenuItem).Owner;
            // bool esPromocionRegalo = dgvRegalo.Equals(cnx.SourceControl);
            DataGridView gridSeleccionado = cnx.SourceControl as DataGridView;
            clsPaquete   paquete          = new clsPaquete();

            if (dgvPaquete.SelectedRows.Count > 0)
            {
                if (dgvPaquete.SelectedRows[0].Cells[0].Value != null)
                {
                    DataSet paq = paquete.TraerPaqueteUnicoPorClave(dgvPaquete.SelectedRows[0].Cells[1].Value.ToString());
                    string  fi  = paq.Tables[0].Rows[0].ItemArray[2].ToString().Replace(" a.m.", "");
                    fi.Replace(" p.m.", "");
                    string ff = paq.Tables[0].Rows[0].ItemArray[3].ToString().Replace(" a.m.", "");
                    ff.Replace(" p.m.", "");
                    DateTime fechIni = Convert.ToDateTime(DateTime.Parse(fi));
                    DateTime fechFin = DateTime.Parse(ff);
                    txtCodigo.Text      = paq.Tables[0].Rows[0].ItemArray[1].ToString();
                    txtCodigo.ReadOnly  = true;
                    txtDescripcion.Text = paq.Tables[0].Rows[0].ItemArray[4].ToString();
                    dtpInicio.Text      = fi;
                    dtpFin.Text         = ff;
                    txtPrecio.Text      = paq.Tables[0].Rows[0].ItemArray[5].ToString();
                }
                else
                {
                    dgvPaquete.ClearSelection();
                }
            }
        }
Beispiel #4
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 #5
0
        private void btnGrabarPaquete_Click(object sender, EventArgs e)
        {
            if (tbNomdestinatario.Text != string.Empty && tbDniDestinatario.Text != string.Empty && tbciudadCliente.Text != string.Empty && tbdirecDest.Text != string.Empty && tbKg.Text != string.Empty && tbBultos.Text != string.Empty && tbCodigoPostal.Text != string.Empty)
            {
                clsPaquete nuevo = new clsPaquete();
                nuevo.Id = nuevo.RecuperarUltimoId() + 1;
                nuevo.NombreDestinatario = tbNomdestinatario.Text;
                nuevo.DniDestinatario    = int.Parse(tbDniDestinatario.Text);
                nuevo.Ciudad             = tbciudadCliente.Text;
                nuevo.Direccion          = tbdirecDest.Text;
                nuevo.Kilos        = float.Parse(tbKg.Text);
                nuevo.Estado       = "Para enviar";
                nuevo.Bultos       = int.Parse(tbBultos.Text);
                nuevo.CodigoPostal = int.Parse(tbCodigoPostal.Text);
                nuevo.Codigo       = "CDP" + nuevo.Id;

                string res = string.Empty;
                res = nuevo.Grabar();
                if (res == string.Empty)
                {
                    MessageBox.Show("Paquete registrado");
                }
                else
                {
                    MessageBox.Show("ocurrio el siguiente error" + res);
                }
            }

            else
            {
                MessageBox.Show("Campos incompletos");
            }
        }
        List <ArticuloVenta> ObtenerListaArticulosAGuardar(ref decimal diferenciaPrecio)
        {
            List <ArticuloVenta> listaSinPaquetes = (from art in listaArticulosVenta where !art.EsPaquete select art).ToList();
            decimal    totalDetallePaquete        = 0;
            decimal    totalPaquete    = 0;
            var        consultaPaquete = from art in listaArticulosVenta where art.EsPaquete select art;
            clsPaquete cPaquete        = new clsPaquete();

            foreach (ArticuloVenta pqte in consultaPaquete)
            {
                cPaquete.pqt_codigo = pqte.CodigoArticulo;
                var detalles = cPaquete.TraerDetallePaquetes();
                totalPaquete += pqte.Precio;
                if (detalles == null)
                {
                    continue;
                }

                foreach (DataRow r in detalles.Tables[0].Rows)
                {
                    int          cantidad       = int.Parse(r.ItemArray[3].ToString());
                    string       claveArt       = r.ItemArray[0].ToString();
                    clsArticulos cArticulo      = new clsArticulos();
                    DataSet      articulo       = cArticulo.leerArticulosUnicoPorClave(claveArt);
                    decimal      precio         = decimal.Parse(articulo.Tables[0].Rows[0][10].ToString());
                    string       descripcionArt = articulo.Tables[0].Rows[0][1].ToString();
                    AgregarArticuloALista(claveArt, descripcionArt, cantidad, precio, false, ref listaSinPaquetes);
                    totalDetallePaquete += (precio * cantidad);
                }
            }
            diferenciaPrecio = totalDetallePaquete - totalPaquete;
            return(listaSinPaquetes);
        }
Beispiel #7
0
        void CargarPaquetes()
        {
            clsPaquete paquete  = new clsPaquete();
            DataSet    consulta = paquete.TraerPaquetes();

            if (consulta != null && consulta.Tables.Count > 0)
            {
                dgvPaquete.DataSource = consulta.Tables[0];
            }
            else if (!string.IsNullOrEmpty(paquete.mensaje))
            {
                MessageBox.Show(paquete.mensaje, "¡Ocurrio un error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            if (articulos.Count == 0)
            {
                MostrarMensajeInformacion("Se debe seleccionar al menos un artículo");
                return;
            }

            string errores = "";
            int    veces   = 1;

            foreach (ArticuloPaquete art in articulos)
            {
                clsPaquete paquete = new clsPaquete();
                paquete.part_codpqte  = string.Format("'{0}'", CodigoPaquete);
                paquete.part_cantidad = art.Cantidad;
                paquete.part_keyart   = string.Format("'{0}'", art.Codigo);

                if (veces == 1)
                {
                    if (paquete.EliminarTodoDetallePaquete())
                    {
                    }
                }

                veces++;

                if (!paquete.GuardarDetallePaquete())
                {
                    errores = errores + art.NombreArticulo + " " + paquete.mensaje + Environment.NewLine;
                }
            }

            if (!string.IsNullOrEmpty(errores))
            {
                MostrarMensajeInformacion("Paquete guardado pero con errores: " + Environment.NewLine + errores);
            }
            else
            {
                MostrarMensajeInformacion("Paquete guardado");
            }
            DialogResult = DialogResult.OK;
            this.Close();
        }
        void CargarDetallesPaquete()
        {
            clsPaquete cPaquete = new clsPaquete();

            dgvArticulos.AutoGenerateColumns = false;
            cPaquete.pqt_codigo = CodigoPaquete;
            DataSet consulta = cPaquete.TraerDetallePaquetes();

            if (consulta != null && consulta.Tables.Count > 0)
            {
                dgvArticulos.DataSource = null;
                articulos = ArticuloPaquete.ConvertirDataSetProducto(consulta);
                dgvArticulos.DataSource = articulos;
            }
            else if (!string.IsNullOrEmpty(cPaquete.mensaje))
            {
                MessageBox.Show(cPaquete.mensaje, "¡Ocurrio un error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #10
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            clsPaquete nuevoPaquete = new clsPaquete();

            if (string.IsNullOrEmpty(txtCodigo.Text))
            {
                MessageBox.Show("El campo de código es obligatorio");
                return;
            }
            if (string.IsNullOrEmpty(txtCodigo.Text))
            {
                MessageBox.Show("El campo de descripción es obligatorio");
                return;
            }

            decimal precio = 0;

            if (!decimal.TryParse(txtPrecio.Text, out precio))
            {
                MessageBox.Show("El campo de descripción es obligatorio");
                return;
            }

            nuevoPaquete.pqt_codigo  = txtCodigo.Text;
            nuevoPaquete.pqt_descrip = txtDescripcion.Text;
            nuevoPaquete.pqt_fini    = DateTime.Parse(dtpInicio.Text);
            nuevoPaquete.pqt_ffin    = DateTime.Parse(dtpFin.Text);
            nuevoPaquete.pqt_precio  = precio;
            if (nuevoPaquete.GuardarPaquete())
            {
                AbrirVentadaDetalle(nuevoPaquete.pqt_codigo);
                CargarPaquetes();
                Limpiar();
            }
            else
            {
                MessageBox.Show(nuevoPaquete.mensaje, "¡Ocurrio un error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            //Al final del guardado abrir lla pantalla del detalle del paquete
        }
 private void btnCancelar_Click(object sender, EventArgs e)
 {
     if (dgvArticulos.SelectedRows.Count > 0)
     {
         if (dgvArticulos.SelectedRows[0].Cells[0].Value != null)
         {
             clsPaquete paquete = new clsPaquete();
             if (paquete.EliminarDetallePaquete(txtCodigoPaquete.Text, dgvArticulos.SelectedRows[0].Cells[0].Value.ToString()))
             {
                 CargarDetallesPaquete();
             }
             else
             {
                 MessageBox.Show(paquete.mensaje, "¡Ocurrio un error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
         else
         {
             dgvArticulos.ClearSelection();
         }
     }
 }
Beispiel #12
0
        private void frmRegistrarEncomienda_Load(object sender, EventArgs e)
        {
            dgvElegircliente.DataSource = null;
            dgvElegirPaquete.DataSource = null;

            List <clsCliente> listaclientes = new List <clsCliente>();
            List <clsPaquete> listapaquetes = new List <clsPaquete>();
            clsPaquete        p1            = new clsPaquete();
            clsCliente        c1            = new clsCliente();

            foreach (clsCliente cli in c1.Leer())
            {
                if (cli.Estado == true)
                {
                    listaclientes.Add(cli);
                }
            }

            foreach (clsPaquete paq in p1.Leer())
            {
                if (paq.Estado == "Para enviar")
                {
                    listapaquetes.Add(paq);
                }
            }

            dgvElegircliente.DataSource = listaclientes;
            dgvElegirPaquete.DataSource = listapaquetes;

            clsEmpresa nueva = new clsEmpresa();

            foreach (clsEmpresa c in nueva.Leer())
            {
                if (c != null)
                {
                    cbempresas.Items.Add(c.NombreEmpresa);
                }
            }
        }
Beispiel #13
0
 private void btnCancelar_Click(object sender, EventArgs e)
 {
     if (dgvPaquete.SelectedRows.Count > 0)
     {
         if (dgvPaquete.SelectedRows[0].Cells[0].Value != null)
         {
             clsPaquete paquete = new clsPaquete();
             string     codigo  = dgvPaquete.SelectedRows[0].Cells[1].Value.ToString();
             if (paquete.EliminarPaquete(codigo))
             {
                 CargarPaquetes();
             }
             else
             {
                 MessageBox.Show(paquete.mensaje, "¡Ocurrio un error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
         else
         {
             dgvPaquete.ClearSelection();
         }
     }
 }
Beispiel #14
0
        void TraerArticulos()
        {
            List <ArticuloVenta> articulosEncontrados = new List <ArticuloVenta>();
            string dato = txtDatoProducto.Text;

            clsArticulos artic             = new clsArticulos();
            DataSet      consultaArticulos = artic.leerArticulos();

            if (consultaArticulos != null && consultaArticulos.Tables.Count > 0)
            {
                foreach (DataRow r in consultaArticulos.Tables[0].Rows)
                {
                    articulosEncontrados.Add(ConvertirDataSetArticulo(r));
                }
            }

            clsPaquete paquete          = new clsPaquete();
            DataSet    consultaPaquetes = paquete.TraerDetallePaquetes();

            if (consultaPaquetes != null && consultaPaquetes.Tables.Count > 0)
            {
                foreach (DataRow r in consultaPaquetes.Tables[0].Rows)
                {
                    articulosEncontrados.Add(ConvertirDataSetPaquete(r));
                }
            }

            dgvProductos.AutoGenerateColumns = false;
            if (articulosEncontrados.Count > 0)
            {
                dgvProductos.DataSource = articulosEncontrados;
            }
            else if (!string.IsNullOrEmpty(artic.mensaje))
            {
                MessageBox.Show(artic.mensaje, "¡Ocurrio un error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #15
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 #16
0
        public void Cotizaciones(clsRemitente remitente, clsDestinatario destinatario, clsPaquete paquete, int tipoenvio)
        {
            RedPackWs1.RedpackWSPortTypeClient _cliente = new RedPackWs1.RedpackWSPortTypeClient();
            RedPackWs1.Guia _guia = new RedPackWs1.Guia();

            _guia.remitente = new RedPackWs1.Direccion();
            _guia.remitente.codigoPostal          = remitente.Direccion.CP;
            _guia.remitente.codigoPostalSpecified = true;

            _guia.consignatario = new RedPackWs1.Direccion();
            _guia.consignatario.codigoPostal          = destinatario.Direccion.CP;
            _guia.consignatario.codigoPostalSpecified = true;

            _guia.tipoEntrega = new RedPackWs1.IdDesc();

            _guia.tipoEntrega.id          = tipoenvio;
            _guia.tipoEntrega.idSpecified = true;
        }
Beispiel #17
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 #18
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");
            }
        }
 public bool actualizarPaquete(clsPaquete objPaquete)
 {
     return(objDatosPaquete.modificarPaquete(objPaquete.id_paquete, objPaquete.fecha_paquete, objPaquete.id_cliente,
                                             objPaquete.subtotal_paquete, objPaquete.valor_total_paquete, objPaquete.estado_paquete));
 }
 public bool insertarPaquete(clsPaquete objPaquete)
 {
     return(objDatosPaquete.insertarPaquete(objPaquete.fecha_paquete, objPaquete.id_cliente, objPaquete.subtotal_paquete,
                                            objPaquete.valor_total_paquete, objPaquete.estado_paquete));
 }
        void BuscarProducto()
        {
            if (string.IsNullOrEmpty(txtClaveProducto.Text))
            {
                return;
            }

            string[] cantidadCodigo = txtClaveProducto.Text.Split('*');
            int      cantidad       = 0;
            string   codigo         = "";

            if (cantidadCodigo.Length > 1)
            {
                if (!int.TryParse(cantidadCodigo[0], out cantidad))
                {
                    cantidad = 1;
                }
                codigo = cantidadCodigo[1];
            }
            else
            {
                cantidad = 1;
                codigo   = cantidadCodigo[0];
            }

            clsArticulos articulos = new clsArticulos();

            articulos.art_codbar = codigo;
            DataSet respuesta = articulos.leerArticulosUnicoPorCodigoBarras();

            bool articuloEncontrado = false;
            bool esPaquete          = false;

            if (!string.IsNullOrEmpty(articulos.mensaje))
            {
                MessageBox.Show(articulos.mensaje, "Información", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            articuloEncontrado = respuesta != null && respuesta.Tables[0].Rows.Count > 0;

            if (!articuloEncontrado)
            {
                respuesta          = articulos.leerArticulosUnicoPorClave(codigo);
                articuloEncontrado = respuesta != null && respuesta.Tables[0].Rows.Count > 0;
            }

            if (!articuloEncontrado)
            {
                clsPaquete cPaquete = new clsPaquete();
                respuesta          = cPaquete.TraerPaqueteUnicoPorClave(codigo);
                articuloEncontrado = respuesta != null && respuesta.Tables[0].Rows.Count > 0;
                esPaquete          = articuloEncontrado;
            }

            if (!articuloEncontrado)
            {
                txtClaveProducto.Text = "";
                return;
            }

            string  clavearticulo  = esPaquete ? respuesta.Tables[0].Rows[0][1].ToString() : respuesta.Tables[0].Rows[0][0].ToString();
            string  codigoBarras   = esPaquete ? respuesta.Tables[0].Rows[0][1].ToString() : respuesta.Tables[0].Rows[0][20].ToString();
            string  nombreArticulo = esPaquete ? respuesta.Tables[0].Rows[0][4].ToString() : respuesta.Tables[0].Rows[0][1].ToString();
            decimal precio         = esPaquete ? decimal.Parse(respuesta.Tables[0].Rows[0][5].ToString()) : decimal.Parse(respuesta.Tables[0].Rows[0][10].ToString());

            AgregarVentaArticulo(clavearticulo, nombreArticulo, cantidad, precio, esPaquete);
            CalcularMontos();
            txtClaveProducto.Text = "";
        }
Beispiel #22
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");
            }
        }
Beispiel #23
0
        private void btnVender_Click(object sender, EventArgs e)
        {
            int                    idPaquete              = 0;
            int                    idDetallePaquete       = 0;
            int                    count                  = 0;
            DataTable              dtProducto             = new DataTable();
            clsVenta               objVenta               = new clsVenta();
            clsDetalleVenta        objDetalleVenta        = new clsDetalleVenta();
            clsNegocioVenta        objNegocioVenta        = new clsNegocioVenta();
            clsNegocioDetalleVenta objNegocioDetalleVenta = new clsNegocioDetalleVenta();
            clsNegocioSaldo        objNegocioSaldo        = new clsNegocioSaldo();
            clsNegocioProducto     objNegocioProducto     = new clsNegocioProducto();
            clsPaquete             objPaqueteTemporal     = new clsPaquete();
            clsSaldo               objSaldo               = new clsSaldo();

            try
            {
                if (lbPaquete.Items.Count > 0)
                {
                    idPaquete = int.Parse(lbPaquete.SelectedValue.ToString());

                    if (cbEstadoPaquete.SelectedIndex == 1)
                    {
                        objVenta.id_cliente     = int.Parse(cbBusquedaCliente.SelectedValue.ToString());
                        objVenta.fecha_venta    = DateTime.Today.ToShortDateString();
                        objVenta.estado_venta   = cbEstadoPaquete.SelectedIndex;
                        objVenta.subtotal_venta = double.Parse(txtSubtotalPaquete.Text);

                        if (objNegocioVenta.insertarVenta(objVenta))
                        {
                            foreach (DataRow fila in dtDetallePaqueteLogico.Rows)
                            {
                                if (bool.Parse(fila[6].ToString()))
                                {
                                    idDetallePaquete = int.Parse(dtDetallePaqueteLogicoTemporal.Rows[count][0].ToString());
                                    int idVenta = objNegocioVenta.consultarUltimoID();
                                    objDetalleVenta.id_venta = idVenta;
                                    int id_producto = int.Parse(fila[1].ToString());
                                    objDetalleVenta.id_producto               = id_producto;
                                    objDetalleVenta.cantidad                  = int.Parse(fila[4].ToString());
                                    objDetalleVenta.total_detalle             = double.Parse(fila[5].ToString());
                                    objDetalleVenta.estado_detalle            = true;
                                    objDetalleVenta.id_detalle_paquete        = idDetallePaquete;
                                    objDetallePaquete.id_paquete              = idPaquete;
                                    objDetalleVenta.id_color                  = int.Parse(fila[2].ToString());
                                    objDetalleVenta.id_tamano                 = int.Parse(fila[3].ToString());
                                    objDetalleVenta.observacion_detalle_venta = fila[7].ToString();

                                    dtProducto = objNegocioProducto.consultarProductoId(id_producto).Tables[0];
                                    objDetalleVenta.precio_producto = double.Parse(dtProducto.Rows[0][2].ToString());

                                    if (objNegocioDetalleVenta.insertarDetalleVenta(objDetalleVenta))
                                    {
                                    }
                                    else
                                    {
                                        int idDetalleVenta = objNegocioDetalleVenta.ConsultarUltimoDetalleVenta();
                                        objNegocioDetalleVenta.eliminarDetalleVenta(idDetalleVenta, idVenta);
                                        objNegocioVenta.eliminarVenta(idPaquete);
                                    }
                                }
                                count++;
                            }
                            objNegocioPaquete.cambiarEstadoPaquete(idPaquete);
                            objSaldo.id_cliente = int.Parse(cbBusquedaCliente.SelectedValue.ToString());
                            objSaldo.saldo      = double.Parse(txtSubtotalPaquete.Text);
                            objNegocioSaldo.cambiarSaldo(objSaldo, 1);
                            MessageBox.Show("Venta registrada con exito");
                        }
                        else
                        {
                            objNegocioVenta.eliminarVenta(idPaquete);

                            MessageBox.Show("Error al ingresar la venta");
                        }
                    }
                    else
                    {
                        MessageBox.Show("Paquete ya vendido, no se puede volver a vender.");
                    }
                }
                else
                {
                    MessageBox.Show("No existe ningun paquete seleccionado para la venta");
                }
            }

            catch (Exception)
            {
                MessageBox.Show("Error al vender el paquete");
            }
            llenarDatosPaquete();
        }
Beispiel #24
0
        private void btnGuardarCliente_Click(object sender, EventArgs e)
        {
            List <int>        diferencia                = new List <int>();
            int               contadorFilas             = 0;
            clsPaquete        objPaqueteTemporal        = new clsPaquete();
            clsDetallePaquete objDetallePaqueteTemporal = new clsDetallePaquete();

            try
            {
                dtDetallePaqueteLogico.Rows[indexDataGrid][7] = txtObservaciones.Text;

                if (operacion == 0)
                {
                    contadorFilas = 0;
                    objPaqueteTemporal.id_cliente       = int.Parse(cbBusquedaCliente.SelectedValue.ToString());
                    objPaqueteTemporal.subtotal_paquete = double.Parse(txtSubtotalPaquete.Text);
                    objPaqueteTemporal.fecha_paquete    = calendarioPaquete.Value.ToString("yyyy-MM-dd");
                    objPaqueteTemporal.estado_paquete   = false;

                    bool flagIngresoPaquete = false;

                    if (objNegocioPaquete.insertarPaquete(objPaqueteTemporal))
                    {
                        foreach (DataRow fila in dtDetallePaqueteLogico.Rows)
                        {
                            ultimoID = objNegocioPaquete.ultimoID();
                            objDetallePaqueteTemporal.id_paquete     = ultimoID;
                            objDetallePaqueteTemporal.id_producto    = int.Parse(fila[1].ToString());
                            objDetallePaqueteTemporal.id_color       = int.Parse(fila[2].ToString());
                            objDetallePaqueteTemporal.id_tamano      = int.Parse(fila[3].ToString());
                            objDetallePaqueteTemporal.cantidad       = int.Parse(fila[4].ToString());
                            objDetallePaqueteTemporal.total_detalle  = double.Parse(fila[5].ToString());
                            objDetallePaqueteTemporal.estado_detalle = bool.Parse(fila[6].ToString());
                            objDetallePaqueteTemporal.observacion_detalle_paquete = fila[7].ToString();
                            contadorFilas++;

                            if (objNegocioDatallePaquete.insertarDetallePaquete(objDetallePaqueteTemporal))
                            {
                                flagIngresoPaquete = true;
                            }
                            else
                            {
                                MessageBox.Show("Error al ingresar el detalle");
                                flagIngresoPaquete = false;
                                objNegocioPaquete.eliminarPaquete(ultimoID);
                            }
                        }

                        if (flagIngresoPaquete)
                        {
                            MessageBox.Show("Paquete ingresado con exito");
                        }
                    }
                }

                if (operacion == 1)
                {
                    contadorFilas = 0;
                    int idPaquete = int.Parse(lbPaquete.SelectedValue.ToString());
                    objPaqueteTemporal.id_paquete       = idPaquete;
                    objPaqueteTemporal.id_cliente       = int.Parse(cbBusquedaCliente.SelectedValue.ToString());
                    objPaqueteTemporal.subtotal_paquete = double.Parse(txtSubtotalPaquete.Text);
                    objPaqueteTemporal.fecha_paquete    = calendarioPaquete.Value.ToString("yyyy-MM-dd");
                    objPaqueteTemporal.estado_paquete   = false;

                    if (objNegocioPaquete.actualizarPaquete(objPaqueteTemporal))
                    {
                        diferencia = obtenerDiferencia();

                        foreach (int idDetalle in diferencia)
                        {
                            if (int.Parse(dtDetallePaqueteLogico.Rows[contadorFilas][0].ToString()) != 0)
                            {
                                objNegocioDatallePaquete.eliminarDetallePaqueteID(idDetalle);
                            }
                        }

                        foreach (DataRow fila in dtDetallePaqueteLogico.Rows)
                        {
                            if (int.Parse(fila[0].ToString()) != 0)
                            {
                                objDetallePaqueteTemporal.id_paquete                  = idPaquete;
                                objDetallePaqueteTemporal.id_detalle_paquete          = int.Parse(fila[0].ToString());
                                objDetallePaqueteTemporal.id_producto                 = int.Parse(fila[1].ToString());
                                objDetallePaqueteTemporal.id_color                    = int.Parse(fila[2].ToString());
                                objDetallePaqueteTemporal.id_tamano                   = int.Parse(fila[3].ToString());
                                objDetallePaqueteTemporal.cantidad                    = int.Parse(fila[4].ToString());
                                objDetallePaqueteTemporal.total_detalle               = double.Parse(fila[5].ToString());
                                objDetallePaqueteTemporal.estado_detalle              = bool.Parse(fila[6].ToString());
                                objDetallePaqueteTemporal.observacion_detalle_paquete = fila[7].ToString();

                                if (objNegocioDatallePaquete.actualizarDetallePaquete(objDetallePaqueteTemporal))
                                {
                                }
                                else
                                {
                                    MessageBox.Show("Error al ingresar el detalle");
                                }
                            }
                            else
                            {
                                objDetallePaqueteTemporal.id_paquete         = idPaquete;
                                objDetallePaqueteTemporal.id_detalle_paquete = int.Parse(fila[0].ToString());
                                objDetallePaqueteTemporal.id_producto        = int.Parse(fila[1].ToString());
                                objDetallePaqueteTemporal.id_color           = int.Parse(fila[2].ToString());
                                objDetallePaqueteTemporal.id_tamano          = int.Parse(fila[3].ToString());
                                objDetallePaqueteTemporal.cantidad           = int.Parse(fila[4].ToString());
                                objDetallePaqueteTemporal.total_detalle      = double.Parse(fila[5].ToString());
                                objDetallePaqueteTemporal.estado_detalle     = bool.Parse(fila[6].ToString());

                                if (objNegocioDatallePaquete.insertarDetallePaquete(objDetallePaqueteTemporal))
                                {
                                }
                                else
                                {
                                    MessageBox.Show("Error al ingresar el detalle");
                                }
                            }
                            contadorFilas++;
                        }
                    }
                }
            }
            catch (Exception)
            {
            }
            bloquearPantalla();
            llenarPaquete();
        }