public bool Booking(RESERVATION bookroom)
        {
            bool customerAdded = false;

            SqlConnection con     = new SqlConnection(ConnectionString);
            string        command = "RESERVATION_booking";
            SqlCommand    cmd     = new SqlCommand(command, con);

            cmd.CommandType = CommandType.StoredProcedure;

            cmd.Parameters.Add("@ReserveID", SqlDbType.UniqueIdentifier).Value = bookroom.RESERVE_ID;
            cmd.Parameters.Add("@CustID", SqlDbType.UniqueIdentifier).Value    = bookroom.CUST_ID;
            cmd.Parameters.Add("@ArrivalDate", SqlDbType.DateTime).Value       = bookroom.ARRIVAL_DATE;
            cmd.Parameters.Add("@Departure", SqlDbType.DateTime).Value         = bookroom.DEPARTURE_DATE;
            cmd.Parameters.Add("@RoomID", SqlDbType.NVarChar).Value            = bookroom.ROOM_ID;


            try
            {
                con.Open();
                cmd.ExecuteNonQuery();
                customerAdded = true;
            }
            catch (Exception ex)
            {
                throw;
            }

            con.Close();
            return(customerAdded);
        }
        public ContentResult Index(int?doctor_id, DateTime?time, string comment)
        {
            // var section = db.SECTION_TYPE.Select(s => s.SECTION_NM).ToList();
            if (doctor_id == null || time == null)
            {
                return(Content("error"));
            }
            if (Global.CurrentUserGroup != GroupType.Patient)
            {
                return(Content("group error"));
            }
            var r = new RESERVATION()
            {
                RESERVATION_ID = Global.NextReservationID(),
                DOCTOR_ID      = (int)doctor_id,
                TIME_START     = time,
                CONFIRMED      = "F",
                VALID          = time > DateTime.Now ? "T" : "F",
                PATIENT_ID     = Global.CurrentUserID,
                COMMENT        = comment,
                INSDATE        = DateTime.Now,
            };

            try
            {
                db.RESERVATION.Add(r);
                db.SaveChanges();
            }
            catch (Exception)
            {
                return(Content("database error"));
            }
            Response.Redirect("~/Patient/Index");
            return(Content("true"));
        }
        public RESERVATION Add(RESERVATION entity)
        {
            RESERVATION insertedReservation = null;

            if (CheckHelper.IsFilled(entity))
            {
                using (ctx = new ReadingRoomsEntities())
                {
                    entity.RES_ID = 1;

                    RESERVATION maxReservation = ctx.RESERVATIONs.OrderByDescending(s => s.RES_ID).FirstOrDefault();
                    if (CheckHelper.IsFilled(maxReservation))
                    {
                        entity.RES_ID = maxReservation.RES_ID + 1;
                    }

                    if (CheckHelper.IsFilled(entity.SEATs))
                    {
                        foreach (SEAT seat in entity.SEATs)
                        {
                            ctx.Entry(seat).State = EntityState.Unchanged;
                        }
                    }

                    insertedReservation = ctx.RESERVATIONs.Add(entity);
                    ctx.SaveChanges();
                }
            }

            return(insertedReservation);
        }
        private void EditButton_Click(object sender, RoutedEventArgs e)
        {
            RESERVATION selected = controller.GetReservation(ReservationList);

            ReservationEditor editorView = new ReservationEditor(selected);

            editorView.Show();
        }
Esempio n. 5
0
        public ReservationEditor(RESERVATION selectedReservation)
        {
            InitializeComponent();

            this.selectedReservation = selectedReservation;

            setAttributes();
        }
Esempio n. 6
0
 internal void Edit(RESERVATION reservation)
 {
     using (entity = new klassycafeEntities())
     {
         reservationRepo = new GenericRepo <RESERVATION>(entity);
         reservationRepo.Update(reservation);
         reservationRepo.Save();
     }
 }
Esempio n. 7
0
 internal void Add(RESERVATION reservation)
 {
     using (entity = new klassycafeEntities())
     {
         reservation.CREATED_DATE = DateTime.Now;
         reservationRepo          = new GenericRepo <RESERVATION>(entity);
         reservationRepo.Insert(reservation);
         reservationRepo.Save();
     }
 }
Esempio n. 8
0
        public ActionResult Reservation_Remove(int ID)
        {
            if (Session["UserId"] == null)
            {
                return(RedirectToAction("Login"));
            }

            RESERVATION r = reservationDA.GetById(ID);

            return(View(r));
        }
Esempio n. 9
0
 public bool PutReservation(RESERVATION reservation)
 {
     try
     {
         db.Entry(reservation).State = System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
         return(true);
     }
     catch (Exception ex) {
         return(false);
     }
 }
Esempio n. 10
0
        //
        // GET: /Reservation/
        public ActionResult Booking(DateTime ArrivalDate, DateTime DepertureDate, string RoomID)
        {
            RESERVATION BookRoom = new RESERVATION();

            BookRoom.ARRIVAL_DATE   = ArrivalDate;
            BookRoom.DEPARTURE_DATE = DepertureDate;
            BookRoom.ROOM_ID        = RoomID;
            BookRoom.CUST_ID        = SessionHandler.CurrentUser.UserID;
            BookRoom.RESERVE_ID     = Guid.NewGuid();
            BookRoom.Booking();
            return(RedirectToAction("Reserve_Room", "ReservationDetails", new { reservationID = BookRoom.RESERVE_ID }));
        }
 public void Delete(long id)
 {
     using (ctx = new ReadingRoomsEntities())
     {
         RESERVATION entity = ctx.RESERVATIONs.Where(s => s.RES_ID == id).FirstOrDefault();
         if (CheckHelper.IsFilled(entity))
         {
             ctx.RESERVATIONs.Remove(entity);
             ctx.SaveChanges();
         }
     }
 }
Esempio n. 12
0
        public ActionResult Reservation_Edit(int ID)
        {
            if (Session["UserId"] == null)
            {
                return(RedirectToAction("Login"));
            }

            RESERVATION reservation = reservationDA.GetById(ID);

            PopulateReservationStateDropdownList(reservation.RESERVATIONSTATE_ID);

            return(View(reservation));
        }
Esempio n. 13
0
        public bool PutReservation(RESERVATION reservation)
        {
            var isUpdated = sportsSideService.PutReservation(reservation);

            if (isUpdated)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 14
0
 public bool PostReservation(RESERVATION reservation)
 {
     try
     {
         db.RESERVATION.Add(reservation);
         db.SaveChanges();
         return(true);
     }
     catch (Exception e)
     {
         return(false);
     }
 }
        public RESERVATION Update(RESERVATION entity)
        {
            RESERVATION updatedReservation = null;

            using (ctx = new ReadingRoomsEntities())
            {
                updatedReservation      = ctx.RESERVATIONs.Attach(entity);
                ctx.Entry(entity).State = EntityState.Modified;
                ctx.SaveChanges();
            }

            return(updatedReservation);
        }
Esempio n. 16
0
 public ActionResult RemoveReservationForm(RESERVATION reservation)
 {
     try
     {
         reservationDA.Remove(reservation.ID);
         return(RedirectToAction("Reservations", "Admin"));
     }
     catch (Exception ex)
     {
         ViewBag.Error = "Try Again.";
         PopulateReservationStateDropdownList(reservation.RESERVATIONSTATE_ID);
         return(View("Reservation_Add", reservation));
     }
 }
        private void aDDRESERVATIONToolStripMenuItem_Click(object sender, EventArgs e)
        {
            foreach (Form f in this.MdiChildren)
            {
                if (f.GetType() == typeof(RESERVATION))
                {
                    f.Activate();
                    return;
                }
            }
            Form ITEMS = new RESERVATION();

            ITEMS.MdiParent = this;
            ITEMS.Show();
        }
Esempio n. 18
0
        internal RESERVATIONLIST GetByIdForList(int id)
        {
            using (entity = new klassycafeEntities())
            {
                reservationRepo = new GenericRepo <RESERVATION>(entity);
                stateRepo       = new GenericRepo <RESERVATIONSTATE>(entity);

                RESERVATION reservation = reservationRepo.FindByID(id);

                return(new RESERVATIONLIST()
                {
                    reservation = reservation,
                    reservationStateName = stateRepo.FindByID(reservation.RESERVATIONSTATE_ID).NAME
                });
            }
        }
        private void SaveButton_Click(object sender, RoutedEventArgs e)
        {
            int selectedRoom = controller.GetRoom(RoomList);

            if (Email.Text == "Guest E-mail" && reservation != null)
            {
                RESERVATION res = controller.findReservation(reservation);
                controller.associateReservation(selectedRoom.ToString(), res);
            }
            else
            {
                ReservationCreator resCreator = new ReservationCreator(selectedRoom.ToString(), checkIn, checkOut, Email.Text);
            }

            Close();
        }
Esempio n. 20
0
        public void addBookTable(string customerName, string phone, int idTable, DateTime date, TimeSpan time, int idUser)
        {
            using (QuanLyNhaHangDataContext db = new QuanLyNhaHangDataContext())
            {
                RESERVATION res = new RESERVATION();

                res.CUSTOMER_NAME = customerName;
                res.PHONE         = phone;
                res.ID_TABLE      = idTable;
                res.STATUS        = 0;
                res.DATE          = date;
                res.TIME          = time;
                res.ID_USER       = idUser;

                db.RESERVATIONs.InsertOnSubmit(res);
                db.SubmitChanges();
            }
        }
        public RESERVATION GetById(long id)
        {
            RESERVATION reservation = null;

            using (ctx = new ReadingRoomsEntities())
            {
                if (id > 0)
                {
                    reservation = ctx.RESERVATIONs
                                  .Where(s => s.RES_ID == id)
                                  .Include(s => s.SEATs)
                                  .Include(s => s.USER)
                                  .FirstOrDefault();
                }
            }

            return(reservation);
        }
        private void AddARandomSeat(RESERVATION resToAdd, ReservationDTO res)
        {
            SEAT freeRandomSeat = null;

            List <SEAT> schema = seatRepository.GetForReadingRoom(res.ReadingRoom.Id);

            foreach (var seat in schema)
            {
                if (seatRepository.IsFree(seat.SEAT_ID, res.ETA, res.ETD))
                {
                    freeRandomSeat = seat;
                    break;
                }
            }

            resToAdd.SEATs = new List <SEAT>();
            resToAdd.SEATs.Add(freeRandomSeat);
        }
Esempio n. 23
0
        protected void btnNewRandevu_Click(object sender, EventArgs e)
        {
            if (ValidateNewReservation())
            {
                RESERVATION rec = new RESERVATION();
                using (db = new novartz_stajyer1Entities())
                {
                    rec.ID       = Guid.NewGuid();
                    rec.MEMBERID = TEMPRESERVATION.MEMBERID;
                    rec.TYPERESERVATIONSTATUSID = TEMPRESERVATION.TYPERESERVATIONSTATUSID;
                    rec.FIRMDEPARTMENTMEMBERID  = TEMPRESERVATION.FIRMDEPARTMENTMEMBERID;
                    rec.DATE = TEMPRESERVATION.DATE;
                    db.RESERVATION.Add(rec);
                    db.SaveChanges();

                    TEMPRESERVATION = new RESERVATION();
                }
            }
        }
        //点击确认按钮后,修改confirm值为T,跳转后的页面上的button变为label,显示确认预约
        public ContentResult Confirm(int?reid)
        {
            var reservation = new RESERVATION()
            {
                CONFIRMED = "T",
            };
            var appointedReservation = db.RESERVATION.Find(reid);   //找到那个预约

            appointedReservation.CONFIRMED = reservation.CONFIRMED; //第四种方法,把comment值改为T
            try
            {
                db.SaveChanges();
            }
            catch (Exception)
            {
                return(Content("database error"));
            }
            return(Content("T"));
        }
Esempio n. 25
0
 public ActionResult Reservation_Add(RESERVATION reservation)
 {
     if (ModelState.IsValid)
     {
         try
         {
             reservation.RESERVATIONSTATE_ID = 1;
             ReservationDA.Add(reservation);
             return(Json(new { SuccessMsg = "Rezervation Added." }));
         }
         catch (Exception ex)
         {
             return(Json(new { ErrorMsg = "Try Again." }));
         }
     }
     else
     {
         return(Json(new { ErrorMsg = "Check All Fields." }));
     }
 }
        public async Task <IHttpActionResult> SaveReservation(int id, ReservationDTO r)
        {
            using (var db = new CalendarProjectEntities())
            {
                if (id != r.Id)
                {
                    return(BadRequest());
                }

                RESERVATION reservation = db.RESERVATIONs.FirstOrDefault(i => i.ID == id);

                if (reservation.RESERVED)
                {
                    return(BadRequest());
                }

                reservation.EMAIL     = r.Email;
                reservation.FIRSTNAME = r.Firstname;
                reservation.LASTNAME  = r.Lastname;
                reservation.RESERVED  = r.Reserved;

                db.Entry(reservation).State = EntityState.Modified;

                try
                {
                    await db.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (db.RESERVATIONs.Count(e => e.ID == id) > 0)
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(StatusCode(HttpStatusCode.NoContent));
            }
        }
        public HttpResponseMessage PostClient([FromBody] RESERVATION reservation)
        {
            try
            {
                using (TECAirlinesDBEntities entities = new TECAirlinesDBEntities())
                {
                    entities.INSERT_RESERVATION(reservation.TICKET_COUNT, reservation.LUGGAGE_COUNT, reservation.SEATS,
                                                reservation.CHECKIN,
                                                reservation.T_TYPE, reservation.PRICE, reservation.CLIENT_ID, reservation.FLIGHT_ID);
                    entities.SaveChanges();

                    var message = Request.CreateResponse(HttpStatusCode.Created, reservation);
                    message.Headers.Location = new Uri(Request.RequestUri + reservation.RESERVATION_ID.ToString());
                    return(message);
                }
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex));
            }
        }
Esempio n. 28
0
 public ActionResult EditReservationForm(RESERVATION reservation)
 {
     try
     {
         if (ModelState.IsValid)
         {
             reservationDA.Edit(reservation);
             return(RedirectToAction("Reservations", "Admin"));
         }
         else
         {
             ViewBag.Error = "Try Again.";
             PopulateReservationStateDropdownList(reservation.RESERVATIONSTATE_ID);
             return(View("Reservation_Add", reservation));
         }
     }
     catch (Exception ex)
     {
         ViewBag.Error = "Try Again.";
         PopulateReservationStateDropdownList(reservation.RESERVATIONSTATE_ID);
         return(View("Reservation_Add", reservation));
     }
 }
Esempio n. 29
0
        // Ajoute une réservation dans la base de données.
        public static void AddReservation(Reservation r)
        {
            RESERVATION reservation    = new RESERVATION();
            int         id_utilisateur = 0;
            var         req            = database.GetIdUtilisateur(r.utilisateur);

            foreach (var item in req)
            {
                id_utilisateur = item.ID_Utilisateur;
            }

            reservation.Date           = r.date;
            reservation.HeureDebut     = r.HeureDebut;
            reservation.HeureFin       = r.HeureFin;
            reservation.MinDebut       = r.MinDebut;
            reservation.MinFin         = r.MinFin;
            reservation.Detail         = r.detail;
            reservation.ID_Salle       = r.salle.id;
            reservation.ID_Utilisateur = id_utilisateur;
            reservation.NomR           = r.nomR;

            database.RESERVATION.InsertOnSubmit(reservation);
            database.SubmitChanges();
        }
        private List <RESERVATION> MapRESERVATION(DataTable dt)
        {
            List <RESERVATION> rs = new List <RESERVATION>();

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                RESERVATION obj = new RESERVATION();
                if (dt.Columns.Contains("ID"))
                {
                    obj.ID = dt.Rows[i]["ID"].ToString();
                }
                if (dt.Columns.Contains("RefDate"))
                {
                    obj.RefDate = DateTime.Parse(dt.Rows[i]["RefDate"].ToString());
                }
                if (dt.Columns.Contains("TransferDate"))
                {
                    obj.TransferDate = DateTime.Parse(dt.Rows[i]["TransferDate"].ToString());
                }
                if (dt.Columns.Contains("Ref_OrgNo"))
                {
                    obj.Ref_OrgNo = dt.Rows[i]["Ref_OrgNo"].ToString();
                }
                if (dt.Columns.Contains("RefType"))
                {
                    obj.RefType = int.Parse(dt.Rows[i]["RefType"].ToString());
                }
                if (dt.Columns.Contains("RefStatus"))
                {
                    obj.RefStatus = int.Parse(dt.Rows[i]["RefStatus"].ToString());
                }
                if (dt.Columns.Contains("Status"))
                {
                    obj.Status = int.Parse(dt.Rows[i]["Status"].ToString());
                }
                if (dt.Columns.Contains("Department_ID"))
                {
                    obj.Department_ID = dt.Rows[i]["Department_ID"].ToString();
                }
                if (dt.Columns.Contains("Employee_ID"))
                {
                    obj.Employee_ID = (dt.Rows[i]["Employee_ID"].ToString());
                }
                if (dt.Columns.Contains("FromStock_ID"))
                {
                    obj.FromStock_ID = (dt.Rows[i]["FromStock_ID"].ToString());
                }
                if (dt.Columns.Contains("Sender_ID"))
                {
                    obj.Sender_ID = (dt.Rows[i]["Sender_ID"].ToString());
                }
                if (dt.Columns.Contains("ToStock_ID"))
                {
                    obj.ToStock_ID = (dt.Rows[i]["ToStock_ID"].ToString());
                }
                if (dt.Columns.Contains("Receiver_ID"))
                {
                    obj.Receiver_ID = (dt.Rows[i]["Receiver_ID"].ToString());
                }
                if (dt.Columns.Contains("Barcode"))
                {
                    obj.Barcode = dt.Rows[i]["Barcode"].ToString();
                }
                if (dt.Columns.Contains("Branch_ID"))
                {
                    obj.Branch_ID = dt.Rows[i]["Branch_ID"].ToString();
                }
                if (dt.Columns.Contains("SO_ID"))
                {
                    obj.SO_ID = dt.Rows[i]["SO_ID"].ToString();
                }
                if (dt.Columns.Contains("PO_ID"))
                {
                    obj.PO_ID = dt.Rows[i]["PO_ID"].ToString();
                }
                if (dt.Columns.Contains("ProductOrder_ID"))
                {
                    obj.ProductOrder_ID = dt.Rows[i]["ProductOrder_ID"].ToString();
                }
                if (dt.Columns.Contains("Currency_ID"))
                {
                    obj.Currency_ID = dt.Rows[i]["Currency_ID"].ToString();
                }
                if (dt.Columns.Contains("ExchangeRate"))
                {
                    obj.ExchangeRate = double.Parse(dt.Rows[i]["ExchangeRate"].ToString());
                }
                if (dt.Columns.Contains("Amount"))
                {
                    obj.Amount = double.Parse(dt.Rows[i]["Amount"].ToString());
                }
                if (dt.Columns.Contains("IsReview"))
                {
                    obj.IsReview = bool.Parse(dt.Rows[i]["IsReview"].ToString());
                }
                if (dt.Columns.Contains("IsClose"))
                {
                    obj.IsClose = bool.Parse(dt.Rows[i]["IsClose"].ToString());
                }
                if (dt.Columns.Contains("Description"))
                {
                    obj.Description = dt.Rows[i]["Description"].ToString();
                }
                if (dt.Columns.Contains("Sorted"))
                {
                    obj.Sorted = int.Parse(dt.Rows[i]["Sorted"].ToString());
                }
                if (dt.Columns.Contains("User_ID"))
                {
                    obj.User_ID = dt.Rows[i]["User_ID"].ToString();
                }
                if (dt.Columns.Contains("CreateBy"))
                {
                    obj.CreateBy = dt.Rows[i]["CreateBy"].ToString();
                }
                if (dt.Columns.Contains("Createdate"))
                {
                    obj.Createdate = DateTime.Parse(dt.Rows[i]["Createdate"].ToString());
                }
                if (dt.Columns.Contains("ModifiedBy"))
                {
                    obj.ModifiedBy = dt.Rows[i]["ModifiedBy"].ToString();
                }
                if (dt.Columns.Contains("ModifiedDate"))
                {
                    obj.ModifiedDate = DateTime.Parse(dt.Rows[i]["ModifiedDate"].ToString());
                }
                //if (dt.Columns.Contains("Timestamp"))
                //obj.Timestamp = DateTime.Parse(dt.Rows[i]["Timestamp"].ToString());
                if (dt.Columns.Contains("Active"))
                {
                    obj.Active = bool.Parse(dt.Rows[i]["Active"].ToString());
                }
                rs.Add(obj);
            }
            return(rs);
        }