private int SaveBookingDetails()
        {
            string saveBooking = "insert into Bookings(BookingDate, BookingNo, TravelerCount, CustomerId,TripTypeId, PackageId) VALUES (GETDATE(), 'TT34', 2,(SELECT MAX(Customers.CustomerId)from Customers),@TripTypeId,@PackageId)";
            string getcusID    = "SELECT MAX(Customers.CustomerId)from Customers";

            using (System.Data.SqlClient.SqlConnection sconn = Connection.GetConnection())
            {
                sconn.Open();
                using (System.Data.SqlClient.SqlCommand command1 = new System.Data.SqlClient.SqlCommand(saveBooking, sconn))
                {
                    command1.Parameters.AddWithValue("@BookingNo", Bookingdetails.Bookingnumber);
                    command1.Parameters.AddWithValue("@TravelerCount", Bookingdetails.TravelerCount);
                    command1.Parameters.AddWithValue("@TripTypeId", Bookingdetails.TripTypeId);
                    command1.Parameters.AddWithValue("@PackageId", Bookingdetails.PackageId);

                    if (command1.ExecuteNonQuery() > 0)
                    {
                        using (System.Data.SqlClient.SqlCommand command2 = new System.Data.SqlClient.SqlCommand(getcusID, sconn))
                        {
                            System.Data.SqlClient.SqlDataReader Dreader;
                            Dreader = command2.ExecuteReader();
                            if (Dreader.HasRows)
                            {
                                while (Dreader.Read())
                                {
                                    return(int.Parse(Dreader[0].ToString()));
                                }
                            }
                        }
                    }
                }
            }
            return(0);
        }
        public int IsLoggedIn( )
        {
            System.Data.SqlClient.SqlDataReader Dreader;
            System.Data.SqlClient.SqlConnection conn = Connection.GetConnection();

            try
            {
                using (var cmd = new System.Data.SqlClient.SqlCommand("select CustomerId,UserLogin.UserName,Customers.CustFirstName,Customers.CustLastName from Customers inner join UserLogin on Customers.UserId = UserLogin.UserId where UserLogin.UserName = @userName and UserLogin.UserPassword = @passWord", conn))
                {
                    cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@userName", Users.UserName));
                    cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@passWord", Users.UserPassword));
                    conn.Open();
                    Dreader = cmd.ExecuteReader();
                }

                if (Dreader.Read())
                {
                    CustomersDetails.CusFirstName = (string)Dreader["CustFirstName"];
                    CustomersDetails.CusLastName  = (string)Dreader["CustLastName"];
                    Users.CustomerId = (int)Dreader["CustomerId"];
                    Users.UserName   = (string)Dreader["UserName"];

                    conn.Close(); Dreader.Close();
                    return(1);
                }
            }
            catch (System.Data.SqlClient.SqlException exception)
            {
                throw exception;
            }
            finally
            {
                if (conn.State == System.Data.ConnectionState.Open)
                {
                    conn.Close();
                }
                conn.Dispose();
            }
            return(0);
        }
        private void GenerateID()
        {
            System.Data.SqlClient.SqlConnection conn = Connection.GetConnection();
            conn.Open();
            System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand("Select Max(CustomerId) from Customers", conn);

            System.Data.SqlClient.SqlDataReader Dreader;
            Dreader = cmd.ExecuteReader();

            string newId = string.Format("050{0}0001", DateTime.Now.Year);

            if (Dreader.HasRows)
            {
                string prefix = string.Format("050{0}", DateTime.Now.Year);
                while (Dreader.Read())
                {
                    newId = string.Format("{0}{1}", DateTime.Now.Year, Dreader[0].ToString() + 1);
                }
            }

            Users.UserId = Convert.ToInt64(newId);
            conn.Close();
        }