Beispiel #1
0
        /// <summary>
        /// Phương thức cập nhật một Room xuống csdl theo id
        /// </summary>
        /// <returns>true: thêm mới thành công, false: thêm mới thất bại</returns>
        public bool UpdateRoom(DTORoom Room)
        {
            try
            {
                return roomDAO.UpdateRoom(Room);
            }
            catch (SqlException)
            {

                throw;
            }
        }
Beispiel #2
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     if (roomMulitiSelect.Selection.Count == 0)
     {
         XtraCustomMessageBox.Show("Chưa có dòng dữ liệu nào được chọn!", "Thông báo", true, 1);
         return;
     }
     try
     {
         System.Collections.ArrayList _listroomObjectInDelibility = new System.Collections.ArrayList();
         foreach (object _rowObjectItem in roomMulitiSelect.Selection)
         {
             grdvListRoom.FocusedRowHandle -= 1;
             DataRowView _rowObjectDetail = _rowObjectItem as DataRowView;
             roomObject = new DTORoom(_rowObjectDetail.Row["RoomID"].ToString(), _rowObjectDetail.Row["RoomName"].ToString(), _rowObjectDetail.Row["RoomTypeID"].ToString(), Int32.Parse(_rowObjectDetail.Row["NumberOfBeds"].ToString()), _rowObjectDetail.Row["Description"].ToString(), _rowObjectDetail.Row["StatusID"].ToString());
             if (!roomBUS.DeleteRoom(roomObject.RoomID))
             {
                 _listroomObjectInDelibility.Add(_rowObjectDetail.Row["RoomID"]);
             }
         }
         String _erroContent = "Không thể xóa thông tin các thế loại sách có mã số: \n";
         if (_listroomObjectInDelibility.Count != 0)
         {
             foreach (var item in _listroomObjectInDelibility)
             {
                 _erroContent += item.ToString() + "\n";
             }
             XtraCustomMessageBox.Show(_erroContent, "Lỗi", true, 4);
         }
         else
             XtraCustomMessageBox.Show("Xóa dữ liệu thành công", "Thông báo", true, 1);
     }
     catch (System.Exception)
     {
         XtraCustomMessageBox.Show("Xóa dữ liệu thất bại", "Lỗi", true, 4);
     }
     finally
     {
         updateEnableButtonAndResetValueOfControl(ref btnDelete);
     }
 }
Beispiel #3
0
        /// <summary>
        /// Phương thức thêm mới một Room vào csdl
        /// </summary>
        /// <returns>true: thêm mới thành công, false: thêm mới thất bại</returns>
        public bool InsertRoom(DTORoom Room)
        {
            try
            {
                return roomDAO.InsertRoom(Room);
            }
            catch (SqlException)
            {

                throw;
            }
        }
Beispiel #4
0
        private void SaveDataToDatabase()
        {
            if (!checkData())
            {
                return;
            }
            try
            {
                if (m_IsAdd)
                {
                    String roomName = Utils.standardNamePerson(txtRoomName.Text);
                    String roomType = lkRoomType.EditValue.ToString();
                    int numberOfBeds = Int32.Parse(spNumberOfBeds.Value.ToString());
                    String Description = rtxtDecription.Text;
                    String status = lkStatus.EditValue.ToString();

                    roomObject = new DTORoom("PH00000000", roomName, roomType, numberOfBeds, Description, status);

                    if (roomBUS.InsertRoom(roomObject))
                    {
                        XtraCustomMessageBox.Show("Thêm dữ liệu thành công!", "Thông báo", true, 1);
                    }
                    else
                    {
                        XtraCustomMessageBox.Show("Thêm dữ liệu thất bại!", "Lỗi", true, 4);
                    }
                }
                else
                {
                    String roomName = Utils.standardNamePerson(txtRoomName.Text);
                    String roomType = lkRoomType.EditValue.ToString();
                    int numberOfBeds = Int32.Parse(spNumberOfBeds.Value.ToString());
                    String Description = rtxtDecription.Text;
                    String status = lkStatus.EditValue.ToString();

                    roomObject = new DTORoom(txtRoomId.Text, roomName, roomType, numberOfBeds, Description, status);

                    if (roomBUS.UpdateRoom(roomObject))
                    {
                        XtraCustomMessageBox.Show("Cập nhật dữ liệu thành công!", "Thông báo", true, 1);
                    }
                    else
                    {
                        XtraCustomMessageBox.Show("Cập nhật dữ liệu thất bại!", "Lỗi", true, 4);
                    }
                }

            }
            catch (System.Exception ex)
            {
                XtraCustomMessageBox.Show(ex.ToString(), "Lỗi", true, 3);
            }
            finally
            {
                updateEnableButtonAndResetValueOfControl(ref btnSave);
            }
        }