private void EmialID()
    {
        string Email = Convert.ToString((String)Request.QueryString["Email"]);

        if (con.State == ConnectionState.Closed) con.Open();
        MySqlDataAdapter da;
        DataTable dt;
         cmd = new MySqlCommand("Select * from newsletters Where SubscribeEmailID = '" + Email + "'", con);

        da = new MySqlDataAdapter(cmd);
        dt = new DataTable();
        da.Fill(dt);

        if (dt.Rows.Count == 0)
        {

            cmd = new MySqlCommand("insert into newsletters (SubscribeEmailID,SubscribeDate) values (@SubscribeEmailID,@SubscribeDate)", con);
            cmd.CommandType = CommandType.Text;
            cmd.Parameters.AddWithValue("@SubscribeEmailID", Email);
            cmd.Parameters.AddWithValue("@SubscribeDate", DateTime.Now );
            cmd.ExecuteNonQuery();
            ss.InnerHtml = "Thank you for subscribing to our email list";
            ss.Attributes.Add("class", "email_successbg");

            string msgUser = "******" + Email;

            cmd = new MySqlCommand("SELECT  *  FROM Options Where OptionKey=1", con);
            MySqlDataAdapter objOptionAdapter = new MySqlDataAdapter(cmd);
            DataTable OptionDataTable = new DataTable();

            objOptionAdapter.Fill(OptionDataTable);

            int Portnumber = 0;
            if (OptionDataTable.Rows[0]["PortNumber"].ToString() != "")
            {
                Portnumber = Convert.ToInt32(OptionDataTable.Rows[0]["PortNumber"].ToString());
            }

            //Send To Email and sms
            string[] StrAttachment = new string[0];
            SMSAndEmail objSmsEmail = new SMSAndEmail();
            objSmsEmail.SendMail(OptionDataTable.Rows[0]["SMTPServerName"].ToString(), Portnumber, OptionDataTable.Rows[0]["SMTPServerEmailId"].ToString(), OptionDataTable.Rows[0]["SMTPServerEmailPassword"].ToString(), OptionDataTable.Rows[0]["AdminEmailId1"].ToString(), "New Newsletter Subscriber", msgUser,false ,StrAttachment );
            objSmsEmail.SendMail(OptionDataTable.Rows[0]["SMTPServerName"].ToString(), Portnumber, OptionDataTable.Rows[0]["SMTPServerEmailId"].ToString(), OptionDataTable.Rows[0]["SMTPServerEmailPassword"].ToString(), Email, "Welcome to our Newsletter", "Welcome to our Newsletter \r\nPlease keep this email for later reference. \r\nThanks, Miami & Miami",false,StrAttachment );

        }
        else
        {
            ss.InnerHtml = "Your Email Already Subscribe with us.";
            ss.Attributes.Add("class", "email_errorbg");
        }
        if (con.State == ConnectionState.Open) con.Close();
    }
    protected void BtnSubmit_Click(object sender, EventArgs e)
    {
        if (con.State == ConnectionState.Closed) con.Open();

        cmd = new MySqlCommand("insert into hotelreviews (HotelKey,YName,Email,Comment,Rating,Status,ReviewDate) values (@HotelKey,@YName,@Email,@Comment,@Rating,@Status,@ReviewDate)", con);
        cmd.CommandType = CommandType.Text;
        cmd.Parameters.AddWithValue("@HotelKey", HotelKey);
        cmd.Parameters.AddWithValue("@YName", TxtName .Text);
        cmd.Parameters.AddWithValue("@Email", TxtEmail.Text);
        cmd.Parameters.AddWithValue("@Comment", TxtComment.Text);
        cmd.Parameters.AddWithValue("@Rating", DropDownList1 .Text);
        cmd.Parameters.AddWithValue("@Status", "Unpublished");
        cmd.Parameters.AddWithValue("@ReviewDate", DateTime.Now );
        cmd.ExecuteNonQuery();
        cmd = new MySqlCommand("UPDate HOTELS SET   NoofReview=NoofReview+1 WHERE HotelKey ='"+ HotelKey  +"'", con);
        cmd.ExecuteNonQuery();
        string MessageId = "Name : " + TxtName.Text + " " + "\r\nEmail ID : " + TxtEmail.Text + "\r\nRating : " + DropDownList1 .Text  + "\r\nComment : " + TxtComment.Text;

        cmd = new MySqlCommand("SELECT  *  FROM Options Where OptionKey=1", con);
        MySqlDataAdapter objOptionAdapter = new MySqlDataAdapter(cmd);
        DataTable OptionDataTable = new DataTable();

        objOptionAdapter.Fill(OptionDataTable);

        int Portnumber = 0;
        if (OptionDataTable.Rows[0]["PortNumber"].ToString() != "")
        {
            Portnumber = Convert.ToInt32(OptionDataTable.Rows[0]["PortNumber"].ToString());
        }
        SMSAndEmail objSmsEmail = new SMSAndEmail();
        //Send To Email and sms
        string[] StrAttachment = new string[0];
        objSmsEmail.SendMail(OptionDataTable.Rows[0]["SMTPServerName"].ToString(), Portnumber, OptionDataTable.Rows[0]["SMTPServerEmailId"].ToString(), OptionDataTable.Rows[0]["SMTPServerEmailPassword"].ToString(), EmailID , "New Post Review", MessageId,false,StrAttachment);
        objSmsEmail.SendMail(OptionDataTable.Rows[0]["SMTPServerName"].ToString(), Portnumber, OptionDataTable.Rows[0]["SMTPServerEmailId"].ToString(), OptionDataTable.Rows[0]["SMTPServerEmailPassword"].ToString(), OptionDataTable.Rows[0]["AdminEmailId1"].ToString(), "Post Review", "Hotel Post Review : " + LblHotelName .Text   +"\r\n " +MessageId,false,StrAttachment);
        objSmsEmail.SendMail(OptionDataTable.Rows[0]["SMTPServerName"].ToString(), Portnumber, OptionDataTable.Rows[0]["SMTPServerEmailId"].ToString(), OptionDataTable.Rows[0]["SMTPServerEmailPassword"].ToString(), TxtEmail.Text, "Miami & Miami Post Review", "Thank you for submitting your Comment.  We will contact you soon. Thanks, Miami & Miami",false,StrAttachment );

        //LblError.Text = "Thank you for submitting your enquiry.  We will contact you soon. Thanks, Miami & Miami";

        if (con.State == ConnectionState.Open) con.Close();

        ss.Visible = false;
        Message.Visible = true;
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (con.State == ConnectionState.Closed) con.Open();

        cmd = new MySqlCommand("SELECT  *  FROM Options Where OptionKey=1", con);
        MySqlDataAdapter objOptionAdapter = new MySqlDataAdapter(cmd);
        DataTable OptionDataTable = new DataTable();

        objOptionAdapter.Fill(OptionDataTable);

        int Portnumber = 0;
        if (OptionDataTable.Rows[0]["PortNumber"].ToString() != "")
        {
            Portnumber = Convert.ToInt32(OptionDataTable.Rows[0]["PortNumber"].ToString());
        }
        SMSAndEmail objSmsEmail = new SMSAndEmail();
        string[] StrAttachment=new string[0];
        Int32 Total = 0;
        foreach (GridViewRow row in this.GrdServiceProviders.Rows)
        {
            bool flag = Convert.ToBoolean(((CheckBox)row.FindControl("ChkPaidStatus")).Checked);
            NewsletterKey = Convert.ToString(((LinkButton)row.FindControl("lnkUserKey")).Text);
            if (flag)
            {
                Total = Total + 1;
                string Email = Convert.ToString(((Label)row.FindControl("lblEmail")).Text);
                if (DropDownList1.Text == "Plain Text")
               {
                   objSmsEmail.SendMail(OptionDataTable.Rows[0]["SMTPServerName"].ToString(), Portnumber, OptionDataTable.Rows[0]["SMTPServerEmailId"].ToString(), OptionDataTable.Rows[0]["SMTPServerEmailPassword"].ToString(), Email, Txtsubject.Text, TxtMessage.Text,false ,StrAttachment );
               }
               else
               {

                   objSmsEmail.SendMail(OptionDataTable.Rows[0]["SMTPServerName"].ToString(), Portnumber, OptionDataTable.Rows[0]["SMTPServerEmailId"].ToString(), OptionDataTable.Rows[0]["SMTPServerEmailPassword"].ToString(), Email, Txtsubject.Text, TxtMessage.Text, true, StrAttachment);
               }

            }
        }
        LblError.Text = Total + " email successfully sent";
    }
    protected void adddata()
    {
        if (con.State == ConnectionState.Closed) con.Open();
        string CurrentPassword = TxtPassword.Text;
        string encrptionpass = Encryption.PasswordEncryption(ref CurrentPassword);
        DateTime Todays = DateTime.Now.AddHours(10).AddMinutes(30);
        Todays = DateTime.Now;
        string SendingDate = null;
        SendingDate = Todays.Year.ToString() + "-" + Todays.Month.ToString() + "-" + Todays.Day.ToString() + " " + Todays.Hour.ToString() + ":" + Todays.Minute.ToString() + ":" + Todays.Second.ToString();
        cmd = new MySqlCommand("insert into Users (UserName,Password,UserType,Title,FirstName,LastName,Gender,RegistrationDate) values (@UserName,@Password,@UserType,@Title,@FirstName,@LastName,@Gender,@RegistrationDate)", con);
        cmd.CommandType = CommandType.Text;
        cmd.Parameters.AddWithValue("@UserName", TtxEmail.Text);
        cmd.Parameters.AddWithValue("@Password", encrptionpass);
        cmd.Parameters.AddWithValue("@UserType", "User");
        cmd.Parameters.AddWithValue("@Title", DdlTitle.Text);
        cmd.Parameters.AddWithValue("@FirstName", TxtFName.Text);
        cmd.Parameters.AddWithValue("@LastName", TxtLastName.Text);
        cmd.Parameters.AddWithValue("@Gender", DdlGender.Text);
        cmd.Parameters.AddWithValue("@RegistrationDate", SendingDate);
        cmd.ExecuteNonQuery();

        string UserKey = "";
        cmd = new MySqlCommand("Select UserKey from Users order by UserKey desc", con);
        MySqlDataReader dr = cmd.ExecuteReader();
        if (dr.Read())
        {
            UserKey = dr["UserKey"].ToString();
        }
        dr.Close();
        Int64 num = 0;
        this.cmd = new MySqlCommand("select max(RegistrationId) as RegistrationId from Registrations ", this.con);
        MySqlDataReader reader = this.cmd.ExecuteReader();
        if (reader.HasRows)
        {
            if (reader.Read())
            {
                num = Convert.ToInt64(reader.GetValue(0));
            }
            reader.Close();
        }
        num++;

        this.cmd = new MySqlCommand("Insert into Registrations (UserKey,RegistrationId,RegistrationDate,Email,Address1,Address2,City,State,Country,Zipcode,Phone) values (@UserKey,@RegistrationId,@RegistrationDate,@Email,@Address1,@Address2,@City,@State,@Country,@Zipcode,@Phone) ", this.con);
        this.cmd.CommandType = CommandType.Text;
        this.cmd.Parameters.AddWithValue("@UserKey", UserKey);
        this.cmd.Parameters.AddWithValue("@RegistrationId", num);
        this.cmd.Parameters.AddWithValue("@RegistrationDate", DateTime.Now);
        this.cmd.Parameters.AddWithValue("@Email", TtxEmail.Text);
        this.cmd.Parameters.AddWithValue("@Address1", "");
        this.cmd.Parameters.AddWithValue("@Address2", "");
        this.cmd.Parameters.AddWithValue("@City", "");
        this.cmd.Parameters.AddWithValue("@State", "");
        this.cmd.Parameters.AddWithValue("@Country", "");
        this.cmd.Parameters.AddWithValue("@Zipcode", "");
        this.cmd.Parameters.AddWithValue("@Phone", this.TxtMobileNumber.Text);
        this.cmd.ExecuteNonQuery();

        cmd = new MySqlCommand("SELECT  *  FROM Options Where OptionKey=1", con);
        MySqlDataAdapter objOptionAdapter = new MySqlDataAdapter(cmd);
        DataTable OptionDataTable = new DataTable();

        objOptionAdapter.Fill(OptionDataTable);
        if (OptionDataTable.Rows.Count > 0)
        {
            string Message = "Dear " + TxtFName.Text + ",\r\n \r\n You are now a registered member of http://MiamiandMiami.com . \r\n \r\n Please find your account details below:.\r\n Username : "******"\r\n Password : "******"\r\n \r\n Thanks,\r\nMiami & Miami Team.";

            SMSAndEmail objSmsEmail = new SMSAndEmail();
            string[] StrAttachment = new string[0];
            objSmsEmail.SendMail(OptionDataTable.Rows[0]["SMTPServerName"].ToString(), Convert.ToInt16(OptionDataTable.Rows[0]["PortNumber"]), OptionDataTable.Rows[0]["SMTPServerEmailId"].ToString(), OptionDataTable.Rows[0]["SMTPServerEmailPassword"].ToString(), OptionDataTable.Rows[0]["AdminEmailId"].ToString(), "New Registration at Miami & Miami", "Dear admin,\r\n \r\n An user has been registered in the http://MiamiandMiami.com . Kindly check your inbox.\r\n \r\nThanks,\r\nMiami & Miami Team.",false, StrAttachment );
            objSmsEmail.SendMail(OptionDataTable.Rows[0]["SMTPServerName"].ToString(), Convert.ToInt16(OptionDataTable.Rows[0]["PortNumber"]), OptionDataTable.Rows[0]["SMTPServerEmailId"].ToString(), OptionDataTable.Rows[0]["SMTPServerEmailPassword"].ToString(), TtxEmail.Text, "Your Registration at Miami & Miami", Message, false, StrAttachment);

        }

        con.Close();

        Response.Redirect("Thanks.aspx");
    }
    protected void BtnEnquiry_Click(object sender, EventArgs e)
    {
        if (con.State == ConnectionState.Closed) con.Open();

        string ArrivalDate = null;// DateTime.ParseExact(TxtArrival.Text, "yyyy-MM-dd", System.DateTime);
        string DepartureDate = null;// DateTime.ParseExact(TxtDeparture.Text, "yyyy-MM-dd", System.DateTime);
        if (HiddenField1.Value != "")
        {
            ArrivalDate = HiddenField1.Value.Substring(6, 4) + "-" + HiddenField1.Value.Substring(3, 2) + "-" + HiddenField1.Value.Substring(0, 2);
        }
        if (HiddenField2.Value != "")
        {
            DepartureDate = HiddenField2.Value.Substring(6, 4) + "-" + HiddenField2.Value.Substring(3, 2) + "-" + HiddenField2.Value.Substring(0, 2);
        }

        cmd = new MySqlCommand("insert into Bookings (HotelKey,PackageKey,Type,YName,Email,Telephone,TravalingCity,PaymentType,ArrivalDate,DepartureDate,Adult,Child,NoofRooms,Requriments,Hotel_PackageName,BookingDate,Status) values (@HotelKey,@PackageKey,@Type,@YName,@Email,@Telephone,@TravalingCity,@PaymentType,@ArrivalDate,@DepartureDate,@Adult,@Child,@NoofRooms,@Requriments,@Hotel_PackageName,@BookingDate,@Status)", con);
        cmd.CommandType = CommandType.Text;
        if (Type == "Hotel")
        {

            cmd.Parameters.AddWithValue("@HotelKey", ID);
            cmd.Parameters.AddWithValue("@PackageKey", 0);
        }
        else
        {
            cmd.Parameters.AddWithValue("@HotelKey", 0);
            cmd.Parameters.AddWithValue("@PackageKey", ID);
        }

        cmd.Parameters.AddWithValue("@Type", Type);
        cmd.Parameters.AddWithValue("@YName", TxtName.Text);
        cmd.Parameters.AddWithValue("@Email", TxtEmail.Text);
        cmd.Parameters.AddWithValue("@Telephone", TxtTelephone.Text);
        cmd.Parameters.AddWithValue("@PaymentType", TxtRoomType.Text );
        cmd.Parameters.AddWithValue("@TravalingCity", TxtCity.Text);
        cmd.Parameters.AddWithValue("@ArrivalDate", ArrivalDate);
        cmd.Parameters.AddWithValue("@DepartureDate", DepartureDate);
        cmd.Parameters.AddWithValue("@Adult", TxtAdult.Text);
        cmd.Parameters.AddWithValue("@Child", txtChildren.Text);
        cmd.Parameters.AddWithValue("@NoofRooms", TextBox1.Text);
        cmd.Parameters.AddWithValue("@Requriments", TxtMessage.Text);
        cmd.Parameters.AddWithValue("@Hotel_PackageName", LblHotelName.Text);
        cmd.Parameters.AddWithValue("@Status", "Unpublished");
        cmd.Parameters.AddWithValue("@BookingDate", DateTime.Now);
        cmd.ExecuteNonQuery();

        string MessageId = LblHotelName.Text  +"\r\nName : " + TxtName.Text + " " + "\r\nEmail ID : " + TxtEmail.Text + "\r\nTelephone : " + TxtTelephone.Text + "\r\nTravaling City : " + TxtCity.Text + "\r\nPayment Type : " + TxtRoomType.Text + "\r\nArrival Date : " + HiddenField1.Value + "\r\n Departure Date : " + HiddenField2.Value + "\r\nAdult : " + TxtAdult.Text + "\r\nChild : " + txtChildren.Text + "\r\nRoom : " + TextBox1.Text + "\r\nRequriments : " + TxtMessage.Text;

        cmd = new MySqlCommand("SELECT  *  FROM Options Where OptionKey=1", con);
        MySqlDataAdapter objOptionAdapter = new MySqlDataAdapter(cmd);
        DataTable OptionDataTable = new DataTable();

        objOptionAdapter.Fill(OptionDataTable);

        int Portnumber = 0;
        if (OptionDataTable.Rows[0]["PortNumber"].ToString() != "")
        {
            Portnumber = Convert.ToInt32(OptionDataTable.Rows[0]["PortNumber"].ToString());
        }
        SMSAndEmail objSmsEmail = new SMSAndEmail();
        //Send To Email and sms
        string[] StrAttachment = new string[0];
        if (EmailID != "")
        {
            objSmsEmail.SendMail(OptionDataTable.Rows[0]["SMTPServerName"].ToString(), Portnumber, OptionDataTable.Rows[0]["SMTPServerEmailId"].ToString(), OptionDataTable.Rows[0]["SMTPServerEmailPassword"].ToString(), EmailID , LblHotelName.Text , MessageId, false, StrAttachment);
        }
        objSmsEmail.SendMail(OptionDataTable.Rows[0]["SMTPServerName"].ToString(), Portnumber, OptionDataTable.Rows[0]["SMTPServerEmailId"].ToString(), OptionDataTable.Rows[0]["SMTPServerEmailPassword"].ToString(), OptionDataTable.Rows[0]["AdminEmailId1"].ToString(), LblHotelName.Text, MessageId, false, StrAttachment);
        objSmsEmail.SendMail(OptionDataTable.Rows[0]["SMTPServerName"].ToString(), Portnumber, OptionDataTable.Rows[0]["SMTPServerEmailId"].ToString(), OptionDataTable.Rows[0]["SMTPServerEmailPassword"].ToString(), TxtEmail.Text, LblHotelName.Text, "Thank you for submitting your " + LblHotelName.Text   + ". \r\n We will contact you soon. \r\n Thanks, Miami & Miami", false, StrAttachment);

        if (con.State == ConnectionState.Open) con.Close();

        ss.Visible = false;
        Message.Visible = true;
    }