예제 #1
0
    protected string getpass()
    {
        SqlConnection cnn = null;
        SqlDataReader rdr = null;

        try {
            cnn = DBcontroller.MakeConnection(this);
            cnn.Open();
            SqlCommand command;

            String sql = " ";

            sql     = "select password from [user] where id ='" + Session["ID"] + "'";
            command = new SqlCommand(sql, cnn);

            rdr = command.ExecuteReader();
            rdr.Read();
            return(rdr.GetValue(0) + "");
        }
        catch (SqlException e1)
        {
            string script = "alert(\"" + e1.Message + "\");";
            ScriptManager.RegisterStartupScript(this, GetType(),
                                                "ServerControlScript", script, true);
        }
        finally
        {
            if (cnn != null & rdr != null)
            {
                rdr.Close();
                cnn.Close();
            }
        }
        return(null);
    }
예제 #2
0
    public static String getusertype(String ID, System.Web.UI.Page P)
    {
        SqlConnection cnn        = null;
        SqlDataReader dataReader = null;

        try
        {
            cnn = DBcontroller.MakeConnection(P);
            cnn.Open();
            String sql1 = "select * from Viewer where id ='" + ID + "'";
            String sql2 = "select * from Contributor where id ='" + ID + "'";
            String sql3 = "select * from Content_Manager where id ='" + ID + "'";
            String sql4 = "select * from Reviewer where id ='" + ID + "'";

            SqlCommand command1 = new SqlCommand(sql1, cnn);
            SqlCommand command2 = new SqlCommand(sql2, cnn);
            SqlCommand command3 = new SqlCommand(sql3, cnn);
            SqlCommand command4 = new SqlCommand(sql4, cnn);
            String     s        = "";
            dataReader = command1.ExecuteReader();
            if (dataReader.Read())
            {
                s = "Viewer";
            }
            dataReader = command2.ExecuteReader();
            if (dataReader.Read())
            {
                s = "Contributer";
            }
            dataReader = command3.ExecuteReader();
            if (dataReader.Read())
            {
                s = "Content Manager";
            }
            dataReader = command4.ExecuteReader();
            if (dataReader.Read())
            {
                s = "Reviewer";
            }


            return(s);
        }
        catch (SqlException e)
        {
            string script = "alert(\"" + e.Message + "\");";
            ScriptManager.RegisterStartupScript(P, P.GetType(),
                                                "ServerControlScript", script, true);
        }
        finally
        {
            if (cnn != null & dataReader != null)
            {
                dataReader.Close();
                cnn.Close();
            }
        }
        return(null);
    }
예제 #3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["ID"] == null)
        {
            mainnotlog.Visible = true;
            mainlog.Visible    = false;
        }
        else
        {
            SqlConnection cnn        = null;
            SqlDataReader dataReader = null;
            try
            {
                cnn = DBcontroller.MakeConnection(this);
                cnn.Open();

                String sql = "select first_name,middle_name,last_name from [user] where id ='" + Session["ID"] + "'";

                SqlCommand command = new SqlCommand(sql, cnn);

                string s = DBcontroller.getusertype(Session["ID"] + "", this);

                type.Text = "Log In As " + s;

                dataReader = command.ExecuteReader();
                if (dataReader.Read())
                {
                    fname.Text = dataReader.GetValue(0) + "";
                    mname.Text = dataReader.GetValue(1) + "";
                    lname.Text = dataReader.GetValue(2) + "";
                }
            }
            catch (SqlException e1)
            {
                string script = "alert(\"" + e1.Message + "\");";
                ScriptManager.RegisterStartupScript(this, GetType(),
                                                    "ServerControlScript", script, true);
            }
            finally
            {
                if (cnn != null & dataReader != null)
                {
                    dataReader.Close();
                    cnn.Close();
                }
            }
            mainlog.Visible    = true;
            mainnotlog.Visible = false;
        }
    }
예제 #4
0
    protected void Page_Load()
    {
        if (IsCallback)
        {
            changeinform.Visible   = false;
            changepassword.Visible = false;
        }

        CurrentPass.Visible    = false;
        NewPass.Visible        = false;
        ConfirmNewPAss.Visible = false;
        SqlConnection cnn        = null;
        SqlDataReader dataReader = null;

        try {
            cnn = DBcontroller.MakeConnection(this);
            cnn.Open();
            String sql = "select first_name,middle_name,last_name from [user] where id ='" + Session["ID"] + "'";
            s = DBcontroller.getusertype(Session["ID"] + "", this);

            SqlCommand command = new SqlCommand(sql, cnn);
            dataReader = command.ExecuteReader();
            if (dataReader.Read())
            {
                welcom.InnerHtml = "You're logged in as <strong>" + s + " " + dataReader.GetValue(0) + " " + dataReader.GetValue(1) + " " + dataReader.GetValue(2) + "</strong>. ";
            }
        }catch (SqlException e)
        {
            string script = "alert(\"" + e.Message + "\");";
            ScriptManager.RegisterStartupScript(this, GetType(),
                                                "ServerControlScript", script, true);
        }
        finally
        {
            if (cnn != null & dataReader != null)
            {
                dataReader.Close();
                cnn.Close();
            }
        }
    }
예제 #5
0
    protected void Page_Init(object sender, EventArgs e)
    {
        if (Message.Messagekey == true)
        {
            string script = "alert(\"Your profile has been deactivated successfully\");";
            ScriptManager.RegisterStartupScript(this, GetType(),
                                                "ServerControlScript", script, true);
            Message.Messagekey = false;
        }
        SContr.HRef = "ShowData.aspx?Show=1";
        SCont.HRef  = "ShowData.aspx?Show=2";

        if (Session["ID"] == null)
        {
            n1.HRef          = "~/Account/Register";
            n1.InnerHtml     = "Register";
            n2.InnerHtml     = "Log In";
            n2.HRef          = "~/Account/Login";
            Deactive.Visible = false;
            n2.ServerClick  += null;
            view.Visible     = false;
            staff.Visible    = false;
        }
        else
        {
            n1.HRef          = "~/Account/Manage";
            n1.InnerHtml     = "Edit My Profile";
            n2.InnerHtml     = "Log Out";
            n2.ServerClick  += new EventHandler(logout);
            Deactive.Visible = true;
            String s = DBcontroller.getusertype(Session["ID"] + "", this);
            if (s.Equals("Viewer"))
            {
                view.Visible = true;
            }
            if (s.Equals("Content Manager") | s.Equals("Reviewer"))
            {
                staff1.Visible = true;
            }
        }
    }
예제 #6
0
    IEnumerator SavePlayerData()
    {
        WWWForm form = new WWWForm();

        form.AddField("name", DBcontroller.userName);
        form.AddField("score", DBcontroller.score);

        WWW www = new WWW("http://localhost/horrorunity/savedata.php", form);

        yield return(www);

        if (www.text == "0")
        {
            Debug.Log("Game Saved");
        }
        else
        {
            Debug.Log("Save Failed. Error #" + www.text);
        }

        DBcontroller.LogOut();
        UnityEngine.SceneManagement.SceneManager.LoadScene(0);
    }
예제 #7
0
    protected void deact(object sender, EventArgs e)
    {
        SqlConnection cnn = null;

        try
        {
            cnn = DBcontroller.MakeConnection(this);
            cnn.Open();

            SqlCommand command;

            String sql = " ";

            sql     = "exec Deactivate_Profile " + Session["ID"];
            command = new SqlCommand(sql, cnn);

            if (command.ExecuteNonQuery() == 1)
            {
                Message.Messagekey = true;
                Session["ID"]      = null;
                Response.Redirect("~/Default");
            }
        }
        catch (SqlException e1)
        {
            string script = "alert(\"" + e1.Message + "\");";
            ScriptManager.RegisterStartupScript(this, GetType(),
                                                "ServerControlScript", script, true);
        }
        finally
        {
            if (cnn != null)
            {
                cnn.Close();
            }
        }
    }
예제 #8
0
        public void UpdateDB(string id, DateTime Time, string data)
        {
            DBcontroller dbObj = new DBcontroller();

            dbObj.DBInsert(id, Time, data);
        }
예제 #9
0
    protected void searchby(object sender, EventArgs args)
    {
        if (Request.QueryString["SearchBy"] != null)
        {
            String word1 = TextBox1.Text;
            String word2 = TextBox2.Text;
            if (int.Parse(Request.QueryString["SearchBy"]) == 1)
            {
                if (word1 != null & word1 != null)
                {
                    SqlConnection cnn        = null;
                    SqlDataReader dataReader = null;

                    try {
                        cnn = DBcontroller.MakeConnection(this);
                        cnn.Open();


                        SqlCommand command;

                        String sql = " ";


                        sql = "exec Original_Content_Search '" + word2 + "','" + word1 + "'";

                        command = new SqlCommand(sql, cnn);

                        dataReader = command.ExecuteReader();

                        DataTable tb = new DataTable();
                        tb.Columns.Add(new DataColumn("num"));
                        tb.Columns.Add(new DataColumn("ID"));
                        tb.Columns.Add(new DataColumn("content_manager_id"));
                        tb.Columns.Add(new DataColumn("reviewer_id"));
                        tb.Columns.Add(new DataColumn("review_status"));
                        tb.Columns.Add(new DataColumn("filter_status"));
                        tb.Columns.Add(new DataColumn("rating"));
                        tb.Columns.Add(new DataColumn("link"));
                        tb.Columns.Add(new DataColumn("uploaded_at"));
                        tb.Columns.Add(new DataColumn("category"));
                        tb.Columns.Add(new DataColumn("subcategory_name"));
                        tb.Columns.Add(new DataColumn("type"));
                        DataColumn[] PrimaryKeyColumns = new DataColumn[1];
                        PrimaryKeyColumns[0] = tb.Columns["ID"];
                        tb.PrimaryKey        = PrimaryKeyColumns;
                        int i = 0;
                        while (dataReader.Read())
                        {
                            i++;
                            DataRow row = tb.NewRow();
                            row["num"] = i;
                            row["ID"]  = dataReader.GetValue(0);
                            row["content_manager_id"] = dataReader.GetValue(1);
                            row["reviewer_id"]        = dataReader.GetValue(2);
                            row["review_status"]      = dataReader.GetValue(3);
                            row["filter_status"]      = dataReader.GetValue(4);
                            row["rating"]             = dataReader.GetValue(5);
                            row["link"]             = dataReader.GetValue(7);
                            row["uploaded_at"]      = dataReader.GetValue(8);
                            row["category"]         = dataReader.GetValue(10);
                            row["subcategory_name"] = dataReader.GetValue(11);
                            row["type"]             = dataReader.GetValue(12);
                            tb.Rows.Add(row);
                        }

                        labelcount.Text = "Number of Contents which Found : " + i + " Content";

                        Repeater2.DataSource = tb;
                        Repeater2.DataBind();
                    }
                    catch (SqlException e1)
                    {
                        string script = "alert(\"" + e1.Message + "\");";
                        ScriptManager.RegisterStartupScript(this, GetType(),
                                                            "ServerControlScript", script, true);
                    }
                    finally
                    {
                        if (cnn != null & dataReader != null)
                        {
                            dataReader.Close();
                            cnn.Close();
                        }
                    }
                }
            }
            if (int.Parse(Request.QueryString["SearchBy"]) == 2)
            {
                if (word1 != null)
                {
                    SqlConnection cnn        = null;
                    SqlDataReader dataReader = null;
                    try {
                        cnn = DBcontroller.MakeConnection(this);
                        cnn.Open();


                        SqlCommand command;

                        String sql = " ";

                        sql = "exec Contributor_Search '" + word1 + "'";

                        command = new SqlCommand(sql, cnn);

                        dataReader = command.ExecuteReader();

                        DataTable tb = new DataTable();
                        tb.Columns.Add(new DataColumn("num"));
                        tb.Columns.Add(new DataColumn("ID"));
                        tb.Columns.Add(new DataColumn("first_name"));
                        tb.Columns.Add(new DataColumn("middle_name"));
                        tb.Columns.Add(new DataColumn("last_name"));
                        tb.Columns.Add(new DataColumn("email"));
                        tb.Columns.Add(new DataColumn("specialization"));
                        tb.Columns.Add(new DataColumn("years_of_experience"));
                        tb.Columns.Add(new DataColumn("portfolio_link"));
                        tb.Columns.Add(new DataColumn("age"));
                        tb.Columns.Add(new DataColumn("birthdate"));
                        DataColumn[] PrimaryKeyColumns = new DataColumn[1];
                        PrimaryKeyColumns[0] = tb.Columns["ID"];
                        tb.PrimaryKey        = PrimaryKeyColumns;
                        int i = 0;
                        while (dataReader.Read())
                        {
                            i++;
                            DataRow row = tb.NewRow();
                            row["num"]                 = i;
                            row["ID"]                  = dataReader.GetValue(0);
                            row["first_name"]          = dataReader.GetValue(7);
                            row["middle_name"]         = dataReader.GetValue(8);
                            row["last_name"]           = dataReader.GetValue(9);
                            row["email"]               = dataReader.GetValue(6);
                            row["specialization"]      = dataReader.GetValue(3);
                            row["years_of_experience"] = dataReader.GetValue(1);
                            row["portfolio_link"]      = dataReader.GetValue(2);
                            row["age"]                 = dataReader.GetValue(11);
                            row["birthdate"]           = dataReader.GetValue(10);
                            tb.Rows.Add(row);
                        }

                        labelcount.Text = "Number of Contributors which Found : " + i + " Contributor";

                        Repeater1.DataSource = tb;
                        Repeater1.DataBind();
                    }
                    catch (SqlException e1)
                    {
                        string script = "alert(\"" + e1.Message + "\");";
                        ScriptManager.RegisterStartupScript(this, GetType(),
                                                            "ServerControlScript", script, true);
                    }
                    finally
                    {
                        if (cnn != null & dataReader != null)
                        {
                            dataReader.Close();
                            cnn.Close();
                        }
                    }
                }
            }
        }
    }
예제 #10
0
    protected void ChangePassword_Click(object sender, EventArgs e)
    {
        CurrentPass.Visible    = false;
        NewPass.Visible        = false;
        ConfirmNewPAss.Visible = false;
        int i = 0;

        if (CurrentPassword.Text == "")
        {
            i++;
            CurrentPass.Visible = true;
        }
        if (NewPassword.Text == "")
        {
            i++;
            NewPass.Visible = true;
        }
        if (ConfirmNewPassword.Text == "")
        {
            i++;
            ConfirmNewPAss.Text    = "The confirm new password field is required.";
            ConfirmNewPAss.Visible = true;
        }
        if (NewPassword.Text != "" & ConfirmNewPAss.Text != "" & !NewPassword.Text.Equals(ConfirmNewPassword.Text))
        {
            i++;
            ConfirmNewPAss.Text    = "The confirm new password field does not match with new password field";
            ConfirmNewPAss.Visible = true;
        }
        if (i == 0)
        {
            SqlConnection cnn        = null;
            SqlDataReader dataReader = null;
            try {
                cnn = DBcontroller.MakeConnection(this);
                cnn.Open();

                String sql = "select password from [user] where id ='" + Session["ID"] + "'";

                SqlCommand command = new SqlCommand(sql, cnn);
                dataReader = command.ExecuteReader();
                if (dataReader.Read())
                {
                    if (dataReader.GetValue(0).Equals(CurrentPassword.Text))
                    {
                        sql     = "UPDATE [USER] set PASSWORD='******' WHERE ID =" + Session["ID"];
                        command = new SqlCommand(sql, cnn);
                        if (command.ExecuteNonQuery() == 1)
                        {
                            alert("Your password has been changed successfully");
                        }
                    }
                    else
                    {
                        alert("Please enter correct current password");
                    }
                }
            }
            catch (SqlException e1)
            {
                string script = "alert(\"" + e1.Message + "\");";
                ScriptManager.RegisterStartupScript(this, GetType(),
                                                    "ServerControlScript", script, true);
            }
            finally
            {
                if (cnn != null & dataReader != null)
                {
                    dataReader.Close();
                    cnn.Close();
                }
            }
        }
    }
예제 #11
0
    protected void fillunfo()
    {
        SqlConnection cnn = null;

        try {
            cnn = DBcontroller.MakeConnection(this);
            cnn.Open();
            SqlCommand cmd = new SqlCommand("Show_Profile", cnn);
            cmd.CommandType = System.Data.CommandType.StoredProcedure;

            cmd.Parameters.Add(new SqlParameter("@user_id", Session["ID"] + ""));

            cmd.Parameters.Add("@email", System.Data.SqlDbType.VarChar, 400).Direction                     = System.Data.ParameterDirection.Output;
            cmd.Parameters.Add("@firstname", System.Data.SqlDbType.VarChar, 400).Direction                 = System.Data.ParameterDirection.Output;
            cmd.Parameters.Add("@middlename", System.Data.SqlDbType.VarChar, 400).Direction                = System.Data.ParameterDirection.Output;
            cmd.Parameters.Add("@password", System.Data.SqlDbType.VarChar, 400).Direction                  = System.Data.ParameterDirection.Output;
            cmd.Parameters.Add("@lastname", System.Data.SqlDbType.VarChar, 400).Direction                  = System.Data.ParameterDirection.Output;
            cmd.Parameters.Add("@birth_date", System.Data.SqlDbType.Date).Direction                        = System.Data.ParameterDirection.Output;
            cmd.Parameters.Add("@working_place_name", System.Data.SqlDbType.VarChar, 400).Direction        = System.Data.ParameterDirection.Output;
            cmd.Parameters.Add("@working_place_type", System.Data.SqlDbType.VarChar, 400).Direction        = System.Data.ParameterDirection.Output;
            cmd.Parameters.Add("@wokring_place_description", System.Data.SqlDbType.VarChar, 400).Direction = System.Data.ParameterDirection.Output;
            cmd.Parameters.Add("@specilization", System.Data.SqlDbType.VarChar, 400).Direction             = System.Data.ParameterDirection.Output;
            cmd.Parameters.Add("@portofolio_link", System.Data.SqlDbType.VarChar, 400).Direction           = System.Data.ParameterDirection.Output;
            cmd.Parameters.Add("@years_experience", System.Data.SqlDbType.Int).Direction                   = System.Data.ParameterDirection.Output;
            cmd.Parameters.Add("@hire_date", System.Data.SqlDbType.Date).Direction           = System.Data.ParameterDirection.Output;
            cmd.Parameters.Add("@working_hours", System.Data.SqlDbType.Int).Direction        = System.Data.ParameterDirection.Output;
            cmd.Parameters.Add("@payment_rate", System.Data.SqlDbType.Decimal, 10).Direction = System.Data.ParameterDirection.Output;
            cmd.Parameters["@payment_rate"].Precision = 10;
            cmd.Parameters["@payment_rate"].Scale     = 2;
            SqlDataReader rdr = cmd.ExecuteReader();
            FirstName.Text  = cmd.Parameters["@firstname"].Value + "";
            SecondName.Text = cmd.Parameters["@middlename"].Value + "";
            ThirdName.Text  = cmd.Parameters["@lastname"].Value + "";
            mail.Text       = cmd.Parameters["@email"].Value + "";
            birthdate.Text  = (Convert.ToDateTime(cmd.Parameters["@birth_date"].Value + "")).ToString("yyyy-MM-dd");
            if (s.Equals("Viewer"))
            {
                working_place_name.Text        = (String)cmd.Parameters["@working_place_name"].Value;
                working_place_type.Text        = cmd.Parameters["@working_place_type"].Value + "";
                wokring_place_description.Text = cmd.Parameters["@wokring_place_description"].Value + "";
            }
            else if (s.Equals("Contributer"))
            {
                years_experience.Text = cmd.Parameters["@years_experience"].Value + "";
                portofolio_link.Text  = cmd.Parameters["@portofolio_link"].Value + "";
                specilization.Text    = cmd.Parameters["@specilization"].Value + "";
            }
            else
            {
                hire_date.Text     = (Convert.ToDateTime(cmd.Parameters["@hire_date"].Value + "")).ToString("yyyy-MM-dd");
                working_hours.Text = cmd.Parameters["@working_hours"].Value + "";
                payment_rate.Text  = (((decimal)cmd.Parameters["@payment_rate"].Value)) + "";
            }
        }
        catch (SqlException e1)
        {
            string script = "alert(\"" + e1.Message + "\");";
            ScriptManager.RegisterStartupScript(this, GetType(),
                                                "ServerControlScript", script, true);
        }
        finally
        {
            if (cnn != null)
            {
                cnn.Close();
            }
        }
    }
예제 #12
0
    protected void changedata(object sender, EventArgs e)
    {
        FirstName1.Visible                 = false;
        SecondName1.Visible                = false;
        ThirdName1.Visible                 = false;
        mail1.Visible                      = false;
        birthdate1.Visible                 = false;
        working_place_name1.Visible        = false;
        working_place_type1.Visible        = false;
        wokring_place_description1.Visible = false;
        specilization1.Visible             = false;
        years_experience1.Visible          = false;
        portofolio_link1.Visible           = false;
        hire_date1.Visible                 = false;
        working_hours1.Visible             = false;
        payment_rate1.Visible              = false;

        int i = 0;

        if (FirstName.Text == "")
        {
            i++;
            FirstName1.Visible = true;
        }
        if (SecondName.Text == "")
        {
            i++;
            SecondName1.Visible = true;
        }
        if (ThirdName.Text == "")
        {
            i++;
            ThirdName1.Visible = true;
        }
        if (mail.Text == "")
        {
            i++;
            mail1.Visible = true;
        }
        if (birthdate.Text == "")
        {
            i++;
            birthdate1.Visible = true;
        }
        if (s.Equals("Viewer"))
        {
            if (working_place_name.Text == "")
            {
                i++;
                working_place_name1.Visible = true;
            }
            if (working_place_type.Text == "")
            {
                i++;
                working_place_type1.Visible = true;
            }
            if (wokring_place_description.Text == "")
            {
                i++;
                wokring_place_description1.Visible = true;
            }
        }
        else if (s.Equals("Contributer"))
        {
            if (specilization.Text == "")
            {
                i++;
                specilization1.Visible = true;
            }
            if (years_experience.Text == "")
            {
                i++;
                years_experience1.Visible = true;
            }
            if (portofolio_link.Text == "")
            {
                i++;
                portofolio_link1.Visible = true;
            }
        }
        else
        {
            if (hire_date.Text == "")
            {
                i++;
                hire_date1.Visible = true;
            }
            if (working_hours.Text == "")
            {
                i++;
                working_hours1.Visible = true;
            }
            if (payment_rate.Text == "")
            {
                i++;
                payment_rate1.Visible = true;
            }
        }
        if (i == 0)
        {
            SqlConnection cnn = null;
            try
            {
                cnn = DBcontroller.MakeConnection(this);
                cnn.Open();

                SqlCommand cmd = new SqlCommand("Edit_Profile", cnn);

                cmd.CommandType = System.Data.CommandType.StoredProcedure;
                cmd.Parameters.Add(new SqlParameter("@user_id", Session["ID"]));
                cmd.Parameters.Add(new SqlParameter("@email", mail.Text));
                cmd.Parameters.Add(new SqlParameter("@password", getpass()));
                cmd.Parameters.Add(new SqlParameter("@firstname", FirstName.Text));
                cmd.Parameters.Add(new SqlParameter("@middlename", SecondName.Text));
                cmd.Parameters.Add(new SqlParameter("@lastname", ThirdName.Text));
                cmd.Parameters.Add(new SqlParameter("@birth_date", birthdate.Text));
                if (s.Equals("Viewer"))
                {
                    cmd.Parameters.Add(new SqlParameter("@working_place_name", working_place_name.Text));
                    cmd.Parameters.Add(new SqlParameter("@working_place_type", working_place_type.Text));
                    cmd.Parameters.Add(new SqlParameter("@wokring_place_description", wokring_place_description.Text));
                    cmd.Parameters.Add(new SqlParameter("@specilization", DBNull.Value));
                    cmd.Parameters.Add(new SqlParameter("@portofolio_link", DBNull.Value));
                    cmd.Parameters.Add(new SqlParameter("@years_experience", DBNull.Value));
                    cmd.Parameters.Add(new SqlParameter("@hire_date", DBNull.Value));
                    cmd.Parameters.Add(new SqlParameter("@working_hours", DBNull.Value));
                    cmd.Parameters.Add(new SqlParameter("@payment_rate", DBNull.Value));
                }
                else if (s.Equals("Contributer"))
                {
                    cmd.Parameters.Add(new SqlParameter("@working_place_name", DBNull.Value));
                    cmd.Parameters.Add(new SqlParameter("@working_place_type", DBNull.Value));
                    cmd.Parameters.Add(new SqlParameter("@wokring_place_description", DBNull.Value));
                    cmd.Parameters.Add(new SqlParameter("@specilization", specilization.Text));
                    cmd.Parameters.Add(new SqlParameter("@portofolio_link", portofolio_link.Text));
                    cmd.Parameters.Add(new SqlParameter("@years_experience", years_experience.Text));
                    cmd.Parameters.Add(new SqlParameter("@hire_date", DBNull.Value));
                    cmd.Parameters.Add(new SqlParameter("@working_hours", DBNull.Value));
                    cmd.Parameters.Add(new SqlParameter("@payment_rate", DBNull.Value));
                }
                else
                {
                    cmd.Parameters.Add(new SqlParameter("@working_place_name", DBNull.Value));
                    cmd.Parameters.Add(new SqlParameter("@working_place_type", DBNull.Value));
                    cmd.Parameters.Add(new SqlParameter("@wokring_place_description", DBNull.Value));
                    cmd.Parameters.Add(new SqlParameter("@specilization", DBNull.Value));
                    cmd.Parameters.Add(new SqlParameter("@portofolio_link", DBNull.Value));
                    cmd.Parameters.Add(new SqlParameter("@years_experience", DBNull.Value));
                    cmd.Parameters.Add(new SqlParameter("@hire_date", hire_date.Text));
                    cmd.Parameters.Add(new SqlParameter("@working_hours", working_hours.Text));
                    cmd.Parameters.Add(new SqlParameter("@payment_rate", payment_rate.Text));
                }
                int changedrow = cmd.ExecuteNonQuery();
                if (changedrow > 0)
                {
                    string script = "alert(\" Your data has been edited successfully \");";
                    ScriptManager.RegisterStartupScript(this, GetType(),
                                                        "ServerControlScript", script, true);
                    fillunfo();
                }
            }
            catch (SqlException e1)
            {
                string script = "alert(\"" + e1.Message + "\");";
                ScriptManager.RegisterStartupScript(this, GetType(),
                                                    "ServerControlScript", script, true);
            }
            finally
            {
                if (cnn != null)
                {
                    cnn.Close();
                }
            }
        }
    }
예제 #13
0
    protected void CreateUser_Click(object sender, EventArgs e)
    {
        usertype1.Visible                  = false;
        FirstName1.Visible                 = false;
        SecondName1.Visible                = false;
        ThirdName1.Visible                 = false;
        mail1.Visible                      = false;
        birthdate1.Visible                 = false;
        Password1.Visible                  = false;
        ConfirmPassword1.Visible           = false;
        working_place_name1.Visible        = false;
        working_place_type1.Visible        = false;
        wokring_place_description1.Visible = false;
        specilization1.Visible             = false;
        years_experience1.Visible          = false;
        portofolio_link1.Visible           = false;
        hire_date1.Visible                 = false;
        working_hours1.Visible             = false;
        payment_rate1.Visible              = false;

        int i = 0;

        if (usertype.SelectedIndex == -1)
        {
            i++;
            usertype1.Visible = true;
        }
        if (FirstName.Text == "")
        {
            i++;
            FirstName1.Visible = true;
        }
        if (SecondName.Text == "")
        {
            i++;
            SecondName1.Visible = true;
        }
        if (ThirdName.Text == "")
        {
            i++;
            ThirdName1.Visible = true;
        }
        if (mail.Text == "")
        {
            i++;
            mail1.Visible = true;
        }
        if (birthdate.Text == "")
        {
            i++;
            birthdate1.Visible = true;
        }
        if (Password.Text == "")
        {
            i++;
            Password1.Visible = true;
        }
        if (ConfirmPassword.Text == "")
        {
            i++;
            ConfirmPassword1.Text    = "The confirm password field is required";
            ConfirmPassword1.Visible = true;
        }
        if (working_place_name.Text == "" & usertype.SelectedIndex == 0)
        {
            i++;
            working_place_name1.Visible = true;
        }
        if (working_place_type.Text == "" & usertype.SelectedIndex == 0)
        {
            i++;
            working_place_type1.Visible = true;
        }
        if (wokring_place_description.Text == "" & usertype.SelectedIndex == 0)
        {
            i++;
            wokring_place_description1.Visible = true;
        }
        if (specilization.Text == "" & usertype.SelectedIndex == 1)
        {
            i++;
            specilization1.Visible = true;
        }
        if (years_experience.Text == "" & usertype.SelectedIndex == 1)
        {
            i++;
            years_experience1.Visible = true;
        }
        if (portofolio_link.Text == "" & usertype.SelectedIndex == 1)
        {
            i++;
            portofolio_link1.Visible = true;
        }
        if (hire_date.Text == "" & (usertype.SelectedIndex == 2 | usertype.SelectedIndex == 3))
        {
            i++;
            hire_date1.Visible = true;
        }
        if (working_hours.Text == "" & (usertype.SelectedIndex == 2 | usertype.SelectedIndex == 3))
        {
            i++;
            working_hours1.Visible = true;
        }
        if (payment_rate.Text == "" & (usertype.SelectedIndex == 2 | usertype.SelectedIndex == 3))
        {
            i++;
            payment_rate1.Visible = true;
        }
        if (Password.Text != "" & ConfirmPassword.Text != null & Password.Text != ConfirmPassword.Text)
        {
            i++;
            ConfirmPassword1.Text    = "The confirm password field does not match with password field";
            ConfirmPassword1.Visible = true;
        }
        if (i == 0)
        {
            SqlConnection cnn        = null;
            SqlDataReader dataReader = null;
            int           U_id       = 0;

            try
            {
                cnn = DBcontroller.MakeConnection(this);
                cnn.Open();

                String sql = "select email from [user] where email ='" + mail.Text + "'";

                SqlCommand command = new SqlCommand(sql, cnn);
                dataReader = command.ExecuteReader();
                if (!dataReader.Read())
                {
                    SqlCommand cmd = new SqlCommand("Register_User", cnn);

                    cmd.CommandType = System.Data.CommandType.StoredProcedure;
                    cmd.Parameters.Add(new SqlParameter("@usertype", usertype.SelectedValue));
                    cmd.Parameters.Add(new SqlParameter("@email", mail.Text));
                    cmd.Parameters.Add(new SqlParameter("@password", Password.Text));
                    cmd.Parameters.Add(new SqlParameter("@firstname", FirstName.Text));
                    cmd.Parameters.Add(new SqlParameter("@middlename", SecondName.Text));
                    cmd.Parameters.Add(new SqlParameter("@lastname", ThirdName.Text));
                    cmd.Parameters.Add(new SqlParameter("@birth_date", birthdate.Text));
                    if (usertype.SelectedIndex == 0)
                    {
                        cmd.Parameters.Add(new SqlParameter("@working_place_name", working_place_name.Text));
                        cmd.Parameters.Add(new SqlParameter("@working_place_type", working_place_type.Text));
                        cmd.Parameters.Add(new SqlParameter("@wokring_place_description", wokring_place_description.Text));
                        cmd.Parameters.Add(new SqlParameter("@specilization", DBNull.Value));
                        cmd.Parameters.Add(new SqlParameter("@portofolio_link", DBNull.Value));
                        cmd.Parameters.Add(new SqlParameter("@years_experience", DBNull.Value));
                        cmd.Parameters.Add(new SqlParameter("@hire_date", DBNull.Value));
                        cmd.Parameters.Add(new SqlParameter("@working_hours", DBNull.Value));
                        cmd.Parameters.Add(new SqlParameter("@payment_rate", DBNull.Value));
                    }
                    else if (usertype.SelectedIndex == 1)
                    {
                        cmd.Parameters.Add(new SqlParameter("@working_place_name", DBNull.Value));
                        cmd.Parameters.Add(new SqlParameter("@working_place_type", DBNull.Value));
                        cmd.Parameters.Add(new SqlParameter("@wokring_place_description", DBNull.Value));
                        cmd.Parameters.Add(new SqlParameter("@specilization", specilization.Text));
                        cmd.Parameters.Add(new SqlParameter("@portofolio_link", portofolio_link.Text));
                        cmd.Parameters.Add(new SqlParameter("@years_experience", years_experience.Text));
                        cmd.Parameters.Add(new SqlParameter("@hire_date", DBNull.Value));
                        cmd.Parameters.Add(new SqlParameter("@working_hours", DBNull.Value));
                        cmd.Parameters.Add(new SqlParameter("@payment_rate", DBNull.Value));
                    }
                    else
                    {
                        cmd.Parameters.Add(new SqlParameter("@working_place_name", DBNull.Value));
                        cmd.Parameters.Add(new SqlParameter("@working_place_type", DBNull.Value));
                        cmd.Parameters.Add(new SqlParameter("@wokring_place_description", DBNull.Value));
                        cmd.Parameters.Add(new SqlParameter("@specilization", DBNull.Value));
                        cmd.Parameters.Add(new SqlParameter("@portofolio_link", DBNull.Value));
                        cmd.Parameters.Add(new SqlParameter("@years_experience", DBNull.Value));
                        cmd.Parameters.Add(new SqlParameter("@hire_date", hire_date.Text));
                        cmd.Parameters.Add(new SqlParameter("@working_hours", working_hours.Text));
                        cmd.Parameters.Add(new SqlParameter("@payment_rate", payment_rate.Text));
                    }

                    cmd.Parameters.Add("@user_id", System.Data.SqlDbType.Int).Direction = System.Data.ParameterDirection.Output;

                    using (SqlDataReader rdr = cmd.ExecuteReader())
                    {
                        U_id = Convert.ToInt32(cmd.Parameters["@user_id"].Value);
                    }
                    Session["ID"] = U_id;
                    Response.Redirect("~/Default.aspx");
                }
                else
                {
                    string script = "alert(\"This E-mail used for other profile\");";
                    ScriptManager.RegisterStartupScript(this, GetType(),
                                                        "ServerControlScript", script, true);
                }
            }
            catch (SqlException e1)
            {
                string script = "alert(\"" + e1.Message + "\");";
                ScriptManager.RegisterStartupScript(this, GetType(),
                                                    "ServerControlScript", script, true);
            }
            finally
            {
                if (cnn != null)
                {
                    cnn.Close();
                }
            }
        }
    }
예제 #14
0
    protected void LogIn(object sender, EventArgs e)
    {
        if (mail.Text == "" & Password.Text == "")
        {
            mailText.Text        = "The email field is required.";
            mailText.Visible     = true;
            PasswordText.Text    = "The password field is required.";
            ValidInfo.Visible    = false;
            PasswordText.Visible = true;
        }
        else if (mail.Text == "")
        {
            mailText.Text        = "The user name field is required.";
            mailText.Visible     = true;
            ValidInfo.Visible    = false;
            PasswordText.Visible = false;
        }
        else if (Password.Text == "")
        {
            PasswordText.Text    = "The password field is required.";
            PasswordText.Visible = true;
            ValidInfo.Visible    = false;
            mailText.Visible     = false;
        }
        else
        {
            SqlConnection cnn        = null;
            SqlDataReader dataReader = null;
            int           U_id       = 0;
            Boolean       c          = true;
            try {
                cnn = DBcontroller.MakeConnection(this);
                cnn.Open();

                String sql = "select active from [user] where email ='" + mail.Text + "' and password ='******'";

                SqlCommand command = new SqlCommand(sql, cnn);

                dataReader = command.ExecuteReader();

                if (dataReader.Read())
                {
                    c = Boolean.Parse(dataReader.GetValue(0) + "");
                }
                mail1 = mail.Text;
                pass1 = Password.Text;

                SqlCommand cmd = new SqlCommand("User_login", cnn);

                cmd.CommandType = System.Data.CommandType.StoredProcedure;

                cmd.Parameters.Add(new SqlParameter("@email", mail.Text));
                cmd.Parameters.Add(new SqlParameter("@password", Password.Text));

                cmd.Parameters.Add("@user_id", System.Data.SqlDbType.Int).Direction = System.Data.ParameterDirection.Output;



                using (SqlDataReader rdr = cmd.ExecuteReader())
                {
                    U_id = Convert.ToInt32(cmd.Parameters["@user_id"].Value);
                }
            }
            catch (SqlException e1)
            {
                string script = "alert(\"" + e1.Message + "\");";
                ScriptManager.RegisterStartupScript(this, GetType(),
                                                    "ServerControlScript", script, true);
            }
            finally
            {
                if (cnn != null & dataReader != null)
                {
                    dataReader.Close();
                    cnn.Close();
                }
            }


            if (U_id == -1 & !c)
            {
                PasswordText.Visible = false;
                mailText.Visible     = false;
                ValidInfo.Visible    = true;
                ValidInfo.Text       = "Your acount was deactivted.";
                mail1 = "";
                pass1 = "";
            }
            else if (U_id == -1)
            {
                PasswordText.Visible = false;
                mailText.Visible     = false;
                ValidInfo.Visible    = true;
                ValidInfo.Text       = "Please inter Valide Information .";
                mail1 = "";
                pass1 = "";
            }
            else
            {
                Session["ID"] = U_id;
                Response.Redirect("~/Default.aspx");
                mail1 = "";
                pass1 = "";
            }
        }
    }