コード例 #1
0
        /// <summary>
        /// Obtiene registros del catalogo SegmentCategories
        /// </summary>
        /// <param name="nStatus">-1. Todos | 0. Inactivos | 1. Activos</param>
        /// <param name="segmenCategory">Objeto con filtros adicionales</param>
        /// <returns>Lista de tipo SegmentCategory</returns>
        /// <history>
        /// [emoguel] created 02/06/2016
        /// </history>
        public async static Task <List <SegmentCategory> > GetSegmentsCategories(int nStatus = -1, SegmentCategory segmenCategory = null)
        {
            List <SegmentCategory> lstSegmentsCategories = await Task.Run(() =>
            {
                using (var dbContext = new IMEntities(ConnectionHelper.ConnectionString()))
                {
                    var query = from sc in dbContext.SegmentsCategories
                                select sc;

                    if (nStatus != -1)//Filtro por estatus
                    {
                        bool blnStatus = Convert.ToBoolean(nStatus);
                        query          = query.Where(sc => sc.scA == blnStatus);
                    }

                    if (segmenCategory != null)                              //Verificamos que tengamos un objeto
                    {
                        if (!string.IsNullOrWhiteSpace(segmenCategory.scID)) //filtro por ID
                        {
                            query = query.Where(sc => sc.scID == segmenCategory.scID);
                        }

                        if (!string.IsNullOrWhiteSpace(segmenCategory.scN))//Filtro por Descripción
                        {
                            query = query.Where(sc => sc.scN.Contains(segmenCategory.scN));
                        }
                    }

                    return(query.OrderBy(sc => sc.scN).ToList());
                }
            });

            return(lstSegmentsCategories);
        }
コード例 #2
0
ファイル: BRZones.cs プロジェクト: jackjet870/IM-2
        /// <summary>
        /// OObtiene registros del catalogo Zones
        /// </summary>
        /// <param name="nStatus">-1 Todos | 0. inactivos | 1. Activos</param>
        /// <param name="zone">objeto con filtros adicionales</param>
        /// <returns>Lista de tipo ZOne</returns>
        /// <history>
        /// [emoguel] created 07/06/2016
        /// </history>
        public static async Task <List <Zone> > GetZones(int nStatus = -1, Zone zone = null)
        {
            List <Zone> lstZones = await Task.Run(() =>
            {
                using (var dbContext = new IMEntities(ConnectionHelper.ConnectionString()))
                {
                    var query = from zn in dbContext.Zones
                                select zn;

                    if (nStatus != -1)//filtro por estatus
                    {
                        bool blnStatus = Convert.ToBoolean(nStatus);
                        query          = query.Where(zn => zn.znA == blnStatus);
                    }

                    if (zone != null)
                    {
                        if (!string.IsNullOrWhiteSpace(zone.znID))//filtro por id
                        {
                            query = query.Where(zn => zn.znID == zone.znID);
                        }

                        if (!string.IsNullOrWhiteSpace(zone.znN))//Filtro por descripción
                        {
                            query = query.Where(zn => zn.znN.Contains(zone.znN));
                        }
                    }

                    return(query.OrderBy(zn => zn.znN).ToList());
                }
            });

            return(lstZones);
        }
コード例 #3
0
ファイル: BRTeamTypes.cs プロジェクト: jackjet870/IM-2
        /// <summary>
        /// Obtiene registros del catalogo TeamTypes
        /// </summary>
        /// <param name="nStatus">-1. Todos | 0. Inactivos | 1. Activos</param>
        /// <param name="teamType">Objeto con filtros adicionales</param>
        /// <returns>Lista tipo TeamType</returns>
        /// <history>
        /// [emoguel] created 27/04/2016
        /// [emoguel] modified 28/06/2016---> Se volvió async
        /// </history>
        public async static Task <List <TeamType> > GetTeamTypes(int nStatus = -1, TeamType teamType = null)
        {
            return(await Task.Run(() =>
            {
                using (var dbContext = new IMEntities(ConnectionHelper.ConnectionString()))
                {
                    var query = from tt in dbContext.TeamsTypes
                                select tt;

                    if (nStatus != -1)//Filtro por estatus
                    {
                        bool blnStatus = Convert.ToBoolean(nStatus);
                        query = query.Where(tt => tt.ttA == blnStatus);
                    }

                    if (teamType != null)
                    {
                        if (!string.IsNullOrWhiteSpace(teamType.ttID))
                        {
                            query = query.Where(tt => tt.ttID == teamType.ttID);
                        }
                        if (!string.IsNullOrWhiteSpace(teamType.ttN))
                        {
                            query = query.Where(tt => tt.ttN.Contains(teamType.ttN));
                        }
                    }
                    return query.OrderBy(tt => tt.ttN).ToList();
                }
            }));
        }
コード例 #4
0
ファイル: BRSalesRooms.cs プロジェクト: jackjet870/IM-2
 /// <summary>
 /// Obtiene los datos de una sala de ventas en específico.
 /// </summary>
 /// <param name="user"></param>
 /// <param name="regions"></param>
 /// <returns></returns>
 ///  <history>
 /// [edgrodriguez] 29/Feb/2016 Created
 /// </history>
 public static SalesRoomCloseDates GetSalesRoom(string salesRoom)
 {
     using (var dbContext = new IMEntities(ConnectionHelper.ConnectionString()))
     {
         return(dbContext.USP_OR_GetSalesRoom(salesRoom).FirstOrDefault());
     }
 }
コード例 #5
0
 /// <summary>
 /// Función que se encarga de guarda el historico de cambios realizados
 /// </summary>
 /// <param name="SalesRoomID"> Clave de la sala de ventas </param>
 /// <param name="HoursDif"> Horas de diferencia </param>
 /// <param name="ChangedBy"> Clave del usuario que esta haciendo el cambio </param>
 /// <history>
 /// [vipacheco] 02/03/2016 Created
 /// </history>
 public static void SaveSalesRoomLog(string SalesRoomID, Int16 HoursDif, string ChangedBy)
 {
     using (var dbContext = new IMEntities(ConnectionHelper.ConnectionString()))
     {
         dbContext.USP_OR_SaveSalesRoomLog(SalesRoomID, HoursDif, ChangedBy);
     }
 }
コード例 #6
0
        /// <summary>
        /// Devuelve el catalogo de AssistanceSatatus
        /// </summary>
        /// <param name="assistanceStatus">objeto con filtros extra, puede ser null</param>
        /// <param name="nStatus">-1. Sin filtro| 0. Inactivos| 1. Activos</param>
        /// <returns>Lista de AssitanceStatus</returns>
        /// <history>
        /// [emoguel] 27/Feb/2016 Created
        /// [emoguel] modified 17/03/2016--->Se agregó la validacion null del objeto y se cambió el filtro por descripcion a "contains"
        /// [emoguel] modified 30/05/2016--->Se volvió async
        /// </history>
        public async static Task <List <AssistanceStatus> > GetAssitanceStatus(AssistanceStatus assistanceStatus = null, int nStatus = -1)
        {
            List <AssistanceStatus> lstAssitanceStatus = new List <AssistanceStatus>();
            await Task.Run(() =>
            {
                using (var dbContext = new IMEntities(ConnectionHelper.ConnectionString()))
                {
                    var query = from ast in dbContext.AssistancesStatus
                                select ast;
                    if (nStatus != -1)//Filtra por status
                    {
                        bool bStat = Convert.ToBoolean(nStatus);
                        query      = query.Where(ast => ast.atA == bStat);
                    }

                    if (assistanceStatus != null)                              //validacion del objeto
                    {
                        if (!string.IsNullOrWhiteSpace(assistanceStatus.atID)) //Filtra por ID
                        {
                            query = query.Where(ast => ast.atID == assistanceStatus.atID);
                        }

                        if (!string.IsNullOrWhiteSpace(assistanceStatus.atN))//Filtra por Descripción
                        {
                            query = query.Where(ast => ast.atN.Contains(assistanceStatus.atN));
                        }
                    }

                    lstAssitanceStatus = query.OrderBy(a => a.atN).ToList();
                }
            });

            return(lstAssitanceStatus);
        }
コード例 #7
0
ファイル: BRSalesRooms.cs プロジェクト: jackjet870/IM-2
 /// <summary>
 /// Obtiene los registros de un Sales Room por su ID
 /// </summary>
 /// <param name="srID"> Identificador de Sales Room </param>
 /// <returns></returns>
 /// <history>
 /// [vipacheco] 14/Abril/2016 Created
 /// </history>
 public static SalesRoom GetSalesRoomByID(string srID)
 {
     using (var dbContext = new IMEntities(ConnectionHelper.ConnectionString()))
     {
         return(dbContext.SalesRooms.Where(x => x.srID == srID).FirstOrDefault());
     }
 }
コード例 #8
0
        /// <summary>
        /// Obtiene registros del catalogo SaleTypeCategories
        /// </summary>
        /// <param name="nStatus">-1. Todos | 0. Inactivos | 1. Activos</param>
        /// <param name="saleTypeCategory">Objeto con filtros adicionales</param>
        /// <returns>Lista de tipo SaleTypeCategory</returns>
        /// <history>
        /// [emoguel] created 19/04/2016
        /// [emoguel] modified 28/06/2016 -----> Se volvió async
        /// </history>
        public async static Task <List <SaleTypeCategory> > GetSaleCategories(int nStatus = -1, SaleTypeCategory saleTypeCategory = null)
        {
            return(await Task.Run(() =>
            {
                using (var dbContext = new IMEntities(ConnectionHelper.ConnectionString()))
                {
                    var query = from stc in dbContext.SaleTypesCategories
                                select stc;

                    if (nStatus != -1)//Filtro por estatus
                    {
                        bool blnStatus = Convert.ToBoolean(nStatus);
                        query = query.Where(stc => stc.stcA == blnStatus);
                    }

                    if (saleTypeCategory != null)//Verificamos que se tenga un objeto
                    {
                        if (!string.IsNullOrWhiteSpace(saleTypeCategory.stcID))
                        {
                            query = query.Where(stc => stc.stcID == saleTypeCategory.stcID);
                        }

                        if (!string.IsNullOrWhiteSpace(saleTypeCategory.stcN))//Filtro por descripción
                        {
                            query = query.Where(stc => stc.stcN.Contains(saleTypeCategory.stcN));
                        }
                    }
                    return query.OrderBy(stc => stc.stcN).ToList();
                }
            }));
        }
コード例 #9
0
        /// <summary>
        /// Guarda un sale Type Category.
        /// agregar sale Types al sale type category
        /// Eliminar saleTypes del sale type category
        /// </summary>
        /// <param name="saleTypeCategory">Objeto a guardar en la BD</param>
        /// <param name="blnUpdate">
        /// True. Actualiza
        /// False. Agrega
        /// </param>
        /// <param name="lstAddSaleTypes">Sale Types a agregar</param>
        /// <param name="lstDelSaleTypes">Sale Types a Eliiminar</param>
        /// <returns>-1.- Existe un registro con el mismo ID| 0. No se guardó | >0. Se guardó correctamente</returns>
        /// <history>
        /// [emoguel] created 01-08-2016
        /// </history>
        public static async Task <int> SaveSaleTypeCategory(SaleTypeCategory saleTypeCategory, bool blnUpdate, List <SaleType> lstAddSaleTypes, List <SaleType> lstDelSaleTypes)
        {
            return(await Task.Run(() =>
            {
                using (var dbContext = new IMEntities(ConnectionHelper.ConnectionString()))
                {
                    using (var transacction = dbContext.Database.BeginTransaction(System.Data.IsolationLevel.Serializable))
                    {
                        try
                        {
                            if (blnUpdate)
                            {
                                dbContext.Entry(saleTypeCategory).State = EntityState.Modified;
                            }
                            else
                            {
                                if (dbContext.SaleTypesCategories.Where(stc => stc.stcID == saleTypeCategory.stcID).FirstOrDefault() != null)
                                {
                                    return -1;
                                }
                                else
                                {
                                    dbContext.Entry(saleTypeCategory).State = EntityState.Added;
                                }
                            }

                            #region
                            //Agregar saleTypes
                            if (lstAddSaleTypes.Count > 0)
                            {
                                lstAddSaleTypes.ForEach(st =>
                                {
                                    st.ststc = saleTypeCategory.stcID;
                                    dbContext.Entry(st).State = EntityState.Modified;
                                });
                            }
                            //Eliminar saleTypes
                            if (lstDelSaleTypes.Count > 0)
                            {
                                lstDelSaleTypes.ForEach(st =>
                                {
                                    st.ststc = null;
                                    dbContext.Entry(st).State = EntityState.Modified;
                                });
                            }
                            #endregion

                            int nRes = dbContext.SaveChanges();
                            transacction.Commit();
                            return nRes;
                        }
                        catch
                        {
                            transacction.Rollback();
                            throw;
                        }
                    }
                }
            }));
        }
コード例 #10
0
 /// <summary>
 /// Función para obtener el log de exchenge rate de acuerdo a un currency especificado.
 /// </summary>
 /// <param name="currency"></param>
 /// <returns> Lista de tipo GetExchangeRateLog </returns>
 /// <history>
 /// [vipacheco] 05/03/2016 Created
 /// </history>
 public static List <ExchangeRateLogData> GetExchangeRateLog(string currency)
 {
     using (var dbContext = new IMEntities(ConnectionHelper.ConnectionString()))
     {
         return(dbContext.USP_OR_GetExchangeRateLog(currency).ToList());
     }
 }
コード例 #11
0
 /// <summary>
 /// Función que guarda el historico de un cambio en Exchange Rate
 /// </summary>
 /// <param name="currency"></param>
 /// <param name="date"></param>
 /// <param name="HoursDif"></param>
 /// <param name="ChangedBy"></param>
 /// <history>
 /// [vipacheco] 14/03/2016 Created
 /// </history>
 public static void SaveExchangeRateLog(string currency, DateTime date, Int16 HoursDif, string ChangedBy)
 {
     using (var dbContext = new IMEntities(ConnectionHelper.ConnectionString()))
     {
         dbContext.USP_OR_SaveExchangeRateLog(currency, date, HoursDif, ChangedBy);
     }
 }
コード例 #12
0
 /// <summary>
 /// Guarda una promocion de Opera
 /// </summary>
 /// <param name="Receipt"> Clave del recibo de regalos </param>
 /// <param name="Gift"> Clave del regalo </param>
 /// <param name="Promotion"> Clave de la promocion de Opera </param>
 /// <param name="Guest"> Clave del huesped </param>
 /// <param name="Quantity"> Cantidad </param>
 /// <param name="Date"> Fecha </param>
 /// <history>
 /// [vipacheco] 01/Junio/2016 Created
 /// </history>
 public static void SaveGuestPromotion(int Receipt, string Gift, string Promotion, int?Guest, int Quantity, DateTime Date)
 {
     using (var dbContext = new IMEntities(ConnectionHelper.ConnectionString()))
     {
         dbContext.USP_OR_SaveGuestPromotion(Receipt, Gift, Promotion, Guest, Quantity, Date);
     }
 }
コード例 #13
0
ファイル: BRHotelGroups.cs プロジェクト: jackjet870/IM-2
        /// <summary>
        /// Agrega|Actualiza registros en el catalogo HotelGroup
        /// Asigan|Desasigna Hotels de HotelGroups
        /// </summary>
        /// <param name="hotelGrooup">Objeto a guardar</param>
        /// <param name="blnUpdate">True. Actualiza | False. Inserta</param>
        /// <param name="lstAdd">Lista a asignar al Hotel Group</param>
        /// <param name="lstDel">Lista a Eliminar del grupo</param>
        /// <returns>-1. Existe un registro con el mismo ID | 0. No se pudo guardar | 1. Se guardó correctamente</returns>
        /// <history>
        /// [emoguel] created 13/05/2016
        /// [emoguel] modified 27/06/2016
        /// </history>
        public async static Task <int> SaveHotelGroup(HotelGroup hotelGrooup, bool blnUpdate, List <Hotel> lstAdd, List <Hotel> lstDel)
        {
            return(await Task.Run(() =>
            {
                using (var dbContext = new IMEntities(ConnectionHelper.ConnectionString()))
                {
                    using (var transacction = dbContext.Database.BeginTransaction(System.Data.IsolationLevel.Serializable))
                    {
                        try
                        {
                            #region Update
                            if (blnUpdate)
                            {
                                dbContext.Entry(hotelGrooup).State = EntityState.Modified;
                            }
                            #endregion

                            #region Add
                            else
                            {
                                if (dbContext.HotelsGroups.Where(hoo => hoo.hgID == hotelGrooup.hgID).FirstOrDefault() != null)
                                {
                                    return -1;
                                }
                                else
                                {
                                    dbContext.HotelsGroups.Add(hotelGrooup);
                                }
                            }
                            #endregion

                            #region List Add
                            dbContext.Hotels.AsEnumerable().Where(ho => lstAdd.Any(hoo => hoo.hoID == ho.hoID)).ToList().ForEach(ho =>
                            {
                                ho.hoGroup = hotelGrooup.hgID;
                                dbContext.Entry(ho).State = EntityState.Modified;
                            });
                            #endregion

                            #region ListDel
                            dbContext.Hotels.AsEnumerable().Where(ho => lstDel.Any(hoo => hoo.hoID == ho.hoID)).ToList().ForEach(ho =>
                            {
                                ho.hoGroup = null;
                                dbContext.Entry(ho).State = EntityState.Modified;
                            });
                            #endregion

                            int nRes = dbContext.SaveChanges();
                            transacction.Commit();
                            return nRes;
                        }
                        catch
                        {
                            transacction.Rollback();
                            return 0;
                        }
                    }
                }
            }));
        }
コード例 #14
0
ファイル: BRHotelGroups.cs プロジェクト: jackjet870/IM-2
        /// <summary>
        /// Obtiene registros del catalogo HotelGroups
        /// </summary>
        /// <param name="hotelGroup">Objeto con filtros adicionales</param>
        /// <param name="nStatus">-1. Todos los registros | 0. Registros inactivos | 1. Registros Activos</param>
        /// <returns>Lista de tipo HotelGroup</returns>
        /// <history>
        /// [emoguel] created 29/03/2016
        /// [emoguel] modified 27/06/2016 se volvió async
        /// </history>
        public async static Task <List <HotelGroup> > GetHotelGroups(HotelGroup hotelGroup = null, int nStatus = -1)
        {
            return(await Task.Run(() =>
            {
                using (var dbContext = new IMEntities(ConnectionHelper.ConnectionString()))
                {
                    var query = from hg in dbContext.HotelsGroups
                                select hg;

                    if (nStatus != -1)//Filtro por estatus
                    {
                        bool blnEstatus = Convert.ToBoolean(nStatus);
                        query = query.Where(hg => hg.hgA == blnEstatus);
                    }

                    if (hotelGroup != null)                              //Verificamos si tenemos un objeto
                    {
                        if (!string.IsNullOrWhiteSpace(hotelGroup.hgID)) //Filtro por ID
                        {
                            query = query.Where(hg => hg.hgID == hotelGroup.hgID);
                        }

                        if (!string.IsNullOrWhiteSpace(hotelGroup.hgN))//Filtro por descripcion
                        {
                            query = query.Where(hg => hg.hgN.Contains(hotelGroup.hgN));
                        }
                    }

                    return query.OrderBy(hg => hg.hgN).ToList();
                }
            }));
        }
コード例 #15
0
ファイル: BRFoliosCXCPR.cs プロジェクト: jackjet870/IM-2
        /// <summary>
        /// Obtiene personnels ligados a FoliosCxCPR
        /// </summary>
        /// <param name="personnelShort">Objeto con filtros adicionales</param>
        /// <returns>Lista tipo PersonnelShort</returns>
        /// <history>
        /// [emoguel] created 05/05/2016
        /// </history>
        public async static Task <List <PersonnelShort> > GetPRByFoliosCXC(PersonnelShort personnelShort = null)
        {
            List <PersonnelShort> lstPersonnelShort = await Task.Run(() =>
            {
                using (var dbContext = new IMEntities(ConnectionHelper.ConnectionString()))
                {
                    var query = from pe in dbContext.Personnels
                                join pr in dbContext.FoliosCxCPR
                                on pe.peID equals pr.fcppe
                                group pe by new { pe.peID, pe.peN } into p
                    select p;

                    if (personnelShort != null)
                    {
                        if (!string.IsNullOrWhiteSpace(personnelShort.peID))//Filtro por ID
                        {
                            query = query.Where(pe => pe.Key.peID == personnelShort.peID);
                        }

                        if (!string.IsNullOrWhiteSpace(personnelShort.peN))//Filtro por descripción
                        {
                            query = query.Where(pe => pe.Key.peN.Contains(personnelShort.peN));
                        }
                    }

                    List <PersonnelShort> lstPersonnelShorts = query.ToList().Select(pe => new PersonnelShort {
                        peID = pe.Key.peID, peN = pe.Key.peN
                    }).ToList();
                    return(lstPersonnelShorts.OrderBy(pe => pe.peN).ToList());
                }
            });

            return(lstPersonnelShort);
        }
コード例 #16
0
ファイル: BRMarkets.cs プロジェクト: jackjet870/IM-2
        /// <summary>
        ///Devuelve una lista de markets con todos sus datos incluyendo el status
        /// </summary>
        /// <param name="market">Objeto para filtros adicionales</param>
        /// <param name="nStatus">-1. Todos los registros | 0. Registros inactivos | 1. Registros Activos</param>
        /// <returns>Lista de markets</returns>
        /// <history>
        /// [emoguel]created 09/03/2016
        /// [emoguel] modified 17/03/2016--->Se agregó la validacion null del objeto y se cambió el filtro por descripcion a "contains"
        /// </history>
        public async static Task <List <Market> > GetMarkets(Market market = null, int nStatus = -1)
        {
            return(await Task.Run(() =>
            {
                using (var dbContext = new IMEntities(ConnectionHelper.ConnectionString()))
                {
                    var query = from mkt in dbContext.Markets
                                select mkt;

                    if (nStatus != -1)//Filtro por status
                    {
                        bool blnStatus = Convert.ToBoolean(nStatus);
                        query = query.Where(mkt => mkt.mkA == blnStatus);
                    }

                    if (market != null)                              //Valida si se tiene un objeto
                    {
                        if (!string.IsNullOrWhiteSpace(market.mkID)) //Filtro por ID
                        {
                            query = query.Where(mkt => mkt.mkID == market.mkID);
                        }

                        if (!string.IsNullOrWhiteSpace(market.mkN))//Filtro por Nombre(Descripcion)
                        {
                            query = query.Where(mkt => mkt.mkN.Contains(market.mkN));
                        }
                    }
                    return query.ToList();
                }
            }));
        }
コード例 #17
0
ファイル: BRFoliosCXCPR.cs プロジェクト: jackjet870/IM-2
 /// <summary>
 /// Valida que el rango de folios By PR no lo tenga asignado otro PR
 /// </summary>
 /// <param name="prID">ID del PR</param>
 /// <param name="From">incio del rango a validar</param>
 /// <param name="To">Final del rango a validar</param>
 /// <param name="blnIsCancel">True. Cancel Folios | False. FolioCXCPR</param>
 /// <returns>ValidateFolioCxCPR</returns>
 /// <history>
 /// [emoguel] created 06/05/2016
 /// </history>
 public static ValidationFolioData ValidateFolio(string prID, int from, int to, bool blnIsCancel)
 {
     using (var dbContext = new IMEntities(ConnectionHelper.ConnectionString()))
     {
         return(dbContext.USP_OR_ValidateFolioCxCPR(prID, from, to, blnIsCancel).FirstOrDefault());
     }
 }
コード例 #18
0
        /// <summary>
        /// Obtiene registros del catalogo desk
        /// </summary>
        /// <param name="desk">objeto con filtros adicionales</param>
        /// <param name="nStatus">-1. Todos los registros | 0. Registros inactivos | 1. registros activos</param>
        /// <returns>Lista de tipo desk</returns>
        /// <history>
        /// [emoguel] created 16/03/2016
        /// </history>
        public async static Task <List <Desk> > GetDesks(Desk desk = null, int nStatus = -1)
        {
            List <Desk> lstDesk = new List <Desk>();
            await Task.Run(() =>
            {
                using (var dbContext = new IMEntities(ConnectionHelper.ConnectionString()))
                {
                    var query = from dk in dbContext.Desks
                                select dk;

                    if (nStatus != -1)//Filtro por estatus
                    {
                        bool blnEstatus = Convert.ToBoolean(nStatus);
                        query           = query.Where(dk => dk.dkA == blnEstatus);
                    }

                    if (desk != null)      //validacion de si hay objeto
                    {
                        if (desk.dkID > 0) //Filtro por ID
                        {
                            query = query.Where(dk => dk.dkID == desk.dkID);
                        }

                        if (!string.IsNullOrWhiteSpace(desk.dkN))//Filtro por Nombre Descripcion
                        {
                            query = query.Where(dk => dk.dkN.Contains(desk.dkN));
                        }
                    }

                    lstDesk = query.OrderBy(dk => dk.dkN).ToList();
                }
            });

            return(lstDesk);
        }
コード例 #19
0
ファイル: BRSalesSalemen.cs プロジェクト: jackjet870/IM-2
        /// <summary>
        /// devuelve un boleando indicando si exite un registro de SaleAmountWith o SaleAmountOwn por venta y vendedor
        /// </summary>
        /// <history>
        /// [jorcanche] created 09/06/2016
        /// </history>
        public static SalesSalesman GetSalesSalesmens(SalesSalesman salesSalesmen = null)
        {
            List <SalesSalesman> result = null;

            using (var dbContext = new IMEntities(ConnectionHelper.ConnectionString()))
            {
                var query = from ss in dbContext.SalesSalesmen
                            select ss;
                if (salesSalesmen != null)
                {
                    if (salesSalesmen.smsa != 0)//filtro por ID
                    {
                        query = query.Where(ss => ss.smsa == salesSalesmen.smsa);
                    }
                    if (!String.IsNullOrWhiteSpace(salesSalesmen.smpe))//Filtro por descripcion
                    {
                        query = query.Where(ss => ss.smpe == salesSalesmen.smpe);
                    }
                    if (salesSalesmen.smSale)//Filtro por descripcion
                    {
                        query = query.Where(ss => ss.smSale == true);
                    }
                    if (salesSalesmen.smSaleAmountOwn != 0)//Filtro por descripcion
                    {
                        query = query.Where(ss => ss.smSaleAmountOwn == salesSalesmen.smSaleAmountOwn);
                    }
                    if (salesSalesmen.smSaleAmountWith != 0)//Filtro por descripcion
                    {
                        query = query.Where(ss => ss.smSaleAmountWith == salesSalesmen.smSaleAmountWith);
                    }
                }
                result = query.OrderBy(pt => pt.smsa).ToList();
            }
            return(result.FirstOrDefault());
        }
コード例 #20
0
        /// <summary>
        /// Agrega|Actualiza un registro en el catalogo Desk
        /// </summary>
        /// <param name="desk">Objeto a guardar en la BD</param>
        /// <param name="blnUpdate">True. Actualiza un registro | False. Agrega un registro</param>
        /// <param name="lstIdsComputers">id's de computers a relacionar</param>
        /// <returns>0. No se puedo guardar | > 0 . Se guardó correctamente | -1. Existe un registro con el mismo ID (Sólo cuando es insertar)</returns>
        /// <history>
        /// [emoguel] created 16/03/2016
        /// [emoguel] modified 09/06/2016---> se volvió async
        /// </history>
        public async static Task <int> SaveDesk(Desk desk, bool blnUpdate, List <string> lstIdsComputers)
        {
            int nRes = await Task.Run(() =>
            {
                using (var dbContext = new IMEntities(ConnectionHelper.ConnectionString()))
                {
                    using (var transacction = dbContext.Database.BeginTransaction(System.Data.IsolationLevel.Serializable))
                    {
                        try
                        {
                            #region Actualizar
                            if (blnUpdate)//Si es actualizar
                            {
                                dbContext.Entry(desk).State = System.Data.Entity.EntityState.Modified;
                            }
                            #endregion
                            #region Agregar
                            else//Si es guardar
                            {
                                dbContext.Desks.Add(desk);
                            }
                            #endregion

                            #region Actualizar Computers

                            #region Desaignar
                            var lstComputersDes = (from cmp in dbContext.Computers
                                                   where !lstIdsComputers.Contains(cmp.cpID) &&
                                                   cmp.cpdk == desk.dkID
                                                   select cmp).ToList();     //Buscamos todas las computers asigndas que ya no estan en la lista

                            lstComputersDes.ForEach(cmp => cmp.cpdk = null); //Des-relacionamos las computers que no esten en la nueva lista

                            #endregion

                            #region Asignar
                            var lstComputersAsi = (from cmp in dbContext.Computers
                                                   where lstIdsComputers.Contains(cmp.cpID)
                                                   select cmp).ToList();          //Buscamos todas las computers que se van a asignar

                            lstComputersAsi.ForEach(cmp => cmp.cpdk = desk.dkID); //Des-relacionamos las computers que no esten en la nueva lista

                            #endregion
                            #endregion

                            int nSave = dbContext.SaveChanges();
                            transacction.Commit();
                            return(nSave);
                        }
                        catch
                        {
                            transacction.Rollback();
                            return(0);
                        }
                    }
                }
            });

            return(nRes);
        }
コード例 #21
0
ファイル: BRSalesRooms.cs プロジェクト: jackjet870/IM-2
        /// <summary>
        /// Obtiene la fecha de cierre de algun Sales Room
        /// </summary>
        /// <param name="salesRoomType"></param>
        /// <param name="salesRoom"></param>
        /// <returns> DateTime </returns>
        /// <history>
        /// [vipacheco] 19/Abril/2016 Created
        /// [michan]  07/Junio/2016 Modified Se agregó la fecha de cierre de CxC
        /// </history>
        public static DateTime?GetCloseSalesRoom(EnumEntities salesRoomType, string salesRoom)
        {
            using (var dbContext = new IMEntities(ConnectionHelper.ConnectionString()))
            {
                SalesRoom _salesRoom;
                switch (salesRoomType)
                {
                case EnumEntities.Shows:
                    _salesRoom = dbContext.SalesRooms.Where(x => x.srID == salesRoom).SingleOrDefault();
                    return(_salesRoom.srShowsCloseD);

                case EnumEntities.MealTickets:
                    _salesRoom = dbContext.SalesRooms.Where(x => x.srID == salesRoom).SingleOrDefault();
                    return(_salesRoom.srMealTicketsCloseD);

                case EnumEntities.Sales:
                    _salesRoom = dbContext.SalesRooms.Where(x => x.srID == salesRoom).SingleOrDefault();
                    return(_salesRoom.srSalesCloseD);

                case EnumEntities.GiftsReceipts:
                    _salesRoom = dbContext.SalesRooms.Where(x => x.srID == salesRoom).SingleOrDefault();
                    return(_salesRoom.srGiftsRcptCloseD);

                case EnumEntities.CxC:
                    _salesRoom = dbContext.SalesRooms.Where(x => x.srID == salesRoom).SingleOrDefault();
                    return(_salesRoom.srCxCCloseD);

                default:
                    return(null);
                }
            }
        }
コード例 #22
0
ファイル: BRAreas.cs プロジェクト: jackjet870/IM-2
        /// <summary>
        /// Obtiene el catalogo de Areas
        /// </summary>
        /// <param name="nStatus">-1. Sin filtro| 0. Inactivos| 1. Activos</param>
        /// <param name="area">filtra dependiendo de los valores que contenga, puede ser null</param>
        /// <returns>Lista de Areas</returns>
        /// <history>
        /// [emoguel] 26/Feb/2016 Created
        /// [emoguel] modified 17/03/2016--->Se agregó la validacion null del objeto y se cambió el filtro por descripcion a "contains"
        /// </history>
        public async static Task <List <Area> > GetAreas(Area area = null, int nStatus = -1)
        {
            List <Area> lstAreas = new List <Area>();
            await Task.Run(() =>
            {
                using (var dbContext = new IMEntities(ConnectionHelper.ConnectionString()))
                {
                    var query = from areas in dbContext.Areas
                                select areas;

                    if (nStatus != -1)//filtro por estatus
                    {
                        bool bStat = Convert.ToBoolean(nStatus);
                        query      = query.Where(a => a.arA == bStat);
                    }

                    if (area != null)                              //Validacion del objeto
                    {
                        if (!string.IsNullOrWhiteSpace(area.arID)) //Filtra por ID
                        {
                            query = query.Where(a => a.arID == area.arID);
                        }
                        if (!string.IsNullOrWhiteSpace(area.arN))//Filtra por nombre
                        {
                            query = query.Where(a => a.arN.Contains(area.arN));
                        }
                    }
                    lstAreas = query.OrderBy(a => a.arN).ToList();//pasar el resultado a la lista
                }
            });

            return(lstAreas);
        }
コード例 #23
0
ファイル: BRReps.cs プロジェクト: jackjet870/IM-2
        /// <summary>
        /// Devuelve la lista de Reps
        /// </summary>
        /// <param name="rep">Entidad con filtros adicionales</param>
        /// <param name="nStatus">-1. Todos los registros | 0. Registros inactivos | 1.Registros Activos</param>
        /// <returns>Lista de reps</returns>
        /// <history>
        /// [Emoguel] created 11/03/2016
        /// [emoguel] modified 17/03/2016--->Se agregó la validacion null del objeto
        /// </history>
        public async static Task <List <Rep> > GetReps(Rep rep = null, int nStatus = -1)
        {
            List <Rep> lstReps = new List <Rep>();
            await Task.Run(() =>
            {
                using (var dbContext = new IMEntities(ConnectionHelper.ConnectionString()))
                {
                    var query = from r in dbContext.Reps select r;

                    if (nStatus != -1)//Filtro por Estatus
                    {
                        bool blnStatus = Convert.ToBoolean(nStatus);
                        query          = query.Where(r => r.rpA == blnStatus);
                    }

                    if (rep != null)                              //Valida si se tiene un objeto
                    {
                        if (!string.IsNullOrWhiteSpace(rep.rpID)) //Filtro por ID
                        {
                            query = query.Where(r => r.rpID == rep.rpID);
                        }
                    }

                    lstReps = query.OrderBy(r => r.rpID).ToList();
                }
            });

            return(lstReps);
        }
コード例 #24
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="changedBy"></param>
        /// <param name="password"></param>
        /// <param name="placeType"></param>
        /// <param name="placeID"></param>
        /// <param name="userType"></param>
        /// <param name="pR"></param>
        /// <returns></returns>
        /// <history>
        /// [jorcanche]  29/Mar/2016 Created
        /// </history>

        public static List <ValidationData> ValidateChangedByExist(string ptxtChangedBy, string ptxtPwd, string pstrLeadSource, string pstrUserType = "Changed By", string ptxtPR = "")
        {
            using (var dbContext = new IMEntities(ConnectionHelper.ConnectionString()))
            {
                return(dbContext.USP_OR_ValidateChangedBy(ptxtChangedBy, ptxtPwd, "LS", pstrLeadSource, pstrUserType, ptxtPR).ToList());
            }
        }
コード例 #25
0
 /// <summary>
 /// Función para obtener el log de Sales Room
 /// </summary>
 /// <param name="salesRoom"></param>
 /// <returns></returns>
 /// <history>
 /// [vipacheco] 22/02/2016 Created
 /// </history>
 public static List <SalesRoomLogData> GetSalesRoomLog(string salesRoom)
 {
     using (var dbContext = new IMEntities(ConnectionHelper.ConnectionString()))
     {
         return(dbContext.USP_OR_GetSalesRoomLog(salesRoom).ToList());
     }
 }
コード例 #26
0
 /// <summary>
 /// Consulta los pagos de un recibo de regalos
 /// </summary>
 /// <param name="receipt"> Clave del recibo de regalos </param>
 /// <returns></returns>
 /// <history>
 /// [vipacheco] 08/04/2016 Created
 /// </history>
 public static List <GiftsReceiptPayment> GetGiftsReceiptPayments(int GiftsReceipt)
 {
     using (var dbContext = new IMEntities(ConnectionHelper.ConnectionString()))
     {
         return(dbContext.GiftsReceiptsPayments.Where(x => x.gygr == GiftsReceipt).ToList());
     }
 }
コード例 #27
0
        /// <summary>
        /// Obtiene registros del catalogo SegmentByLeadSource
        /// </summary>
        /// <param name="nStatus">-1. Todos | 0. Inactivos | 1. Activos</param>
        /// <param name="segment">Objeto con filtros adicionales</param>
        /// <returns>Lista de tipo SegmentByLeadSource</returns>
        /// <history>
        /// [emoguel] created 16/05/2016
        /// </history>
        public async static Task <List <SegmentByLeadSource> > GetSegmentsByLeadSource(int nStatus = -1, SegmentByLeadSource segment = null)
        {
            List <SegmentByLeadSource> lstSegments = await Task.Run(() =>
            {
                using (var dbContext = new IMEntities(ConnectionHelper.ConnectionString()))
                {
                    var query = from so in dbContext.SegmentsByLeadSources
                                select so;

                    if (nStatus != -1)//Filtro por Estatus
                    {
                        bool blnStatus = Convert.ToBoolean(nStatus);
                        query          = query.Where(so => so.soA == blnStatus);
                    }

                    if (segment != null)
                    {
                        if (!string.IsNullOrWhiteSpace(segment.soID))//Filtro por ID
                        {
                            query = query.Where(so => so.soID == segment.soID);
                        }

                        if (!string.IsNullOrWhiteSpace(segment.soN))//Filtro por descripción
                        {
                            query = query.Where(so => so.soN.Contains(segment.soN));
                        }
                    }

                    return(query.OrderBy(so => so.soN).ToList());
                }
            });

            return(lstSegments);
        }
コード例 #28
0
 /// <summary>
 /// Obtiene un GiftsReceiptPayment de acuerdo a los criterios ingresados
 /// </summary>
 /// <param name="Receipt"></param>
 /// <param name="GiftPaymentID"></param>
 /// <returns></returns>
 /// <history>
 /// [vipacheco] 07/Mayo/2016 Created
 /// </history>
 public static GiftsReceiptPayment GetGiftReceiptPayment(int Receipt, int GiftPaymentID)
 {
     using (var dbContext = new IMEntities(ConnectionHelper.ConnectionString()))
     {
         return(dbContext.GiftsReceiptsPayments.Where(x => x.gygr == Receipt && x.gyID == GiftPaymentID).SingleOrDefault());
     }
 }
コード例 #29
0
        /// <summary>
        /// Obtiene registros del catalogo NotBoikingMotives
        /// </summary>
        /// <param name="nStatus">-1. Todos | 0. Inactivos | 1.Activos</param>
        /// <param name="notBookingMotive">Objeto con filtros adicionales</param>
        /// <returns>lista de tipo NotBookingMotive</returns>
        /// <history>
        /// [emoguel] created 05/04/2016
        /// </history>
        public async static Task <List <NotBookingMotive> > GetNotBookingMotives(int nStatus = -1, NotBookingMotive notBookingMotive = null)
        {
            return(await Task.Run(() =>
            {
                using (var dbContext = new IMEntities(ConnectionHelper.ConnectionString()))
                {
                    var query = from nb in dbContext.NotBookingMotives
                                select nb;

                    if (nStatus != -1)//Filtro por estatus
                    {
                        bool blnStatus = Convert.ToBoolean(nStatus);
                        query = query.Where(nb => nb.nbA == blnStatus);
                    }

                    #region Filtros adicionales
                    if (notBookingMotive != null)
                    {
                        if (notBookingMotive.nbID > 0)//Filtro por ID
                        {
                            query = query.Where(nb => nb.nbID == notBookingMotive.nbID);
                        }

                        if (!string.IsNullOrEmpty(notBookingMotive.nbN))//Filtro por Descripción
                        {
                            query = query.Where(nb => nb.nbN.Contains(notBookingMotive.nbN));
                        }
                    }
                    #endregion

                    return query.OrderBy(nb => nb.nbN).ToList();
                }
            }));
        }
コード例 #30
0
        /// <summary>
        /// Actualiza la posición de los registros de segmentcategory
        /// </summary>
        /// <param name="lstSegmentsCategoriesOrder">Lista de SegmentCategory</param>
        /// <returns>0. No se guardó | >0. Se guardó correctamente</returns>
        /// <history>
        /// [emoguel] created 03/06/2016
        /// </history>
        public static async Task <int> ChangeSegmentsCategoryOrder(List <SegmentCategory> lstSegmentsCategoriesOrder)
        {
            int nRes = await Task.Run(() =>
            {
                using (var dbContext = new IMEntities(ConnectionHelper.ConnectionString()))
                {
                    using (var transaction = dbContext.Database.BeginTransaction(System.Data.IsolationLevel.Serializable))
                    {
                        try
                        {
                            lstSegmentsCategoriesOrder.ForEach(sc =>
                            {
                                dbContext.Entry(sc).State = System.Data.Entity.EntityState.Modified;
                            });
                            int nSave = dbContext.SaveChanges();
                            transaction.Commit();
                            return(nSave);
                        }
                        catch
                        {
                            transaction.Rollback();
                            return(0);
                        }
                    }
                }
            });

            return(nRes);
        }