Beispiel #1
0
            public PlazaGroup ToPlazaGroup()
            {
                PlazaGroup inst = new PlazaGroup();

                this.AssignTo(inst); // set all properties to new instance.
                return(inst);
            }
Beispiel #2
0
                public static PlazaShift Create(UserShift shift, PlazaGroup plazaGroup)
                {
                    var ret = new PlazaShift();

                    ret.Shift      = shift;
                    ret.PlazaGroup = plazaGroup;
                    return(ret);
                }
Beispiel #3
0
                public static GetActive Create(User user, PlazaGroup plazGroup)
                {
                    var ret = new GetActive();

                    ret.User       = user;
                    ret.PlazaGroup = plazGroup;
                    return(ret);
                }
Beispiel #4
0
                    public static ByUserShift Create(UserShift shift, PlazaGroup plazaGroup,
                                                     DateTime revenueDate)
                    {
                        var ret = new ByUserShift();

                        ret.Shift       = shift;
                        ret.PlazaGroup  = plazaGroup;
                        ret.RevenueDate = revenueDate;
                        return(ret);
                    }
Beispiel #5
0
 public static List <Lane> GetPlazaGroupLanes(PlazaGroup value)
 {
     lock (sync)
     {
         if (null == value)
         {
             return(new List <Lane>());
         }
         return(GetPlazaGroupLanes(value.TSBId, value.PlazaGroupId));
     }
 }
        public static UserShiftRevenue CreatePlazaRevenue(UserShift shift, PlazaGroup plazaGroup)
        {
            if (null == shift || null == plazaGroup)
            {
                return(null);
            }
            UserShiftRevenue inst = new UserShiftRevenue();

            plazaGroup.AssignTo(inst);
            shift.AssignTo(inst);
            return(inst);
        }
        public static UserShiftRevenue GetPlazaRevenue(UserShift shift, PlazaGroup plazaGroup)
        {
            lock (sync)
            {
                if (null == shift || null == plazaGroup)
                {
                    return(null);
                }
                string cmd = string.Empty;

                /*
                 * cmd += "SELECT UserShiftRevenue.* ";
                 * cmd += "     , TSB.TSBNameEN, TSB.TSBNameTH ";
                 * cmd += "     , PlazaGroup.PlazaGroupNameEN, PlazaGroup.PlazaGroupNameTH, PlazaGroup.Direction ";
                 * cmd += "     , Plaza.PlazaNameEN, Plaza.PlazaNameTH ";
                 * cmd += "     , Shift.ShiftNameEN, Shift.ShiftNameTH ";
                 * cmd += "     , User.FullNameEN, User.FullNameTH ";
                 * cmd += "  FROM UserShiftRevenue, TSB, PlazaGroup, Plaza, Shift, User, UserShift ";
                 * cmd += " WHERE PlazaGroup.TSBId = TSB.TSBId ";
                 * cmd += "   AND Plaza.TSBId = TSB.TSBId ";
                 * cmd += "   AND Plaza.PlazaGroupId = PlazaGroup.PlazaGroupId ";
                 * cmd += "   AND UserShift.ShiftId = Shift.ShiftId ";
                 * cmd += "   AND UserShift.UserId = User.UserId ";
                 * cmd += "   AND UserShiftRevenue.TSBId = TSB.TSBId ";
                 * cmd += "   AND UserShiftRevenue.PlazaGroupId = PlazaGroup.PlazaGroupId ";
                 * cmd += "   AND UserShiftRevenue.PlazaId = Plaza.PlazaId ";
                 * cmd += "   AND UserShiftRevenue.ShiftId = Shift.ShiftId ";
                 * cmd += "   AND UserShiftRevenue.UserId = User.UserId ";
                 * cmd += "   AND UserShiftRevenue.UserShiftId = ? ";
                 * cmd += "   AND UserShiftRevenue.PlazaGroupId = ? ";
                 */
                cmd += "SELECT UserShiftRevenue.* ";
                cmd += "     , TSB.TSBNameEN, TSB.TSBNameTH ";
                cmd += "     , PlazaGroup.PlazaGroupNameEN, PlazaGroup.PlazaGroupNameTH, PlazaGroup.Direction ";
                cmd += "     , Shift.ShiftNameEN, Shift.ShiftNameTH ";
                cmd += "     , User.FullNameEN, User.FullNameTH ";
                cmd += "  FROM UserShiftRevenue, TSB, PlazaGroup, Shift, User, UserShift ";
                cmd += " WHERE PlazaGroup.TSBId = TSB.TSBId ";
                cmd += "   AND UserShift.ShiftId = Shift.ShiftId ";
                cmd += "   AND UserShift.UserId = User.UserId ";
                cmd += "   AND UserShiftRevenue.TSBId = TSB.TSBId ";
                cmd += "   AND UserShiftRevenue.PlazaGroupId = PlazaGroup.PlazaGroupId ";
                cmd += "   AND UserShiftRevenue.ShiftId = Shift.ShiftId ";
                cmd += "   AND UserShiftRevenue.UserId = User.UserId ";
                cmd += "   AND UserShiftRevenue.UserShiftId = ? ";
                cmd += "   AND UserShiftRevenue.PlazaGroupId = ? ";
                var ret = NQuery.Query <FKs>(cmd, shift.UserShiftId,
                                             plazaGroup.PlazaGroupId).FirstOrDefault();
                return((null != ret) ? ret.ToUserShiftRevenue() : null);
            }
        }
Beispiel #8
0
        /// <summary>
        /// Gets Lanes (By PlazaGroup).
        /// </summary>
        /// <param name="value">The PlazaGroup instance.</param>
        /// <returns>Returns List fo Lanes.</returns>
        public static NDbResult <List <Lane> > GetPlazaGroupLanes(PlazaGroup value)
        {
            var result          = new NDbResult <List <Lane> >();
            SQLiteConnection db = Default;

            if (null == db)
            {
                result.DbConenctFailed();
                return(result);
            }
            lock (sync)
            {
                return(GetPlazaGroupLanes(value.TSBId, value.PlazaGroupId));
            }
        }
Beispiel #9
0
        /// <summary>
        /// Gets Plazas (By PlazaGroup).
        /// </summary>
        /// <param name="value">The PlazaGroup Instance.</param>
        /// <returns>Returns List of Plaza.</returns>
        public static NDbResult <List <Plaza> > GetPlazaGroupPlazas(PlazaGroup value)
        {
            var result          = new NDbResult <List <Plaza> >();
            SQLiteConnection db = Default;

            if (null == value)
            {
                result.ParameterIsNull();
                return(result);
            }

            lock (sync)
            {
                return(GetPlazaGroupPlazas(value.TSBId, value.PlazaGroupId));
            }
        }
Beispiel #10
0
        /// <summary>
        /// Create Plaza Revenue.
        /// </summary>
        /// <param name="shift">The UserShift instance.</param>
        /// <param name="plazaGroup">The PlazaGroup instance.</param>
        /// <returns>Returns UserShiftRevenue instance.</returns>
        public static NDbResult <UserShiftRevenue> CreatePlazaRevenue(
            UserShift shift, PlazaGroup plazaGroup)
        {
            var result = new NDbResult <UserShiftRevenue>();

            if (null == shift || null == plazaGroup)
            {
                result.ParameterIsNull();
                result.data = null;
            }
            else
            {
                UserShiftRevenue inst = Create();
                plazaGroup.AssignTo(inst);
                shift.AssignTo(inst);
                result.data = inst;
                result.Success();
            }
            return(result);
        }
Beispiel #11
0
        /// <summary>
        /// Gets Plaza Revenue.
        /// </summary>
        /// <param name="shift">The Shift instance.</param>
        /// <param name="plazaGroup">The PlazaGroup instance.</param>
        /// <returns>Returns UserShiftRevenue instance.</returns>
        public static NDbResult <UserShiftRevenue> GetPlazaRevenue(
            UserShift shift, PlazaGroup plazaGroup)
        {
            var result          = new NDbResult <UserShiftRevenue>();
            SQLiteConnection db = Default;

            if (null == db)
            {
                result.DbConenctFailed();
                return(result);
            }
            if (null == shift || null == plazaGroup)
            {
                result.ParameterIsNull();
                return(result);
            }
            lock (sync)
            {
                MethodBase med = MethodBase.GetCurrentMethod();
                try
                {
                    string cmd = string.Empty;
                    cmd += "SELECT * ";
                    cmd += "  FROM UserShiftRevenueView ";
                    cmd += " WHERE UserShiftId = ? ";
                    cmd += "   AND PlazaGroupId = ? ";
                    var ret = NQuery.Query <FKs>(cmd,
                                                 shift.UserShiftId, plazaGroup.PlazaGroupId).FirstOrDefault();
                    result.data = (null != ret) ? ret.ToModel() : null;
                    result.Success();
                }
                catch (Exception ex)
                {
                    med.Err(ex);
                    result.Error(ex);
                }
                return(result);
            }
        }
        /// <summary>
        /// Search.
        /// </summary>
        /// <param name="shift">The User Shift instance.</param>
        /// <param name="plazaGroup">The PlazaGroup instance.</param>
        /// <param name="revenueDate">The Revenue Date Time.</param>
        /// <returns>Returns List of LaneAttendance.</returns>
        public static NDbResult <List <LaneAttendance> > Search(UserShift shift,
                                                                PlazaGroup plazaGroup, DateTime revenueDate)
        {
            var result          = new NDbResult <List <LaneAttendance> >();
            SQLiteConnection db = Default;

            if (null == db)
            {
                result.DbConenctFailed();
                return(result);
            }
            if (null == shift)
            {
                result.ParameterIsNull();
                return(result);
            }
            lock (sync)
            {
                MethodBase med = MethodBase.GetCurrentMethod();
                try
                {
                    string cmd = string.Empty;

                    cmd += "SELECT * ";
                    cmd += "  FROM LaneAttendanceView ";
                    cmd += " WHERE UserId = ? ";
                    cmd += "   AND (Begin >= ? AND Begin <= ?)";
                    cmd += "   AND ((End >= ? AND End <= ?) " +
                           "        OR  End = ?) ";
                    if (null != plazaGroup)
                    {
                        cmd += "   AND PlazaGroupId = ? ";
                    }
                    if (revenueDate == DateTime.MinValue)
                    {
                        cmd += "   AND (RevenueDate IS NULL ";
                        cmd += "        OR RevenueDate = ?) ";
                    }
                    else
                    {
                        cmd += "   AND RevenueDate = ? ";
                    }
                    cmd += " ORDER BY UserId, Begin";

                    DateTime end = (shift.End == DateTime.MinValue) ? DateTime.Now : shift.End;
                    if (null != plazaGroup)
                    {
                        var rets = NQuery.Query <FKs>(cmd,
                                                      shift.UserId,
                                                      shift.Begin, end,
                                                      shift.Begin, end,
                                                      DateTime.MinValue,
                                                      plazaGroup.PlazaGroupId,
                                                      revenueDate).ToList();
                        var results = rets.ToModels();
                        result.Success(results);
                    }
                    else
                    {
                        var rets = NQuery.Query <FKs>(cmd,
                                                      shift.UserId,
                                                      shift.Begin, end,
                                                      shift.Begin, end,
                                                      DateTime.MinValue,
                                                      revenueDate).ToList();
                        var results = rets.ToModels();
                        result.Success(results);
                    }
                }
                catch (Exception ex)
                {
                    med.Err(ex);
                    result.Error(ex);
                }
                return(result);
            }
        }
        public static List <LaneAttendance> Search(UserShift shift, PlazaGroup plazaGroup,
                                                   DateTime revenueDate)
        {
            if (null == shift)
            {
                return(new List <LaneAttendance>());
            }
            lock (sync)
            {
                string cmd = string.Empty;

                cmd += "SELECT LaneAttendance.* ";
                cmd += "     , TSB.TSBNameEN, TSB.TSBNameTH ";
                cmd += "     , PlazaGroup.PlazaGroupNameEN, PlazaGroup.PlazaGroupNameTH, PlazaGroup.Direction ";
                cmd += "     , Plaza.PlazaNameEN, Plaza.PlazaNameTH ";
                cmd += "     , Lane.LaneNo ";
                cmd += "     , User.FullNameEN, User.FullNameTH ";
                cmd += "  FROM LaneAttendance, TSB, PlazaGroup, Plaza, Lane, User ";
                cmd += " WHERE PlazaGroup.TSBId = TSB.TSBId ";
                cmd += "   AND Plaza.TSBId = TSB.TSBId ";
                cmd += "   AND Plaza.PlazaGroupId = PlazaGroup.PlazaGroupId ";
                cmd += "   AND Lane.TSBId = TSB.TSBId ";
                cmd += "   AND Lane.PlazaGroupId = PlazaGroup.PlazaGroupId ";
                cmd += "   AND Lane.PlazaId = Plaza.PlazaId ";
                cmd += "   AND LaneAttendance.TSBId = TSB.TSBId ";
                cmd += "   AND LaneAttendance.PlazaGroupId = PlazaGroup.PlazaGroupId ";
                cmd += "   AND LaneAttendance.PlazaId = Plaza.PlazaId ";
                cmd += "   AND LaneAttendance.LaneId = Lane.LaneId ";
                cmd += "   AND LaneAttendance.UserId = User.UserId ";
                cmd += "   AND LaneAttendance.UserId = ? ";
                cmd += "   AND (LaneAttendance.Begin >= ? AND LaneAttendance.Begin <= ?)";
                cmd += "   AND ((LaneAttendance.End >= ? AND LaneAttendance.End <= ?) " +
                       "        OR  LaneAttendance.End = ?)";
                if (null != plazaGroup)
                {
                    cmd += "   AND LaneAttendance.PlazaGroupId = ? ";
                }

                if (revenueDate == DateTime.MinValue)
                {
                    cmd += "   AND (LaneAttendance.RevenueDate IS NULL ";
                    cmd += "        OR LaneAttendance.RevenueDate = ?) ";
                }
                else
                {
                    cmd += "   AND LaneAttendance.RevenueDate = ? ";
                }

                DateTime end = (shift.End == DateTime.MinValue) ? DateTime.Now : shift.End;

                if (null != plazaGroup)
                {
                    return(NQuery.Query <FKs>(cmd,
                                              shift.UserId,
                                              shift.Begin, end,
                                              shift.Begin, end,
                                              DateTime.MinValue,
                                              plazaGroup.PlazaGroupId,
                                              revenueDate).ToList <LaneAttendance>());
                }
                else
                {
                    return(NQuery.Query <FKs>(cmd,
                                              shift.UserId,
                                              shift.Begin, end,
                                              shift.Begin, end,
                                              DateTime.MinValue,
                                              revenueDate).ToList <LaneAttendance>());
                }
            }
        }