/// DELETE USER
    // btnDeleteUser method
    protected void btnDeleteUser_Click(object sender, EventArgs e)
    {
        // bool for delete error
        bool userDeleteError = false;

        // path for database
        string       tempPath    = Server.MapPath("~/App_Data/dsProgramaholics.mdb");
        clsDataLayer myDataLayer = new clsDataLayer(tempPath);

        // try block to update customer
        try
        {
            myDataLayer.DeleteUser(Convert.ToInt32(userID.Text));
        }
        catch (Exception error)
        {
            userDeleteError = true;
            string message = "Error deleting user. Please check your form data. ";
            Master.UserFeedBack.Text = message + error.Message;
        } // end catch

        // if no error update feedback text to display success message
        if (!userDeleteError)
        {
            ClearInput(Page.Controls);
            Master.UserFeedBack.Text = "Customer Updated Succesfully.";
        } // end if
    }     // end delete
Beispiel #2
0
    /// insertUser method
    // add a new user info to database
    protected void btnCreate_Click(object sender, EventArgs e)
    {
        // set error to false
        bool userAddError = false;

        // connection path
        string       tempPath = Server.MapPath("~/App_Data/Programaholics.mdb");
        clsDataLayer myData   = new clsDataLayer(tempPath);

        // try to add new user
        try
        {
            // insert user details
            myData.InsertUser(txtFirstName.Text, txtLastName.Text,
                              txtEmail.Text, txtPassword.Text, txtStreet.Text, txtCity.Text,
                              txtState.Text);
            myData.InsertUserProgram(txtFav.Text, txtLeast.Text);

            myData.InsertUserCompleted(txtProgramName.Text, txtProgramLanguage.Text, txtDate.Text);
        } // end try
        catch (Exception error)
        {
            userAddError = true;
            string message = "Error adding user, please check your information! ";
            Master.UserFeedBack.Text = message + error.Message;
        } // end catch

        // if no error
        if (!userAddError)
        {
            ClearInputs(Page.Controls);
            Master.UserFeedBack.Text = "User added successfully! ";
            BindUserGrid();
        }
    }
Beispiel #3
0
    // UpdateUser_click method
    protected void btnUpdate_Click(object sender, EventArgs e)
    {
        // start off error as false
        bool userUpdateError = false;

        // path for database
        string       tempPath = Server.MapPath("~App_Data/Programaholics.mdb");
        clsDataLayer myData   = new clsDataLayer(tempPath);

        // try to update, catch error
        try
        {
            myData.UpdateTblUser(txtFirstName.Text, txtLastName.Text,
                                 txtEmail.Text, txtPassword.Text, txtStreet.Text, txtCity.Text, txtState.Text);

            myData.UpdateTblProgram(txtFav.Text, txtLeast.Text);

            myData.UpdateTblCompleted(txtProgramLanguage.Text, txtProgramName.Text, txtDate.Text);
        } // end try
        catch (Exception error)
        {
            userUpdateError = true;
            string message = "Error updating user information! Please check your info. ";
            Master.UserFeedBack.Text = message + error.Message;
        } // end catch

        // if there is no error updating
        if (!userUpdateError)
        {
            ClearInputs(Page.Controls);
            Master.UserFeedBack.Text = "User information updated Successfully! ";
            BindUserGrid();
        }
    }
    }     // end btnUpdate

    /// add a new customer button
    // btnAdd_Click method
    protected void btnAddUser_Click(object sender, EventArgs e)
    {
        // customer error set to false
        bool userAddError = false;

        // path to database
        string       tempPath    = Server.MapPath("~/App_Data/dsProgramaholics.mdb");
        clsDataLayer myDataLayer = new clsDataLayer(tempPath);

        // try block to insert customer information
        try
        {
            // insert info
            myDataLayer.InsertUser(txtFirstName.Text, txtLastName.Text,
                                   txtStreet.Text, txtCity.Text, txtState.Text,
                                   txtUsername.Text, txtPassword.Text, txtFavLanguage.Text,
                                   txtLeastFavLang.Text, txtDateCompleted.Text);
        }
        catch (Exception error)
        {
            // catch the error & display error message
            userAddError = true;
            string message = "Error adding user, please check form data. ";
            Master.UserFeedBack.Text = message + error.Message;
        } // end catch

        // if there is no error display success message
        if (!userAddError)
        {
            ClearInput(Page.Controls);
            Master.UserFeedBack.Text = "User Added Successfully.";
        } // end if
    }
Beispiel #5
0
    protected void submitNewCategoryTime(object sender, EventArgs e)
    {
        int      catID;
        DateTime startDateTimeObject;
        DateTime endDateTimeObject;

        if (dropdownCategoryTypes.SelectedIndex == 0)
        {
            catMessageText.InnerHtml = "Please select a category";
        }
        else if (catStartTime.Text == "")
        {
            catMessageText.InnerHtml = "Please enter a start time";
        }
        else if (catEndTime.Text == "")
        {
            catMessageText.InnerHtml = "Please enter an end time";
        }
        if ((catID = dropdownCategoryTypes.SelectedIndex) != -1)
        {
            catID = dropdownCategoryTypes.SelectedIndex;

            string startDate = catStartDate.Text + ' ' + catStartTime.Text;
            startDateTimeObject = Convert.ToDateTime(startDate);

            string endDate = catEndDate.Text + ' ' + catEndTime.Text;
            endDateTimeObject = Convert.ToDateTime(endDate);

            clsDataLayer dataLayer = new clsDataLayer();

            dataLayer.InsertCategoryInstance(username, catID, startDateTimeObject, endDateTimeObject);
        }

        Response.Redirect("frmDashBoard.aspx");
    }
    // Method to delete customers
    protected void btnDelete_Click(object sender, EventArgs e)
    {
        // Set to false to ensure completion
        bool userUpdateError = false;

        // Mine is in App_Data
        string       tempPath    = Server.MapPath("~/App_Data/Users.accdb");
        clsDataLayer myDataLayer = new clsDataLayer(tempPath);

        // Try-catch statement to delete users
        try
        {
            myDataLayer.DeleteUser(txtUsername.Text, txtCity.Text,
                                   txtState.Text, txtFavLang.Text, txtWorstLang.Text, txtLastProgram.Text);
        }

        // Error details for syntax, spelling or run-time issues.
        catch (Exception error)
        {
            userUpdateError = true;
            string message = "Error updating customer, please check form data. ";
            Master.UserFeedBack.Text = message + error.Message;
        }

        // If no errors, success has been made
        if (!userUpdateError)
        {
            // Wipes the controls so another update can be made
            ClearInputs(Page.Controls);
            Master.UserFeedBack.Text = "Customer Updated Successfully.";
        }

        // Necessary for displaying the info for the table "Customers in Database"
        BindCustomerGridView();
    }
Beispiel #7
0
    protected void Page_Load(object sender, EventArgs e)
    {
        startDate               = DateTime.Today.ToString("yyyy/MM/dd");
        connectionString        = @"Server=" + SERVER + @";Database=" + DATABASE + @";Uid=" + UID + @";Pwd=" + PWD;
        DataLayer               = new clsDataLayer();
        username                = Session["sessionUserID"].ToString();
        usernameLabel.InnerText = username;

        // TODO: move code in to this method
        //GetCategoryTypes();


        //loads categories
        clsDataLayer cls;

        if (!IsPostBack)
        {
            cls = new clsDataLayer();
            dropdownCategoryTypes.DataSource     = cls.GetCategoryTypes((string)Session["sessionUserID"]);
            dropdownCategoryTypes.DataTextField  = "CatName";
            dropdownCategoryTypes.DataValueField = "CatID";
            dropdownCategoryTypes.DataBind();
            dropdownCategoryTypes.Items.Insert(0, new ListItem("--Select Category--", "0"));
            getChartData(username);
        }
        else
        {
        }
    }
Beispiel #8
0
    protected void cmdFind_Click(object sender, EventArgs e)
    {
        //creates a new data access layer object.
        clsDataLayer myDAL = new clsDataLayer();
        dsAddress    myAddressSet;

        //call the FindAddress method in the data access layer and store the results in myAddressSet.
        myAddressSet   = (myDAL.FindAddress(Server.MapPath("~/App_Data/AddressBook.mdb"), Convert.ToInt32(txtAddressId.Text)));
        lblStatus.Text = string.Empty;

        //if the above operation returns a myAddressSet that is not null and contains a row then display the information in the forms textboxes.
        if (!(myAddressSet == null) && (myAddressSet.tblAddressBook.Rows.Count != 0))
        {
            this.txtFirstName.Text   = myAddressSet.tblAddressBook[0].FirstName.ToString();
            this.txtLastName.Text    = myAddressSet.tblAddressBook[0].LastName.ToString();
            this.txtEmail.Text       = myAddressSet.tblAddressBook[0].Email.ToString();
            this.txtPhoneNumber.Text = myAddressSet.tblAddressBook[0].PhoneNumber.ToString();

            Session.Add("ValidRecord", true);
        }
        else
        {
            //dislay a message in the status label that no record was found.
            lblStatus.Text = "No record was found";
            Session.Add("ValidRecord", false);
        }

        BindGridView();
    }
    //Adds click event that calls Data Layer method InsertCustomer.
    protected void btnAddCustomer_Click(object sender, EventArgs e)
    {
        //Creates a boolean to false if the add customer creates an error
        bool customerAddError = false;

        //accesses Accounts.mdb database for the clsDataLayer
        string       tempPath    = Server.MapPath("Accounts.mdb");
        clsDataLayer myDataLayer = new clsDataLayer(tempPath);

        //Inserts Customer Information for all fields
        try
        {
            myDataLayer.InsertCustomer(txtUserName.Text, txtCity.Text, txtState.Text, txtLeastLanguage.Text, txtFavoriteLanguage.Text, txtDateCompleted.Text);
        }
        catch (Exception error)
        {
            customerAddError = true;
            string message = "Error adding customer, please check form data. ";
            Master.UserProgrammer.Text = message + error.Message;
        }

        if (!customerAddError)
        {
            ClearInputs(Page.Controls);
            Master.UserProgrammer.Text = "Customer Added Successfully";
        }

        //Binds CustomerGridView()
        BindCustomerGridView();
    }
Beispiel #10
0
    protected void LnkBtnAdd_Click(object sender, EventArgs e)
    {
        clsDataLayer cls = new clsDataLayer();

        cls.AddCategory(Session["sessionUserID"].ToString(), txbxCatName.Text, txbxCatDesc.Text);
        Response.Redirect("frmEditCategories.aspx");
    }
Beispiel #11
0
    protected void LnkBtnUpdate_Click(object sender, EventArgs e)
    {
        clsDataLayer cls = new clsDataLayer();

        cls.UpdateCategory(Int32.Parse(Session["UpdateCatID"].ToString()), txbxCatName.Text, txbxCatDesc.Text, "T");
        Response.Redirect("frmEditCategories.aspx");
    }
    protected void btnDeleteUser_Click(object sender, EventArgs e)
    {
        //Creates a boolean to false if the update creates an error
        bool customerDeleteError = false;

        //accesses Accounts.mdb database for the clsDataLayer
        string       tempPath    = Server.MapPath("Accounts.mdb");
        clsDataLayer myDataLayer = new clsDataLayer(tempPath);

        //Deletes User Name
        try
        {
            myDataLayer.DeleteInfo(txtUserName.Text, txtCity.Text, txtState.Text, txtLeastLanguage.Text, txtFavoriteLanguage.Text);
        }
        catch (Exception error)
        {
            customerDeleteError = true;
            string message = "Error deleting customer, please check form data. ";
            Master.UserProgrammer.Text = message + error.Message;
        }
        if (!customerDeleteError)
        {
            ClearInputs(Page.Controls);
            Master.UserProgrammer.Text = "Customer Deleted Successfully";
        }
    }
Beispiel #13
0
        } /* end Page_Load() */

        protected void btnLogOut_Click(object sender, EventArgs e)
        {
            clsDataLayer c = new clsDataLayer();

            c.signOut();
            Response.Redirect("/Default.aspx");
        }
Beispiel #14
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // instantiate objects for method access //
            clsDataLayer c = new clsDataLayer();
            clsCustomers p = new clsCustomers();

            if (Session["CustomerID"] == null)
            {
                Response.Redirect("~/Customers/CustomerLogin.aspx");
            } /* end if() */

            bool creditCardAdded;

            creditCardAdded = p.checkCCInfoAdded(Convert.ToInt32(Session["CustomerID"]));

            if (!creditCardAdded)
            {
                lblAddCCInfo.Text = "Please click on Account Details below and enter a credit card";
            }

            if (Page.IsPostBack)
            {
                lblAddCCInfo.Visible = false;
            }
        } /* end Page_Load() */
        protected void btmSubmit_Click(object sender, EventArgs e)
        {
            // instantiate clsDataLayer object for access to methods //
            clsDataLayer c = new clsDataLayer();

            // check if form is posting back to Register page //
            if (IsPostBack)
            {
                lblRegistrationSuccess.Visible = true;
            }
            else
            {
                lblRegistrationSuccess.Visible = false;
            } /* end if (IsPostBack) */



            if (c.customerLogin(txtEmail.Text, txtPassword.Text))
            {
                int sessionID = c.getSessionID(txtEmail.Text);
                Session["CustomerID"] = sessionID;
                Response.Redirect("~/Customers/CustomerPortal.aspx");
            }

            {
                // //
                lblLoginError.Text = "Incorrect username/password";
            }
        } /* end btmSubmit_Click() */
 public clsBusinessLayer(string serverMappedPath)
 {
     // NMeggos
     // Contructor init var\values
     // New instance of dl passing relation path to ms access asset.
     dataPath = serverMappedPath;
     myDataLayer = new clsDataLayer(path: String.Format("{0}Accounts.mdb", dataPath));
 }
Beispiel #17
0
 protected void lnkBtnDelete_Click(object sender, EventArgs e)
 {
     if (lstCategoryNames.SelectedIndex >= 0)
     {
         clsDataLayer cls = new clsDataLayer();
         cls.DeleteCategory(Int32.Parse(lstCategoryNames.SelectedValue));
         Response.Redirect("frmEditCategories.aspx");
     }
 }
Beispiel #18
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            clsDataLayer cls = new clsDataLayer();
            Tuple <int, String, String> catInfo = cls.GetCategoryDetails(Int32.Parse(Session["UpdateCatID"].ToString()));

            DataTable dt = cls.GetCategoryTypes(Session["sessionUserID"].ToString());
            txbxCatName.Text = catInfo.Item2;
            txbxCatDesc.Text = catInfo.Item3;
        }
    }
Beispiel #19
0
    protected void Page_Load(object sender, EventArgs e)
    {
        clsDataLayer cdl;

        if (!IsPostBack)
        {
            cdl = new clsDataLayer();
            lstCategoryNames.DataSource     = cdl.GetCategoryTypes((string)Session["sessionUserID"]);
            lstCategoryNames.DataTextField  = "CatName";
            lstCategoryNames.DataValueField = "CatID";
            lstCategoryNames.DataBind();
        }
    }
Beispiel #20
0
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        //instantiate new clsDataLayer object.
        clsDataLayer myDataLayer = new clsDataLayer();

        //string to hold location of database.
        string TempPath = Server.MapPath("App_Data/AddressBook.mdb");

        //call the method in clsDataLayer Object and pass in arguments from the text boxes on the form.
        myDataLayer.InsertAddress(TempPath, txtFirstName.Text, txtLastName.Text, txtPhoneNumber.Text, txtEmail.Text);

        //bind the grid view with the newly added information.
        BindGridView();
    }
Beispiel #21
0
    protected void cmdUpdate_Click(object sender, EventArgs e)
    {
        //create new data access layer object.
        clsDataLayer myDAL = new clsDataLayer();

        //check the session state value for ValidRecord.  If true call the UpdateAddress record which will update the record in the database.
        if (Convert.ToBoolean(Session["ValidRecord"]))
        {
            //call the Update Address method in myDAL clsDataLayer object.
            myDAL.UpdatAddress(Server.MapPath("~/App_Data/AddressBook.mdb"), Convert.ToInt32(txtAddressId.Text), txtFirstName.Text, txtLastName.Text, txtPhoneNumber.Text, txtEmail.Text);
        }

        BindGridView();
    }
        // btn click method to destroy user sessions //
        protected void btnLogOut_Click(object sender, EventArgs e)
        {
            // instantiate clsDataLayer object //
            clsDataLayer c = new clsDataLayer();

            // run the signOut method to clear sessions //
            c.signOut();

            //remove the logout button from navbar
            btnLogOut.Visible  = false;
            lnkProfile.Visible = false;

            // redirect back to login page //
            Response.Redirect("~/Default.aspx");
        }
    }//end clearinputs 


    //bind customer grid view
    private dsAccounts BindCustomerGridView()
    {
        
        string tempPath = Server.MapPath("~/App_Data/Accounts.mdb");
        clsDataLayer myDataLayer = new clsDataLayer(tempPath);

        dsAccounts customerListing = myBusinessLayer.SelectAllCustomers();

        gvCustomerList.DataSource = customerListing.tblCustomers;

        //binding customer list griedview
        gvCustomerList.DataBind();
        Cache.Insert("CustomerDataSet", customerListing);

        return customerListing;
    }
    private dsAccounts BindCustomerGridView()
    {
        //accesses Accounts.mdb database for the clsDataLayer
        string       tempPath    = Server.MapPath("Accounts.mdb");
        clsDataLayer myDataLayer = new clsDataLayer(tempPath);

        //retrieve customer listings from data layer in GetAllCustomers() method
        dsAccounts customerListing = myDataLayer.GetAllCustomers();

        //adds information from customerListing in tblCustomers to the grid view
        gvCustomerList.DataSource = customerListing.tblCustomers;

        //data binds gvCustomerList and inserts into the cache
        gvCustomerList.DataBind();
        Cache.Insert("CustomerDataSet", customerListing);

        return(customerListing);
    }
    private dsAccounts BindOrdersGridView()
    {
        // Pulls data from the database for use
        string tempPath = Server.MapPath("~/App_Data/Accounts.mdb");
        clsDataLayer myDataLayer = new clsDataLayer(tempPath);

        // Adds data from the first to the second
        dsAccounts orderListing = myDataLayer.FillOrders(Username.Text);

        // Adds data from the first to the second
        gvCart.DataSource = orderListing.tblOrders;

        // Caches data collected
        gvCart.DataBind();
        Cache.Insert("CustomerDataSet", orderListing);

        return orderListing;
    }
Beispiel #26
0
    /// BindUserGrid method
    // binds gridview to data
    private dsProgramaholics BindUserGrid()
    {
        // path
        string       tempPath = Server.MapPath("~/App_Data/Programaholics.mdb");
        clsDataLayer myData   = new clsDataLayer(tempPath);

        // get users
        dsProgramaholics userList = myData.GetAllUsers();

        // fill gridview
        gvUsers.DataSource = userList.tblUserDetails;

        // bind gridview
        gvUsers.DataBind();
        Cache.Insert("UserDataSet", userList);

        return(userList);
    }
    private dsAccounts BindCartGridView()
    {
        // Pulls data from the database for use
        string       tempPath    = Server.MapPath("~/App_Data/Accounts.mdb");
        clsDataLayer myDataLayer = new clsDataLayer(tempPath);

        // Adds data from the first to the second
        dsAccounts cartListing = myDataLayer.FillCart(lblCurrentCustomer.Text);

        // Adds data from the first to the second
        gvCart.DataSource = cartListing.tblCart;

        // Caches data collected
        gvCart.DataBind();
        Cache.Insert("CustomerDataSet", cartListing);

        return(cartListing);
    }
Beispiel #28
0
    private dsAccounts BindCustomerGridView()
    {
        // Pulls data from the database for use
        string       tempPath    = Server.MapPath("~/App_Data/Accounts.mdb");
        clsDataLayer myDataLayer = new clsDataLayer(tempPath);

        // Adds data from the first to the second
        dsAccounts customerListing = myDataLayer.GetAllCustomers();

        // Adds data from the first to the second
        gvCustomerList.DataSource = customerListing.tblCustomers;

        // Caches data collected
        gvCustomerList.DataBind();
        Cache.Insert("CustomerDataSet", customerListing);

        return(customerListing);
    }
    // Button with actions to find user's name (not legal name)
    protected void btnFind_Click(object sender, EventArgs e)
    {
        // Instance of object, dsAccounts
        dsAccounts dsFind;

        // My path is via App_Data.
        string       tempPath     = Server.MapPath("~/App_Data/Users.accdb");
        clsDataLayer dataLayerObj = new clsDataLayer(tempPath);


        // Try-catch statement to check for user's info
        try
        {
            // Reference to the usernames
            dsFind = dataLayerObj.FindUser(Username.Text);

            // Another check to make sure data is present
            if (dsFind.tblUsers.Rows.Count > 0)
            {
                // The following variables should be there from the sample data
                txtUsername.Text    = dsFind.tblUsers[0].Username;
                txtCity.Text        = dsFind.tblUsers[0].City;
                txtState.Text       = dsFind.tblUsers[0].State;
                txtFavLang.Text     = dsFind.tblUsers[0].FavLang;
                txtWorstLang.Text   = dsFind.tblUsers[0].WorstLang;
                txtLastProgram.Text = dsFind.tblUsers[0].LastProgram;

                // Default error text
                Master.UserFeedBack.Text = "Record Found";
            }

            else
            {
                // Error text as a complement to above
                Master.UserFeedBack.Text = "No records were found!";
            }
        }
        catch (Exception error)
        {
            // Hopefuly the stack can trace what went wrong.
            string message = "Something went wrong - ";
            Master.UserFeedBack.Text = message + error.Message;
        }
    }
Beispiel #30
0
    protected void GetCategoryTypes()
    {
        if (!IsPostBack)
        {
            clsDataLayer cls = new clsDataLayer();
            //DatacatInfo = cls.GetCategoryDetails( username);

            DataTable dt = cls.GetCategoryTypes(username);
            //dropdownCategoryTypes.Text =


            //ddlTeamLead.DataSource = cmd.ExecuteReader();
            dropdownCategoryTypes.DataSource     = dt;
            dropdownCategoryTypes.DataTextField  = "TeamLead";
            dropdownCategoryTypes.DataValueField = "TeamLead";
            //dropdownCategoryTypes.DataBind();
            //ddlTeamLead.DataBind();
        }
    }
    // find user by last name
    protected void btnFindUser_Click(object sender, EventArgs e)
    {
        dsProgramaholics dsFindLastName;

        // database path
        string       tempPath     = Server.MapPath("~/App_Data/dsProgramaholics.mdb");
        clsDataLayer dataLayerObj = new clsDataLayer(tempPath);

        // try comparing
        try
        {
            dsFindLastName = dataLayerObj.FindUser(txtLastName.Text);

            // if matching record
            if (dsFindLastName.tblProgramaholics.Rows.Count > 0)
            {
                // fill with info
                txtFirstName.Text     = dsFindLastName.tblProgramaholics[0].FName;
                txtLastName.Text      = dsFindLastName.tblProgramaholics[0].LName;
                txtStreet.Text        = dsFindLastName.tblProgramaholics[0].Street;
                txtCity.Text          = dsFindLastName.tblProgramaholics[0].City;
                txtState.Text         = dsFindLastName.tblProgramaholics[0].State;
                txtUsername.Text      = dsFindLastName.tblProgramaholics[0].Email;
                txtPassword.Text      = dsFindLastName.tblProgramaholics[0].Password;
                txtFavLanguage.Text   = dsFindLastName.tblProgramaholics[0].FavLang;
                txtLeastFavLang.Text  = dsFindLastName.tblProgramaholics[0].LeastFavLang;
                txtDateCompleted.Text = dsFindLastName.tblProgramaholics[0].DateComplete.ToString();
                userID.Text           = dsFindLastName.tblProgramaholics[0].ID.ToString();

                Master.UserFeedBack.Text = "Record Found!";
            }//end if
            else
            {
                Master.UserFeedBack.Text = "No Records Found!";
            } //end else
        }     // end try
        catch (Exception error)
        {
            // error message
            string message = "Something went wrong...";
            Master.UserFeedBack.Text = message + " " + error.Message;
        }// end catch
    }