Example #1
0
        private void CargarDetalleCpCompra()
        {
            VwCpcompra vwCpcompraSel = (VwCpcompra)gvConsulta.GetFocusedRow();

            if (vwCpcompraSel != null)
            {
                Cursor               = Cursors.WaitCursor;
                string where         = string.Format("idcpcompra = {0} and saldoaimportar >0", vwCpcompraSel.Idcpcompra);
                _vwCpcompraimpncList = Service.GetAllVwCpcompraimpnc(where, "numeroitem");

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

                gvDetalleImp.BestFitColumns();
                Cursor = Cursors.Default;
            }
        }
Example #2
0
        private void CargarDetalleCpCompra()
        {
            VwCpcompra vwCpcompra = (VwCpcompra)gvConsulta.GetFocusedRow();

            if (vwCpcompra != null)
            {
                Cursor       = Cursors.WaitCursor;
                string where = string.Format("idcpcompra = {0} and saldoaimportar > 0 ", vwCpcompra.Idcpcompra);
                VwCpcompradetguiaremisionimpList = Service.GetAllVwCpcompradetguiaremisionimp(where, "numeroitem");


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

                //}

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

                //Borrar

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

                gvDetalleImp.BestFitColumns();
                Cursor = Cursors.Default;
            }
        }
Example #3
0
        private void ShowFormMnt()
        {
            if (TipoMnt == TipoMantenimiento.SinEspecificar)
            {
                throw new ArgumentException("No se especifico el tipo de mantenimiento.");
            }

            AsignarIdEntidadMnt();
            CpcompraMntFrm formMnt = new CpcompraMntFrm(IdEntidadMnt, TipoMnt, gcConsulta, this);

            formMnt.ShowDialog();

            switch (formMnt.DataEntityState)
            {
            case DataEntityState.Added:
                VwCpcompra vwCpcompraAdded = Service.GetVwCpcompra(x => x.Idcpcompra == formMnt.IdEntidadMnt);
                VwCpcompraList.Add(vwCpcompraAdded);
                IdEntidadMnt = formMnt.IdEntidadMnt;
                SetFocusIdEntity();
                EstadoBotonesMantenimiento();
                break;

            case DataEntityState.Modified:
                VwCpcompra vwCpcompraUnchanged = VwCpcompraList.FirstOrDefault(x => x.Idcpcompra == formMnt.IdEntidadMnt);
                int        index = VwCpcompraList.IndexOf(vwCpcompraUnchanged);
                VwCpcompraList.Remove(vwCpcompraUnchanged);
                if (vwCpcompraUnchanged != null)
                {
                    VwCpcompraList.Insert(index, Service.GetVwCpcompra(x => x.Idcpcompra == formMnt.IdEntidadMnt));
                }
                break;

            case DataEntityState.Deleted:
                VwCpcompraList.Remove(VwCpcompraList.SingleOrDefault(x => x.Idcpcompra == formMnt.IdEntidadMnt));
                break;
            }

            gcConsulta.RefreshDataSource();
            gvConsulta.BestFitColumns(true);
        }
Example #4
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;
                }

                if (EntradaalmacenMntFrm.IdEntidadMnt == 0)
                {
                    if (!EntradaalmacenMntFrm.Validaciones())
                    {
                        return;
                    }

                    string numeroDoc = string.Format("{0} {1}-{2}", EntradaalmacenMntFrm.iIdtipocp.Text.Trim(), EntradaalmacenMntFrm.rSerieentradaalmacen.Text.Trim(), EntradaalmacenMntFrm.rNumeroentradaalmacen.Text.Trim());
                    if (DialogResult.No == XtraMessageBox.Show(string.Format("¿Desea guardar el documento {0}?", numeroDoc),
                                                               "Atención", MessageBoxButtons.YesNo,
                                                               MessageBoxIcon.Question, MessageBoxDefaultButton.Button1))
                    {
                        return;
                    }
                    VwCpcompra vwCpcompraSel = (VwCpcompra)gvConsulta.GetFocusedRow();

                    //Asignar los controles de entrada a almacen desde la orden de compra seleccionada
                    EntradaalmacenMntFrm.iIdtipomoneda.EditValue         = vwCpcompraSel.Idtipomoneda;
                    EntradaalmacenMntFrm.iIdtipomoneda.ReadOnly          = true;
                    EntradaalmacenMntFrm.iIncluyeimpuestoitems.EditValue = vwCpcompraSel.Incluyeimpuestoitems;
                    EntradaalmacenMntFrm.iTipocambio.EditValue           = vwCpcompraSel.Tipocambio;

                    //Asignar la propiedad del documento de referencia

                    EntradaalmacenMntFrm.EntradaalmacenMnt.Idcpcompra = vwCpcompraSel.Idcpcompra;
                    if (EntradaalmacenMntFrm.Guardar())
                    {
                        EntradaalmacenMntFrm.DeshabilitarModificacion();
                    }
                }

                if (EntradaalmacenMntFrm.IdEntidadMnt > 0)
                {
                    foreach (var item in VwCpcompradetimpentradaalmacenList.Where(x => x.Itemseleccionado))
                    {
                        Entradaalmacendet entradaalmacendetMnt = AsignarEntradaAlmacenDetalle(item);

                        int identradaalmacendet = Service.SaveEntradaalmacendet(entradaalmacendetMnt);
                        if (identradaalmacendet > 0)
                        {
                            //Verificar las ubicacion registradas por articulo
                            long cantidadRefUbicaciones = Service.CountVwArticuloubicacion(
                                x => x.Idarticulo == entradaalmacendetMnt.Idarticulo &&
                                x.Idalmacen == (int)iIdalmacen.EditValue);

                            if (cantidadRefUbicaciones == 0)
                            {
                                //Insertar ubicacion por defecto
                                Entradaalmacenubicacion entradaalmacenubicacion = new Entradaalmacenubicacion
                                {
                                    Identradaalmacendet = identradaalmacendet,
                                    Idubicacion         = AlmacenSel.Idubicaciondefecto,
                                    Cantidadarticulo    = entradaalmacendetMnt.Cantidad
                                };
                                Service.SaveEntradaalmacenubicacion(entradaalmacenubicacion);
                            }
                            else
                            {
                                //Insertar la ubicaciones del articulo del almacen seleccionado
                                List <VwArticuloubicacion> vwArticuloubicacionList = Service.GetAllVwArticuloubicacion(
                                    x => x.Idarticulo == entradaalmacendetMnt.Idarticulo &&
                                    x.Idalmacen == (int)iIdalmacen.EditValue);

                                foreach (var vwArticuloubicacion in vwArticuloubicacionList)
                                {
                                    Entradaalmacenubicacion entradaalmacenubicacion = new Entradaalmacenubicacion
                                    {
                                        Identradaalmacendet = identradaalmacendet,
                                        Idubicacion         = vwArticuloubicacion.Idubicacion,
                                        Cantidadarticulo    = entradaalmacendetMnt.Cantidad
                                    };
                                    Service.SaveEntradaalmacenubicacion(entradaalmacenubicacion);
                                }
                            }
                        }
                    }

                    EntradaalmacenMntFrm.CargarDetalle();
                    EntradaalmacenMntFrm.CargarDocumentoReferencia();
                }

                DialogResult = DialogResult.OK;

                break;

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

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


                break;

            case "btnCerrar":
                DialogResult = DialogResult.Cancel;
                break;
            }
        }
Example #5
0
        private void bmMantenimiento_ItemClick(object sender, ItemClickEventArgs e)
        {
            var subMenu = e.Item as BarSubItem;

            if (subMenu != null)
            {
                return;
            }
            switch (e.Item.Name)
            {
            case "btnNuevo":
                LimpiarCampos();

                TipoMnt = TipoMantenimiento.Nuevo;

                IdEntidadMnt          = 0;
                pkIdEntidad.EditValue = 0;

                NotadebitoMnt = null;
                NotadebitoMnt = new Notadebito();

                btnGrabar.Enabled       = true;
                btnGrabarCerrar.Enabled = true;
                btnGrabarNuevo.Enabled  = true;

                btnEliminar.Enabled   = false;
                btnActualizar.Enabled = false;

                ValoresPorDefecto();

                if (Permisos.Nuevo)
                {
                    CamposSoloLectura(false);
                }
                break;

            case "btnGrabar":
                if (Guardar())
                {
                    SeGuardoObjeto = true;
                    //btnGrabar.Enabled = false;
                    //btnGrabarCerrar.Enabled = false;
                    btnGrabarNuevo.Enabled = false;

                    if (IdEntidadMnt > 0)
                    {
                        TipoMnt = TipoMantenimiento.Modificar;
                    }

                    if (Permisos.Eliminar)
                    {
                        btnEliminar.Enabled   = true;
                        btnActualizar.Enabled = true;
                    }
                    //
                    DeshabilitarModificacion();
                }
                break;

            case "btnGrabarCerrar":
                if (Guardar())
                {
                    SeGuardoObjeto = true;
                    DialogResult   = DialogResult.OK;
                }
                break;

            case "btnEliminar":
                EliminaRegistro();
                break;

            case "btnLimpiarCampos":
                LimpiarCampos();
                break;

            case "btnActualizar":
                if (IdEntidadMnt > 0)
                {
                    TraerDatos();
                    CargarDetalle();
                }
                break;

            case "btnCerrar":
                if (SeGuardoObjeto)
                {
                    DialogResult = DialogResult.OK;
                }
                else
                {
                    NotadebitoMnt = null;
                    DialogResult  = DialogResult.OK;
                }
                break;

            case "btnImprimir":
                if (ImpresionFormato == null)
                {
                    ImpresionFormato = new ImpresionFormato();
                }
                if (IdEntidadMnt > 0)
                {
                }
                break;

            case "btnImportarCp":
                int idProveedorSel = (int)iIdproveedor.EditValue;
                if (idProveedorSel == 0)
                {
                    XtraMessageBox.Show("Seleccione el proveedor.", "Atención", MessageBoxButtons.OK,
                                        MessageBoxIcon.Error);
                    iIdproveedor.Select();
                    return;
                }

                var vwSocionegocioSel = VwSocionegocioList.FirstOrDefault(x => x.Idsocionegocio == (int)iIdproveedor.EditValue);

                NotadebitoImpCpCompraFrm notadebitoMntImpOcFrm = new NotadebitoImpCpCompraFrm(VwNotadebitodetList, vwSocionegocioSel);
                notadebitoMntImpOcFrm.ShowDialog();

                if (notadebitoMntImpOcFrm.DialogResult == DialogResult.OK)
                {
                    VwCpcompra vwCpcompraSelImp = notadebitoMntImpOcFrm.VwCpcompraSel;
                    if (vwCpcompraSelImp != null)
                    {
                        iIdproveedor.EditValue  = vwCpcompraSelImp.Idproveedor;
                        iIdtipomoneda.EditValue = vwCpcompraSelImp.Idtipomoneda;
                    }
                    foreach (var item in VwNotadebitodetList.Where(x => x.DataEntityState != DataEntityState.Deleted))
                    {
                        CalculaItem1(item);
                    }
                    SumarTotales();


                    iIdproveedor.Enabled = false;
                }


                break;
            }
        }
Example #6
0
        private void btnBuscarCp_Click(object sender, EventArgs e)
        {
            var idSocio = (int)iIdsocionegocio.EditValue;

            if (idSocio == 0)
            {
                XtraMessageBox.Show("Seleccione el SOCIO DE NEGOCIO", "Atención", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                beSocioNegocio.Select();
                return;
            }

            var idTipoCp = iIdtipocp.EditValue;

            if (idTipoCp == null)
            {
                XtraMessageBox.Show("Seleccione el tipo de documento", "Atención", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                iIdtipocp.Select();
                return;
            }


            int    idSucursal       = SessionApp.SucursalSel.Idsucursal;
            int    idSocionegocio   = (int)iIdsocionegocio.EditValue;
            string serieCotizacion  = (string)iSerietipocp.EditValue;
            string numeroCotizacion = (string)iNumerotipocp.EditValue;

            VwCpcompra cpcompra = Service.GetVwCpcompra(
                x => x.Idtipocp == (int)idTipoCp &&
                x.Idsucursal == idSucursal &&
                x.Seriecpcompra == serieCotizacion.Trim() &&
                x.Numerocpcompra == numeroCotizacion.Trim() &&
                x.Idproveedor == idSocionegocio &&
                x.Escajachica &&
                !x.Anulado
                );

            if (cpcompra != null)
            {
                //Verificar si tiene items el comprobante de compra
                long cantidadItemsCotizacion = Service.CountCpcompradet(x => x.Idcpcompra == cpcompra.Idcpcompra);
                if (cantidadItemsCotizacion <= 0)
                {
                    XtraMessageBox.Show("El comprobante no tiene items, verifique", "Atencion", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    iNumerotipocp.Text = @"0";
                    iNumerotipocp.Focus();
                    iNumerotipocp.Select();
                    iNumerotipocp.SelectAll();
                    return;
                }


                //Verificar si el recibo tiene cuadro rendicion
                Rendicioncajachicadet rendicioncajachicadet = Service.GetRendicioncajachicadet(
                    x => x.Idtipocp == cpcompra.Idtipocp &&
                    x.Serietipocp == cpcompra.Seriecpcompra &&
                    x.Numerotipocp == cpcompra.Numerocpcompra &&
                    x.Idsocionegocio == cpcompra.Idproveedor);

                if (rendicioncajachicadet != null)
                {
                    // string numeroDocCc = string.Format("{0}-{1}", rendicioncajachicadet.Serierendicioncaja.Trim(), rendicioncajachicadet.Numerorendicioncaja);
                    XtraMessageBox.Show("Comprobante ya fue importado", "Atención", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    iNumerotipocp.Text     = @"0";
                    rImportepago.EditValue = 0m;
                    iNumerotipocp.Focus();
                    iNumerotipocp.Select();
                    iNumerotipocp.SelectAll();
                    return;
                }

                List <VwCpcompradet> vwCpcompradets = Service.GetAllVwCpcompradet(x => x.Idcpcompra == cpcompra.Idcpcompra);

                string listadoitems = null;
                foreach (var item in vwCpcompradets)
                {
                    listadoitems = listadoitems + item.Nombrearticulo + " " + item.Nombremarca + ", ";
                }

                rImportepago.EditValue    = cpcompra.Totaldocumento;
                iFechatipocp.EditValue    = cpcompra.Fechaemision;
                iIdsocionegocio.EditValue = cpcompra.Idproveedor;
                if (listadoitems != null)
                {
                    iDescripciongasto.EditValue = listadoitems.Trim();
                }

                iNumerordendetrabajo.EditValue     = cpcompra.Numerordendetrabajo;
                iFechaordentrabajo.EditValue       = cpcompra.Fechaordentrabajo;
                iDescripcionordentrabajo.EditValue = cpcompra.Descripcionordentrabajo;
                iIdcpcompra.EditValue = cpcompra.Idcpcompra;

                rImportepago.Enabled = false;
                iFechatipocp.Enabled = false;


                XtraMessageBox.Show("COMPROBANTE DE COMPRA encontrado con exito", "Atencion", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                XtraMessageBox.Show("No se encontró el número de Recibo de Caja, verifique", "Atencion", MessageBoxButtons.OK, MessageBoxIcon.Warning);

                iNumerotipocp.EditValue = @"00000000";
                iNumerotipocp.Focus();
                iNumerotipocp.Select();
                iNumerotipocp.SelectAll();
            }
        }
Example #7
0
        private void bmMntItems_ItemClick(object sender, ItemClickEventArgs e)
        {
            var subMenu = e.Item as BarSubItem;

            if (subMenu != null)
            {
                return;
            }


            switch (e.Item.Name)
            {
            case "btnGrabarItem":
                var saldoporrendir = (decimal)rPorrendir.EditValue;

                var importegastado = (decimal)rImportepago.EditValue;

                if (importegastado > saldoporrendir)
                {
                    XtraMessageBox.Show("Gasto es Mayor al Saldo", "Atención", MessageBoxButtons.OK,
                                        MessageBoxIcon.Error);
                    //break;
                }


                int    idTipoCp         = (int)iIdtipocp.EditValue;
                int    idSucursal       = SessionApp.SucursalSel.Idsucursal;
                int    idSocionegocio   = (int)iIdsocionegocio.EditValue;
                string serieCotizacion  = (string)iSerietipocp.EditValue;
                string numeroCotizacion = (string)iNumerotipocp.EditValue;

                VwCpcompra cpcompra = Service.GetVwCpcompra(
                    x => x.Idtipocp == idTipoCp &&
                    x.Idsucursal == idSucursal &&
                    x.Seriecpcompra == serieCotizacion.Trim() &&
                    x.Numerocpcompra == numeroCotizacion.Trim() &&
                    x.Idproveedor == idSocionegocio &&
                    x.Escajachica &&
                    !x.Anulado
                    );

                if (cpcompra == null)
                {
                    XtraMessageBox.Show("Comprobante no registrado en comprobante", "Atencion",
                                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                    // iNumerotipocp.Text = @"0";
                    iNumerotipocp.Focus();
                    iNumerotipocp.Select();
                    iNumerotipocp.SelectAll();
                    return;
                }



                if (!Validaciones())
                {
                    return;
                }


                //VwRendicioncajachicadetMnt.Idrendicioncajachica = (int)iIdrendicioncajachica.EditValue;
                VwRendicioncajachicadetMnt.Idsocionegocio   = (int)iIdsocionegocio.EditValue;
                VwRendicioncajachicadetMnt.Numeroitem       = (int)iNumeroitem.EditValue;
                VwRendicioncajachicadetMnt.Idtipocp         = (int)iIdtipocp.EditValue;
                VwRendicioncajachicadetMnt.Serietipocp      = iSerietipocp.Text.Trim();
                VwRendicioncajachicadetMnt.Numerotipocp     = iNumerotipocp.Text.Trim();
                VwRendicioncajachicadetMnt.Importepago      = (decimal)rImportepago.EditValue;
                VwRendicioncajachicadetMnt.Fechatipocp      = (DateTime)iFechatipocp.EditValue;
                VwRendicioncajachicadetMnt.Descripciongasto = iDescripciongasto.Text.Trim();
                VwRendicioncajachicadetMnt.Idcpcompra       = (int)iIdcpcompra.EditValue;



                DialogResult = DialogResult.OK;

                break;

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