示例#1
0
            public RoomTypeRow AddRoomTypeRow(long RMTYPEID, string NAME, string SHORTNAME)
            {
                RoomTypeRow rowRoomTypeRow = ((RoomTypeRow)(this.NewRow()));

                object[] columnValuesArray = new object[] {
                    RMTYPEID,
                    NAME,
                    SHORTNAME
                };
                rowRoomTypeRow.ItemArray = columnValuesArray;
                this.Rows.Add(rowRoomTypeRow);
                return(rowRoomTypeRow);
            }
示例#2
0
        private void pgRoomStatus_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            if (App.mainWindow.Visibility == Visibility.Visible)
            {
                if (Auth.GetLoginStatus() && Auth.GetLoggedInUserTypeIsCustomer() == false)
                {
                    // Disable buttons
                    btnRoomDetail.IsEnabled = false;
                    btnSearch.IsEnabled     = true;


                    // Load Hotel info
                    SqlCommand cmd = new SqlCommand();
                    cmd.Connection  = dbQLKS.dbConnection;
                    cmd.CommandType = CommandType.Text;
                    cmd.CommandText = @"select * from KhachSan as KS, NhanVien as NV
                                        where NV.maNV = '" + Auth.GetLoggedInUserId() + "' AND NV.MaKS = KS.maKS";

                    SqlDataReader dr;

                    dbQLKS.dbConnection.Open();

                    dr = cmd.ExecuteReader();

                    if (dr.Read())
                    {
                        lblHotelName.Content    = dr["tenKS"].ToString();
                        lblHotelAddress.Content = dr["soNha"] + ", " + dr["duong"] + ", " + dr["quan"] + ", " + dr["thanhPho"];
                        MaKS = dr["maKS"].ToString();

                        // Load RoomType list
                        cmd.CommandText = "SELECT * FROM LoaiPhong WHERE maKS = '" + MaKS + "'";

                        List <RoomTypeRow> RoomtTypeList = new List <RoomTypeRow>();

                        dr.Close();

                        dr = cmd.ExecuteReader();

                        while (dr.Read())
                        {
                            RoomTypeRow roomTypeRow = new RoomTypeRow();
                            roomTypeRow.MaLoaiPhong  = dr["maLoaiPhong"].ToString();
                            roomTypeRow.TenLoaiPhong = dr["tenLoaiPhong"].ToString();

                            RoomtTypeList.Add(roomTypeRow);
                        }

                        dgRoomStatus.ItemsSource = RoomtTypeList;
                    }
                    else
                    {
                        MessageBox.Show("You are not beloing to any Hotel");
                        Auth.Logout();
                        App.mainWindow.Hide();
                        Login x = new Login();
                        x.Show();
                    }

                    dbQLKS.dbConnection.Close();
                }
                else
                {
                    App.mainWindow.Hide();
                    Login x = new Login();
                    x.Show();
                }
            }
        }
示例#3
0
        private void btnSearch_Click(object sender, RoutedEventArgs e)
        {
            if (dgRoomStatus.SelectedIndex != -1)
            {
                bool dataIsValid = true;

                // validate
                if (dpkDate.SelectedDate == null)
                {
                    MessageBox.Show("Please select a date");
                    dataIsValid = false;
                }


                // Query
                if (dataIsValid)
                {
                    DateTime   selectedDate = (DateTime)dpkDate.SelectedDate;
                    SqlCommand cmd          = new SqlCommand();
                    cmd.Connection  = dbQLKS.dbConnection;
                    cmd.CommandType = CommandType.Text;

                    RoomTypeRow row = (RoomTypeRow)dgRoomStatus.Items[dgRoomStatus.SelectedIndex];
                    cmd.CommandText = @"SELECT *
                                    FROM Phong as PH, LoaiPhong as LP, TrangThaiPhong as TTh
                                    WHERE LP.maLoaiPhong = PH.loaiPHong
                                    AND PH.loaiPhong = '" + row.MaLoaiPhong + "'" +
                                      @"AND TTh.maPhong = PH.maPhong
                                    AND year(TTh.ngay) =" + selectedDate.Year +
                                      "AND month(TTh.ngay) =" + selectedDate.Month +
                                      "AND day(TTh.ngay) =" + selectedDate.Day;


                    dbQLKS.dbConnection.Open();

                    SqlDataReader dr = cmd.ExecuteReader();

                    List <RoomRow> RoomList = new List <RoomRow>();

                    while (dr.Read())
                    {
                        RoomRow r = new RoomRow();

                        r.LoaiPhong = dr["tenLoaiPhong"].ToString();
                        r.MaPhong   = dr["maPhong"].ToString();
                        r.SoPhong   = dr["soPhong"].ToString();
                        r.TrangThai = dr["tinhTrang"].ToString();

                        RoomList.Add(r);
                    }

                    dgRoomStatus.ItemsSource = RoomList;
                    dbQLKS.dbConnection.Close();

                    // Disable buttons
                    btnRoomDetail.IsEnabled = true;
                    btnSearch.IsEnabled     = false;
                }
            }
            else
            {
                MessageBox.Show("Please select a Room Type");
            }
        }
示例#4
0
 public RoomTypeRowChangeEvent(RoomTypeRow row, global::System.Data.DataRowAction action)
 {
     this.eventRow    = row;
     this.eventAction = action;
 }
示例#5
0
 public void RemoveRoomTypeRow(RoomTypeRow row)
 {
     this.Rows.Remove(row);
 }
示例#6
0
 public void AddRoomTypeRow(RoomTypeRow row)
 {
     this.Rows.Add(row);
 }