Пример #1
0
        protected void searchbtn_Click(object sender, EventArgs e)
        {
            // shows visiblity of  update form when data is read from db
            Update.Visible = true;
            // hide status of update or delete notification
            dvMsg.Visible = false;

            // read from database.
            DBconn mydb = new DBconn();

            mydb.connect();

            // first sqlDataReader is for finding the personal info with email. (CMS_USER)
            SqlDataReader rdr = mydb.execsp("CMS_RecipeBox_Search", new Object[, ] {
                { "@searchEmail", T_email.Text }
            }
                                            );

            GenerateOutPersonalInfo(rdr);
            rdr.Close();
            rdr.Dispose();

            // second sqlDataReader is for finding the one-to-many relationship
            // for all websites to e-mail
            SqlDataReader rdr2 = mydb.execsp("CMS_RecipeBox_Search_Site", new Object[, ] {
                { "@searchEmail", T_email.Text }
            }
                                             );

            ClearCheckBoxes();
            GenerateOutSites(rdr2);
            rdr2.Close();
            rdr2.Dispose();
            mydb.close();
        }
Пример #2
0
        protected void Generate_hashtable()
        {
            DBconn mydb = new DBconn();

            mydb.connect();

            SqlDataReader rdr = mydb.execsp("CMS_RecipeBox_Hashtable", new Object[, ] {
                { "@searchEmail", T_email.Text }
            });

            // generates hashtable by loading table values in
            while (rdr.Read())
            {
                Site_Keys.Add(rdr.GetString(rdr.GetOrdinal("UR")), rdr.GetInt32(rdr.GetOrdinal("Common_WebSiteID")));
            }
            rdr.Close();
            rdr.Dispose();
            mydb.close();
        }
Пример #3
0
        protected void Dlt_btn_Click(object sender, EventArgs e)
        {
            // process update
            DBconn mydb = new DBconn();

            mydb.connect();
            // Delete does not actually remove the information, but simply toggles Active to 0.
            SqlDataReader rdr = mydb.execsp("CMS_RecipeBox_Delete_User", new Object[, ] {
                { "@SearchEmail", T_email.Text }
            });

            rdr.Close();
            rdr.Dispose();
            // clean up the page after processing and no exceptions
            // after db processes clear text boxes
            ClearTextBoxes(Page);
            ClearCheckBoxes();
            // show that the whole process was successful to the user
            dvMsg.Visible = true;
            lblMsg.Text   = "Successfully Deleted!";
        }
Пример #4
0
        protected void Updt_btn_Click(object sender, EventArgs e)
        {
            // process update
            DBconn mydb = new DBconn();

            mydb.connect();
            // commenting out for testing
            // test for exceptions
            // create rdr sqldatareader to pass into a function that will
            // output the data.

            SqlDataReader rdr = mydb.execsp("CMS_RecipeBox_Update", new Object[, ] {
                { "@SearchEmail", T_email.Text },
                { "@EmailAddress", Updt_email.Text },
                { "@FirstName", Updt_fname.Text },
                { "@LastName", Updt_lname.Text },
                { "@Address", Updt_add.Text },
                { "@City", Updt_city.Text },
                { "@PostalCode", Updt_zip.Text }
            }
                                            );

            rdr.Close();
            rdr.Dispose();

            /**********************   SITE UPDATE ****************************/
            // this array is for keeping track of active and inactive website id's
            // We will insert each of the values in the array intoi a temporary sql table
            //we will then determine what is active or non-active check box.
            int[] siteArray;
            siteArray = new int[50];
            // hash table has all the respective site names their id's.  The id's are the values.
            Generate_hashtable();
            // returns array for all active check boxes
            siteArray = count_markboxes();
            // failsafe to eliminate duplicates
            siteArray = siteArray.Distinct().ToArray();
            //Next step is to insert all the elements in the array, 'siteArray' in a new sql temp table
            for (int i = 0; i < siteArray.Length; i++)
            {
                // because I allocated 50 spots for the array, we want to ignore those 0's
                // the first key of the website id's start at 1.
                // this builds the temporary table in sql
                if (siteArray[i] != 0)
                {
                    SqlDataReader rdr2 = mydb.execsp("CMS_RecipeBox_Update_SiteList", new Object[, ] {
                        { "@data", siteArray[i] },
                        { "@SearchEmail", T_email.Text }
                    });
                    rdr2.Close();
                    rdr2.Dispose();
                }
            }
            // now that we built the temp table(is important we delete the data after we do the update)
            // we run the standard update proc for websites
            // this proc should toggle website's Active to 0 or 1 or insert a new site for that user
            SqlDataReader rdr3 = mydb.execsp("CMS_RecipeBox_Update_Site", new Object[, ] {
                { "@SearchEmail", T_email.Text }
            });

            rdr3.Close();
            rdr3.Dispose();
            mydb.close();
            // clean up the page after processing and no exceptions
            // after db processes clear text boxes
            ClearTextBoxes(Page);
            ClearCheckBoxes();
            // show that the whole process was successful to the user
            dvMsg.Visible = true;
            lblMsg.Text   = "Successfully Updated!";
        }