예제 #1
0
        private void ListarDocumentosReferencias()
        {
            List <string> listadoDoc = VwCotizacionprvdetList
                                       .Select(itemEnt =>
                                               Service.GetVwCotizacionprvdet(x => x.Idcotizacionprvdet == itemEnt.Idcotizacionprvdet))
                                       .Select(ordencompraRef => string.Format("{0}-{1}",
                                                                               Convert.ToInt32(ordencompraRef.Seriecotizacionprv),
                                                                               Convert.ToInt32(ordencompraRef.Numerocotizacionprv))).Distinct().ToList();

            string docsReferencia = listadoDoc
                                    .Aggregate(string.Empty
                                               , (current, item) => current + item + ",");

            docsReferencia = docsReferencia.Trim().Length == 0 ? string.Empty : docsReferencia.Substring(0, docsReferencia.Length - 1);
        }
예제 #2
0
        private void CargarDetalleRequerimiento()
        {
            VwRequerimiento vwRequerimientoSel = (VwRequerimiento)gvConsulta.GetFocusedRow();

            if (vwRequerimientoSel != null)
            {
                Cursor       = Cursors.WaitCursor;
                string where = string.Format("idrequerimiento = {0} and saldoaimportar >0", vwRequerimientoSel.Idrequerimiento);
                VwRequerimientodetcotizaprvimpList = Service.GetAllVwRequerimientodetcotizaprvimp(where, "numeroitem");

                foreach (var itemReq in VwRequerimientodetcotizaprvimpList)
                {
                    var totalCantidadImporta = VwCotizacionprvdetList.Where(x =>
                                                                            x.Idarticulo == itemReq.Idarticulo &&
                                                                            x.Idrequerimientodet == itemReq.Idrequerimientodet &&
                                                                            x.DataEntityState != DataEntityState.Deleted).Sum(x => x.Cantidad);
                    if (totalCantidadImporta > 0)
                    {
                        itemReq.Cantidadimportada = (decimal)totalCantidadImporta;
                        itemReq.Saldoaimportar    = itemReq.Cantidad - itemReq.Cantidadimportada;
                    }
                }

                var itemsARemover = VwRequerimientodetcotizaprvimpList.Where(x => x.Saldoaimportar <= 0).ToList();
                foreach (var itemToRemove in itemsARemover)
                {
                    VwRequerimientodetcotizaprvimpList.Remove(itemToRemove);
                }

                //Borrar

                gcDetalleImp.BeginUpdate();
                gcDetalleImp.DataSource = VwRequerimientodetcotizaprvimpList;
                gcDetalleImp.EndUpdate();

                gvDetalleImp.BestFitColumns();
                Cursor = Cursors.Default;
            }
        }
예제 #3
0
        private void bmMntItems_ItemClick(object sender, ItemClickEventArgs e)
        {
            var subMenu = e.Item as BarSubItem;

            if (subMenu != null)
            {
                return;
            }

            switch (e.Item.Name)
            {
            case "btnImportar":

                if (!Validaciones())
                {
                    return;
                }

                var maxItem = VwCotizacionprvdetList.Where(w => w.DataEntityState != DataEntityState.Deleted)
                              .OrderByDescending(t => t.Numeroitem)
                              .FirstOrDefault();

                int sgtItem = maxItem == null ? 1 : maxItem.Numeroitem + 1;

                foreach (var item in VwRequerimientodetcotizaprvimpList.Where(x => x.Itemseleccionado))
                {
                    Cotizacionprvdet cotizacionprvdetMnt = new Cotizacionprvdet
                    {
                        Idcotizacionprv    = IdEntidadMnt,
                        Numeroitem         = sgtItem,
                        Cantidad           = item.Cantidadaimportar,
                        Idrequerimientodet = item.Idrequerimientodet,
                    };

                    sgtItem++;
                    Service.SaveCotizacionprvdet(cotizacionprvdetMnt);

                    VwRequerimientoSel = (VwRequerimiento)gvConsulta.GetFocusedRow();
                }


                DialogResult = DialogResult.OK;

                break;

            case "btnCancelarItem":
                DialogResult = DialogResult.Cancel;
                break;

            case "btnConsultar":
                if (!ValidacionDatosConsulta())
                {
                    return;
                }
                CargarRequerimientos();


                break;

            case "btnCerrar":
                DialogResult = DialogResult.Cancel;
                break;
            }
        }