//Hide edit functions and save user details to db protected void EditConfirm_Click(object sender, EventArgs e) { //hide edit functions txtAccfName.Visible = false; lblAccfName.Visible = true; txtAcclName.Visible = false; lblAcclName.Visible = true; txtAccAddress.Visible = false; lblAccAddress.Visible = true; txtAccPhoneNumber.Visible = false; lblAccPhoneNumber.Visible = true; EditDetailsbtn.Visible = true; EditConfirmbtn.Visible = false; //update database details GETSET objuseraccount = new GETSET(); objuseraccount.FirstNameGetSet = txtAccfName.Text; objuseraccount.LastNameGetSet = txtAcclName.Text; objuseraccount.StreetAddressGetSet = txtAccAddress.Text; objuseraccount.PhoneNumberGetSet = txtAccPhoneNumber.Text; objuseraccount.EmailAddressGetSet = (string)(Session["id"]); BL2 changeUserDetails = new BL2(); changeUserDetails.UserRegistration(objuseraccount); Response.Redirect("Account.aspx"); }
public object FetchProductDetails(GETSET objUserBusinessLayer) { using (SqlConnection connection = new SqlConnection(WebConfigurationManager.ConnectionStrings["PCPARTSEXPRESSDB"].ConnectionString)) { SqlCommand GetProducts = new SqlCommand("Select productID, categoryName, productName, model, manufacturer, price, stockcount, description, releaseDate from Products where productID = @id", connection); GetProducts.Parameters.AddWithValue("@id", objUserBusinessLayer.IDGetSet); connection.Open(); SqlDataReader dr = GetProducts.ExecuteReader(); while (dr.Read()) { objUserBusinessLayer.IDGetSet = dr[0].ToString(); objUserBusinessLayer.CategoryGetSet = dr[1].ToString(); objUserBusinessLayer.ProductNameGetSet = dr[2].ToString(); objUserBusinessLayer.ModelGetSet = dr[3].ToString(); objUserBusinessLayer.ManufacturerGetSet = dr[4].ToString(); objUserBusinessLayer.PriceGetSet = Convert.ToInt32(dr[5]); objUserBusinessLayer.StockcountGetSet = Convert.ToInt32(dr[6]); objUserBusinessLayer.DescriptionGetSet = dr[7].ToString(); objUserBusinessLayer.ReleaseDateGetSet = Convert.ToDateTime(dr[8].ToString()); } return(objUserBusinessLayer); } }
protected void BtnSubmit_Click(object sender, EventArgs e) { string Output = string.Empty; //Once new item details are filled in a client side verified add verified data to database if (Page.IsValid) { GETSET objuserBusinesslayer = new GETSET(); //get data from user layer objuserBusinesslayer.ProductNameGetSet = txtbxproductname.Text; objuserBusinesslayer.CategoryGetSet = ddlcategory.Text; objuserBusinesslayer.ModelGetSet = txtbxmodel.Text; objuserBusinesslayer.ManufacturerGetSet = txtbxmanufacturer.Text; objuserBusinesslayer.PriceGetSet = Convert.ToInt32(txtbxprice.Text); objuserBusinesslayer.StockcountGetSet = Convert.ToInt32(txtbxstock.Text); objuserBusinesslayer.DescriptionGetSet = txtbxdescription.Text; objuserBusinesslayer.ReleaseDateGetSet = DateTime.Now; //save data to database BL2 objuserBl2 = new BL2(); Output = objuserBl2.InsertNewProduct(objuserBusinesslayer); lblconfirmation.Visible = true; //reset data for new item entry txtbxproductname.Text = ""; ddlcategory.SelectedIndex = 0; txtbxmodel.Text = ""; txtbxmanufacturer.Text = ""; txtbxprice.Text = ""; txtbxstock.Text = ""; txtbxdescription.Text = ""; } }
//Button event takes the users email and password and compares it to current session registration// protected void BtnLogin_Click(object sender, EventArgs e) { //login to site redirection and validation test if (Page.IsValid) { //taking user input details and comapairing it with the data stored in database string Output = string.Empty; GETSET objuserBusinesslayer = new GETSET(); objuserBusinesslayer.EmailAddressGetSet = txtemailaddress.Text; objuserBusinesslayer.PasswordGetSet = passwordLogin.Text; BL2 objuserBl2 = new BL2(); Output = objuserBl2.CheckAccountDetails(objuserBusinesslayer); //returned strings are checked for customer or admin to redirect specific logins and set session variables if (string.Compare(Output, "correctc") == 0) { Session["id"] = txtemailaddress.Text; Response.Redirect("~/User_Layer/Account.aspx"); } if (string.Compare(Output, "correcta") == 0) { Session["idAdmin"] = txtemailaddress.Text; Response.Redirect("~/User_Layer/AdminMain.aspx"); } else { lblError.Text = "Incorrect Email or Password"; } } }
protected void Page_Load(object sender, EventArgs e) { //Retrieve admin user details GETSET objuseraccount = new GETSET(); objuseraccount.EmailAddressGetSet = (string)(Session["idAdmin"]); BL2 details = new BL2(); details.AdminDetails(objuseraccount); //Display User Details lblAccName.Text = objuseraccount.FirstNameGetSet + " " + objuseraccount.LastNameGetSet; lblAccEmail.Text = objuseraccount.EmailAddressGetSet; }
public string AddRegistration(GETSET objuserbusinessLayer) { using (SqlConnection connection = new SqlConnection(WebConfigurationManager.ConnectionStrings["PCPARTSEXPRESSDB"].ConnectionString)) { SqlCommand adduserCommand = new SqlCommand("INSERT INTO [dbo].[Customer] (CustomerEmailAddress, firstName, lastName, [CustomerPassword], Address, contactNo) VALUES(@emailAddress, @firstname, @lastname, @password, @Address, @contactNo)", connection); connection.Open(); adduserCommand.Parameters.AddWithValue("@emailAddress", objuserbusinessLayer.EmailAddressGetSet); adduserCommand.Parameters.AddWithValue("@firstname", objuserbusinessLayer.FirstNameGetSet); adduserCommand.Parameters.AddWithValue("@lastname", objuserbusinessLayer.LastNameGetSet); adduserCommand.Parameters.AddWithValue("@password", objuserbusinessLayer.PasswordGetSet); adduserCommand.Parameters.AddWithValue("@Address", objuserbusinessLayer.StreetAddressGetSet + " " + objuserbusinessLayer.SuburbsGetSet + " " + objuserbusinessLayer.StateGetSet); adduserCommand.Parameters.AddWithValue("@contactNo", objuserbusinessLayer.PhoneNumberGetSet); adduserCommand.ExecuteNonQuery(); } return(""); }
public string UpdateRegistration(GETSET objuserbusinessLayer) { string query = "UPDATE [Customer] SET firstName = @firstname, lastName = @lastname, Address = @Address, contactNo = @PhoneNumber WHERE CustomerEmailAddress = @EmailAddress"; using (SqlConnection connection = new SqlConnection(WebConfigurationManager.ConnectionStrings["PCPARTSEXPRESSDB"].ConnectionString)) { SqlCommand command = new SqlCommand(query, connection); connection.Open(); command.Parameters.AddWithValue("@EmailAddress", objuserbusinessLayer.EmailAddressGetSet); command.Parameters.AddWithValue("@firstname", objuserbusinessLayer.FirstNameGetSet); command.Parameters.AddWithValue("@lastname", objuserbusinessLayer.LastNameGetSet); command.Parameters.AddWithValue("@Address", objuserbusinessLayer.StreetAddressGetSet); command.Parameters.AddWithValue("@PhoneNumber", objuserbusinessLayer.PhoneNumberGetSet); command.ExecuteNonQuery(); } return(""); }
//user account details on page load protected void Page_Load(object sender, EventArgs e) { //load user account details GETSET objuseraccount = new GETSET(); objuseraccount.EmailAddressGetSet = (string)(Session["id"]); BL2 getUserDetails = new BL2(); getUserDetails.UserDetails(objuseraccount); //Display user account details lblAccfName.Text = objuseraccount.FirstNameGetSet; lblAcclName.Text = objuseraccount.LastNameGetSet; lblAccAddress.Text = objuseraccount.StreetAddressGetSet; lblAccPhoneNumber.Text = objuseraccount.PhoneNumberGetSet; lblAccEmail.Text = objuseraccount.EmailAddressGetSet; lblAccName2.Text = objuseraccount.FirstNameGetSet + " " + objuseraccount.LastNameGetSet; }
public string AddNewProduct(GETSET objUserBusinessLayer) { using (SqlConnection connection = new SqlConnection(WebConfigurationManager.ConnectionStrings["PCPARTSEXPRESSDB"].ConnectionString)) { SqlCommand NewProducts = new SqlCommand("insert into products(categoryName, productName, model, manufacturer, price, stockcount, description, releaseDate) values(@categoryName, @productName, @model, @manufacturer, @price, @stockcount, @description, @releaseDate)", connection); NewProducts.Parameters.AddWithValue("@categoryName", objUserBusinessLayer.CategoryGetSet); NewProducts.Parameters.AddWithValue("@productName", objUserBusinessLayer.ProductNameGetSet); NewProducts.Parameters.AddWithValue("@model", objUserBusinessLayer.ModelGetSet); NewProducts.Parameters.AddWithValue("@manufacturer", objUserBusinessLayer.ManufacturerGetSet); NewProducts.Parameters.AddWithValue("@price", objUserBusinessLayer.PriceGetSet); NewProducts.Parameters.AddWithValue("@stockcount", objUserBusinessLayer.StockcountGetSet); NewProducts.Parameters.AddWithValue("@description", objUserBusinessLayer.DescriptionGetSet); NewProducts.Parameters.AddWithValue("@releaseDate", objUserBusinessLayer.ReleaseDateGetSet); connection.Open(); NewProducts.ExecuteNonQuery(); } return(""); }
//on product page load read data and fill out template to display data protected void Page_Load(object sender, EventArgs e) { //obtain product details GETSET productdetails = new GETSET(); productdetails.IDGetSet = (string)Session["productdetails"]; BL2 getProduct = new BL2(); getProduct.ProductDetails(productdetails); string category = productdetails.CategoryGetSet; //apply product details to user layer display lblProductName.Text = productdetails.ProductNameGetSet; lblPrice.Text = Convert.ToString(productdetails.PriceGetSet); int stock = productdetails.StockcountGetSet; lblStock2.Text = Convert.ToString(productdetails.StockcountGetSet); lblDescription.Text = productdetails.DescriptionGetSet; lblManufacturer.Text = productdetails.ManufacturerGetSet; lblModel.Text = productdetails.ModelGetSet; lblReleaseDate.Text = productdetails.ReleaseDateGetSet.ToString(); //test if stock is avaliable and display avaliable or unavaliable and grey out button if (stock > 0) { lblStock.Text = "In Stock"; } else { lblStock.Text = "Out of Stock"; AddToCartBtn.Enabled = false; } //set bread crumb title for the items category catref.Text = " " + category + " -> "; breadcrumref.Text = lblProductName.Text; //set visibility of edit item detials if ((string)Session["idAdmin"] != null) { btnEditPage.Visible = true; } }
public string UpdateProductDetails(GETSET objUserBusinessLayer) { using (SqlConnection connection = new SqlConnection(WebConfigurationManager.ConnectionStrings["PCPARTSEXPRESSDB"].ConnectionString)) { SqlCommand NewProducts = new SqlCommand("Update products SET productName = @productName, model = @model, manufacturer = @manufacturer, price = @price, stockcount = @stockcount, description = @description, releaseDate = @releaseDate WHERE productID = @productID ", connection); NewProducts.Parameters.AddWithValue("@productID", objUserBusinessLayer.IDGetSet); NewProducts.Parameters.AddWithValue("@productName", objUserBusinessLayer.ProductNameGetSet); NewProducts.Parameters.AddWithValue("@model", objUserBusinessLayer.ModelGetSet); NewProducts.Parameters.AddWithValue("@manufacturer", objUserBusinessLayer.ManufacturerGetSet); NewProducts.Parameters.AddWithValue("@price", objUserBusinessLayer.PriceGetSet); NewProducts.Parameters.AddWithValue("@stockcount", objUserBusinessLayer.StockcountGetSet); NewProducts.Parameters.AddWithValue("@description", objUserBusinessLayer.DescriptionGetSet); NewProducts.Parameters.AddWithValue("@releaseDate", objUserBusinessLayer.ReleaseDateGetSet); connection.Open(); NewProducts.ExecuteNonQuery(); } return(""); }
public object GetAdminAccountDetails(GETSET objUserBusinessLayer) { using (SqlConnection connection = new SqlConnection(WebConfigurationManager.ConnectionStrings["PCPARTSEXPRESSDB"].ConnectionString)) { SqlCommand GetAccountSC = new SqlCommand("Select AdminEmailAddress, firstName, lastName from Admin where AdminEmailAddress=@email", connection); GetAccountSC.Parameters.AddWithValue("@email", objUserBusinessLayer.EmailAddressGetSet); connection.Open(); SqlDataReader dr = GetAccountSC.ExecuteReader(); while (dr.Read()) { objUserBusinessLayer.EmailAddressGetSet = dr[0].ToString(); objUserBusinessLayer.FirstNameGetSet = dr[1].ToString(); objUserBusinessLayer.LastNameGetSet = dr[2].ToString(); } return(objUserBusinessLayer); } }
public string CheckAccountCustomer(GETSET objuserbusinessLayer) { using (SqlConnection connection = new SqlConnection(WebConfigurationManager.ConnectionStrings["PCPARTSEXPRESSDB"].ConnectionString)) { SqlCommand CheckaccountSDA = new SqlCommand("Select CustomerEmailAddress, CustomerPassword from Customer where (CustomerEmailAddress=@email and CustomerPassword=@password)", connection); CheckaccountSDA.Parameters.AddWithValue("@email", objuserbusinessLayer.EmailAddressGetSet); CheckaccountSDA.Parameters.AddWithValue("@password", objuserbusinessLayer.PasswordGetSet); SqlDataAdapter SDA = new SqlDataAdapter(CheckaccountSDA); DataTable dt = new DataTable(); SDA.Fill(dt); if (dt.Rows.Count > 0) { return("correctc"); } else { return(null); } } }
protected void btnSave_Click(object sender, EventArgs e) { GETSET SetNewDetails = new GETSET(); SetNewDetails.IDGetSet = (string)Session["productdetails"]; SetNewDetails.ProductNameGetSet = txtbxProductName.Text; SetNewDetails.PriceGetSet = Convert.ToInt32(txtbxPrice.Text); SetNewDetails.StockcountGetSet = Convert.ToInt32(txtbxStock.Text); SetNewDetails.DescriptionGetSet = txtbxDescription.Text; SetNewDetails.ManufacturerGetSet = txtbxManufacturer.Text; SetNewDetails.ModelGetSet = txtbxModel.Text; SetNewDetails.ReleaseDateGetSet = Convert.ToDateTime(txtbxReleaseDate.Text); BL2 objectPass = new BL2(); objectPass.UpdateProductDetails(SetNewDetails); btnEditPage.Visible = true; btnSave.Visible = true; lblProductName.Visible = true; lblPrice.Visible = true; lblDescription.Visible = true; lblManufacturer.Visible = true; lblModel.Visible = true; lblReleaseDate.Visible = true; txtbxProductName.Visible = false; txtbxPrice.Visible = false; txtbxStock.Visible = false; txtbxDescription.Visible = false; txtbxManufacturer.Visible = false; txtbxModel.Visible = false; txtbxReleaseDate.Visible = false; btnSave.Visible = false; Response.Redirect("ProductDetail.aspx"); }
protected void BtnRegister_Click(object sender, EventArgs e) { string Output = string.Empty; if (Page.IsValid) { GETSET objuserBusinesslayer = new GETSET(); objuserBusinesslayer.FirstNameGetSet = txtbxfirstname.Text; objuserBusinesslayer.LastNameGetSet = txtbxlastname.Text; objuserBusinesslayer.FirstNameGetSet = txtbxfirstname.Text; objuserBusinesslayer.LastNameGetSet = txtbxlastname.Text; objuserBusinesslayer.SuburbsGetSet = txtbxsuburb.Text; objuserBusinesslayer.StateGetSet = ddlstate.Text; objuserBusinesslayer.PostcodeGetSet = txtbxpostcode.Text; objuserBusinesslayer.PhoneNumberGetSet = txtbxphonenumber.Text; objuserBusinesslayer.EmailAddressGetSet = txtbxemail.Text; objuserBusinesslayer.PasswordGetSet = txtbxpassword.Text; BL2 objuserBl2 = new BL2(); Output = objuserBl2.InsertUserDetails(objuserBusinesslayer); Session["id"] = txtbxemail.Text; Response.Redirect("Account.aspx"); } }