예제 #1
0
        public int GuardarReciboCajaIngreso(TipoMantenimiento tipoMantenimiento, int idCpVenta, Recibocajaingreso recibocajaingreso, List <VwRecibocajaingresodet> vWrecibocajaingresodetList)
        {
            using (var db = OrmLiteHelper.DbFactory.Open())
            {
                using (IDbTransaction trans = db.OpenTransaction(IsolationLevel.ReadCommitted))
                {
                    switch (tipoMantenimiento)
                    {
                    case TipoMantenimiento.Nuevo:
                        db.Save(recibocajaingreso);
                        if (recibocajaingreso.Idrecibocajaingreso > 0)
                        {
                            var tipocp = db.SingleById <Tipocp>(recibocajaingreso.Idtipocp);
                            if (tipocp.Numeracionauto)
                            {
                                db.Update <Tipocp>(new { Numerocorrelativocp = Convert.ToInt32(recibocajaingreso.Numerorecibo) + 1 }, p => p.Idtipocp == tipocp.Idtipocp);
                            }
                        }
                        break;

                    case TipoMantenimiento.Modificar:
                        db.Update(recibocajaingreso);
                        break;
                    }

                    if (recibocajaingreso.Idrecibocajaingreso > 0)
                    {
                        foreach (var item in vWrecibocajaingresodetList)
                        {
                            Recibocajaingresodet recibocajaingresodet = new Recibocajaingresodet();

                            recibocajaingresodet.Idrecibocajaingresodet = 0;
                            recibocajaingresodet.Idrecibocajaingreso    = recibocajaingreso.Idrecibocajaingreso;
                            recibocajaingresodet.Importepago            = item.Importepago;
                            recibocajaingresodet.Idmediopago            = item.Idmediopago;
                            recibocajaingresodet.Numeromediopago        = item.Numeromediopago;
                            recibocajaingresodet.Numeroitem             = item.Numeroitem;
                            recibocajaingresodet.Comentario             = item.Comentario;
                            recibocajaingresodet.Idcpventa        = idCpVenta;
                            recibocajaingresodet.Idnotacreditocli = item.Idnotacreditocli;
                            recibocajaingresodet.Importenc        = item.Importenc;


                            //Nuevo
                            if (item.Idrecibocajaingresodet == 0 && item.DataEntityState != DataEntityState.Deleted)
                            {
                                db.Save(recibocajaingresodet);
                                item.Idrecibocajaingresodet = recibocajaingresodet.Idrecibocajaingresodet;
                            }
                        }
                    }

                    trans.Commit();
                    return(recibocajaingreso.Idrecibocajaingreso);
                }
            }
        }
예제 #2
0
        private Recibocajaingresodet AsignarRecibocajaDetalle(VwRecibocajaingresodet vwRecibocajadet)
        {
            Recibocajaingresodet recibocajadetMnt = new Recibocajaingresodet
            {
                Idrecibocajaingreso    = IdEntidadMnt,
                Idrecibocajaingresodet = vwRecibocajadet.Idrecibocajaingresodet,
                Numeroitem             = vwRecibocajadet.Numeroitem,
                Importepago            = vwRecibocajadet.Importepago,
                Idmediopago            = vwRecibocajadet.Idmediopago,
                Numeromediopago        = vwRecibocajadet.Numeromediopago,
                Comentario             = vwRecibocajadet.Comentario,
                Idcpventa        = vwRecibocajadet.Idcpventa,
                Idnotacreditocli = vwRecibocajadet.Idnotacreditocli,
                Importenc        = vwRecibocajadet.Importenc
            };

            return(recibocajadetMnt);
        }
예제 #3
0
        public int GuardarCpVentaReciboIngreso(TipoMantenimiento tipoMantenimiento, Cpventa entidadCab, List <VwCpventadet> entidadDetList, Recibocajaingreso recibocajaingreso, List <VwRecibocajaingresodet> vWrecibocajaingresodetList)
        {
            using (var db = OrmLiteHelper.DbFactory.Open())
            {
                using (IDbTransaction trans = db.OpenTransaction(IsolationLevel.ReadCommitted))
                {
                    switch (tipoMantenimiento)
                    {
                    case TipoMantenimiento.Nuevo:
                        db.Save(entidadCab);
                        if (entidadCab.Idcpventa > 0)
                        {
                            var tipocp = db.SingleById <Tipocp>(entidadCab.Idtipocp);
                            if (tipocp.Numeracionauto)
                            {
                                db.Update <Tipocp>(new { Numerocorrelativocp = Convert.ToInt32(entidadCab.Numerocpventa) + 1 }, p => p.Idtipocp == tipocp.Idtipocp);
                            }
                        }
                        break;

                    case TipoMantenimiento.Modificar:
                        db.Update(entidadCab);
                        break;
                    }

                    if (entidadCab.Idcpventa > 0)
                    {
                        foreach (var item in entidadDetList)
                        {
                            Cpventadet cpventadet = new Cpventadet();

                            cpventadet.Idcpventadet         = item.Idcpventadet;
                            cpventadet.Idcpventa            = entidadCab.Idcpventa;
                            cpventadet.Numeroitem           = item.Numeroitem;
                            cpventadet.Idarticulo           = item.Idarticulo;
                            cpventadet.Articulomodificado   = item.Articulomodificado;
                            cpventadet.Nombrearticulo       = item.Nombrearticulo;
                            cpventadet.Idunidadmedida       = item.Idunidadmedida;
                            cpventadet.Idimpuesto           = item.Idimpuesto;
                            cpventadet.Cantidad             = item.Cantidad;
                            cpventadet.Preciounitario       = item.Preciounitario;
                            cpventadet.Especificacion       = item.Especificacion;
                            cpventadet.Descuento1           = item.Descuento1;
                            cpventadet.Descuento2           = item.Descuento2;
                            cpventadet.Descuento4           = item.Descuento4;
                            cpventadet.Descuento3           = item.Descuento3;
                            cpventadet.Preciounitarioneto   = item.Preciounitarioneto;
                            cpventadet.Importetotal         = item.Importetotal;
                            cpventadet.Porcentajepercepcion = item.Porcentajepercepcion;
                            cpventadet.Idtipoafectacionigv  = item.Idtipoafectacionigv;
                            cpventadet.Idalmacen            = item.Idalmacen;
                            cpventadet.Idarea            = item.Idarea;
                            cpventadet.Idproyecto        = item.Idproyecto;
                            cpventadet.Idcentrodecosto   = item.Idcentrodecosto;
                            cpventadet.Idordendeventadet = item.Idordendeventadet;
                            cpventadet.Idvalorizacion    = item.Idvalorizacion;
                            cpventadet.Calcularitem      = item.Calcularitem;
                            //ordencompradet.Createdby = item.Createdby;
                            //ordencompradet.Creationdate = item.Creationdate;
                            //ordencompradet.Modifiedby = item.Modifiedby;
                            //ordencompradet.Lastmodified = item.Lastmodified;

                            //Nuevo
                            if (item.Idcpventadet == 0 && item.DataEntityState != DataEntityState.Deleted)
                            {
                                db.Save(cpventadet);
                                item.Idcpventadet = cpventadet.Idcpventadet;
                            }

                            //Modificar
                            if (item.Idcpventadet > 0 && item.DataEntityState == DataEntityState.Modified)
                            {
                                db.Update(cpventadet);
                            }

                            //Eliminar
                            if (item.Idcpventadet > 0 && item.DataEntityState == DataEntityState.Deleted)
                            {
                                db.DeleteById <Cpventadet>(item.Idcpventadet);
                            }
                        }
                    }

                    //Verificar si hubo cambios en el orden de items
                    int cntNoOrden   = 0;
                    int nItemInicial = 0;
                    foreach (var item in entidadDetList.Where(x => x.DataEntityState != DataEntityState.Deleted))
                    {
                        if (nItemInicial + 1 != item.Numeroitem)
                        {
                            cntNoOrden++;
                        }
                        nItemInicial = item.Numeroitem;
                    }

                    if (cntNoOrden > 0)
                    {
                        int numeroItem = 1;
                        //Reenumerar y actualizar solo el nro de item
                        foreach (var item in entidadDetList.Where(x => x.DataEntityState != DataEntityState.Deleted))
                        {
                            item.Numeroitem = numeroItem;
                            Cpventadet cpventadet = new Cpventadet
                            {
                                Numeroitem   = item.Numeroitem,
                                Idcpventadet = item.Idcpventadet
                            };
                            db.Update <Cpventadet>(new { cpventadet.Numeroitem },
                                                   p => p.Idcpventadet == cpventadet.Idcpventadet);
                            numeroItem++;
                        }
                    }


                    //Grabar recibo


                    switch (tipoMantenimiento)
                    {
                    case TipoMantenimiento.Nuevo:
                        db.Save(recibocajaingreso);
                        if (recibocajaingreso.Idrecibocajaingreso > 0)
                        {
                            var tipocp = db.SingleById <Tipocp>(recibocajaingreso.Idtipocp);
                            if (tipocp.Numeracionauto)
                            {
                                db.Update <Tipocp>(new { Numerocorrelativocp = Convert.ToInt32(recibocajaingreso.Numerorecibo) + 1 }, p => p.Idtipocp == tipocp.Idtipocp);
                            }
                        }
                        break;

                    case TipoMantenimiento.Modificar:
                        db.Update(recibocajaingreso);
                        break;
                    }

                    if (recibocajaingreso.Idrecibocajaingreso > 0)
                    {
                        foreach (var item in vWrecibocajaingresodetList)
                        {
                            Recibocajaingresodet recibocajaingresodet = new Recibocajaingresodet();

                            recibocajaingresodet.Idrecibocajaingresodet = 0;
                            recibocajaingresodet.Idrecibocajaingreso    = recibocajaingreso.Idrecibocajaingreso;
                            recibocajaingresodet.Importepago            = item.Importepago;
                            recibocajaingresodet.Idmediopago            = item.Idmediopago;
                            recibocajaingresodet.Numeromediopago        = item.Numeromediopago;
                            recibocajaingresodet.Numeroitem             = item.Numeroitem;
                            recibocajaingresodet.Comentario             = item.Comentario;
                            recibocajaingresodet.Idcpventa = entidadCab.Idcpventa;

                            //Nuevo
                            if (item.Idrecibocajaingresodet == 0 && item.DataEntityState != DataEntityState.Deleted)
                            {
                                db.Save(recibocajaingresodet);
                                item.Idrecibocajaingresodet = recibocajaingresodet.Idrecibocajaingresodet;
                            }
                        }
                    }

                    trans.Commit();
                    return(entidadCab.Idcpventa);
                }
            }
        }
예제 #4
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;

                RecibocajaMnt = null;
                RecibocajaMnt = new Recibocajaingreso();

                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
                {
                    RecibocajaMnt = null;
                    DialogResult  = DialogResult.OK;
                }
                break;

            case "btnCtacteCliente":
                if (!ValidarDatosImportacion())
                {
                    return;
                }


                List <VwRecibocajaingresodet> vwRecibocajadetMntList = new List <VwRecibocajaingresodet>();

                RecibocajaImpCtacteClienteFrm recibocajaImpCtacteClienteFrm = new RecibocajaImpCtacteClienteFrm(vwRecibocajadetMntList, VwSocionegocioSel, (int)iIdtipomoneda.EditValue);
                recibocajaImpCtacteClienteFrm.ShowDialog();

                if (recibocajaImpCtacteClienteFrm.DialogResult == DialogResult.OK)
                {
                    VwRecibocajaingreso vwRecibocajaSelImp = recibocajaImpCtacteClienteFrm.VwRecibocajaSel;
                    if (vwRecibocajaSelImp != null)
                    {
                        iIdsocionegocio.EditValue = vwRecibocajaSelImp.Idsocionegocio;
                        iIdtipomoneda.EditValue   = vwRecibocajaSelImp.Idtipomoneda;
                    }

                    foreach (var item in vwRecibocajadetMntList)
                    {
                        Recibocajaingresodet recibocajadet = new Recibocajaingresodet();
                        recibocajadet.Idrecibocajaingreso    = IdEntidadMnt;
                        recibocajadet.Idrecibocajaingresodet = item.Idrecibocajaingresodet;
                        recibocajadet.Numeroitem             = item.Numeroitem;
                        recibocajadet.Importepago            = item.Importepago;
                        recibocajadet.Idmediopago            = item.Idmediopago;
                        recibocajadet.Numeromediopago        = item.Numeromediopago;
                        recibocajadet.Comentario             = item.Comentario;
                        recibocajadet.Idcpventa = item.Idcpventa;
                        Service.SaveRecibocajaingresodet(recibocajadet);
                    }

                    //Asignar la moneda


                    CargarDetalle();
                    CargarDetalleImprevistos();
                    SumarTotales(true);
                }
                break;

            case "btnImprimir":
                //if (EntradaalmacenImpresion == null)
                //{
                //    EntradaalmacenImpresion = new EntradaalmacenImpresion();
                //}
                //if (IdEntidadMnt > 0)
                //{
                //    EntradaalmacenImpresion.VistaPrevia(IdEntidadMnt);
                //}
                break;
            }
        }
예제 #5
0
        public bool Guardar()
        {
            if (!Validaciones())
            {
                return(false);
            }

            RecibocajaMnt.Idsucursal      = (int)iIdsucursal.EditValue;
            RecibocajaMnt.Idtipocp        = (int)iIdtipocp.EditValue;
            RecibocajaMnt.Idcptooperacion = (int)iIdcptooperacion.EditValue;
            RecibocajaMnt.Serierecibo     = rSerierecibo.Text.Trim();
            RecibocajaMnt.Numerorecibo    = rNumerorecibo.Text.Trim();
            RecibocajaMnt.Idempleado      = (int)iIdempleado.EditValue;
            RecibocajaMnt.Idsocionegocio  = (int)iIdsocionegocio.EditValue;
            RecibocajaMnt.Fecharecibo     = (DateTime)iFecharecibo.EditValue;
            RecibocajaMnt.Fechapago       = (DateTime)iFechapago.EditValue;
            RecibocajaMnt.Anulado         = (bool)iAnulado.EditValue;
            RecibocajaMnt.Fechaanulado    = (DateTime?)iFechaanulado.EditValue;
            RecibocajaMnt.Tipocambio      = (decimal)iTipocambio.EditValue;
            RecibocajaMnt.Idtipomoneda    = (int)iIdtipomoneda.EditValue;
            RecibocajaMnt.Comentario      = iComentario.Text.Trim();
            RecibocajaMnt.Idtiporecibo    = (int)iIdtiporecibo.EditValue;
            RecibocajaMnt.Totaldocumento  = (decimal)rTotaldocumento.EditValue;

            switch (TipoMnt)
            {
            case TipoMantenimiento.Nuevo:
                //RecibocajaMnt.Createdby = IdUsuario;
                //RecibocajaMnt.Creationdate = DateTime.Now;
                break;

            case TipoMantenimiento.Modificar:
                //RecibocajaMnt.Modifiedby = IdUsuario;
                //RecibocajaMnt.Lastmodified = DateTime.Now;
                break;
            }

            try
            {
                Cursor = Cursors.WaitCursor;
                switch (TipoMnt)
                {
                case TipoMantenimiento.Nuevo:
                    IdEntidadMnt = Service.SaveRecibocajaingreso(RecibocajaMnt);
                    RecibocajaMnt.Idrecibocajaingreso = IdEntidadMnt;
                    pkIdEntidad.EditValue             = IdEntidadMnt;

                    if (IdEntidadMnt > 0 &&
                        TipoCpMnt.Numeracionauto &&
                        Service.ActualizarCorrelativo((int)iIdtipocp.EditValue, Convert.ToInt32(rNumerorecibo.EditValue)))
                    {
                        iIdtipocp.ReadOnly        = true;
                        iIdcptooperacion.ReadOnly = true;
                    }

                    if (IdcpventaCita > 0)
                    {
                        VwCpventa vwCpventa = Service.GetVwCpventa(IdcpventaCita);
                        if (vwCpventa != null)
                        {
                            VwRecibocajaingresodet vwRecibocajaingresodet = new VwRecibocajaingresodet();
                            vwRecibocajaingresodet.Numeroitem = 1;

                            vwRecibocajaingresodet.Idtipodocmov    = vwCpventa.Idtipodocmov;
                            vwRecibocajaingresodet.Idtipocp        = vwCpventa.Idtipocp;
                            vwRecibocajaingresodet.Serietipocp     = vwCpventa.Seriecpventa;
                            vwRecibocajaingresodet.Numerotipocp    = vwCpventa.Numerocpventa;
                            vwRecibocajaingresodet.Importepago     = vwCpventa.Importetotal;
                            vwRecibocajaingresodet.Idmediopago     = 9; //Efectivo
                            vwRecibocajaingresodet.Numeromediopago = string.Empty;
                            vwRecibocajaingresodet.Comentario      = string.Empty;
                            vwRecibocajaingresodet.Idcpventa       = IdcpventaCita;

                            Recibocajaingresodet recibocajadet = AsignarRecibocajaDetalle(vwRecibocajaingresodet);

                            int idrecibocajadet = Service.SaveRecibocajaingresodet(recibocajadet);
                            if (idrecibocajadet > 0)
                            {
                                //vwRecibocajaingresodet.Idrecibocajaingresodet = idrecibocajadet;
                                //VwRecibocajadetList.Add(vwRecibocajaingresodet);

                                //Enfocar el id generado
                                if (idrecibocajadet > 0)
                                {
                                    CargarDetalle();
                                    var rowHandle = gvDetalle.LocateByValue("Idrecibocajaingresodet", idrecibocajadet);
                                    if (rowHandle != GridControl.InvalidRowHandle)
                                    {
                                        gvDetalle.FocusedRowHandle = rowHandle;
                                    }
                                }

                                gvDetalle.RefreshData();
                                gvDetalle.BestFitColumns(true);
                            }
                            CargarDetalleImprevistos();
                            SumarTotales(true);
                        }
                    }

                    break;

                case TipoMantenimiento.Modificar:
                    Service.UpdateRecibocajaingreso(RecibocajaMnt);
                    if (RecibocajaMnt.Anulado)
                    {
                        // Service.AnularReferenciaEntradaOrdenCompraDet(RecibocajaMnt.Idrecibocaja);
                    }
                    break;
                }
                if (IdEntidadMnt > 0)
                {
                    RegistrarValoresPorDefecto();
                }


                var numeroDoc = string.Format("{0} {1}-{2}", iIdtipocp.Text.Trim(), rSerierecibo.Text.Trim(), rNumerorecibo.Text.Trim());
                Cursor = Cursors.Default;

                XtraMessageBox.Show("Se guardo correctamente el documento " + numeroDoc, "Atención",
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch
            {
                Cursor = Cursors.Default;
                throw;
            }
            return(true);
        }
예제 #6
0
 public void UpdateRecibocajaingresodet(Recibocajaingresodet entity)
 {
     RecibocajaingresodetDao.Update(entity);
 }
예제 #7
0
 public int SaveRecibocajaingresodet(Recibocajaingresodet entity)
 {
     return(RecibocajaingresodetDao.Save(entity));
 }