private void btn_Submit_Click(object sender, EventArgs e)
        {
            try {
                BookingDetails b = new BookingDetails();
                b.Amount     = Convert.ToInt32(txt_Amt.Text);
                b.BookedFrom = DTP_BookedFrom.Value;
                if (DTP_BookedFrom.Value < System.DateTime.Now)
                {
                    throw new HMS_Exception("Booked-from date should be greater than today's date!");
                }
                else
                {
                    b.BookedTo = DTP_bookedTo.Value;
                }
                if (DTP_bookedTo.Value < DTP_BookedFrom.Value)
                {
                    throw new HMS_Exception("Booked-to date should be greater than booked-from date!");
                }
                else
                {
                    b.BookingID = txt_BookingId.Text;
                }
                b.NoOfAdults   = Convert.ToInt32(txt_NoOfAdults.Text);
                b.NoOfChildren = Convert.ToInt32(txt_NoOfChildren.Text);
                b.RoomID       = txt_RoomId.Text;
                b.UserID       = txt_UserId.Text;

                bool Bookadded = HBMS_BLL.AddBookingBL(b);
                if (!Bookadded)
                {
                    throw new HMS_Exception("Booking Cannot be added");
                }
                else
                {
                    MessageBox.Show("Booking Added Successfully");
                    UserHome uh = new UserHome();
                    this.Hide();
                    uh.Show();
                }
            }
            catch (HMS_Exception ex)
            { MessageBox.Show(ex.Message); }
            catch (SqlException e2)
            { MessageBox.Show(e2.Message); }
            catch (Exception e1)
            { MessageBox.Show(e1.Message); }
        }
Ejemplo n.º 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); }
 }