Exemplo n.º 1
0
 void InitValues(CinemaRoom room)
 {
     roomObject       = room.Clone() as CinemaRoom;
     textBoxName.Text = roomObject.RoomName;
     richTextBoxScheme.Document.Blocks.Clear();
     richTextBoxScheme.AppendText(roomObject.RoomScheme);
 }
        /*
         * // GET: CinemaRooms/Delete/5
         * public ActionResult Delete(int? id)
         * {
         *  if (id == null)
         *  {
         *      return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
         *  }
         *  CinemaRoom cinemaRoom = db.cinemaRooms.Find(id);
         *  if (cinemaRoom == null)
         *  {
         *      return HttpNotFound();
         *  }
         *  return View(cinemaRoom);
         * }
         *
         * // POST: CinemaRooms/Delete/5
         * [HttpPost, ActionName("Delete")]
         * [ValidateAntiForgeryToken]
         * public ActionResult DeleteConfirmed(int id)
         * {
         *  CinemaRoom cinemaRoom = db.cinemaRooms.Find(id);
         *  db.cinemaRooms.Remove(cinemaRoom);
         *  db.SaveChanges();
         *  return RedirectToAction("Index");
         * }
         */

        public ActionResult Delete(int id)
        {
            CinemaRoom cinemaRoom = db.cinemaRooms.Find(id);

            db.cinemaRooms.Remove(cinemaRoom);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 3
0
        internal static CinemaRoom ShowDialog_Redactor(CinemaRoom room)
        {
            Window_CinemaRoomRedactor wstr = new Window_CinemaRoomRedactor();

            wstr.InitValues(room);
            wstr.ShowDialog();
            return(wstr.okPress ? wstr.roomObject.Clone() as CinemaRoom : null);
        }
Exemplo n.º 4
0
        internal static void ShowDialog_View(CinemaRoom room)
        {
            Window_CinemaRoomRedactor wstr = new Window_CinemaRoomRedactor();

            wstr.InitValues(room);
            wstr.richTextBoxScheme.IsReadOnly = true;
            wstr.textBoxName.IsReadOnly       = true;
            wstr.ShowDialog();
        }
Exemplo n.º 5
0
        public void AddCinemaRoom(CinemaRoom val)
        {
            string sql = string.Format(
                "INSERT  INTO cinema_admin.cinema_rooms(room_name,room_scheme_object) VALUES (\"{0}\", \"{1}\");",
                val.RoomName,
                val.RoomScheme
                );

            val.Id = ExSql_Insert(sql);
        }
 public ActionResult Edit([Bind(Include = "CinemaRoomId,Name,Number")] CinemaRoom cinemaRoom)
 {
     if (ModelState.IsValid)
     {
         db.Entry(cinemaRoom).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(cinemaRoom));
 }
        public ActionResult Create([Bind(Include = "CinemaRoomId,Name,Number")] CinemaRoom cinemaRoom)
        {
            if (ModelState.IsValid)
            {
                db.cinemaRooms.Add(cinemaRoom);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(cinemaRoom));
        }
Exemplo n.º 8
0
        public void UpdateCinemaRoom(CinemaRoom val)
        {
            string sql = string.Format(
                "UPDATE cinema_admin.cinema_rooms SET room_name=\"{0}\",room_scheme_object=\"{1}\" WHERE id=\"{2}\";",
                val.RoomName,
                val.RoomScheme,
                val.GetId()
                );

            ExSql(sql);
        }
Exemplo n.º 9
0
        /// <summary>
        /// 删除影厅
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public JsonResult CinemaRoom_remove(string id)
        {
            CinemaRoom en = new CinemaRoom();

            en.id = Convert.ToInt32(id);

            DaCinemaRoom dal    = new DaCinemaRoom();
            var          result = new CustomJsonResult();

            result.Data = dal.delete(en);
            return(result);
        }
Exemplo n.º 10
0
        CinemaRoom DictionaryToCinemaRoom(Dictionary <string, object> dict)
        {
            if (dict == null)
            {
                return(null);
            }
            var res = new CinemaRoom();

            res.Id         = Convert.ToInt32(dict["id"]);
            res.RoomName   = Convert.ToString(dict["room_name"]);
            res.RoomScheme = Convert.ToString(dict["room_scheme_object"]);
            return(res);
        }
        public CinemaRoom getRoomByID(string id)
        {
            CinemaRoom room  = null;
            string     query = "SELECT * FROM PHONGCHIEU WHERE MaPhong = " + id;
            DataTable  data  = DataProvider.Instance.ExecuteQuery(query);

            foreach (DataRow item in data.Rows)
            {
                room = new CinemaRoom(item);
                return(room);
            }
            return(room);
        }
Exemplo n.º 12
0
        /// <summary>
        /// 删除影厅
        /// </summary>
        /// <param name="en"></param>
        /// <returns></returns>
        public int delete(CinemaRoom en)
        {
            string strSql = "delete from CinemaRoom where id=@id";

            SqlParameter[] param = new SqlParameter[]
            {
                new SqlParameter("@id", en.id)
            };

            int result = SqlHelper.ExecuteNonQuery(BaseHelper.DBConnStr, CommandType.Text, strSql, param);

            return(result);
        }
        public List <CinemaRoom> getRoomsByID(string id)
        {
            List <CinemaRoom> rooms = new List <CinemaRoom>();
            string            query = "SELECT * FROM PHONGCHIEU WHERE MaRap = " + id;
            DataTable         data  = DataProvider.Instance.ExecuteQuery(query);

            foreach (DataRow item in data.Rows)
            {
                CinemaRoom room = new CinemaRoom(item);
                rooms.Add(room);
            }
            return(rooms);
        }
Exemplo n.º 14
0
        public Result EditCinemaRoom(int cinemaId, int cinemaRoomId, CinemaRoomInfo cinemaRoomInfo)
        {
            if (!CinemaExists(cinemaId))
            {
                return(new Result
                {
                    ResultOk = false,
                    Details = "Such cinema does not exist."
                });
            }

            if (!CinemaRoomExists(cinemaRoomId))
            {
                return(new Result
                {
                    ResultOk = false,
                    Details = "Such cinema room does not exist."
                });
            }

            if (!CinemaRoomInfoValid(cinemaRoomInfo))
            {
                return(new ResultCreated
                {
                    ResultOk = false,
                    Details = "Invalid cinema room info."
                });
            }

            CinemaRoom cinemaRoom = dbContext.CinemaRooms
                                    .Include(r => r.Seats)
                                    .FirstOrDefault(r => r.CinemaRoomId == cinemaRoomId);

            cinemaRoom.Name = cinemaRoomInfo.Name;

            cinemaRoom.Seats = cinemaRoomInfo.Seats
                               .Select(s => new Seat
            {
                Type   = dbContext.SeatTypes.FirstOrDefault(st => st.TypeName == s.Type),
                Row    = s.Row,
                Column = s.Column
            }).ToList();


            dbContext.SaveChanges();

            return(new Result
            {
                ResultOk = true
            });
        }
        // GET: CinemaRooms/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CinemaRoom cinemaRoom = db.cinemaRooms.Find(id);

            if (cinemaRoom == null)
            {
                return(HttpNotFound());
            }
            return(View(cinemaRoom));
        }
Exemplo n.º 16
0
        public JsonResult CinemaRoom_add(string room, string cinemaID, string typeID, string memo)
        {
            CinemaRoom en = new CinemaRoom();

            en.room     = room;
            en.cinemaID = Convert.ToInt32(cinemaID);
            en.typeID   = Convert.ToInt32(typeID);
            en.memo     = memo;

            DaCinemaRoom dal    = new DaCinemaRoom();
            var          result = new CustomJsonResult();

            result.Data = dal.add(en);
            return(result);
        }
Exemplo n.º 17
0
        public JsonResult CinemaRoom_edit(string id, string name, string cinema, string type, string memo)
        {
            CinemaRoom en = new CinemaRoom();

            en.id       = Convert.ToInt32(id);
            en.room     = name;
            en.cinemaID = Convert.ToInt32(cinema);
            en.typeID   = Convert.ToInt32(type);
            en.memo     = memo;

            DaCinemaRoom dal    = new DaCinemaRoom();
            var          result = new CustomJsonResult();

            result.Data = dal.update(en);
            return(result);
        }
Exemplo n.º 18
0
        /// <summary>
        /// 新增影厅
        /// </summary>
        /// <param name="en"></param>
        /// <returns></returns>
        public int add(CinemaRoom en)
        {
            string strSql = "insert into CinemaRoom (cinemaID, room, typeID, memo) "
                            + "values (@cinemaID, @room, @typeID, @memo)";

            SqlParameter[] param = new SqlParameter[]
            {
                new SqlParameter("@cinemaID", en.cinemaID),
                new SqlParameter("@room", en.room),
                new SqlParameter("@typeID", en.typeID),
                new SqlParameter("@memo", en.memo)
            };

            int result = SqlHelper.ExecuteNonQuery(BaseHelper.DBConnStr, CommandType.Text, strSql, param);

            return(result);
        }
Exemplo n.º 19
0
        /// <summary>
        /// 修改影厅
        /// </summary>
        /// <param name="en"></param>
        /// <returns></returns>
        public int update(CinemaRoom en)
        {
            string strSql = "update CinemaRoom set cinemaID=@cinemaID, room=@room, typeID=@typeID, memo=@memo where id=@id";

            SqlParameter[] param = new SqlParameter[]
            {
                new SqlParameter("@id", en.id),
                new SqlParameter("@cinemaID", en.cinemaID),
                new SqlParameter("@room", en.room),
                new SqlParameter("@typeID", en.typeID),
                new SqlParameter("@memo", en.memo)
            };

            int result = SqlHelper.ExecuteNonQuery(BaseHelper.DBConnStr, CommandType.Text, strSql, param);

            return(result);
        }
Exemplo n.º 20
0
        public ResultCreated CreateCinemaRoom(int cinemaId, CinemaRoomInfo cinemaRoomInfo)
        {
            if (!CinemaExists(cinemaId))
            {
                return(new ResultCreated
                {
                    ResultOk = false,
                    Details = "Cinema does not exist."
                });
            }

            if (!CinemaRoomInfoValid(cinemaRoomInfo))
            {
                return(new ResultCreated
                {
                    ResultOk = false,
                    Details = "Invalid cinema room data."
                });
            }

            CinemaRoom cinemaRoom = new CinemaRoom
            {
                Name  = cinemaRoomInfo.Name,
                Seats = cinemaRoomInfo.Seats.Select(s => new Seat
                {
                    Type   = dbContext.SeatTypes.FirstOrDefault(seat => seat.TypeName == s.Type),
                    Row    = s.Row,
                    Column = s.Column
                }).ToList()
            };

            Cinema cinema = dbContext.Cinemas
                            .Include(c => c.CinemaRooms)
                            .FirstOrDefault(c => c.CinemaId == cinemaId);

            cinema.CinemaRooms.Add(cinemaRoom);

            dbContext.SaveChanges();

            return(new ResultCreated
            {
                ResultOk = true,
                Id = cinemaRoom.CinemaRoomId
            });
        }
Exemplo n.º 21
0
        static void PrintZaal(CinemaRoom PrintedRoom)
        {
            int printRow;

            for (int row = PrintedRoom.GetRows() - 1; row > -1; row--)
            {
                printRow = row + 1;
                Console.Write(printRow + "  ");
                for (int seat = 0; seat < PrintedRoom.GetSeatsPerRow(); seat++)
                {
                    if (PrintedRoom.SeatsRowCollection[row].RowSeats[seat].Available)
                    {
                        Console.Write(" _");
                    }
                    else
                    {
                        Console.Write(" *");
                    }
                }
                Console.WriteLine();
            }
        }
Exemplo n.º 22
0
        static void Main(string[] args)
        {
            CinemaRoom kinezaal    = new CinemaRoom(4, 10);
            FindSeats  seatsFinder = new FindSeats(kinezaal);

            PrintHeader();
            PrintZaal(kinezaal);

            var input = "";

            do
            {
                Console.WriteLine("How many tickets would you like to purchase?");
                input = Console.ReadLine();
                bool inputValid = Int32.TryParse(input, out int nrSeats);
                if (inputValid && nrSeats > 0)
                {
                    var succes = seatsFinder.FindInRoom(nrSeats);
                    if (succes)
                    {
                        PrintZaal(kinezaal);
                    }
                    else
                    {
                        Console.WriteLine("Couldn't find a seat");
                    }
                }
                else
                {
                    if (nrSeats != 0)
                    {
                        Console.WriteLine("That was not a valid number, input 0 to exit or a valid number");
                    }
                }
            } while (input != "0");
            Console.WriteLine("Thanks for your purchases");
            Console.ReadLine();
        }
Exemplo n.º 23
0
 public ActionResult EditCinemaRoom(CinemaRoom cinemaRoom)
 {
     _service.EditCinemaRoom(cinemaRoom);
     return(Ok());
 }
Exemplo n.º 24
0
 public ActionResult AddCinemaRoom(CinemaRoom cinemaRoom)
 {
     _service.AddCinemaRoom(cinemaRoom);
     return(Ok());
 }
Exemplo n.º 25
0
 public ActionResult DeleteCinemaRoom(CinemaRoom cinemaRoom)
 {
     _service.DeleteCinemaRoom(cinemaRoom);
     return(Ok());
 }
Exemplo n.º 26
0
        public void RemoveCinemaRoom(CinemaRoom val)
        {
            string sql = string.Format("DELETE FROM cinema_rooms WHERE id = \"{0}\" LIMIT 3;", val.GetId());

            ExSql(sql);
        }
Exemplo n.º 27
0
 public int AddCinemaRoom(CinemaRoom cinemaRoom)
 {
     _dbContext.CinemaRooms.Add(cinemaRoom);
     _dbContext.SaveChanges();
     return(cinemaRoom.Id);
 }
Exemplo n.º 28
0
 public void DeleteCinemaRoom(CinemaRoom cinemaRoom)
 {
     _dbContext.CinemaRooms.Remove(cinemaRoom);
     _dbContext.SaveChanges();
 }
Exemplo n.º 29
0
 public void EditCinemaRoom(CinemaRoom cinemaRoom)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 30
0
 private void buttonCancel_Click(object sender, RoutedEventArgs e)
 {
     roomObject = null;
     Close();
 }