protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            sql.cpn();



            u.umail             = Request.Form["fgmail"];
            u.upass             = g.rs(10);
            sql.com.CommandText = "select fname,lname,umob from udetails where umail='" + u.umail + "'";
            sql.dr = sql.com.ExecuteReader();
            if (sql.dr.HasRows)
            {
                while (sql.dr.Read())
                {
                    u.fname   = sql.dr.GetString(0);
                    u.lname   = sql.dr.GetString(1);
                    u.umobile = sql.dr.GetString(2);
                }
                sql.dr.Close();
                sql.com.CommandText = "update udetails set upass='******' where umail='" + u.umail + "'";
                sql.com.ExecuteNonQuery();
                body  = @"<html><body>
                                <font face='Lucida Grande'>
                                <p style='font-size:30px;color:#c86004;'><b>Rainbow Entertainments</b><p>
                                <p style='font-size:23px;color:#333'><b>hello ! <span style='color:#03a8ec;'>" + u.fname + " " + u.lname + @"</span> ,</b><p>
                                <p style='font-size:20px;color:#333'> your new password is <b><span style='color:#000'>" + u.upass + @"</span></b> for the account : <b>" + u.umail + @"</b></p>
                                <p style='font-size:20px;color:#333'>note : you can change your password on your profile.</p>
                                <p style='font-size:17px;color:#777'><b> -- thank you, rainbow enteratinments</b></p>
                                </font>     
                                </body></html>";
                sresp = "Hello ! " + u.fname + ", your new Password is " + u.upass + " . Thank you for choosing Rainbow Entertainsments.";
                sms.send(sresp, u.umobile);
                if (m.SendMail(body, u.umail))
                {
                    Response.Write("<div class='f-r-f'>Oops! mail sending failed, please try again</div>");
                }
                else
                {
                    Response.Write("<div class='f-r-s'>new password has been sent to your email address</div>");
                }
            }
            else
            {
                sql.rcls();
                Response.Write("<div class='f-r-f'>Oops! the specified email adderss not found</div>");
            }

            sql.cls();
        }
        catch (System.Data.SqlClient.SqlException se)
        {
            Response.Write("<div class='f-r-f'>Sorry! unable to process request. error : " + se.Message + "</div>");
        }
        catch (Exception ex)
        {
            Response.Write("<div class='f-r-f'>Oops! error occured : " + ex.Message + "</div>");
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            sql.cpn();
            u.fname             = Request.Form["firstname"].ToLower();
            u.lname             = Request.Form["lastname"].ToLower();
            u.umail             = Request.Form["upemail"];
            u.umobile           = Request.Form["mobile"];
            u.upass             = g.rs(10);
            sql.com.CommandText = "select uid from udetails where umail='" + u.umail + "'";

            sql.dr = sql.com.ExecuteReader();
            if (sql.dr.HasRows)
            {
                sql.dr.Close();
                resp = @"<div id='r-failure'><div>Oops! your registration failed !</div>
                                  <div>specified email address already exists</div>
                                  <div>" + Request.Form["upemail"] + "</div><div>note : if you are a registered user please sign in with the your credentials</div></div>";
                Response.Write(resp);
            }
            else
            {
                sql.rcls();
                sql.com.CommandText = "select uid from udetails where umob='" + u.umobile + "'";
                sql.dr = sql.com.ExecuteReader();
                if (sql.dr.HasRows)
                {
                    sql.rcls();
                    resp = @"<div id='r-failure'><div>Oops! your registration failed !</div>
                                  <div>specified mobile number already exists</div>
                                  <div>" + Request.Form["mobile"] + "</div><div>note : if you are a registered user please sign in with the your credentials</div></div>";
                    Response.Write(resp);
                }
                else
                {
                    sql.rcls();
                    sql.com.CommandText = "insert into udetails values('" + u.umail + "','" + u.fname + "','" + u.lname + "','" + u.upass + "','" + u.umobile + "','','','','')";
                    sql.com.ExecuteNonQuery();
                    resp  = @"<div id='r-success'><div>your registration successful !</div>
                                  <div>new password has been sent to your email address</div>
                                  <div>" + Request.Form["upemail"] + "</div><div>note : you can change your password on your profile</div></div>";
                    body  = @"<html><body>
                                <font face='Lucida Grande'>
                                <p style='font-size:30px;color:#c86004;'><b>Rainbow Entertainments</b><p>
                                <p style='font-size:23px;color:#333'><b>hello ! <span style='color:#03a8ec;'>" + u.fname + " " + u.lname + @"</span> ,</b><p>
                                <p style='font-size:20px;color:#333'> email id  : <b><span style='color:#000'>" + u.umail + @"</span></b></p>
                                <p style='font-size:20px;color:#333'> mobile no : <b><span style='color:#000'>" + u.umobile + @"</span></b></p>
                                <p style='font-size:20px;color:#333'> your new password is <b><span style='color:#000'>" + u.upass + @"</span></b> for the account : <b>" + u.umail + @"</b></p>
                                <p style='font-size:20px;color:#333'>note : you can change your password on your profile.</p>
                                <p style='font-size:17px;color:#777'><b> -- thank you, rainbow enteratinments</b></p>
                                </font>     
                                </body></html>";
                    sresp = "Hello ! " + u.fname + ", Your emailID:" + u.umail + " and your Password is " + u.upass + ". Thank you for choosing Rainbow Entertainsments.";
                    sms.send(sresp, u.umobile);
                    if (m.SendMail(body, u.umail))
                    {
                        Response.Write("<div class='f-r-f'>mail sending failed, please try again</div>");
                    }
                    else
                    {
                        Response.Write(resp);
                    }
                }
            }

            sql.cls();
        }
        catch (System.Data.SqlClient.SqlException ex)
        {
            int code = ex.ErrorCode;
            resp = @"<div id='r-failure'><div>unable to process your request</div>
                     <div>an error occured while processing your request, please try again</div>
                     <div> error code : " + code + "</div><div>error message : " + ex.Message + "</div></div>";
            Response.Write(resp);
        }
        catch (Exception ex)
        {
            string code = ex.InnerException + "";
            resp = @"<div id='r-failure'><div>unable to process your request</div>
                     <div>an error occured while processing your request, please try again</div>
                     <div> error : " + code + "</div><div>error message : " + ex.Message + "</div></div>";
            Response.Write(resp);
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        try
        {
            Button1.Visible = false;

            sql.cpn();
            for (int i = 0; i < seat_selected.Length; i++)
            {
                s = seat_selected[i];

                rowid  = s.Substring(0, s.IndexOf("-"));
                s      = s.Substring(s.IndexOf("-") + 1);
                tname  = s.Substring(0, s.IndexOf("-"));
                seatid = s.Substring(s.IndexOf("-") + 1);

                sql.com.CommandText = "select " + seatid + " from " + tname + " where " + seatid + "=1 and rowid='" + rowid + "'";
                sql.dr = sql.com.ExecuteReader();
                if (sql.dr.HasRows)
                {
                    booked = 1;
                    break;
                }
                sql.dr.Close();
            }
            sql.cls();
            if (booked == 0)
            {
                sql.cpn();
                for (int i = 0; i < seat_selected.Length; i++)
                {
                    s      = seat_selected[i];
                    rowid  = s.Substring(0, s.IndexOf("-"));
                    s      = s.Substring(s.IndexOf("-") + 1);
                    tname  = s.Substring(0, s.IndexOf("-"));
                    seatid = s.Substring(s.IndexOf("-") + 1);
                    sql.dr.Close();
                    sql.com.CommandText = "update " + tname + " set " + seatid + "=1 where " + seatid + "=0 and rowid='" + rowid + "'";
                    resp = sql.com.ExecuteNonQuery();
                    if (resp == 1)
                    {
                        booked = 0;
                    }
                    else
                    {
                        booked = 1;
                    }
                }
                if (booked == 0)
                {
                    u     = getUserInfo();
                    gcode = g.rs(10).ToUpper() + Session["userid"];
                    sql.cpn();
                    sql.com.CommandText = "select fname,lname,umail,umob from udetails where uid=" + Session["userid"];
                    sql.dr = sql.com.ExecuteReader();
                    if (sql.dr.HasRows)
                    {
                        while (sql.dr.Read())
                        {
                            cu.fname   = sql.dr.GetString(0);
                            cu.lname   = sql.dr.GetString(1);
                            cu.umail   = sql.dr.GetString(2);
                            cu.umobile = sql.dr.GetString(3);
                        }
                        sql.rcls();
                    }
                    sql.cls();
                    sql.cpn();
                    cname = cu.fname + " " + cu.lname;
                    sql.com.CommandText = "insert into booking values('" + gcode + "','" + nscreen.InnerText + "','" + nmovie.InnerText + "','" + ndate.InnerText + "','" + ntime.InnerText + "','" + nseat.InnerText + "','" + nticket.InnerText + "','" + nprice.InnerText + "','" + cname + "')";
                    resp = sql.com.ExecuteNonQuery();

                    if (resp == 1)
                    {
                        date = DateTime.Now.Date.ToString("MMMM") + ", " + DateTime.Now.Date.ToString("dd") + " " + DateTime.Now.Date.ToString("yyyy");
                        mres = "BookingID:" + gcode + ",Movie:" + nmovie.InnerText + ",Show:" + edatetime + ",Seats:" + ((nseat.InnerText).Replace(" ", "")) + "Thank you";
                        res  = @"<table bgcolor='#ff9900' border='0' cellpadding='7' cellspacing='2' width='600' style='font-family: Verdana; font-size: 18px;'><tr bgcolor='#333' style='color: #fff; font-size: 20px' height='30px'><td colspan='2'> Rainbow Entertainments Inc. </td></tr><tr style='border: #fff thin solid'><td colspan='2' bgcolor='#fff' style='font-size: 20px;'><span>Hello! <span style='color: #026a96'>" + cu.fname + " " + cu.lname + "</span></span><p style='font-size: 15px; text-indent: 10px;'> Below are your order details for the tickets you booked at www.rainbowcinemas.in on " + date + "</p></td></tr><tr bgcolor='#fff'><td colspan='2'><span>Booking ID<span style='color: #546604; font-size: 25px; padding-left: 35px;'>" + gcode + "</span></span></td></tr><tr><td width='130'> movie </td><td bgcolor='#fff'>" + nmovie.InnerText + "</td></tr><tr><td> screen </td><td bgcolor='#fff'>" + nscreen.InnerText + "</td></tr><tr><td> show date </td><td bgcolor='#fff'>" + ndate.InnerText + "</td></tr><tr><td> show time </td><td bgcolor='#fff'>" + ntime.InnerText + "</td></tr><tr><td> seats </td><td bgcolor='#fff'>" + nseat.InnerText + "</td></tr><tr><td> no. of tickets </td><td bgcolor='#fff'>" + nticket.InnerText + "</td></tr><tr><td> price </td><td bgcolor='#fff'>" + nprice.InnerText + "</td></tr><tr bgcolor='#fff'><td colspan='2'><p style='font-size: 14px;padding:5px 5px 0 5px' >Please note that your tickets are confirmed; we will not release the tickets under any circumstances. You can collect your tickets even if you are late for the movie.</p><p style='font-size: 15px;padding:5px 5px 0 5px' >Thank you for choosing Rainbow Entertainments !!</p></td></tr></table>";
                        sms.send(mres, cu.umobile);
                        if (mail.SendMail(res, cu.umail))
                        {
                            res                = @"<tr><td align='center' style='color:#fff' id='tresp' runat='server'><p style='font-size:30px;color:#a0d105;margin-top:35px'>hooray!! booking successfull</p><p style='font-size:25px;color:#ef9c02;margin-top:10px;'>Booking ID : " + gcode + "</p><p style='width:450px;padding:10px 30px 0 30px;color:#f13e07'>error oocured while sending email to following address</p><p style='font-size:25px;color:#0ab6dc;margin-top:10px;'>" + cu.umail + "</p><p style='width:450px;padding:10px 30px 0 30px;'>please make a note on Booking ID.thank you for choosing Rainbow Entertainments!!</p></td></tr>";
                            tresp.InnerHtml    = res;
                            Panel2.Visible     = true;
                            Panel1.Visible     = false;
                            Session["booking"] = false;
                        }
                        else
                        {
                            res                = @"<tr><td align='center' style='color:#fff' id='tresp' runat='server'><p style='font-size:30px;color:#a1d105;margin-top:35px'>hooray!! booking successfull</p><p style='font-size:25px;color:#ef9c02;margin-top:10px;'>Booking ID : " + gcode + "</p><p style='width:450px;padding:10px 30px 0 30px;'>your booking information are sent to your registered email address</p><p style='font-size:25px;color:#0ab6dc;margin-top:10px;'>" + cu.umail + "</p><p style='width:450px;padding:10px 30px 0 30px;'>thank you for choosing Rainbow Entertainments!!</p></td></tr>";
                            tresp.InnerHtml    = res;
                            Panel2.Visible     = true;
                            Panel1.Visible     = false;
                            Session["booking"] = false;
                        }
                    }
                    else
                    {
                        res                = @"<tr><td align='center' style='color:#fff' id='tresp' runat='server'><p style='font-size:30px;color:#ef3c03;margin-top:35px'>oops!! booking failed</p><p style='width:450px;padding:10px 30px 0 30px;'>Error occured while collection your information, please try again</p></td></tr>";
                        tresp.InnerHtml    = res;
                        Panel2.Visible     = true;
                        Panel1.Visible     = false;
                        Session["booking"] = false;
                    }
                }


                sql.cls();
            }

            else
            {
                res                = @"<tr><td align='center' style='color:#fff' id='tresp' runat='server'><p style='font-size:30px;color:#ef3c03;margin-top:35px'>oops!! booking failed</p><p style='width:450px;padding:10px 30px 0 30px;'>Requested seats alreay taken by other users, please try again</p></td></tr>";
                tresp.InnerHtml    = res;
                Panel2.Visible     = true;
                Panel1.Visible     = false;
                Session["booking"] = false;
            }
        }
        catch (System.Data.SqlClient.SqlException sqle)
        {
            res                = @"<tr><td align='center' style='color:#fff' id='tresp' runat='server'><p style='font-size:30px;color:#ef3c03;margin-top:35px'>oops!! booking failed</p><p style='width:450px;padding:10px 30px 0 30px;'>following error occured while booking tickets</p><p style='width:450px;padding:10px 30px 0 30px;'>" + sqle.Message + ", please try again</p></td></tr>";
            tresp.InnerHtml    = res;
            Panel2.Visible     = true;
            Panel1.Visible     = false;
            Session["booking"] = false;
        }
        catch (Exception ee)
        {
            res                = @"<tr><td align='center' style='color:#fff' id='tresp' runat='server'><p style='font-size:30px;color:#ef3c03;margin-top:35px'>oops!! booking failed</p><p style='width:450px;padding:10px 30px 0 30px;'>following error occured while booking tickets</p><p style='width:450px;padding:10px 30px 0 30px;'>" + ee.Message + ", please try again</p></td></tr>";
            tresp.InnerHtml    = res;
            Panel2.Visible     = true;
            Panel1.Visible     = false;
            Session["booking"] = false;
        }
    }