Beispiel #1
0
    protected void register_btn_Click(object sender, EventArgs e)
    {
        Databs db = new Databs();

        String        id  = TextBox2.Text;
        var           id1 = id.ToCharArray();
        StringBuilder s   = new StringBuilder("YG");
        string        q   = "select COUNT(Name) from register17";
        DataTable     dt  = new DataTable();

        dt = db.verifys(q);

        for (int i = 0; i < id.Length; i++)
        {
            if (i == 0)
            {
                s.Append(id1[i]);
            }

            else
            {
                if (id1[i] == ' ' && id1[i + 1] != ' ')
                {
                    s.Append(id1[i + 1]);
                }
            }
        }
        int a = 100;

        a = a + Convert.ToInt32(dt.Rows[0][0]) + 1;
        string app = a.ToString();

        s.Append(app);
        s.Append(DateTime.Now.Second.ToString());
        string query = "insert into register17(Id,Name,College,Email,Phone,Passwords) values('" + s + "','" + TextBox1.Text + "','" + TextBox2.Text + "','" + TextBox3.Text + "','" + TextBox4.Text + "','" + TextBox5.Text + "')";

        try
        {
            Session["id"] = s;
            Page.ClientScript.RegisterClientScriptBlock(typeof(Page), "testScript", " $(document).ready(function() { $('#cg').show();});", true);
            if (TextBox1.Text == "")
            {
                ClientScript.RegisterStartupScript(GetType(), "alert", "alert('Enter name');", true);
            }
            else if (!(new Regex(@"^([a-zA-Z]*)$").IsMatch(TextBox1.Text)))
            {
                ClientScript.RegisterStartupScript(GetType(), "alert", "alert('Enter valid character in name');", true);
            }

            else if (TextBox2.Text == "")
            {
                ClientScript.RegisterStartupScript(GetType(), "alert", "alert('Enter college');", true);
            }
            else if (!(new Regex(@"^([a-zA-Z\s]*)$").IsMatch(TextBox2.Text)))
            {
                ClientScript.RegisterStartupScript(GetType(), "alert", "alert('Enter valid characters in college name');", true);
            }
            else if (!(new Regex(@"^([a-zA-Z0-9_\.\-])+\@(([gmailyhoutk\-])+\.)+([com]{2,4})+$").IsMatch(TextBox3.Text)))
            {
                ClientScript.RegisterStartupScript(GetType(), "alert", "alert('Enter valid Email address');", true);
            }
            else if (TextBox4.Text.Length < 10)
            {
                ClientScript.RegisterStartupScript(GetType(), "alert", "alert('Enter valid Mobile no');", true);
            }
            else if (TextBox5.Text.Length < 6 || TextBox5.Text.Length > 12)
            {
                ClientScript.RegisterStartupScript(GetType(), "alert", "alert('Enter password length between 6-12');", true);
            }
            else if (TextBox5.Text != TextBox6.Text)
            {
                ClientScript.RegisterStartupScript(GetType(), "alert", "alert('Password not matched');", true);
            }
            else
            {
                db.InsertData(query);
                ClientScript.RegisterStartupScript(GetType(), "alert", "alert('Data Submitted Successfully Check  your mail for your user id');", true);
            }
        }
        catch
        {
            ClientScript.RegisterStartupScript(GetType(), "alert", "alert('Unable to register. Please verify the e mail.');", true);
        }
    }
    protected void create_team_Click(object sender, EventArgs e)
    {
        DataTable dt1 = new DataTable();
        string    que = "Select * from event_reg ";//where Id='" + Session["name"] + "' or Id1='" + Session["name"] + "' or Id2='" + Session["name"] + "'";

        try
        {
            dt1 = db.verifys(que);
            if (TextBox5.Text == "")
            {
                Label1.Text = "Create your unique team name";
            }
            else if (valid1() && valid2() && valid3() && valid4() && valid5())
            {
                if (DropDownList1.SelectedValue.ToString() == "18")
                {
                    db.InsertData("insert into event_reg values('" + TextBox5.Text + "','" + Session["name"].ToString() + "','" + "" + "','" + "" + "','" + "" + "','" + "" + "','" + DropDownList1.SelectedItem.Value + "','" + "" + "')");
                    ShowMessage("Record submitted successfully", MessageType.Success);
                    Label1.Text = "Student is registered";
                    Response.Redirect("Usr_lgn.aspx");
                }

                else if (DropDownList1.SelectedValue.ToString() == "7" || DropDownList1.SelectedValue.ToString() == "13")
                {
                    if (TextBox6.Text.Equals(Session["name"].ToString()))
                    {
                        ShowMessage("Check user id", MessageType.Error);
                    }
                    else
                    {
                        db.InsertData("insert into event_reg values('" + TextBox5.Text + "','" + Session["name"].ToString() + "','" + TextBox6.Text + "','" + "" + "','" + "" + "','" + "" + "','" + DropDownList1.SelectedItem.Value + "','" + "" + "')");
                        Label1.Text = "Student is registered";
                        ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Successfully Registered');", true);
                        ShowMessage("Record submitted successfully", MessageType.Success);
                        Page.ClientScript.RegisterClientScriptBlock(typeof(Page), "modal", " $('#Modal').hide();", true);
                        Modal.Style.Add("display", "none");
                        Response.Redirect("Usr_lgn.aspx");
                    }
                }
                else if (DropDownList1.SelectedValue.ToString() == "2" || DropDownList1.SelectedValue.ToString() == "5" || DropDownList1.SelectedValue.ToString() == "19" || DropDownList1.SelectedValue.ToString() == "9" || DropDownList1.SelectedValue.ToString() == "1" || DropDownList1.SelectedValue.ToString() == "3" || DropDownList1.SelectedValue.ToString() == "15" || DropDownList1.SelectedValue.ToString() == "20")
                {
                    if (TextBox6.Text.Equals(Session["name"].ToString()) || TextBox7.Text.Equals(Session["name"].ToString()))
                    {
                        ShowMessage("Check user id", MessageType.Error);
                    }
                    else
                    {
                        db.InsertData("insert into event_reg values('" + TextBox5.Text + "','" + Session["name"].ToString() + "','" + TextBox6.Text + "','" + TextBox7.Text + "','" + "" + "','" + "" + "','" + DropDownList1.SelectedItem.Value + "','" + "" + "')");
                        ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Successfully Registered');", true);
                        Label1.Text = "Student is registered";
                        ShowMessage("Record submitted successfully", MessageType.Success);
                        Page.ClientScript.RegisterClientScriptBlock(typeof(Page), "modal", " $('#Modal').hide();", true);
                        Response.Redirect("Usr_lgn.aspx");
                        Modal.Style.Add("display", "none");
                    }
                }
                else if (DropDownList1.SelectedValue.ToString() == "12" || DropDownList1.SelectedValue.ToString() == "17")
                {
                    if (TextBox6.Text.Equals(Session["name"].ToString()) || TextBox7.Text.Equals(Session["name"].ToString()) || TextBox8.Text.Equals(Session["name"].ToString()))
                    {
                        ShowMessage("Check user id", MessageType.Error);
                    }
                    else
                    {
                        db.InsertData("insert into event_reg values('" + TextBox5.Text + "','" + Session["name"].ToString() + "','" + TextBox6.Text + "','" + TextBox7.Text + "','" + TextBox8.Text + "','" + "" + "','" + DropDownList1.SelectedItem.Value + "','" + "" + "')");
                        ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Successfully Registered');", true);
                        Label1.Text = "Student is registered";
                        ShowMessage("Record submitted successfully", MessageType.Success);
                        Page.ClientScript.RegisterClientScriptBlock(typeof(Page), "modal", " $('#Modal').hide();", true);
                        Modal.Style.Add("display", "none");
                        Response.Redirect("Usr_lgn.aspx");
                    }
                }
                else if (DropDownList1.SelectedValue.ToString() == "6" || DropDownList1.SelectedValue.ToString() == "10" || DropDownList1.SelectedValue.ToString() == "16" || DropDownList1.SelectedValue.ToString() == "14" || DropDownList1.SelectedValue.ToString() == "8" || DropDownList1.SelectedValue.ToString() == "11")
                {
                    if (TextBox6.Text.Equals(Session["name"].ToString()) || TextBox7.Text.Equals(Session["name"].ToString()) || TextBox8.Text.Equals(Session["name"].ToString()) || TextBox9.Text.Equals(Session["name"].ToString()))
                    {
                        ShowMessage("Check user id", MessageType.Error);
                    }
                    else
                    {
                        db.InsertData("insert into event_reg values('" + TextBox5.Text + "','" + Session["name"].ToString() + "','" + TextBox6.Text + "','" + TextBox7.Text + "','" + TextBox8.Text + "','" + TextBox9.Text + "','" + DropDownList1.SelectedItem.Value + "','" + "" + "')");
                        ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Successfully Registered');", true);
                        Label1.Text = "Student is registered";
                        ShowMessage("Record submitted successfully", MessageType.Success);
                        Page.ClientScript.RegisterClientScriptBlock(typeof(Page), "modal", " $('#Modal').hide();", true);
                        Modal.Style.Add("display", "none");
                        Response.Redirect("Usr_lgn.aspx");
                    }
                }
                else if (DropDownList1.SelectedValue.ToString() == "4")
                {
                    if (TextBox6.Text.Equals(Session["name"].ToString()) || TextBox7.Text.Equals(Session["name"].ToString()) || TextBox8.Text.Equals(Session["name"].ToString()) || TextBox9.Text.Equals(Session["name"].ToString()))
                    {
                        ShowMessage("Check user id", MessageType.Error);
                    }
                    else
                    {
                        db.InsertData("insert into event_reg values('" + TextBox5.Text + "','" + Session["name"].ToString() + "','" + TextBox6.Text + "','" + TextBox7.Text + "','" + TextBox8.Text + "','" + TextBox9.Text + "','" + DropDownList1.SelectedItem.Value + "','" + TextBox10.Text + "')");
                        ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Successfully Registered');", true);
                        Label1.Text = "Student is registered";
                        ShowMessage("Record submitted successfully", MessageType.Success);
                        Page.ClientScript.RegisterClientScriptBlock(typeof(Page), "modal", " $('#Modal').hide();", true);
                        Modal.Style.Add("display", "none");
                        Response.Redirect("Usr_lgn.aspx");
                    }
                }
            }
        }
        catch
        {
            ShowMessage("Record not submitted, please try again", MessageType.Error);

            Label1.Text = "";
            Page.ClientScript.RegisterClientScriptBlock(typeof(Page), "modal", " $('#Modal').hide();", true);
            Modal.Style.Add("display", "none");
        }
    }