protected void btnSubmit_Click(object sender, EventArgs e) { try { if (Page.IsValid) { //Retrieving Control Values string Name = txtName.Text.Trim(); string Surname = txtSurname.Text.Trim(); DateTime DateOfBirth = new DateTimeParser().ParseDate(txtDateOfBirth.Text.Trim().Replace('/', '-')); string Address = txtAddressLine1.Text.Trim().Replace("|", String.Empty) + "|" + txtAddressLine2.Text.Trim().Replace("|", String.Empty); string Town = txtTown.Text.Trim(); string PostCode = txtPostCode.Text.Trim(); string Country = ddlCountry.SelectedItem.Text; string Username = txtUsername.Text.Trim(); string Password = FormsAuthentication.HashPasswordForStoringInConfigFile(txtPassword.Text.Trim(), "MD5"); string ConfirmPassword = FormsAuthentication.HashPasswordForStoringInConfigFile(txtConfirmPassword.Text.Trim(), "MD5"); string Email = txtEmail.Text.Trim(); switch (new UsersLogic().FinalizeSignUp(Name, Surname, DateOfBirth, Address, Email, Town, PostCode, Country, Username, Password)) { case UserSignup.UsernameAndEmailExist: lblServerSideError.Text = "Email Already Exists</br>Username Already Exists"; break; case UserSignup.EmailExists: lblServerSideError.Text = "Email Already Exists"; break; case UserSignup.UsernameExists: lblServerSideError.Text = "Username Already Exists"; break; case UserSignup.Successful: Response.Redirect("~/login.aspx"); break; } } } catch (Exception Exception) { throw Exception; } }
public bool AddPriceType(string UserTypeID, string ProductID, string Price, string DiscountStart, string DiscountEnd, string DiscountPercentage) { try { if (Context.User.IsInRole("Administrator")) { int myUserTypeID = Convert.ToInt32(UserTypeID); Guid myProductID = Guid.Parse(ProductID); double myPrice = Convert.ToDouble(Price); if ((DiscountStart != string.Empty) && (DiscountEnd != string.Empty) && (DiscountPercentage != string.Empty)) { DateTime? myDiscountStart = new DateTimeParser().ParseDate(DiscountStart.Trim().Replace('/', '-')); DateTime? myDiscountEnd = new DateTimeParser().ParseDate(DiscountEnd.Trim().Replace('/', '-')); double? myDiscountPercentage = Convert.ToDouble(DiscountPercentage); if (myDiscountStart < myDiscountEnd) { new PriceTypesLogic().AddPriceType(myUserTypeID, myProductID, myPrice, myDiscountStart, myDiscountEnd, myDiscountPercentage); return true; } else { return false; } } else { new PriceTypesLogic().AddPriceType(myUserTypeID, myProductID, myPrice, null, null, null); return true; } } else { return false; } } catch (Exception Exception) { throw Exception; } }
protected void Page_Load(object sender, EventArgs e) { try { string StartDate = null; string EndDate = null; string Users = null; if((Request.QueryString["sd"] != null) && (Request.QueryString["ed"] != null)) { StartDate = Request.QueryString["sd"].ToString(); EndDate = Request.QueryString["ed"].ToString(); } else if (Request.QueryString["u"] != null) { Users = Request.QueryString["u"].ToString(); } else { Response.Redirect("~/pagenotfound.aspx"); } string HTML = ""; if (Users == null) { DateTime myStartDate = new DateTime(); DateTime myEndDate = new DateTime(); try { myStartDate = new DateTimeParser().ParseDate(StartDate.Replace('/', '-')); myEndDate = new DateTimeParser().ParseDate(EndDate.Replace('/', '-')); } catch (Exception) { Response.Redirect("~/pagenotfound.aspx"); } if (myStartDate > myEndDate) { DateTime myInitialStartDate = myStartDate; DateTime myInitialEndDate = myEndDate; myStartDate = myInitialEndDate; myEndDate = myInitialStartDate; } IQueryable<TopTenView> myTopTenList = new OrdersLogic().RetrieveTopTen(myStartDate, myEndDate); HTML = "<table style=\"font-family: Arial;\" cellpadding=\"6\">"; HTML += "<tr>"; HTML += "<td>"; HTML += "Start Date:"; HTML += "</td>"; HTML += "<td>"; HTML += myStartDate.ToShortDateString(); HTML += "</td>"; HTML += "</tr>"; HTML += "<tr>"; HTML += "<td>"; HTML += "End Date:"; HTML += "</td>"; HTML += "<td>"; HTML += myEndDate.ToShortDateString(); HTML += "</td>"; HTML += "</tr>"; HTML += "</table>"; HTML += "<br/>"; HTML += "<br/>"; HTML += "<table style=\"font-family: Arial;\" cellpadding=\"6\">"; HTML += "<tr>"; HTML += "<td>"; HTML += "Rank"; HTML += "</td>"; HTML += "<td>"; HTML += "Product Name"; HTML += "</td>"; HTML += "<td>"; HTML += "Product Description"; HTML += "</td>"; HTML += "<td>"; HTML += "Quantity Bought"; HTML += "</td>"; HTML += "<tr>"; int Counter = 0; foreach (TopTenView myTopTenItem in myTopTenList) { Counter++; if (Counter > 10) { break; } HTML += "<tr>"; HTML += "<td>"; HTML += Counter; HTML += "</td>"; HTML += "<td>"; HTML += myTopTenItem.ProductName; HTML += "</td>"; HTML += "<td>"; HTML += myTopTenItem.ProductDescription; HTML += "</td>"; HTML += "<td>"; HTML += myTopTenItem.QuantitySold; HTML += "</td>"; HTML += "</tr>"; } HTML += "</table>"; } else { IQueryable<TopTenClients> myTopTenList = new OrdersLogic().RetrieveTopTenClients(); HTML += "<table style=\"font-family: Arial;\" cellpadding=\"6\">"; HTML += "<tr>"; HTML += "<td>"; HTML += "Rank"; HTML += "</td>"; HTML += "<td>"; HTML += "Client Name"; HTML += "</td>"; HTML += "<td>"; HTML += "Quantity Bought"; HTML += "</td>"; HTML += "<tr>"; int Counter = 0; foreach (TopTenClients myTopTenItem in myTopTenList) { Counter++; if (Counter > 10) { break; } HTML += "<tr>"; HTML += "<td>"; HTML += Counter; HTML += "</td>"; HTML += "<td>"; HTML += myTopTenItem.ClientName; HTML += "</td>"; HTML += "<td>"; HTML += myTopTenItem.ProductCount; HTML += "</td>"; HTML += "</tr>"; } HTML += "</table>"; } lblOutput.Text = HTML; } catch (Exception Exception) { throw Exception; } }