Ejemplo n.º 1
0
        public bool checkin(Customer pr, BookingRoom book)
        {
            bool result, result2, result3 = false;

            SqlConnection cnn = new SqlConnection(strConnection);
            string        sql = "Insert into Customer values(@ID,@NAME,@PHONE,@BIRTHDAY)";

            cnn.Open();
            SqlCommand cmd = new SqlCommand(sql, cnn);

            cmd.Parameters.AddWithValue("@ID", pr.customerID);
            cmd.Parameters.AddWithValue("@NAME", pr.customerName);
            cmd.Parameters.AddWithValue("@PHONE", pr.phone);

            cmd.Parameters.AddWithValue("@BIRTHDAY", pr.birthday);
            result = cmd.ExecuteNonQuery() > 0;



            string     sql2 = "Insert into Booking (customerID,roomno,checkindate,checkoutdate,totalpay,status,prepay)  values(@customerID,@roomNo,@checkin,@checkout,@totalpay,@status,@prepay)";
            SqlCommand cmd2 = new SqlCommand(sql2, cnn);

            cmd2.Parameters.AddWithValue("@customerID", pr.customerID);
            cmd2.Parameters.AddWithValue("@roomNo", book.RoomNo);
            cmd2.Parameters.AddWithValue("@checkin", book.CheckInDay);
            cmd2.Parameters.AddWithValue("@checkout", book.CheckOutDay);
            cmd2.Parameters.AddWithValue("@totalpay", book.TotalPay);
            cmd2.Parameters.AddWithValue("@status", true);
            cmd2.Parameters.AddWithValue("@prepay", book.PrePay);

            result2 = cmd2.ExecuteNonQuery() > 0;

            string     sql3 = "update room set status= @status where roomno = @ROOMNO";
            SqlCommand cmd3 = new SqlCommand(sql3, cnn);

            cmd3.Parameters.AddWithValue("@status", false);
            cmd3.Parameters.AddWithValue("@ROOMNO", book.RoomNo);
            result3 = cmd3.ExecuteNonQuery() > 0;
            cnn.Close();

            if (result && result2 && result3)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 2
0
        public bool checkinKhachQuen(BookingRoom book, string cusID)
        {
            bool          result, result2 = false;
            SqlConnection cnn = new SqlConnection(strConnection);

            cnn.Open();
            string     sql2 = "Insert into Booking (customerID,roomno,checkindate,checkoutdate,totalpay,status,prepay) values(@customerID,@roomNo,@checkin,@checkout,@totalpay,@status,@prepay)";
            SqlCommand cmd2 = new SqlCommand(sql2, cnn);

            cmd2.Parameters.AddWithValue("@customerID", cusID);
            cmd2.Parameters.AddWithValue("@roomNo", book.RoomNo);
            cmd2.Parameters.AddWithValue("@checkin", book.CheckInDay);
            cmd2.Parameters.AddWithValue("@checkout", book.CheckOutDay);
            cmd2.Parameters.AddWithValue("@totalpay", book.TotalPay);
            cmd2.Parameters.AddWithValue("@status", true);
            cmd2.Parameters.AddWithValue("@prepay", book.PrePay);

            result = cmd2.ExecuteNonQuery() > 0;

            string     sql3 = "update room set status= @status where roomno = @ROOMNO";
            SqlCommand cmd3 = new SqlCommand(sql3, cnn);

            cmd3.Parameters.AddWithValue("@status", false);
            cmd3.Parameters.AddWithValue("@ROOMNO", book.RoomNo);
            result2 = cmd3.ExecuteNonQuery() > 0;
            cnn.Close();

            if (result && result2)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }