Exemplo n.º 1
0
        public List <DetallePedidoDTO> DetallePedidoFactura(int cod, char tipo)
        {
            List <DetallePedidoDTO> ListaDevolver = new List <DetallePedidoDTO>();

            try
            {
                foreach (DetallePedido DP in R_DetPe.DetallePedidoFactura(cod, tipo))
                {
                    Articulo         Cli = R_Art.BuscarXId(DP.Articuloid);
                    Pedido           P   = R_Pe.BuscarID(DP.Pedidoid);
                    DetallePedidoDTO Aux = new DetallePedidoDTO(Cli, P, DP.Cantidad, DP.Preciovendido);
                    ListaDevolver.Add(Aux);
                }
            }
            catch (Exception Ex)
            {
                throw new Exception(Ex.Message);
            }
            return(ListaDevolver);
        }
Exemplo n.º 2
0
        public bool Agregar(DetallePedidoDTO Nuevo)
        {
            bool Exit = false;

            try
            {
                DetallePedido nuevo = new DetallePedido()
                {
                    Articuloid    = Nuevo.Articuloid.Articuloid,
                    Pedidoid      = Nuevo.Pedidoid.Pedidoid,
                    Cantidad      = Nuevo.Cantidad,
                    Preciovendido = Nuevo.Preciovendido
                };
                Exit = R_DetPe.Agregar(nuevo);
            }
            catch (Exception Ex)
            {
                throw new Exception(Ex.Message);
            }
            return(Exit);
        }
Exemplo n.º 3
0
        public List <DetallePedidoDTO> DevolverTodoxID(int id)
        {
            List <DetallePedidoDTO> ListaDevolver = new List <DetallePedidoDTO>();
            Pedido pId = R_Pe.BuscarNro(id);
            List <DetallePedido> Lista = new List <DetallePedido>();

            Lista = R_DetPe.DevolverTodoxID(pId.Pedidoid);
            try
            {
                foreach (DetallePedido DP in Lista)
                {
                    Articulo         Cli = R_Art.BuscarXId(DP.Articuloid);
                    Pedido           P   = R_Pe.BuscarID(DP.Pedidoid);
                    DetallePedidoDTO Aux = new DetallePedidoDTO(Cli, P, DP.Cantidad, DP.Preciovendido);
                    ListaDevolver.Add(Aux);
                }
            }
            catch (Exception Ex)
            {
                throw new Exception(Ex.Message);
            }
            return(ListaDevolver);
        }
Exemplo n.º 4
0
 protected void Button2_Click(object sender, EventArgs e)
 {
     if (!_isRefresh)
     {
         if ((HdfArt.Value == null) || (string.IsNullOrEmpty(HdfArt.Value)))
         {
             if (StockInsuficiente(ArticuloId, Convert.ToInt32(TextCant.Text)))
             {
                 LblError.Visible = true;
                 ModalPopupExtender3.Show();
             }
             else
             {
                 if (!_isRefresh)
                 {
                     DetallePedidoDTO DetalleAux = new DetallePedidoDTO(ArticuloId, ControlPedido.BuscarNro(Convert.ToInt32(txtnropedidomostrar.Text)), Convert.ToInt32(TextCant.Text), ArticuloId.Precioactual);
                     ListaDetalleDTO.Add(DetalleAux);
                     RefrescarTabla();
                     TextCant.Text        = "1";
                     LblError.Visible     = false;
                     TxtBuscarNombre.Text = "";
                     TxtBuscarNombre.Focus();
                 }
                 else
                 {
                     //Limpiar();
                     TextCant.Text    = "1";
                     LblError.Visible = false;
                     Response.Redirect("EditarPedido.aspx");
                 }
             }
         }
         else
         {
             if (ArticuloId != null)
             {
                 if (StockInsuficiente(ArticuloId, Convert.ToInt32(TextCant.Text)))
                 {
                     LblError.Visible = true;
                     ModalPopupExtender3.Show();
                 }
                 else
                 {
                     if (!_isRefresh)
                     {
                         DetallePedidoDTO DetalleAux = new DetallePedidoDTO(ArticuloId, ControlPedido.BuscarNro(Convert.ToInt32(txtnropedidomostrar.Text)), Convert.ToInt32(TextCant.Text), ArticuloId.Cantidad);
                         ListaDetalleDTO.Add(DetalleAux);
                         RefrescarTabla();
                         HdfArt.Value         = null;
                         TxtBuscarNombre.Text = "";
                         TxtBuscarNombre.Focus();
                         TextCant.Text    = "1";
                         LblError.Visible = false;
                     }
                     else
                     {
                         //Limpiar();
                         TextCant.Text    = "1";
                         LblError.Visible = false;
                         Response.Redirect("EditarPedido.aspx");
                     }
                 }
             }
         }
     }
     else
     {
         //Limpiar();
         TextCant.Text    = "1";
         LblError.Visible = false;
         Response.Redirect("EditarPedido.aspx");
     }
 }
Exemplo n.º 5
0
        protected void GrillaArticulos_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            if (!_isRefresh)
            {
                GridViewRow row  = GrillaArticulos.Rows[e.RowIndex];
                TextBox     Txtc = (TextBox)row.Cells[4].Controls[0];
                Txtc.Focus();
                int CodArt    = Convert.ToInt32(row.Cells[0].Text);
                int nropedido = Convert.ToInt32(txtnropedidomostrar.Text);

                Articulo ArticuloAux = ControlArticulo.BuscarXId(CodArt);
                if (ArticuloAux != null)
                {
                    if ((!string.IsNullOrEmpty(Txtc.Text)))
                    {
                        if (Int32.TryParse(Txtc.Text, out int result))
                        {
                            if (Convert.ToInt32(Txtc.Text) > 0)
                            {
                                DetallePedidoDTO AuxiDetalle = ListaDetalleDTO[e.RowIndex];

                                if (AuxiDetalle.Cantidad > Convert.ToInt32(Txtc.Text))//cantidad sdisminuye
                                {
                                    AuxiDetalle.Cantidad      = Convert.ToInt32(Txtc.Text);
                                    GrillaArticulos.EditIndex = -1;
                                    RefrescarTabla();
                                }
                                else
                                {
                                    int cant = Convert.ToInt32(Txtc.Text) - AuxiDetalle.Cantidad;

                                    if (StockInsuficiente(ArticuloAux, cant))
                                    {
                                        ScriptManager.RegisterStartupScript(this, GetType(), "Popup", "errorStockInsu();", true);
                                    }
                                    else
                                    {
                                        AuxiDetalle.Cantidad      = AuxiDetalle.Cantidad + cant;
                                        GrillaArticulos.EditIndex = -1;
                                        RefrescarTabla();
                                    }
                                }
                            }
                            else
                            {
                                ScriptManager.RegisterStartupScript(this, GetType(), "Popup", "errornega();", true);
                            }
                        }
                        else
                        {
                            ScriptManager.RegisterStartupScript(this, GetType(), "Popup", "errornvalorinco();", true);
                        }
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(this, GetType(), "Popup", "errorvacio();", true);
                    }
                }
            }
            else
            {
                Response.Redirect("EditarPedido.aspx");
            }
        }