Ejemplo n.º 1
0
        public int InsertObjectToDB(Reservation dataObject)
        {
            var    insertReservation = SInsertScripts.SqlLiteDBInsertReservation(dataObject, dataObject.client_id, dataObject.services_id, dataObject.employee_id);
            string result            = DBConnectAndExecute.ExecuteQuery(insertReservation);

            if (result != string.Empty)
            {
                return(-1);
            }
            var lastAddedReservation = selectReservation.GetRowsForTable(SGetAllRowsFromSpecificTable.ReservationSelectAllRowsQuery())
                                       .Where(x => x.reservation_id == dataObject.reservation_id).First();

            return(lastAddedReservation.reservation_id);
        }
Ejemplo n.º 2
0
        public bool GetReservationIdAndInsertToDB(DateTime reservationDate, int reservationHour, int reservationMinute, int clientID, int servicesID, int employeeID)
        {
            int         reservationID = selectReservation.GetNextTabletId(SGetIdFromSpecificTable.queryGetLatestReservationID());
            Reservation reservation   = new Reservation()
            {
                reservation_id   = reservationID,
                reservation_date = reservationDate,
                reservation_time = new TimeSpan(reservationHour, reservationMinute, 0),
                client_id        = clientID,
                services_id      = servicesID,
                employee_id      = employeeID
            };

            if (selectReservation.GetRowsForTable(SGetAllRowsFromSpecificTable.ReservationSelectAllRowsQuery())
                .Any(x => x.reservation_date == reservation.reservation_date &&
                     x.reservation_time == reservation.reservation_time &&
                     x.employee_id == reservation.employee_id))
            {
                return(false);
            }
            SLogToFile.SaveDataTebleInToFile("reservation", reservation.ToString());
            insertReservation.InsertObjectToDB(reservation);
            return(true);
        }
Ejemplo n.º 3
0
        public List <VReservation> GetVReservations()
        {
            var clientsList     = selectClient.GetRowsForTable(SGetAllRowsFromSpecificTable.ClientSelectAllRowsQuery());
            var servicesList    = selectServices.GetRowsForTable(SGetAllRowsFromSpecificTable.ServicesSelectAllRowsQuery());
            var reservationList = selectReservation.GetRowsForTable(SGetAllRowsFromSpecificTable.ReservationSelectAllRowsQuery());
            var employeeList    = selectEmployee.GetRowsForTable(SGetAllRowsFromSpecificTable.EmployeeSelectAllRowsQuery());

            var result = reservationList.Join(clientsList,
                                              x => x.client_id,
                                              y => y.client_id,
                                              (x, y) => new
            {
                clName  = y.client_name,
                clSname = y.client_sname,
                clPhone = y.client_phone,
                clDesc  = y.client_description,
                resId   = x.reservation_id,
                resDate = x.reservation_date,
                resTime = x.reservation_time,
                serId   = x.services_id,
                empID   = x.employee_id,
                clId    = y.client_id
            })
                         .Join(servicesList,
                               x => x.serId,
                               y => y.services_id,
                               (x, y) => new
            {
                x.resId,
                x.resDate,
                x.resTime,
                x.clName,
                x.clSname,
                x.clPhone,
                x.clDesc,
                y.services_name,
                y.services_id,
                x.empID,
                x.clId
            })
                         .Join(employeeList,
                               x => x.empID,
                               y => y.employee_id,
                               (x, y) => new
            {
                x.clName,
                x.clSname,
                x.clPhone,
                x.clDesc,
                x.resId,
                x.resDate,
                x.resTime,
                x.services_id,
                x.services_name,
                empName = y.employee_name,
                x.empID,
                x.clId
            }).Select(x => new VReservation
            {
                reservation_id     = x.resId,
                reservation_date   = x.resDate,
                reservation_time   = x.resTime,
                client_name        = x.clName,
                client_sname       = x.clSname,
                client_phone       = x.clPhone,
                client_description = x.clDesc,
                services_name      = x.services_name,
                services_id        = x.services_id,
                employee_name      = x.empName,
                client_id          = x.clId,
                employee_id        = x.empID,
                client_data        = x.clName + " " + x.clSname + " " + x.clPhone + " " + x.clDesc
            }).OrderByDescending(x => x.reservation_date.ToShortDateString()).ThenByDescending(y => y.reservation_time).ToList();

            return(result);
        }
Ejemplo n.º 4
0
        public bool UpdateObject(Reservation dataobjectForChange, int id)
        {
            var    updateReservation = SUpdateScripts.SqlLiteDBUpdateReservation(dataobjectForChange, id);
            string result            = DBConnectAndExecute.ExecuteQuery(updateReservation);

            if (result != string.Empty)
            {
                return(false);
            }

            return(VerifyUpdateData(dataobjectForChange, selectReservation.GetRowsForTable(SGetAllRowsFromSpecificTable.ReservationSelectAllRowsQuery())
                                    .Where(x => x.reservation_id == id).First()));
        }