예제 #1
0
        private bool MethodValidaCaja()
        {
            ESGR_AperturaCierreCaja FirstAperuraCaja = null;
            string Message = string.Empty;

            try
            {
                if (SGRVariables.ESGR_Usuario.ESGR_Perfil.IdPerfil == 1)
                {
                    #region BUSCA CAJAS ABIERTAS PARA ADMINISTRADOR

                    var result = CmpModalDialog.GetContent().ShowDialog("MPSGR_CajaAperturada", null);
                    if (result != null)
                    {
                        FirstAperuraCaja = new ESGR_AperturaCierreCaja()
                        {
                            ESGR_Caja = (ESGR_Caja)result
                        }
                    }
                    ;
                    else
                    {
                        System.Threading.Thread.Sleep(100);
                        new CmpNavigationService().Volver();
                    }

                    #endregion
                }
                else
                {
                    #region VALIDA SI TIENE CAJA APERTURADA

                    var CollectionAperuraCaja = new BSGR_AperturaCierreCaja().CollectionESGR_AperturaCierreCaja().Where(x => x.ESGR_Estado.CodEstado == "APTCJ").ToList();
                    FirstAperuraCaja = CollectionAperuraCaja.FirstOrDefault(x => x.ESGR_UsuarioCajero.IdUsuario == SGRVariables.ESGR_Usuario.IdUsuario);
                    if (FirstAperuraCaja == null)
                    {
                        CmpMessageBox.Show(SGRMessage.AdministratorVenta, SGRVariables.ESGR_Usuario.Nombres + ", no tiene Caja Aperturada.", CmpButton.Aceptar, () => new CmpNavigationService().Volver());
                    }

                    #endregion
                }
                return(FirstAperuraCaja == null);
            }
            catch (Exception ex)
            {
                CmpMessageBox.Show(SGRMessage.AdministratorVenta, ex.Message, CmpButton.Aceptar);
                return(true);
            }

            finally
            {
                if (FirstAperuraCaja != null)
                {
                    ESGR_Caja = FirstAperuraCaja.ESGR_Caja;
                }
            }
        }
 public void MethodTransaccionAperturaCaja(ESGR_AperturaCierreCaja ESGR_AperturaCierreCaja)
 {
     try
     {
         ObjCmpSql.CommandProcedure("spSGR_SET_AperturaCierreCaja");
         ObjCmpSql.AddParameter("@Opcion", SqlDbType.Char, ESGR_AperturaCierreCaja.Opcion);
         ObjCmpSql.AddParameter("@IdAperturaCierreCaja", SqlDbType.SmallInt, ESGR_AperturaCierreCaja.IdAperturaCierreCaja);
         ObjCmpSql.AddParameter("@IdCaja", SqlDbType.SmallInt, ESGR_AperturaCierreCaja.ESGR_Caja.IdCaja);
         ObjCmpSql.AddParameter("@FechaApertura", SqlDbType.DateTime, ESGR_AperturaCierreCaja.FechaApertura);
         ObjCmpSql.AddParameter("@FechaCierre", SqlDbType.DateTime, (ESGR_AperturaCierreCaja.FechaCierre == new DateTime()) ? DateTime.Now : ESGR_AperturaCierreCaja.FechaCierre);
         ObjCmpSql.AddParameter("@CodMotivo", SqlDbType.Char, ESGR_AperturaCierreCaja.ESGR_Motivo.CodMotivo);
         ObjCmpSql.AddParameter("@CodEstado", SqlDbType.Char, ESGR_AperturaCierreCaja.ESGR_Estado.CodEstado);
         ObjCmpSql.AddParameter("@Glosa", SqlDbType.VarChar, ESGR_AperturaCierreCaja.Glosa);
         ObjCmpSql.AddParameter("@IdUsuarioCajero", SqlDbType.Int, ESGR_AperturaCierreCaja.ESGR_UsuarioCajero.IdUsuario);
         ObjCmpSql.AddParameter("@IdUsuarioApertura", SqlDbType.Int, ESGR_AperturaCierreCaja.ESGR_UsuarioApertura.IdUsuario);
         ObjCmpSql.AddParameter("@DetalleXML", SqlDbType.NText, ESGR_AperturaCierreCaja.DetalleXML);
         ObjCmpSql.ExecuteNonQuery();
     }
     catch (Exception)
     {
         throw;
     }
 }
 public CmpObservableCollection <ESGR_AperturaCierreCajaDetalle> CollectionESGR_AperturaCierreCajaDetalle(ESGR_AperturaCierreCaja ESGR_AperturaCierreCaja)
 {
     try
     {
         var CollectionESGR_AperturaCierreCaja = new CmpObservableCollection <ESGR_AperturaCierreCajaDetalle>();
         ObjCmpSql.CommandProcedure("spSGR_GET_BusquedaGeneral");
         ObjCmpSql.AddParameter("@Opcion", SqlDbType.VarChar, "GetAperturaCierreCajaDetalle");
         ObjCmpSql.AddParameter("@Filtro", SqlDbType.VarChar, "%");
         ObjCmpSql.AddParameter("@ParameterId", SqlDbType.Int, ESGR_AperturaCierreCaja.IdAperturaCierreCaja);
         DataTable dt = ObjCmpSql.ExecuteDataTable();
         for (int x = 0; x < dt.Rows.Count; x++)
         {
             CollectionESGR_AperturaCierreCaja.Add(new ESGR_AperturaCierreCajaDetalle()
             {
                 Item        = (dt.Rows[x]["Item"] != DBNull.Value) ? Convert.ToInt32(dt.Rows[x]["Item"]) : 0,
                 ESGR_Moneda = new ESGR_Moneda()
                 {
                     CodMoneda   = (dt.Rows[x]["CodMoneda"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["CodMoneda"]) : string.Empty,
                     Descripcion = (dt.Rows[x]["Descripcion"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["Descripcion"]) : string.Empty
                 },
                 ESGR_MedioPago = new ESGR_MedioPago()
                 {
                     IdMedioPago = (dt.Rows[x]["IdMedioPago"] != DBNull.Value) ? (short)Convert.ToInt32(dt.Rows[x]["IdMedioPago"]) : (short)0,
                     MedioPago   = (dt.Rows[x]["MedioPago"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["MedioPago"]) : string.Empty
                 },
                 Monto_Inicio  = (dt.Rows[x]["Monto_Inicio"] != DBNull.Value) ? Convert.ToDecimal(dt.Rows[x]["Monto_Inicio"]) : 0,
                 Monto_Sistema = (dt.Rows[x]["Monto_Sistema"] != DBNull.Value) ? Convert.ToDecimal(dt.Rows[x]["Monto_Sistema"]) : 0,
                 Monto_Cierre  = (dt.Rows[x]["Monto_Cierre"] != DBNull.Value) ? Convert.ToDecimal(dt.Rows[x]["Monto_Cierre"]) : 0,
                 DiferExceso   = (dt.Rows[x]["DiferExceso"] != DBNull.Value) ? Convert.ToDecimal(dt.Rows[x]["DiferExceso"]) : 0
             });
         }
         return(CollectionESGR_AperturaCierreCaja);
     }
     catch (Exception)
     {
         throw;
     }
 }