示例#1
0
    protected void Button2_Click(object sender, EventArgs e)
    {
        //////////////////////update Button//////////////////////////
        OracleConnect oc = new OracleConnect("localhost", "orcl", "hr", "hr");

        string    update_cdId_check = string.Format("select * from cd_collection where cd_id = {0}", TextBox2.Text);
        DataTable cd_update_table   = oc.searchDB(update_cdId_check);

        if (String.IsNullOrWhiteSpace(TextBox2.Text) || String.IsNullOrWhiteSpace(TextBox3.Text) || DropDownList1.SelectedItem.Text.Equals("Select From"))
        {
            Label2.Text = "Please enter all informations";
        }
        else if (cd_update_table.Rows.Count == 0)
        {
            Label2.Text = "No Cd with this Id, Please enter correct Id";
        }
        else
        {
            string drop_down = DropDownList1.SelectedItem.Text;
            if (drop_down.Equals("price") || drop_down.Equals("category_id") || drop_down.Equals("genre_id"))
            {
                string    update_cat_id_check       = string.Format("select * from cd_category where category_id = {0}", TextBox3.Text);
                string    update_gen_id_check       = string.Format("select * from cd_genre where genre_id = {0}", TextBox3.Text);
                DataTable cd_update_check_cat_table = oc.searchDB(update_cat_id_check);
                DataTable cd_update_check_gen_table = oc.searchDB(update_gen_id_check);

                if (drop_down.Equals("category_id") && cd_update_check_cat_table.Rows.Count == 0)
                {
                    Label2.Text = "No such categroy id available, Please enter correct Id";
                }
                else if (drop_down.Equals("genre_id") && cd_update_check_gen_table.Rows.Count == 0)
                {
                    Label2.Text = "No such genre id available, Please enter correct Id";
                }
                else
                {
                    string updateQuery1 = string.Format("update cd_collection set {0} = {1} where cd_id= {2}", drop_down, TextBox3.Text, TextBox2.Text);
                    oc.updateDB(updateQuery1);
                    TextBox2.Text = "";
                    TextBox3.Text = "";
                    Label2.Text   = "";
                    oc.close();
                }
            }
            else
            {
                string updateQuery2 = string.Format("update cd_collection set {0} = '{1}' where cd_id= {2}", drop_down, TextBox3.Text, TextBox2.Text);
                oc.updateDB(updateQuery2);
                TextBox2.Text = "";
                TextBox3.Text = "";
                Label2.Text   = "";
                oc.close();
            }
        }
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        ///////////////////update button//////////////////////////
        OracleConnect oc = new OracleConnect("localhost", "orcl", "hr", "hr");

        string    update_genreId_check = string.Format("select * from cd_genre where genre_id = {0}", TextBox2.Text);
        DataTable genre_update_table   = oc.searchDB(update_genreId_check);

        if (String.IsNullOrWhiteSpace(TextBox2.Text) || String.IsNullOrWhiteSpace(TextBox3.Text) || DropDownList1.SelectedItem.Text.Equals("Select From"))
        {
            Label2.Text = "Please enter all informations";
        }
        else if (genre_update_table.Rows.Count == 0)
        {
            Label2.Text = "No genre with this Id, Please enter correct Id";
        }
        else
        {
            string drop_down = DropDownList1.SelectedItem.Text;


            string updateQuery2 = string.Format("update cd_genre set {0} = '{1}' where genre_id= {2}", drop_down, TextBox3.Text, TextBox2.Text);
            oc.updateDB(updateQuery2);
            TextBox2.Text = "";
            TextBox3.Text = "";
            Label2.Text   = "";
            oc.close();
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        ///////////////delete button////////////////////
        OracleConnect oc = new OracleConnect("localhost", "orcl", "hr", "hr");

        string    delete_genreId_check = string.Format("select * from cd_genre where genre_id = {0}", TextBox1.Text);
        DataTable genre_delete_table   = oc.searchDB(delete_genreId_check);

        if (String.IsNullOrWhiteSpace(TextBox1.Text))
        {
            Label1.Text = "Please enter all informations";
        }
        else if (genre_delete_table.Rows.Count == 0)
        {
            Label1.Text = "No Genre with this Id, Please enter correct Id";
        }
        else
        {
            string deleteQuery = string.Format("delete from cd_genre where genre_id={0}", TextBox1.Text);
            oc.updateDB(deleteQuery);
            TextBox1.Text = "";
            //TextBox2.Text = "";
            Label1.Text = "";
            oc.close();
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        OracleConnect oc = new OracleConnect("localhost", "orcl", "hr", "hr");

        string    adminusernamecheck = string.Format("select * from np_admin where admin_username = upper('{0}')", TextBox1.Text);
        DataTable admin_table        = oc.searchDB(adminusernamecheck);

        if (String.IsNullOrWhiteSpace(TextBox1.Text) || String.IsNullOrWhiteSpace(TextBox2.Text))
        {
            Label1.Text = "Please enter all informations";
        }
        else if (admin_table.Rows.Count != 0)
        {
            Label1.Text = "User with this name already exists, give another user name";
        }
        else
        {
            string insertQuery = string.Format("insert into np_admin(admin_id, admin_username,admin_password) values(np_admin_sequence.nextval, '{0}', '{1}')", TextBox1.Text.ToUpper(), TextBox2.Text);
            oc.updateDB(insertQuery);
            TextBox1.Text = "";
            TextBox2.Text = "";
            Label1.Text   = "";
            oc.close();
        }
    }
    private void LoadGrid(string q_parameter)
    {
        OracleConnect oc    = new OracleConnect("localhost", "orcl", "hr", "hr");
        string        query = q_parameter;//"select * from products order by id";
        DataTable     table = oc.searchDB(query);

        this.GridView1.DataSource = table;
        this.GridView1.DataBind();
        GridView1.Visible = true;
        oc.close();
    }
    private void LoadGrid(string q_parameter)
    {
        OracleConnect oc    = new OracleConnect("localhost", "orcl", "hr", "hr");
        string        query = q_parameter;//"select * from products order by id";
        DataTable     table = oc.searchDB(query);

        /*  if (!table.IsInitialized)
         * {
         *    Label1.Visible = true;
         *    Label1.Text = "nodata";
         *
         * }*/
        this.GridView1.DataSource = table;
        this.GridView1.DataBind();
        GridView1.Visible = true;
        oc.close();
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        Label1.Visible = false;
        //taking necessary inputs of the customer from a text box.
        string ln       = TextBox1.Text;
        string fn       = TextBox2.Text;
        string loc      = DropDownList1.Text;
        string cell     = TextBox4.Text;
        string email    = TextBox5.Text;
        string username = TextBox6.Text;
        string pass     = TextBox7.Text;

        OracleConnect oc = new OracleConnect("localhost", "orcl", "hr", "hr");

        string    usernamecheck = string.Format("select * from np_user where user_name = '{0}'", TextBox6.Text);
        DataTable user_table    = oc.searchDB(usernamecheck);

        //checking whether the fields are empty of not
        if ((String.IsNullOrWhiteSpace(TextBox1.Text) || String.IsNullOrWhiteSpace(TextBox2.Text) || String.IsNullOrWhiteSpace(DropDownList1.Text) ||
             String.IsNullOrWhiteSpace(TextBox6.Text) || String.IsNullOrWhiteSpace(TextBox7.Text)))
        {
            Label1.Visible = true;
            Label1.Text    = "Some of the mandatory fields (ie last name or first name, or location or username & passwords are still unfilled\nfill them properly )";
        }
        else if (user_table.Rows.Count != 0)
        {
            Label1.Visible = true;
            Label1.Text    = "User with this name already exists, give another user name";
        }
        else//if not, this would redirect to sign in page
        {//if everything is okay, insert the customer entry to the np_user schema
            //insert into np_user(user_id, last_name , first_name, location, cell, email, user_name, user_password) values(1,'kazi','mishkat', 'dhanmandi', '123','m@','misha','misha');
            //(np_user_sequence2.nextval,'kazi','mishkat', 'dhanmandi', '123','m@','misha','misha');
            string q1 = "insert into np_user(user_id, last_name , first_name, location, cell, email, user_name, user_password) values(np_user_sequence2.nextval," + "'" + ln + "'," + "'" + fn + "'," + "'" + loc + "'," + "'" + cell + "'," + "'" + email + "'," + "'" + username + "'," + "'" + pass + "')";


            //connecting to oracle
            SqlDataSource1.SelectCommand     = q1;
            SqlDataSource1.SelectCommandType = SqlDataSourceCommandType.Text;
            DataView dv1 = SqlDataSource1.Select(DataSourceSelectArguments.Empty) as DataView;

            //OleDbCommand comd = new OleDbCommand(q1, SqlDataSource1);

            Response.Redirect("~/decorated_home.aspx");
        }
    }
示例#8
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        OracleConnect oc          = new OracleConnect("localhost", "orcl", "hr", "hr");
        string        searchQuery = string.Format("select user_id from np_user where user_name='{0}'", TextBox3.Text);
        //for check purpose
        //this.LoadGrid(searchQuery);
        DataTable user_id_table = oc.searchDB(searchQuery);

        if (user_id_table.Rows.Count == 0)
        {
            Label1.Text   = "enter user name correctly";
            TextBox3.Text = "";
        }
        else
        {
            this.LoadGrid(searchQuery);
        }



        //TextBox1.Text = "";
        //Label1.Text = "";
        oc.close();
    }