Пример #1
0
 private void btn_Submit_Click(object sender, EventArgs e)
 {
     try {
         RoomDetails room = new RoomDetails();
         room.Availability = Convert.ToInt32(txt_Availability.Text);
         room.HotelID      = txt_HotelID.Text;
         room.PerNightrate = Convert.ToInt32(txt_PerNightRate.Text);
         //room.photo = openFileDialog1.FileName;
         room.RoomID   = txt_RoomId.Text;
         room.RoomNo   = txt_RoomNo.Text;
         room.RoomType = txt_RoomType.Text;
         bool Roomadded = HBMS_BLL.AddRoomBL(room);
         if (!Roomadded)
         {
             throw new HMS_Exception("Room Cannot be added");
         }
         else
         {
             MessageBox.Show("Room Added Successfully");
             HomeView hh = new HomeView();
             this.Hide();
             hh.Show();
         }
     }
     catch (HMS_Exception ex)
     { MessageBox.Show(ex.Message); }
     catch (SqlException e2)
     { MessageBox.Show(e2.Message); }
     catch (Exception e1)
     { MessageBox.Show(e1.Message); }
 }
Пример #2
0
 private void btn_Submit_Click(object sender, EventArgs e)
 {
     try{
         if (comboBox1.SelectedItem.Equals("Admin"))
         {
             Admin newAdmin = new Admin();
             newAdmin.AdminUserName = txt_UserName.Text;
             newAdmin.AdminPwd      = txt_Password.Text;
             bool Useradded = HBMS_BLL.AdminLoginBL(newAdmin);
             if (!Useradded)
             {
                 throw new HMS_Exception("Login Unsuccessfully");
             }
             else
             {
                 MessageBox.Show("Login Successfully");
                 LoginInfo.UserId = txt_UserName.Text;
                 AdminHome ah = new AdminHome();
                 this.Hide();
                 ah.Show();
             }
         }
         else if (comboBox1.SelectedItem.Equals("User"))
         {
             User usr = new User();
             usr.UserID       = txt_UserName.Text;
             usr.UserPassWord = txt_Password.Text;
             bool UserLogin = HBMS_BLL.UserLoginBL(usr);
             if (!UserLogin)
             {
                 throw new HMS_Exception("Login Unsuccessfully");
             }
             else
             {
                 MessageBox.Show("Login Successfully");
                 LoginInfo.UserId = txt_UserName.Text;
                 UserHome Uh = new UserHome();
                 this.Hide();
                 Uh.Show();
             }
         }
         else if (comboBox1.SelectedItem.Equals("Hotel"))
         {
             Hotel htl = new Hotel();
             htl.HotelID   = txt_UserName.Text;
             htl.HotelName = txt_Password.Text;
             bool HotelLogin = HBMS_BLL.HotelLoginBL(htl);
             if (!HotelLogin)
             {
                 throw new HMS_Exception("Login Unsuccessfully");
             }
             else
             {
                 MessageBox.Show("Login Successfully");
                 LoginInfo.UserId = txt_UserName.Text;
                 HomeView Hh = new HomeView();
                 this.Hide();
                 Hh.Show();
             }
         }
     }
     catch (HMS_Exception ex)
     { MessageBox.Show(ex.Message); }
     catch (SqlException e2)
     { MessageBox.Show(e2.Message); }
     catch (Exception e1)
     { MessageBox.Show(e1.Message); }
 }