Exemple #1
0
        //Guardar el Detalle de la Cotizacion.
        public bool GuardarDet(List <clsCotizacionDetalle_Vista> lista_detalle)
        {
            try
            {
                clsCotizacionDetalle_Vista e = new clsCotizacionDetalle_Vista();
                using (CompraEntities ent = new CompraEntities())
                { //se instancia el entity para poder usar los nombres de las tablas
                    //se hace el ingreso de cada detalle que existe en la lista
                    int cantidad = lista_detalle.Count();
                    int i        = 0;
                    while (i < cantidad)
                    {
                        e = lista_detalle[i];
                        CotizacionDet cotizacion_detalle = new CotizacionDet()
                        {
                            Numero       = e.Numero,
                            idEmpresa    = e.IdEmpresa,
                            Linea        = e.linea,
                            NumeroPedido = e.Pedido,
                        };

                        ent.AddToCotizacionDet(cotizacion_detalle);
                        ent.SaveChanges();
                        i++;
                    }
                }
                return(true);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error al guardar el detalle de la Cotización: " + ex);
                return(false);
            }
        }
Exemple #2
0
 //metodo que retorna el detalle de una pedido según su cabecera
 public List <clsCotizacionDetalle_Vista> DetalleCotizacionVista(int NumeroDetalle, int idEmpresa)
 {
     try
     {
         using (CompraEntities ent = new CompraEntities())
         {
             List <clsCotizacionDetalle_Vista> listaCotizacionDet = new List <clsCotizacionDetalle_Vista>();
             var x = (from a in ent.CotizacionDetalle_Vista where a.Numero == NumeroDetalle && a.idEmpresa == idEmpresa select a);
             foreach (var item in x)
             {
                 clsCotizacionDetalle_Vista e = new clsCotizacionDetalle_Vista();
                 e.Numero         = Convert.ToInt32(item.Numero);
                 e.linea          = Convert.ToInt32(item.Linea);
                 e.Pedido         = Convert.ToInt32(item.NumeroPedido);
                 e.idTipoArticulo = Convert.ToInt32(item.idTipoArticulo);
                 e.TipoArticulo   = Convert.ToString(item.TipoArticulo);
                 e.idUsuario      = Convert.ToInt32(item.idUsuario);
                 e.Usuario        = Convert.ToString(item.NombreUsuario);
                 e.Fecha          = Convert.ToDateTime(item.Fecha);
                 e.IdEmpresa      = Convert.ToInt32(item.idEmpresa);
                 e.Empresa        = Convert.ToString(item.Empresa);
                 listaCotizacionDet.Add(e);
             }
             return(listaCotizacionDet);
         }
     }
     catch (Exception e)
     {
         Console.WriteLine("Error: " + e);
         return(null);
     }
 }
Exemple #3
0
        public bool getValores()
        {
            if (txtNumero.Text == "" || txtNumero.Text == "0")
            {
                oCotizacionCab.Numero = 0;//PK
            }
            else
            {
                oCotizacionCab.Numero = Convert.ToInt32(txtNumero.Text);
            }
            if ((cmbEstado.SelectedItem == null) ||
                (txtProveedor1.Text == "") || (txtProveedor2.Text == "") || (txtProveedor3.Text == ""))
            {
                return(false);
            }

            //COTIZACION A 1 PROVEEDOR
            //llenando valores de cabecera  de la Cotizacion1
            oCotizacionCab.Numero      = Convert.ToInt32(txtNumero.Text);
            oCotizacionCab.idEmpresa   = frmPrincipalCompras.id_empresa;
            oCotizacionCab.idUsuario   = frmPrincipalCompras.id_usuario; //esto nos lo da seguridad
            oCotizacionCab.idProveedor = id_proveedor1;
            oCotizacionCab.idEstado    = cmbEstado.SelectedIndex + 1;

            //llenando valores de cabecera  de la Cotizacion2
            oCotizacionCab1.Numero      = Convert.ToInt32(txtNumero.Text) + 1;
            oCotizacionCab1.idEmpresa   = frmPrincipalCompras.id_empresa;
            oCotizacionCab1.idUsuario   = frmPrincipalCompras.id_usuario; //esto nos lo da seguridad
            oCotizacionCab1.idProveedor = id_proveedor2;
            oCotizacionCab1.idEstado    = cmbEstado.SelectedIndex + 1;

            //llenando valores de cabecera  de la Cotizacion3
            oCotizacionCab2.Numero      = Convert.ToInt32(txtNumero.Text) + 2;
            oCotizacionCab2.idEmpresa   = frmPrincipalCompras.id_empresa;
            oCotizacionCab2.idUsuario   = frmPrincipalCompras.id_usuario; //esto nos lo da seguridad
            oCotizacionCab2.idProveedor = id_proveedor3;
            oCotizacionCab2.idEstado    = cmbEstado.SelectedIndex + 1;


            // obteniendo los valores de un detalle
            //se crea una lista con los detalles ya que estos pueden ser uno o más
            int numero_linea = detalleCotDatos.RowCount;
            int i            = 0;

            while (i < numero_linea)
            {
                clsCotizacionDetalle_Vista e = new clsCotizacionDetalle_Vista();
                e.Numero    = Convert.ToInt32(txtNumero.Text);
                e.IdEmpresa = frmPrincipalCompras.id_empresa;
                //e.linea = Convert.ToInt32(detalleCotDatos.GetRowCellDisplayText(i, detalleCotDatos.Columns.ColumnByName("collinea")));
                e.linea  = 1;
                e.Pedido = Convert.ToInt32(detalleCotDatos.GetRowCellDisplayText(i, detalleCotDatos.Columns.ColumnByName("colNumero")));
                detalle.Add(e);
                i++;
            }

            // obteniendo los valores de un detalle1
            //se crea una lista con los detalles ya que estos pueden ser uno o más
            int numero = detalleCotDatos.RowCount;
            int j      = 0;

            while (j < numero)
            {
                clsCotizacionDetalle_Vista e = new clsCotizacionDetalle_Vista();
                e.Numero    = Convert.ToInt32(txtNumero.Text) + 1;
                e.IdEmpresa = frmPrincipalCompras.id_empresa;
                //e.linea = Convert.ToInt32(detalleCotDatos.GetRowCellDisplayText(j, detalleCotDatos.Columns.ColumnByName("collinea")));
                e.linea  = 1;
                e.Pedido = Convert.ToInt32(detalleCotDatos.GetRowCellDisplayText(j, detalleCotDatos.Columns.ColumnByName("colNumero")));
                detalle.Add(e);
                j++;
            }

            // obteniendo los valores de un detalle1m
            //se crea una lista con los detalles ya que estos pueden ser uno o más
            int linea = detalleCotDatos.RowCount;
            int m     = 0;

            while (m < linea)
            {
                clsCotizacionDetalle_Vista e = new clsCotizacionDetalle_Vista();
                e.Numero    = Convert.ToInt32(txtNumero.Text) + 2;
                e.IdEmpresa = frmPrincipalCompras.id_empresa;
                //e.linea = Convert.ToInt32(detalleCotDatos.GetRowCellDisplayText(m, detalleCotDatos.Columns.ColumnByName("collinea")));
                e.linea  = 1;
                e.Pedido = Convert.ToInt32(detalleCotDatos.GetRowCellDisplayText(m, detalleCotDatos.Columns.ColumnByName("colNumero")));
                detalle.Add(e);
                m++;
            }
            return(true);
        }