Ejemplo n.º 1
0
    protected void btnadd_Click(object sender, EventArgs e)
    {
        string password = new SomeFunctionalities().CreateStrongPassword();

        cmd = new SqlCommand("insert into tbl_newemp values('" + txtname.Text + "','" + txtphno.Text + "','" + txtdoj.Text + "','" + txtemail.Text + "','" + txtlogin.Text + "','" + password + "')", con);
        con.Open();
        int k = cmd.ExecuteNonQuery();

        con.Close();
        if (k == 1)
        {
            string to      = txtemail.Text;
            string subject = "Account Confirmation Mail";
            string message = "Dear Mr./Mrs. " + txtname.Text + "\n"
                             + "\tYour User ID is : " + txtlogin.Text + "\n"
                             + "\tYour Password is : " + password + "\n" +
                             "Please use this information to login into your account.";

            new SomeFunctionalities().SendEmail(to, subject, message);

            Response.Write("<script>alert('Employee Details Added. Login info is mailed')</script>");
        }
        else
        {
            Response.Write("<script>alert('Error Occured')</script>");
        }
    }
Ejemplo n.º 2
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        try
        {
            /******       CREATION OF NECCESSARY OBJECTS    ********/

            if (adapter == null)
            {
                adapter = new SqlDataAdapter();
                adapter.MissingSchemaAction = MissingSchemaAction.AddWithKey;
            }

            /**********************************************************/

            // generate strings
            string password = new SomeFunctionalities().CreateStrongPassword();
            //string sqlToInsert = "insert into tblSeminarNWorkshop (title,date,time,venue,description,organisedBy) VALUES (@title,@date,@time,@venue,@description,@organisedBy',getdate())";
            string sqlToInsert = "insert into tblSeminarNWorkshop (title,wdate,wtime,venue,wdescription,organisedBy,dt) VALUES (@title,@wdate,@wtime,@venue,@wdescription,@organisedBy,getdate())";


            // Create command
            adapter.InsertCommand = new SqlCommand(sqlToInsert, con);



            // Create parameters
            adapter.InsertCommand.Parameters.AddWithValue("@title", TextBox1.Text);
            adapter.InsertCommand.Parameters.AddWithValue("@wdate", TextBox2.Text);
            adapter.InsertCommand.Parameters.AddWithValue("@wtime", TextBox3.Text);
            adapter.InsertCommand.Parameters.AddWithValue("@venue", TextBox4.Text);
            adapter.InsertCommand.Parameters.AddWithValue("@wdescription", TextBox6.Text);
            adapter.InsertCommand.Parameters.AddWithValue("@organisedBy", TextBox5.Text);

            // Execute command
            if (con.State == ConnectionState.Closed)
            {
                con.Open();
            }
            int rowsAffected = adapter.InsertCommand.ExecuteNonQuery();
            if (con.State == ConnectionState.Open)
            {
                con.Close();
            }

            if (rowsAffected != 0)
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Successfully Added.')", true);
                lblStatus.Text = "Successfully Added.";
                TextBox1.Text  = string.Empty;
                TextBox2.Text  = string.Empty;
                TextBox3.Text  = string.Empty;
                TextBox4.Text  = string.Empty;
                TextBox5.Text  = string.Empty;
                TextBox6.Text  = string.Empty;
            }
        }
        catch (Exception ex)
        {
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Error : " + ex.Message + "')", true);
            lblStatus.Text = "Error : " + ex.Message;
        }
    }
Ejemplo n.º 3
0
    protected void btnSendPass_Click(object sender, EventArgs e)
    {
        try
        {
            /******       CREATION OF NECCESSARY OBJECTS    ********/

            if (adapter == null)
            {
                adapter = new SqlDataAdapter();
                adapter.MissingSchemaAction = MissingSchemaAction.AddWithKey;
            }

            /**********************************************************/

            // Create SQL Command
            string sql = "select COUNT(id) FROM tblStudentRegistration where email = @email";

            // Create command
            adapter.SelectCommand = new SqlCommand(sql, con);

            // Create parameter
            adapter.SelectCommand.Parameters.AddWithValue("@email", txtEmail.Text);

            // Execute command
            if (con.State == ConnectionState.Closed)
            {
                con.Open();
            }
            adapter.SelectCommand.ExecuteScalar();
            if (con.State == ConnectionState.Open)
            {
                con.Close();
            }

            dataSet = new DataSet();

            adapter.Fill(dataSet, "tblStudentRegistration");



            string temp  = dataSet.Tables["tblStudentRegistration"].Rows[0][0].ToString();
            int    count = dataSet.Tables["tblStudentRegistration"].Rows.Count;

            if (count == 1 && temp == "1")
            {
                adapter = null;
                dataSet = null;


                string newPassword = new SomeFunctionalities().CreateStrongPassword();

                /******       CREATION OF NECCESSARY OBJECTS    ********/

                if (adapter == null)
                {
                    adapter = new SqlDataAdapter();
                    adapter.MissingSchemaAction = MissingSchemaAction.AddWithKey;
                }

                SqlDataAdapter adapter2 = new SqlDataAdapter();
                adapter2.MissingSchemaAction = MissingSchemaAction.AddWithKey;


                dataSet = new DataSet();


                /**********************************************************/

                // Create SQL Command
                string sqltoUpdatePassword = "******";
                string sqltoFetchDetails   = "select firstName, lastName FROM tblStudentRegistration WHERE email = @email";

                // Create command
                adapter.UpdateCommand  = new SqlCommand(sqltoUpdatePassword, con);
                adapter2.SelectCommand = new SqlCommand(sqltoFetchDetails, con);

                // Create parameter
                adapter.UpdateCommand.Parameters.AddWithValue("@pass", newPassword);
                adapter.UpdateCommand.Parameters.AddWithValue("@email", txtEmail.Text);
                adapter2.SelectCommand.Parameters.AddWithValue("@email", txtEmail.Text);

                // Execute command
                if (con.State == ConnectionState.Closed)
                {
                    con.Open();
                }
                int rowsAffected = adapter.UpdateCommand.ExecuteNonQuery();
                adapter2.SelectCommand.ExecuteScalar();
                if (con.State == ConnectionState.Open)
                {
                    con.Close();
                }



                if (rowsAffected != 0)
                {
                    adapter2.Fill(dataSet, "tblStudentRegistration");

                    DataTable table = dataSet.Tables[0];
                    DataRow   row   = table.Rows[0];

                    string firstName = row[0].ToString();
                    string lastName  = row[1].ToString();


                    string to      = txtEmail.Text;
                    string subject = "Password changed successfully";
                    string body    = "Mr./Mrs. " + firstName + " " + lastName + ",\n"
                                     + "\tYour password is successfully changed. Your new login details are :\n"
                                     + "Email :  " + txtEmail.Text + "\n"
                                     + "Password : "******"Password successfully reset. To know new password check your mail";
                    lblStatus.ForeColor = System.Drawing.Color.Green;
                    txtEmail.Text       = string.Empty;
                }
            }
            else
            {
                lblStatus.Text      = "This email id is not registered with us.";
                lblStatus.ForeColor = System.Drawing.Color.Red;
                txtEmail.Focus();
            }
        }
        catch (Exception ex)
        {
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('" + ex.Message + "')", true);
        }
    }
    protected void btnSendPass_Click(object sender, EventArgs e)
    {
        try
        {
            /******       CREATION OF NECCESSARY OBJECTS    ********/

            if (adapter == null)
            {
                adapter = new SqlDataAdapter();
                adapter.MissingSchemaAction = MissingSchemaAction.AddWithKey;
            }

            /**********************************************************/

            // Create SQL Command
            string sql = "select COUNT(id) FROM tblStudentRegistration where email = @email";

            // Create command
            adapter.SelectCommand = new SqlCommand(sql, con);

            // Create parameter
            adapter.SelectCommand.Parameters.AddWithValue("@email", txtEmail.Text);

            // Execute command
            if (con.State == ConnectionState.Closed)
            {
                con.Open();
            }
            adapter.SelectCommand.ExecuteScalar();
            if (con.State == ConnectionState.Open)
            {
                con.Close();
            }

            dataSet = new DataSet();

            adapter.Fill(dataSet, "tblStudentRegistration");

            string temp = dataSet.Tables["tblStudentRegistration"].Rows[0][0].ToString();
            int count = dataSet.Tables["tblStudentRegistration"].Rows.Count;

            if (count == 1 && temp == "1")
            {
                adapter = null;
                dataSet = null;

                string newPassword = new SomeFunctionalities().CreateStrongPassword();

                /******       CREATION OF NECCESSARY OBJECTS    ********/

                if (adapter == null)
                {
                    adapter = new SqlDataAdapter();
                    adapter.MissingSchemaAction = MissingSchemaAction.AddWithKey;
                }

                SqlDataAdapter adapter2 = new SqlDataAdapter();
                adapter2.MissingSchemaAction = MissingSchemaAction.AddWithKey;

                dataSet = new DataSet();

                /**********************************************************/

                // Create SQL Command
                string sqltoUpdatePassword = "******";
                string sqltoFetchDetails = "select firstName, lastName FROM tblStudentRegistration WHERE email = @email";

                // Create command
                adapter.UpdateCommand = new SqlCommand(sqltoUpdatePassword, con);
                adapter2.SelectCommand = new SqlCommand(sqltoFetchDetails, con);

                // Create parameter
                adapter.UpdateCommand.Parameters.AddWithValue("@pass", newPassword);
                adapter.UpdateCommand.Parameters.AddWithValue("@email", txtEmail.Text);
                adapter2.SelectCommand.Parameters.AddWithValue("@email", txtEmail.Text);

                // Execute command
                if (con.State == ConnectionState.Closed)
                {
                    con.Open();
                }
                int rowsAffected = adapter.UpdateCommand.ExecuteNonQuery();
                adapter2.SelectCommand.ExecuteScalar();
                if (con.State == ConnectionState.Open)
                {
                    con.Close();
                }

                if (rowsAffected != 0)
                {
                    adapter2.Fill(dataSet, "tblStudentRegistration");

                    DataTable table = dataSet.Tables[0];
                    DataRow row = table.Rows[0];

                    string firstName = row[0].ToString();
                    string lastName = row[1].ToString();

                    string to = txtEmail.Text;
                    string subject = "Password changed successfully";
                    string body = "Mr./Mrs. " + firstName + " " + lastName + ",\n"
                        + "\tYour password is successfully changed. Your new login details are :\n"
                        + "Email :  " + txtEmail.Text + "\n"
                        + "Password : "******"Password successfully reset. To know new password check your mail";
                    lblStatus.ForeColor = System.Drawing.Color.Green;
                    txtEmail.Text = string.Empty;

                }
            }
            else
            {
                lblStatus.Text = "This email id is not registered with us.";
                lblStatus.ForeColor = System.Drawing.Color.Red;
                txtEmail.Focus();

            }

        }
        catch (Exception ex)
        {

            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('" + ex.Message + "')", true);
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        var    IsValidCaptcha = CaptchaValidate();
        string val            = "";

        try
        {
            IsValidCaptcha.TryGetValue(true, out val);
            if (val == null)
            {
                lblCaptchaResult.Text      = "Provided security code is not valid plese try again....";
                lblCaptchaResult.ForeColor = System.Drawing.Color.Red;
                return;
            }
        }
        catch (Exception ex)
        {
            lblCaptchaResult.Text      = "Provided security code is not valid plese try again....";
            lblCaptchaResult.BackColor = System.Drawing.Color.Red;
            return;
        }



        if (Label17.Text == "Username is Available.")
        {
            string password = new SomeFunctionalities().CreateStrongPassword();
            string email    = TextBox4.Text;
            string gender   = ddlGender.Text;


            da = new SqlDataAdapter("insert into tbl_login(uname,password,securitycode,status,cdate)values('" + TextBox9.Text + "','" + password + "','" + TextBox11.Text + "','Activate',getdate())", con);
            da.SelectCommand.ExecuteNonQuery();
            int uid = GetUid(TextBox9.Text);
            if (uid > 0)
            {
                da = new SqlDataAdapter("insert into tbl_contact(uid,fname,lname,gender,email,city,state,country,mobileno,cdate)values(" + uid + ",'" + TextBox1.Text + "','" + TextBox2.Text + "','" + gender + "','" + TextBox4.Text + "','" + TextBox5.Text + "','" + TextBox6.Text + "','" + TextBox7.Text + "','" + TextBox8.Text + "',getdate())", con);
                int n = da.SelectCommand.ExecuteNonQuery();
                // int k = da.ExecuteNonQuery();


                if (n == 1)
                {
                    /*********** SEND MAIL *************/


                    string subject = "Account Confirmation Mail";
                    string message = "Dear Mr./Mrs. " + TextBox1.Text + " " + TextBox2.Text + "\n"
                                     + "\tYour User ID is : " + TextBox9.Text + "\n"
                                     + "\tYour Password is : " + password + "\n" +
                                     "Please use this information to login into your account.";

                    new SomeFunctionalities().SendEmail(email, subject, message);



                    /************************************/



                    //Response.Write("<script>alert('User Details Added')</script>");
                    //System.Web.HttpContext.Current.Response.Write("<SCRIPT LANGUAGE='JavaScript'>alert(' You have successfully registered.\n Your User ID ')</SCRIPT>");
                    Response.Redirect("~/Userlogin.aspx");
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('You have successfully registered. Your User ID and Password is send to your email address')", true);
                }
            }
        }
        else
        {
            Label1.Text      = "The Username is already taken.Choose another Name.";
            Label1.BackColor = System.Drawing.Color.Red;
        }
    }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        if (lblDuplicateEmail.Text != "This email id is already registered with us.")
        {
            try
            {
                /******       CREATION OF NECCESSARY OBJECTS    ********/

                if (adapter == null)
                {
                    adapter = new SqlDataAdapter();
                    adapter.MissingSchemaAction = MissingSchemaAction.AddWithKey;
                }

                /**********************************************************/

                // generate strings
                string password    = new SomeFunctionalities().CreateStrongPassword();
                string sqlToInsert = "insert into tblFacultyRegistration (firstName,lastName,email,pass,mobileNumber,joiningYear,department,doorNStreet,rlyStation,po,postalCode,district,state,status,dt) VALUES (@firstName,@lastName,@email,@pass,@mobileNumber,@joiningYear,@department,@doorNStreet,@rlyStation,@po,@postalCode,@district,@state,'Deactivated',getdate())";


                // Create command
                adapter.InsertCommand = new SqlCommand(sqlToInsert, con);



                // Create parameters
                adapter.InsertCommand.Parameters.AddWithValue("@firstName", TextBoxFirstName.Text);
                adapter.InsertCommand.Parameters.AddWithValue("@lastName", TextBoxLastName.Text);
                adapter.InsertCommand.Parameters.AddWithValue("@email", TextBoxEmail.Text);
                adapter.InsertCommand.Parameters.AddWithValue("@pass", password);
                adapter.InsertCommand.Parameters.AddWithValue("@mobileNumber", TextBoxMobile.Text);
                adapter.InsertCommand.Parameters.AddWithValue("@joiningYear", DropDownListYear.Text);
                adapter.InsertCommand.Parameters.AddWithValue("@department", TextBoxDepartment.Text);
                adapter.InsertCommand.Parameters.AddWithValue("@doorNStreet", TextBoxDoorNStreet.Text);
                adapter.InsertCommand.Parameters.AddWithValue("@rlyStation", TextBoxRlyStation.Text);
                adapter.InsertCommand.Parameters.AddWithValue("@po", TextBoxPO.Text);
                adapter.InsertCommand.Parameters.AddWithValue("@postalCode", TextBoxPostalCode.Text);
                adapter.InsertCommand.Parameters.AddWithValue("@district", TextBoxDistrict.Text);
                adapter.InsertCommand.Parameters.AddWithValue("@state", TextBoxState.Text);



                // Execute command
                if (con.State == ConnectionState.Closed)
                {
                    con.Open();
                }
                int rowsAffected = adapter.InsertCommand.ExecuteNonQuery();
                if (con.State == ConnectionState.Open)
                {
                    con.Close();
                }


                /************   SEND USER ID AND PASSWORD TO THE PROVIDED MAIL ADDRESS *********/

                //if (rowsAffected != 0)
                //{
                //    string subject = "Account Confirmation Mail";

                //    string message = "Dear Mr./Mrs. " + TextBoxFirstName.Text + " " + TextBoxLastName.Text + "\n"
                //                + "\tYour User ID is : " + TextBoxEmail.Text + "\n"
                //                + "\tYour Password is : " + password + "\n" +
                //                "Please use this information to login into your account.";

                //    //new SomeFunctionalities().SendEmail(TextBoxEmail.Text, subject, message);
                //}



                /************************************************************************************/


                //ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('You have successfully registered. Your User ID and Password will be shortly send to your email address after approval from admin')", true);
                lblStatus.Text      = "You have successfully registered. Your User ID and Password will be shortly send to your email address after approval from admin";
                lblStatus.ForeColor = System.Drawing.Color.Green;

                TextBoxFirstName.Text = string.Empty;
                TextBoxLastName.Text  = string.Empty;
                TextBoxEmail.Text     = string.Empty;
                TextBoxMobile.Text    = string.Empty;
                //TextBoxye.Text = string.Empty;
                DropDownListYear.SelectedIndex = 0;
                TextBoxDepartment.Text         = string.Empty;
                TextBoxDoorNStreet.Text        = string.Empty;
                TextBoxRlyStation.Text         = string.Empty;
                TextBoxPO.Text         = string.Empty;
                TextBoxPostalCode.Text = string.Empty;
                TextBoxDistrict.Text   = string.Empty;
                TextBoxState.Text      = string.Empty;
            }
            catch (Exception ex)
            {
                //ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('" + ex.Message + "')", true);
                lblStatus.Text      = "Error : " + ex.Message;
                lblStatus.ForeColor = System.Drawing.Color.Red;
            }
        }
        else
        {
            lblStatus.Text      = "Please use a different email address.";
            lblStatus.ForeColor = System.Drawing.Color.Red;
            TextBoxEmail.Focus();
        }
    }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        if (lblDuplicateEmail.Text != "This email id is already registered with us.")
        {
            try
            {
                /******       CREATION OF NECCESSARY OBJECTS    ********/

                if (adapter == null)
                {
                    adapter = new SqlDataAdapter();
                    adapter.MissingSchemaAction = MissingSchemaAction.AddWithKey;
                }

                /**********************************************************/

                // generate strings
                string password = new SomeFunctionalities().CreateStrongPassword();
                string sqlToInsert = "insert into tblFacultyRegistration (firstName,lastName,email,pass,mobileNumber,joiningYear,department,doorNStreet,rlyStation,po,postalCode,district,state,status,dt) VALUES (@firstName,@lastName,@email,@pass,@mobileNumber,@joiningYear,@department,@doorNStreet,@rlyStation,@po,@postalCode,@district,@state,'Deactivated',getdate())";

                // Create command
                adapter.InsertCommand = new SqlCommand(sqlToInsert, con);

                // Create parameters
                adapter.InsertCommand.Parameters.AddWithValue("@firstName", TextBoxFirstName.Text);
                adapter.InsertCommand.Parameters.AddWithValue("@lastName", TextBoxLastName.Text);
                adapter.InsertCommand.Parameters.AddWithValue("@email", TextBoxEmail.Text);
                adapter.InsertCommand.Parameters.AddWithValue("@pass", password);
                adapter.InsertCommand.Parameters.AddWithValue("@mobileNumber", TextBoxMobile.Text);
                adapter.InsertCommand.Parameters.AddWithValue("@joiningYear", DropDownListYear.Text);
                adapter.InsertCommand.Parameters.AddWithValue("@department", TextBoxDepartment.Text);
                adapter.InsertCommand.Parameters.AddWithValue("@doorNStreet", TextBoxDoorNStreet.Text);
                adapter.InsertCommand.Parameters.AddWithValue("@rlyStation", TextBoxRlyStation.Text);
                adapter.InsertCommand.Parameters.AddWithValue("@po", TextBoxPO.Text);
                adapter.InsertCommand.Parameters.AddWithValue("@postalCode", TextBoxPostalCode.Text);
                adapter.InsertCommand.Parameters.AddWithValue("@district", TextBoxDistrict.Text);
                adapter.InsertCommand.Parameters.AddWithValue("@state", TextBoxState.Text);

                // Execute command
                if (con.State == ConnectionState.Closed)
                {
                    con.Open();
                }
                int rowsAffected = adapter.InsertCommand.ExecuteNonQuery();
                if (con.State == ConnectionState.Open)
                {
                    con.Close();
                }

                /************   SEND USER ID AND PASSWORD TO THE PROVIDED MAIL ADDRESS *********/

                //if (rowsAffected != 0)
                //{
                //    string subject = "Account Confirmation Mail";

                //    string message = "Dear Mr./Mrs. " + TextBoxFirstName.Text + " " + TextBoxLastName.Text + "\n"
                //                + "\tYour User ID is : " + TextBoxEmail.Text + "\n"
                //                + "\tYour Password is : " + password + "\n" +
                //                "Please use this information to login into your account.";

                //    //new SomeFunctionalities().SendEmail(TextBoxEmail.Text, subject, message);
                //}

                /************************************************************************************/

                //ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('You have successfully registered. Your User ID and Password will be shortly send to your email address after approval from admin')", true);
                lblStatus.Text = "You have successfully registered. Your User ID and Password will be shortly send to your email address after approval from admin";
                lblStatus.ForeColor = System.Drawing.Color.Green;

                TextBoxFirstName.Text = string.Empty;
                TextBoxLastName.Text = string.Empty;
                TextBoxEmail.Text = string.Empty;
                TextBoxMobile.Text = string.Empty;
                //TextBoxye.Text = string.Empty;
                DropDownListYear.SelectedIndex = 0;
                TextBoxDepartment.Text = string.Empty;
                TextBoxDoorNStreet.Text = string.Empty;
                TextBoxRlyStation.Text = string.Empty;
                TextBoxPO.Text = string.Empty;
                TextBoxPostalCode.Text = string.Empty;
                TextBoxDistrict.Text = string.Empty;
                TextBoxState.Text = string.Empty;
            }
            catch (Exception ex)
            {

                //ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('" + ex.Message + "')", true);
                lblStatus.Text = "Error : " + ex.Message;
                lblStatus.ForeColor = System.Drawing.Color.Red;
            }
        }
        else
        {
            lblStatus.Text = "Please use a different email address.";
            lblStatus.ForeColor = System.Drawing.Color.Red;
            TextBoxEmail.Focus();
        }
    }