Esempio n. 1
0
        public void TestUpdateDocumento()
        {
            Documento doc = docRepository.GetById(3320);
            List <Documento_Articulo> lstDocArticulo = new List <Documento_Articulo>();

            for (int i = 0; i < 11; i++)
            {
                Documento_Articulo docArt = new Documento_Articulo();
                Articulo           art    = artRepository.GetById(i);
                if (art != null)
                {
                    docArt.Articulo    = art;
                    docArt.Id_Articulo = art.Id_Articulo;
                    Empresa emp = empresaRespository.GetById(2);
                    docArt.Empresa    = emp;
                    docArt.Id_Empresa = 2;
                    //docArt.empr = "KD DEVELOPERS";
                    docArt.RazonSocial         = "KD UPDATE";
                    docArt.RUC                 = "20153045021";
                    docArt.DescripcionArticulo = "MONITOR 2000";
                    docArt.CodArea             = "test AREA";
                    docArt.UnidadMedida        = "TEST UM";
                    docArt.Cantidad            = 200;
                    docArt.PrecioUnitario      = 20;
                    docArt.Importe             = 2000;
                    docArt.UsuarioCreacion     = "KD.RMALDONADO";
                    docArt.FechaCreacion       = DateTime.Now;
                    lstDocArticulo.Add(docArt);
                }
            }
            docService.Update(doc, lstDocArticulo);
        }
        private Documento GenerarDocumento()
        {
            Documento documento = new Documento();

            documento.TipoDocumento   = TipoDocumento;
            documento.Sede            = cboSede.SelectedValue as Sede;
            documento.Encargado       = Session.CurrentSession.Usuario.Usuario1;
            documento.UsuarioCreacion = Session.CurrentSession.Usuario.Usuario1;
            List <Documento_Articulo> listaDocumentoArticulo = new List <Documento_Articulo>();

            foreach (DataGridViewRow dgvr in dgvSalida.Rows)
            {
                Documento_Articulo da = new Documento_Articulo();

                DataGridViewComboBoxCell comboCell        = (DataGridViewComboBoxCell)dgvr.Cells["CodArea"];
                DataGridViewComboBoxCell comboDescripcion = (DataGridViewComboBoxCell)dgvr.Cells["Descripcion"];

                if (comboCell.Value == null || comboDescripcion.Value == null)
                {
                    MessageBox.Show("Debe completar todos los campos", "Aviso");
                    return(null);
                }


                Area     area     = listaArea.Where(tx => tx.CodArea == comboCell.Value.ToString()).FirstOrDefault();
                Articulo articulo = listaArticulo.Where(tx => tx.Descripcion == comboDescripcion.Value.ToString()).FirstOrDefault();
                da.Articulo = articulo;
                double Cantidad = 0;
                if (dgvr.Cells["Cantidad"].Value == null)
                {
                    MessageBox.Show("Debe ingresar la cantidad", "Aviso");
                    return(null);
                }
                if (!Double.TryParse(dgvr.Cells["Cantidad"].Value.ToString(), out Cantidad))
                {
                    MessageBox.Show("Debe ingresar la cantidad", "Aviso");
                    return(null);
                }
                da.NombreArea          = area.NombreArea;
                da.CodArea             = area.CodArea;
                da.UnidadMedida        = articulo.UnidadMedida.Descripcion;
                da.Cantidad            = Cantidad;
                da.DescripcionArticulo = articulo.Descripcion;
                listaDocumentoArticulo.Add(da);
            }
            documento.Documento_Articulo = listaDocumentoArticulo;
            return(documento);
        }
Esempio n. 3
0
        private Documento GenerarDocumento()
        {
            Documento objDocumento = new Documento();

            objDocumento.TipoDocumento      = TipoDocumento;
            objDocumento.TipoPresupuesto    = documento.TipoPresupuesto;
            objDocumento.Id_DocumentoOrigen = documento.Id_Documento;

            //A = Contado
            //B = Credito

            if (rbContado.Checked)
            {
                objDocumento.FormaPago = "A";
            }
            else if (rbCredito.Checked)
            {
                objDocumento.FormaPago = "B";
            }

            List <Documento_Articulo> listaDocumentoArticulo = new List <Documento_Articulo>();
            List <Pedido>             ListaPedidos           = new List <Pedido>();

            foreach (DataGridViewRow row in dgvArticulos.Rows)
            {
                Documento_Articulo       da               = new Documento_Articulo();
                Pedido                   oPedido          = new Pedido();
                DataGridViewComboBoxCell comboCell        = (DataGridViewComboBoxCell)row.Cells["CodArea"];
                DataGridViewComboBoxCell comboDescripcion = (DataGridViewComboBoxCell)row.Cells["Descripcion"];
                DataGridViewComboBoxCell cboEmpresa       = (DataGridViewComboBoxCell)row.Cells["RazonSocial"];
                DataGridViewComboBoxCell cboProveedor     = (DataGridViewComboBoxCell)row.Cells["Proveedor"];
                DataGridViewComboBoxCell cboBanco         = (DataGridViewComboBoxCell)row.Cells["Banco"];
                DataGridViewTextBoxCell  txtCnt           = (DataGridViewTextBoxCell)row.Cells["Cantidad"];
                DataGridViewTextBoxCell  txtPrecio        = (DataGridViewTextBoxCell)row.Cells["Precio"];
                DataGridViewTextBoxCell  txtCuenta        = (DataGridViewTextBoxCell)row.Cells["Cuenta"];

                if (comboCell.Value == null || comboDescripcion.Value == null || cboEmpresa.Value == null || txtCnt.Value == null || cboProveedor.Value == null ||
                    cboBanco.Value == null || txtCuenta.Value == null)
                {
                    btnGrabar.Visible = true;
                    MessageBox.Show("Complete todos los campos", "Aviso");
                    return(null);
                }

                Area      area      = listaArea.Where(tx => tx.CodArea == comboCell.Value.ToString()).FirstOrDefault();
                Articulo  articulo  = listaArticulo.Where(tx => tx.Descripcion == comboDescripcion.Value.ToString()).FirstOrDefault();
                Empresa   empresa   = listaEmpresa.Where(tx => tx.RazonSocial == cboEmpresa.Value.ToString()).FirstOrDefault();
                Proveedor proveedor = listaProveedor.Where(tx => tx.RazonSocial == cboProveedor.Value.ToString()).FirstOrDefault();
                BANCO     banco     = listaBanco.Where(tx => tx.Nombre == cboBanco.Value.ToString()).FirstOrDefault();;
                da.Articulo = articulo;

                double  Cantidad       = 0;
                double  Importe        = Convert.ToDouble(row.Cells["Importe"].Value.ToString());
                decimal precioUnitario = Convert.ToDecimal(row.Cells["Precio"].Value.ToString());

                if (!Double.TryParse(row.Cells["Cantidad"].Value.ToString(), out Cantidad))
                {
                    MessageBox.Show("Debe ingresar la cantidad", "Aviso");
                    return(null);
                }

                da.Empresa              = empresa;
                da.RazonSocial          = empresa.RazonSocial;
                da.RUC                  = empresa.RUC;
                da.Proveedor            = proveedor;
                da.RazonSocialProveedor = proveedor.RazonSocial;
                da.TelefonoProveedor    = proveedor.Telefono;
                da.RUCProveedor         = proveedor.RUC;
                da.DescripcionArticulo  = articulo.Descripcion;
                da.CodArea              = area.CodArea;
                da.UnidadMedida         = articulo.UnidadMedida.Descripcion;
                da.Cantidad             = Cantidad;
                da.PrecioUnitario       = precioUnitario;
                da.Importe              = Decimal.Parse(Importe.ToString());
                da.Id_Articulo          = articulo.Id_Articulo;
                da.NombreBanco          = banco.Nombre;
                da.CuentaBanco          = proveedor.NumeroCuenta;
                da.TipoCuentaBanco      = da.TipoCuentaBanco;
                da.EmailProveedor       = proveedor.Email_Contacto;
                listaDocumentoArticulo.Add(da);

                //Pedido
                oPedido.Cantidad            = Cantidad;
                oPedido.DescripcionArticulo = articulo.Descripcion;
                oPedido.EmailProveedor      = proveedor.Email_Contacto;
                oPedido.Importe             = Decimal.Parse(Importe.ToString());;
                oPedido.PrecioUnitario      = precioUnitario;
                oPedido.RazonSocial         = proveedor.RazonSocial;
                oPedido.RUC          = empresa.RUC;
                oPedido.UnidadMedida = articulo.UnidadMedida.Descripcion;
                ListaPedidos.Add(oPedido);
            }
            objDocumento.Moneda             = moneda;
            objDocumento.MontoTotal         = Decimal.Parse(lblMonto.Text.ToString());
            objDocumento.Documento_Articulo = listaDocumentoArticulo;
            objDocumento.UsuarioCreacion    = Session.CurrentSession.Usuario.Usuario1;
            objDocumento.MontoDisponible    = Convert.ToDecimal(txtMontoDisponible.Text.ToString().Trim());
            objDocumento.FechaCreacion      = DateTime.Now;
            objDocumento.Estado             = "A";

            //Registrar Cola
            RegistrarColaOC(ListaPedidos);

            return(objDocumento);
        }
Esempio n. 4
0
        private Documento GenerarDocumento()
        {
            Documento documento = new Documento();

            documento.TipoDocumento   = TipoDocumento;
            documento.UsuarioCreacion = Session.CurrentSession.Usuario.Usuario1;
            string tipoPre = "";

            if (cboTipoPre.SelectedItem.ToString() == "Varios")
            {
                tipoPre = "VAR";
            }
            if (cboTipoPre.SelectedItem.ToString() == "Placas")
            {
                tipoPre = "PLA";
            }
            if (cboTipoPre.SelectedItem.ToString() == "Lab")
            {
                tipoPre = "LAB";
            }
            documento.TipoPresupuesto = tipoPre;
            List <Documento_Articulo> listaDocumentoArticulo = new List <Documento_Articulo>();

            foreach (DataGridViewRow dgvr in dgvArticulos.Rows)
            {
                Documento_Articulo da = new Documento_Articulo();

                DataGridViewComboBoxCell comboCell        = (DataGridViewComboBoxCell)dgvr.Cells["CodArea"];
                DataGridViewComboBoxCell comboDescripcion = (DataGridViewComboBoxCell)dgvr.Cells["Descripcion"];
                DataGridViewComboBoxCell cboEmpresa       = (DataGridViewComboBoxCell)dgvr.Cells["RazonSocial"];
                DataGridViewTextBoxCell  txtCnt           = (DataGridViewTextBoxCell)dgvr.Cells["Cantidad"];
                DataGridViewComboBoxCell cboProveedor     = (DataGridViewComboBoxCell)dgvr.Cells["Proveedor"];
                DataGridViewComboBoxCell cboBanco         = (DataGridViewComboBoxCell)dgvr.Cells["Banco"];
                DataGridViewTextBoxCell  txtCuenta        = (DataGridViewTextBoxCell)dgvr.Cells["NumCuenta"];

                if (comboCell.Value == null || comboDescripcion.Value == null || cboEmpresa.Value == null || txtCnt.Value == null || cboProveedor.Value == null || cboBanco.Value == null || txtCuenta.Value == null)
                {
                    MessageBox.Show("Complete todos los campos", "Aviso");
                    return(null);
                }
                Area      area      = listaArea.Where(tx => tx.CodArea == comboCell.Value.ToString()).FirstOrDefault();
                Articulo  articulo  = listaArticulo.Where(tx => tx.Descripcion == comboDescripcion.Value.ToString()).FirstOrDefault();
                Empresa   empresa   = listaEmpresa.Where(tx => tx.RazonSocial == cboEmpresa.Value.ToString()).FirstOrDefault();
                Proveedor proveedor = listaProveedor.Where(tx => tx.RazonSocial == cboProveedor.Value.ToString()).FirstOrDefault();
                BANCO     banco     = listaBanco.Where(tx => tx.Nombre == cboBanco.Value.ToString()).FirstOrDefault();

                da.Articulo = articulo;
                double Cantidad = 0;

                double Importe = Convert.ToDouble(dgvr.Cells["Importe"].Value.ToString());
                string cuenta  = dgvr.Cells["NumCuenta"].Value.ToString();

                if (!Double.TryParse(dgvr.Cells["Cantidad"].Value.ToString(), out Cantidad))
                {
                    MessageBox.Show("Debe ingresar la cantidad", "Aviso");
                    return(null);
                }

                da.Empresa             = empresa;
                da.RazonSocial         = empresa.RazonSocial;
                da.RUC                 = empresa.RUC;
                da.DescripcionArticulo = articulo.Descripcion;
                da.CodArea             = area.CodArea;
                da.UnidadMedida        = articulo.UnidadMedida.Descripcion;
                da.Cantidad            = Cantidad;
                da.PrecioUnitario      = articulo.Costo;
                da.Importe             = Decimal.Parse(Importe.ToString());
                da.Id_Articulo         = articulo.Id_Articulo;
                //
                da.Proveedor            = proveedor;
                da.Id_Proveedor         = proveedor.Id_Proveedor;
                da.RUCProveedor         = proveedor.RUC;
                da.NombreBanco          = banco.Nombre;
                da.RazonSocialProveedor = proveedor.RazonSocial;
                da.TelefonoProveedor    = proveedor.Telefono;
                da.EmailProveedor       = proveedor.Email_Contacto;

                da.CuentaBanco     = cuenta;
                da.TipoCuentaBanco = moneda;
                //
                listaDocumentoArticulo.Add(da);
            }
            documento.Moneda             = moneda;
            documento.MontoTotal         = Decimal.Parse(lblTotalI.Text.ToString());
            documento.Documento_Articulo = listaDocumentoArticulo;
            return(documento);
        }
        private Documento GenerarDocumento()
        {
            documento.UsuarioModificacion = Session.CurrentSession.Usuario.Usuario1;

            if (rbSoles.Checked)
            {
                documento.Moneda = "S";
            }
            else if (rbDolares.Checked)
            {
                documento.Moneda = "D";
            }

            foreach (DataGridViewRow row in dgvArticulos.Rows)
            {
                Documento_Articulo da = new Documento_Articulo();


                DataGridViewComboBoxCell comboCell        = (DataGridViewComboBoxCell)row.Cells["CodArea"];
                DataGridViewComboBoxCell comboDescripcion = (DataGridViewComboBoxCell)row.Cells["Descripcion"];
                DataGridViewComboBoxCell cboEmpresa       = (DataGridViewComboBoxCell)row.Cells["RazonSocial"];
                DataGridViewTextBoxCell  txtCnt           = (DataGridViewTextBoxCell)row.Cells["Cantidad"];
                DataGridViewTextBoxCell  txtPrecio        = (DataGridViewTextBoxCell)row.Cells["Precio"];
                DataGridViewComboBoxCell cboProveedor     = (DataGridViewComboBoxCell)row.Cells["Proveedor"];
                DataGridViewComboBoxCell cboBanco         = (DataGridViewComboBoxCell)row.Cells["Banco"];
                DataGridViewTextBoxCell  txtCuenta        = (DataGridViewTextBoxCell)row.Cells["NumCuenta"];

                if (comboCell.Value == null || comboDescripcion.Value == null || cboEmpresa.Value == null || txtCnt.Value == null || cboProveedor.Value == null || cboBanco.Value == null || txtCuenta.Value == null)
                {
                    btnGrabar.Visible = true;
                    MessageBox.Show("Complete todos los campos", "Aviso");
                    return(null);
                }

                Area      area      = listaArea.Where(tx => tx.CodArea == comboCell.Value.ToString()).FirstOrDefault();
                Articulo  articulo  = listaArticulo.Where(tx => tx.Descripcion == comboDescripcion.Value.ToString()).FirstOrDefault();
                Empresa   empresa   = listaEmpresa.Where(tx => tx.RazonSocial == cboEmpresa.Value.ToString()).FirstOrDefault();
                Proveedor proveedor = listaProveedor.Where(tx => tx.RazonSocial == cboProveedor.Value.ToString()).FirstOrDefault();
                BANCO     banco     = listaBanco.Where(tx => tx.Nombre == cboBanco.Value.ToString()).FirstOrDefault();
                da.Articulo = articulo;

                double  Cantidad       = 0;
                double  Importe        = Convert.ToDouble(row.Cells["Importe"].Value.ToString());
                decimal precioUnitario = Convert.ToDecimal(row.Cells["Precio"].Value.ToString());
                string  cuenta         = row.Cells["NumCuenta"].Value.ToString();

                if (!Double.TryParse(row.Cells["Cantidad"].Value.ToString(), out Cantidad))
                {
                    MessageBox.Show("Debe ingresar la cantidad", "Aviso");
                    return(null);
                }

                da.Empresa              = empresa;
                da.Id_Empresa           = empresa.Id_Empresa;
                da.RazonSocial          = empresa.RazonSocial;
                da.RUC                  = empresa.RUC;
                da.DescripcionArticulo  = articulo.Descripcion;
                da.CodArea              = area.CodArea;
                da.UnidadMedida         = articulo.UnidadMedida.Descripcion;
                da.Cantidad             = Cantidad;
                da.PrecioUnitario       = precioUnitario;
                da.Importe              = Decimal.Parse(Importe.ToString());
                da.Id_Articulo          = articulo.Id_Articulo;
                da.UsuarioCreacion      = Session.CurrentSession.Usuario.Usuario1;
                da.FechaCreacion        = DateTime.Now;
                da.Proveedor            = proveedor;
                da.Id_Proveedor         = proveedor.Id_Proveedor;
                da.RUCProveedor         = proveedor.RUC;
                da.NombreBanco          = banco.Nombre;
                da.RazonSocialProveedor = proveedor.RazonSocial;
                da.TelefonoProveedor    = proveedor.Telefono;
                da.CuentaBanco          = cuenta;
                da.TipoCuentaBanco      = moneda;

                listaDocumentoArticulo.Add(da);
            }
            documento.MontoTotal        = Decimal.Parse(lblMonto.Text.ToString());
            documento.FechaModificacion = DateTime.Now;
            return(documento);
        }