Exemplo n.º 1
0
        public JsonResult Create(string categoryName, int numberOfGuest)
        {
            CategoryRoom categoryRoom = new CategoryRoom
            {
                CategoryRoomID   = RandomString.getRandomString(5),
                CategoryRoomName = categoryName,
                NumberOfGuest    = numberOfGuest
            };

            var create = _dbContext.CategoryRooms.Add(categoryRoom);

            if (create != null)
            {
                try
                {
                    _dbContext.SaveChanges();
                    return(Json(new { data = "Thêm thành công", status = true }, JsonRequestBehavior.AllowGet));
                }
                catch (DbEntityValidationException e)
                {
                    return(Json(new { data = e.Message, status = false }, JsonRequestBehavior.AllowGet));
                }
            }
            else
            {
                return(Json(new { data = "Thêm thất bại", status = false }, JsonRequestBehavior.AllowGet));
            }
        }
Exemplo n.º 2
0
        public void CategoryArrToForm(CategoryRoom curCategoryRoom, ComboBox comboBox, bool isMustChoose)
        {
            //ממירה את הטנ"מ אוסף ישובים לטופס
            CategoryRoomArr catrgoryRoomArr     = new CategoryRoomArr();
            CategoryRoom    categoryRoomDefault = new CategoryRoom();

            categoryRoomDefault.ID = -1;
            if (isMustChoose)
            {
                categoryRoomDefault.CategoryRoomName = "Choose category";
            }
            else
            {
                categoryRoomDefault.CategoryRoomName = "Every category";
            }

            catrgoryRoomArr.Add(categoryRoomDefault);

            catrgoryRoomArr.Fill();
            comboBox.DataSource    = catrgoryRoomArr;
            comboBox.ValueMember   = "ID";
            comboBox.DisplayMember = "CategoryRoomName";
            if (curCategoryRoom != null)
            {
                comboBox.SelectedValue = curCategoryRoom.ID;
            }
        }
Exemplo n.º 3
0
 private void CategoryRoomToForm(CategoryRoom categoryRoom)
 {
     //ממירה את המידע בטנ"מ לקוח לטופס
     label_ID.Text         = categoryRoom.ID.ToString();
     textBox_category.Text = categoryRoom.CategoryRoomName;
     textBox_maxplace.Text = categoryRoom.MaxPlace.ToString();
     textBox_price.Text    = categoryRoom.Price.ToString();
 }
Exemplo n.º 4
0
        private CategoryRoom FormToCategoryRoom()
        {
            CategoryRoom categoryRoom = new CategoryRoom();

            categoryRoom.ID = int.Parse(label_ID.Text);
            categoryRoom.CategoryRoomName = textBox_category.Text;
            categoryRoom.MaxPlace         = int.Parse(textBox_maxplace.Text);
            categoryRoom.Price            = int.Parse(textBox_price.Text);
            return(categoryRoom);
        }
Exemplo n.º 5
0
        public static bool CreateCateRoom(CategoryRoom cr)
        {
            HotelAPIManagementEntities hm = new HotelAPIManagementEntities();

            hm.CategoryRooms.Add(cr);
            if (hm.SaveChanges() > 0)
            {
                return(true);
            }
            return(false);
        }
        // PUT api/<controller>/5
        public IHttpActionResult Put(int id, CategoryRoomView cr)
        {
            var item = new CategoryRoom {
                IDCateRoom = cr.IDCateRoom, NameCateRoom = cr.NameCateRoom, PriceCateRoom = cr.PriceCateRoom
            };

            if (Repositories.UpdateCateRoom(item) == true)
            {
                return(Ok());
            }
            return(InternalServerError());
        }
        // POST api/<controller>
        public IHttpActionResult Post(CategoryRoomView cr)
        {
            var newItem = new CategoryRoom {
                NameCateRoom = cr.NameCateRoom, PriceCateRoom = cr.PriceCateRoom
            };

            if (Repositories.CreateCateRoom(newItem) == true)
            {
                return(Ok());
            }
            return(InternalServerError());
        }
Exemplo n.º 8
0
        public static bool UpdateCateRoom(CategoryRoom cr)
        {
            HotelAPIManagementEntities hm = new HotelAPIManagementEntities();
            var item = hm.CategoryRooms.SingleOrDefault(s => s.IDCateRoom == cr.IDCateRoom);

            item.NameCateRoom  = cr.NameCateRoom;
            item.PriceCateRoom = cr.PriceCateRoom;
            if (hm.SaveChanges() > 0)
            {
                return(true);
            }
            return(false);
        }
Exemplo n.º 9
0
 private void button_save_Click(object sender, EventArgs e)
 {
     if (!CheckGood())
     {
         MessageBox.Show("You didn't write right", "TRY AGAIN", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error);
         All_White();
     }
     else
     {
         CategoryRoom categoryRoom = FormToCategoryRoom();
         if (categoryRoom.ID == 0)
         {
             CategoryRoomArr oldCategoryRoomArr = new CategoryRoomArr();
             oldCategoryRoomArr.Fill();
             if (!oldCategoryRoomArr.IsContain(categoryRoom.CategoryRoomName))
             {
                 if (categoryRoom.Insert())
                 {
                     MessageBox.Show("CategoryRoom Details Saved");
                     Clean_Form();
                     CategoryRoomArr categoryRoomArr = new CategoryRoomArr();
                     categoryRoomArr.Fill();
                     categoryRoom = categoryRoomArr.GetCategoryRoonWithMaxId();
                     CategoryRoomArrToForm(categoryRoom);
                 }
                 else
                 {
                     MessageBox.Show("Cannot Save CategoryRoom Details");
                 }
             }
             else
             {
                 MessageBox.Show("CategoryRoom already existing");
             }
         }
         else
         {
             if (categoryRoom.Update())
             {
                 MessageBox.Show("CategoryRoom Details UPDATED");
                 Clean_Form();
                 CategoryRoomArrToForm(null);
             }
             else
             {
                 MessageBox.Show("Cannot UPDATE CategoryRoom Details");
             }
         }
     }
 }
Exemplo n.º 10
0
        private void CategoryRoomArrToForm(CategoryRoom curCategoryRoom)
        {
            //ממירה את הטנ"מ אוסף לקוחות לטופס
            CategoryRoomArr CategoryRoomArr = new CategoryRoomArr();

            CategoryRoomArr.Fill();
            listBox_Category.DataSource    = CategoryRoomArr;
            listBox_Category.ValueMember   = "ID";
            listBox_Category.DisplayMember = "CategoryRoomName";

            //אם נשלח לפעולה ישוב ,הצבתו בתיבת הבחירה של ישובים בטופס

            if (curCategoryRoom != null)
            {
                listBox_Category.SelectedValue = curCategoryRoom.ID;
            }
        }
Exemplo n.º 11
0
        private void button_deleteCategoryRoom_Click(object sender, EventArgs e)
        {
            CategoryRoom categoryRoom = FormToCategoryRoom();

            if (categoryRoom.ID == 0)
            {
                MessageBox.Show("Please choice a CategoryRoom to delete");
            }
            else
            {
                if (MessageBox.Show("Are you sure to delete the categoryRoom: " + categoryRoom.CategoryRoomName + " " + " ? ", "Be Careful", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2, MessageBoxOptions.RightAlign | MessageBoxOptions.RtlReading) == System.Windows.Forms.DialogResult.Yes)
                {
                    categoryRoom.Delete();
                    Clean_Form();
                    CategoryRoomArrToForm(null);
                }
            }
        }
Exemplo n.º 12
0
        public void Create(CategoryRoomMv data)
        {
            var categoryRoom = new CategoryRoom()
            {
                Name        = data.Name,
                Price       = data.Price,
                Description = data.Description
            };

            try
            {
                _unitOfWork.CategoryRooms.Insert(categoryRoom);
                _unitOfWork.Commit();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }
Exemplo n.º 13
0
        public void Update(CategoryRoomMv category)
        {
            var data = new CategoryRoom()
            {
                Id          = category.Id,
                Name        = category.Name,
                Price       = category.Price,
                Description = category.Description
            };

            try
            {
                _unitOfWork.CategoryRooms.Update(data);
                _unitOfWork.Commit();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }
 public static bool UpdateCateRoom(CategoryRoom cr)
 {
     return(CategoryRoomDAO.UpdateCateRoom(cr));
 }
 public static bool CreateCateRoom(CategoryRoom cr)
 {
     return(CategoryRoomDAO.CreateCateRoom(cr));
 }