protected void btnSignInBand_Click(object sender, EventArgs e) { SiteDCDataContext _siteContext = new SiteDCDataContext(); string message = "Band email and passwored do not match."; int BandKey = 0; string strBandName = ""; //First: test the email is in data base bool blnNotEmailFlag = true; bool blnNoMatchFlag = true; var queryBnads = from b in _siteContext.TBands select b; foreach (TBand bndBand in queryBnads) { if (bndBand.strEmail == txtEmail.Text) { blnNotEmailFlag = false; if (bndBand.strPassword == txtPassword.Text) { blnNoMatchFlag = false; BandKey = bndBand.intBandID; strBandName = bndBand.strBandName; } break; } } if (blnNotEmailFlag == false && blnNoMatchFlag == false) { if (BandKey > 0) { message = "Welcome back " + strBandName; //TODO For now there is no home page //Response.Redirect("/Admin/?pk=" + BandKey + "&message=" + Server.UrlEncode(message)); //So sending to modify product page // Response.Redirect("/Admin/Products.aspx?&message=" + Server.UrlEncode(message)); if (DataHelper.ValidateUser(txtEmail.Text, txtPassword.Text)) { //Response.Redirect("/Admin/Products.aspx?&message=" + Server.UrlEncode(message)); Response.Redirect("/Admin/Default.aspx?&message=" + Server.UrlEncode(message)); } } else { Response.Write("There was an error retrieving band information"); } } else//If one of the flag is still true - there is a problem { //Name used Response.Write(message); } }
protected void Page_Load(object sender, EventArgs e) { //A connection to the database to be used when geting or updatinh data SiteDCDataContext _siteContext = new SiteDCDataContext(); SiteDCDataContext _siteContext = new SiteDCDataContext(); //A tool that we use to bild the html fof each data item comig in from the database StringBuilder sb = new StringBuilder(); //int intProductId = 1; var queryProducts = from c in _siteContext.TProducts // where c.intProductID == intProductId select c; queryProducts.ToList(); if (queryProducts.Count() > 0) { int intCount = 1; sb.Append("<div class='column-left'><div class='col-md-12'><hr /></div></div>"); foreach (TProduct prod in queryProducts) { sb.Append("<div class='column-left' style='padding-bottom: 10px;text-align:left;'>"); sb.Append("<div style='text-align:left;' class='row'>"); sb.Append("<div class='col-md-2'>"); if (prod.strImageLink != "" && intCount == 1) { sb.Append("<img src='../" + prod.strImageLink + "' class='img-responsive' style='display: block !important;margin-left: auto !important;margin-right: auto !important; '" + " />"); } if (prod.strImageLink != "" && intCount != 1) { sb.Append("<img src='../" + prod.strImageLink + "' class='img-responsive''" + " />"); } sb.Append("</div>"); sb.Append("<div style='text-align:left;' class='col-md-6'>" + prod.strProductName + "</div>"); sb.Append("<div class='col-md-4'>"); sb.Append("</div>"); sb.Append("</div>"); sb.Append("<div class='row'><div class='col-md-12'><hr /></div></div>"); intCount += 1; } } else { sb.Append("<div class='row'><div class='col-md-12'>No products in this category are currently available.</div></div>"); } ltrProducts.Text = sb.ToString(); }
protected void btnSignInCustomer_Click(object sender, EventArgs e) { SiteDCDataContext _siteContext = new SiteDCDataContext(); string message = "Customer email and password do not match."; string cart = Server.UrlDecode(Request.QueryString["cart"]); int CustomerKey = 0; string strCustomerName = ""; //First: test the email is in data base bool blnNotEmailFlag = true; bool blnNoMatchFlag = true; var queryCustomers = from c in _siteContext.TCustomers select c; foreach (TCustomer cstCustomer in queryCustomers) { if (cstCustomer.strEmail == txtEmail.Text) { blnNotEmailFlag = false; if (cstCustomer.strPassword == txtPassword.Text) { blnNoMatchFlag = false; CustomerKey = cstCustomer.intCustomerID; strCustomerName = cstCustomer.strLastName + cstCustomer.strLastName; } break; } } if (blnNotEmailFlag == false && blnNoMatchFlag == false) { if (CustomerKey > 0) { message = "Welcome back " + strCustomerName; if (DataHelper.ValidateCustomer(txtEmail.Text, txtPassword.Text)) { Response.Redirect("/Customer/Default?cart=" + Server.UrlEncode(cart), false); } } else { Response.Write("There was an error retrieving customer information"); } } else//If one of the flag is still true - there is a problem { //Name used Response.Write(message); } }
protected void Page_Load(object sender, EventArgs e) { //cart memory string cart = Server.UrlDecode(Request.QueryString["cart"]); if (cart != "" && cart != null) { hdnPassedCartItemsVariable.Value = cart; } SiteDCDataContext _siteContent = new SiteDCDataContext(); StringBuilder sb = new StringBuilder(); var queryBandsProducts = (from b in _siteContent.TBands join p in _siteContent.TProducts on b.intBandID equals p.intBandID where _siteContent.TProducts.Any() orderby b.intBandID select b).Distinct(); queryBandsProducts.ToList(); var queryBands = from b in _siteContent.TBands orderby b.strBandName select b; queryBands.ToList(); sb.Append("<div class='row'>"); foreach (var item in queryBandsProducts) { sb.Append("<div class='col-md-3'><a href='/Products/Product-Details/?cart=" + cart + "&ck=" + item.intBandID + "&ct=" + item.strBandName.Replace(" ", "-").Replace("&", "and") + "' title='" + item.strBandName + "'><div class='resource-box'>"); // MDE - Placeholder until we setup band image (if we get to it) //string newFileDirectory = Request.PhysicalApplicationPath.ToString() + "Uploads\\Products\\category-" + item.ID + ".jpg"; //if (File.Exists(newFileDirectory)) //{ // sb.Append("<img src='/Uploads/Products/category-" + item.ID + ".jpg' class='img-responsive alt='" + item.MenuName + "' />"); //} //else //{ // sb.Append("<img src='/Uploads/Products/box-na.jpg' class='img-responsive alt='" + item.MenuName + "' />"); //} sb.Append("<strong>" + item.strBandName + "</strong></div></a></div></br>"); //added </br> so list runs down page.//EH 12.04.2019 } sb.Append("</div>"); ltrBands.Text = sb.ToString(); }
protected void Page_Load(object sender, EventArgs e) { lblMessage.Text = Server.UrlDecode(Request.QueryString["message"]); int intBandID = 0; if (HttpContext.Current.Session["UserDetails"] != null) { UserDetails ud = HttpContext.Current.Session["UserDetails"] as UserDetails; intBandID = ud.UserKey; } SiteDCDataContext _siteContent = new SiteDCDataContext(); var queryProducts = from p in _siteContent.TProducts orderby p.intProductID where p.intBandID == intBandID && p.intIsDeleted == 0 || p.intIsDeleted == null select p; queryProducts.ToList(); StringBuilder tl = new StringBuilder(); tl.Append("<table class='table table-condensed'>"); tl.Append("<thead>"); tl.Append("<tr><th colspan='3' class='alignright'><strong><a style='font-size:18px;' href='/Admin/ModifyProduct.aspx'>add Product <i class='fa fa-plus fa-lg'></i></a></strong></th></tr>"); tl.Append("</thead>"); tl.Append("<tbody>"); if (queryProducts.Count() > 0) { foreach (var item in queryProducts) { tl.Append("<tr><td><strong>" + item.strProductName + "</strong></td><td><strong>" + "</strong></td><td style='width: 300px;'><div class='pull-right'><strong><a href='/Admin/ModifyProduct.aspx?pk=" + item.intProductID + "'>Edit Product <i class='fa fa-pencil-square-o fa-lg'></i></a> | <a href ='/Admin/ModifyProduct.aspx?pk=" + item.intProductID + "&a=d' class='delete' data-confirm='Are you sure to delete this product?'>Delete Product <i class='fa fa-trash fa-lg'></i></a></strong></div></td></tr>"); } tl.Append("<tr><td colspan='3'> </td></tr>"); } else { tl.Append("<tr><td colspan='3'>No Content currently available.</td></tr>"); } tl.Append("</tbody>"); tl.Append("</table>"); lblProducts.Text = tl.ToString(); }
protected void btnUpdateCustomerAccount_Click(object sender, EventArgs e) { int intCustomer = 0; if (HttpContext.Current.Session["UserDetails"] != null) { UserDetails ud = HttpContext.Current.Session["UserDetails"] as UserDetails; intCustomer = ud.UserKey; } string message = ""; string strTitle = txtLastName.Text + txtFirstName.Text; SiteDCDataContext _siteContext = new SiteDCDataContext(); if (intCustomer > 0) { var queryCustomer = from c in _siteContext.TCustomers where c.intCustomerID == intCustomer select c; foreach (TCustomer cst in queryCustomer) { cst.strFirstName = txtFirstName.Text; cst.strLastName = txtLastName.Text; cst.strPassword = txtPassword.Text; cst.strEmail = txtEmail.Text; cst.strPhone = txtPhone.Text; int intState = 1; int intGeder = 1; //MDE Added convert to int for ddlState intState = Convert.ToInt32(ddlState.SelectedValue); intGeder = Convert.ToInt32(ddlGender.SelectedValue); cst.intStateID = intState; cst.intGenderID = intGeder; cst.strCity = txtCity.Text; cst.strAddress = txtAddress.Text; cst.strZip = txtZip.Text; } _siteContext.SubmitChanges(); message = strTitle + " account information has been updated."; } Response.Redirect("/Customer/Default.aspx?&message=" + Server.UrlEncode(message)); }
public static UserDetails GetCustomerDetails(int UserKey) { UserDetails ud = new UserDetails(); SiteDCDataContext _siteContext = new SiteDCDataContext(); var queryUsers = from u in _siteContext.TCustomers orderby u.strLastName where u.intCustomerID == UserKey select u; foreach (TCustomer user in queryUsers) { ud.UserKey = user.intCustomerID; ud.isValidUser = true; ud.Username = user.strEmail; ud.Name = user.strLastName + user.strLastName; ud.IsBand = false; } return(ud); }
public static bool ValidateUser(string Username, string Password) { SiteDCDataContext _siteContext = new SiteDCDataContext(); bool validUser = false; var queryUsers = from u in _siteContext.TBands where u.strEmail == Username && u.strPassword == Password select u; if (queryUsers.Count() > 0) { foreach (TBand user in queryUsers) { UpdateUserDetailsSession(user.intBandID); validUser = true; } } return(validUser); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { SiteDCDataContext _siteContext = new SiteDCDataContext(); int intBandID = 0; if (HttpContext.Current.Session["UserDetails"] != null) { UserDetails ud = HttpContext.Current.Session["UserDetails"] as UserDetails; intBandID = ud.UserKey; } var queryBand = from b in _siteContext.TBands where b.intBandID == intBandID select b; foreach (TBand band in queryBand) { txtBandName.Text = band.strBandName; txtEmail.Text = band.strEmail; txtPassword.Text = band.strPassword.ToString(); txtPhone.Text = band.strPhone; ddlState.SelectedValue = band.intStateID.ToString(); txtCity.Text = band.strCity; txtAddress.Text = band.strAddress; txtZip.Text = band.strZip; //ltrHeaderImagePath.Text = band.strHeaderImage; ltrBackgroundImagePath.Text = band.strBackroundImage; } } }
protected void Page_Load(object sender, EventArgs e) { //cart memory string cart = Server.UrlDecode(Request.QueryString["cart"]); if (cart != "" && cart != null) { hdnPassedCartItemsVariable.Value = cart; } SiteDCDataContext _siteContext = new SiteDCDataContext(); StringBuilder sb = new StringBuilder(); int CategoryKey = 0; if (!String.IsNullOrEmpty(Request.QueryString["ck"])) { CategoryKey = Convert.ToInt32(Request.QueryString["ck"]); } if (CategoryKey != 0) { var queryBand = (from b in _siteContext.TBands where b.intBandID == CategoryKey select b).First(); //queryBands.ToList(); StringBuilder sbimg = new StringBuilder(); // MDE - Commented out custom band header image //foreach (var name in queryBands) //{ // ltrBandName.Text = name.strBandName; // sbimg.Append("/" + name.strHeaderImage); //} //imgBand.ImageUrl = sbimg.ToString(); var queryProducts = from p in _siteContext.TProducts where p.intBandID == CategoryKey && p.intIsDeleted == 0 join tp in _siteContext.TTypes on p.intTypeID equals tp.intTypeID join tbp in _siteContext.TBaseTypes on tp.intBaseTypeID equals tbp.intBaseTypeID orderby tp.intBaseTypeID select new { p, tp, tbp }; var queryBandsProducts = from b in _siteContext.TBands join p in _siteContext.TProducts on b.intBandID equals p.intBandID where p.intBandID == CategoryKey orderby p.intTypeID select new { b, p }; queryBandsProducts.ToList(); queryProducts.ToList(); string strBandName = ""; //int intBandNameCount = 1; foreach (var item in queryBandsProducts) { strBandName = item.b.strBandName; //if (intBandNameCount == 1) //{ // sb.Append("<h1><strong>Home page for: </strong>" + strBandName + "</h1><h2>Products for Sale:" + "</h2>"); //} //intBandNameCount += 1; } if (queryProducts.Count() > 0) { sb.Append("<div class='oneBandsProductPAGE'>"); sb.Append("<h1 class='ecBantTitle'>" + queryBand.strBandName + "</h1>"); if (queryBand.strBackroundImage != "") { sb.Append("<img class='OneBandOnly_BacroundImage' src='/" + queryBand.strBackroundImage + "' >"); } sb.Append("<div style='margin-top:75px;'>"); sb.Append("<div class='row'style='margin-left:40px;'>"); //sb.Append("<div class='row'><div class='col-md-12'><hr /></div></div>"); int intPreviousBaseType = queryProducts.First().tbp.intBaseTypeID; int intCurrentBaseType = queryProducts.First().tbp.intBaseTypeID; foreach (var prod in queryProducts) { //Only products with image will be displayed in page to customer if (prod.p.strImageLink == "" || prod.p.strImageLink == null) { continue; } intCurrentBaseType = prod.tbp.intBaseTypeID; if (intCurrentBaseType != intPreviousBaseType) { intPreviousBaseType = intCurrentBaseType; sb.Append("</div>"); sb.Append("<div class='row'style='margin-left:40px;'>"); } sb.Append(" <img style='display:inline; margin-right:100px;' title=' " + prod.p.strProductName + "' class='image-responsive saleImage' src='/" + prod.p.strImageLink + "' runat='server' onclick='addToCart(" + prod.p.intProductID + "," + prod.p.intTypeID + ",\"" + prod.p.strImageLink + "\"," + prod.p.decBandPrice + "," + 1 + ")'" + "/>"); sb.Append("<p style='display:inline; z-index:15; color:darkred;position:relative; top:90px; right:200px; background-color:white; font-weight:bold;'>$ "); sb.Append(prod.p.decBandPrice); sb.Append("</p>"); } sb.Append("</div>"); sb.Append("</div>"); sb.Append("</div>"); } else { sb.Append("<div class='row'><div class='col-md-12'>No products for this band are currently available.</div></div>"); } ltrOneBandProducts.Text = sb.ToString(); } else { sb.Append("<div class='row'><div class='col-md-12'>Band key was not provided</div></div>"); } }
protected void btnUpdateBandAccount_Click(object sender, EventArgs e) { int intBandID = 0; if (HttpContext.Current.Session["UserDetails"] != null) { UserDetails ud = HttpContext.Current.Session["UserDetails"] as UserDetails; intBandID = ud.UserKey; } string message = ""; string strTitle = txtBandName.Text; string sOldHeaderPath = ""; string sOldBackgroundPath = ""; SiteDCDataContext _siteContext = new SiteDCDataContext(); if (intBandID > 0) // Update the Product { var queryBand = from b in _siteContext.TBands where b.intBandID == intBandID select b; foreach (TBand band in queryBand) { //BUG //todo This is not getting the new information FROM the textboxes // MDE - Fixed band.strBandName = txtBandName.Text; band.strEmail = txtEmail.Text; band.strPassword = txtPassword.Text; band.strPhone = txtPhone.Text; int intState = 1; //MDE Added convert to int for ddlState intState = Convert.ToInt32(ddlState.SelectedValue); band.intStateID = intState; band.strCity = txtCity.Text; band.strAddress = txtAddress.Text; band.strZip = txtZip.Text; sOldBackgroundPath = band.strBackroundImage; band.strHeaderImage = sOldHeaderPath; band.strBackroundImage = sOldBackgroundPath; } _siteContext.SubmitChanges(); message = strTitle + " account information has been updated."; } string newFileDirectory = Request.PhysicalApplicationPath.ToString() + "Uploads\\Bands\\" + intBandID + "\\"; //string newBandHeaderPath = ""; if (!Directory.Exists(newFileDirectory)) { Directory.CreateDirectory(newFileDirectory); } //if ((BandHeaderImage.HasFile) && (BandHeaderImage.PostedFile.ContentType.ToLower() == "image/jpeg")) //{ // if (sOldBackgroundPath.Length > 0) // { // string OldDocumentFilePath = Request.PhysicalApplicationPath.ToString() + sOldBackgroundPath.Replace("/", "\\"); // if (File.Exists(OldDocumentFilePath)) // { // File.Delete(OldDocumentFilePath); // } // } // if (sOldHeaderPath.Length > 0) // { // string OldDocumentFilePath2 = Request.PhysicalApplicationPath.ToString() + sOldHeaderPath.Replace("/", "\\"); // if (File.Exists(OldDocumentFilePath2)) // { // File.Delete(OldDocumentFilePath2); // } // } // string newFileName = BandHeaderImage.FileName; // string newFilePath = newFileDirectory + newFileName; // BandHeaderImage.PostedFile.SaveAs(newFilePath); // newBandHeaderPath = "Uploads/Bands/" + intBandID + "/" + BandHeaderImage.FileName; //} //if (newBandHeaderPath.Length > 0) //{ // var queryBands = from b in _siteContext.TBands // where b.intBandID == intBandID // select b; // foreach (TBand tband in queryBands) // { // tband.strHeaderImage = newBandHeaderPath; // } // _siteContext.SubmitChanges(); //} string newBandBackgroundPath = ""; if (!Directory.Exists(newFileDirectory)) { Directory.CreateDirectory(newFileDirectory); } if ((BandBackgroundImage.HasFile) && (BandBackgroundImage.PostedFile.ContentType.ToLower() == "image/jpeg")) { if (sOldBackgroundPath.Length > 0) { string OldDocumentFilePath = Request.PhysicalApplicationPath.ToString() + sOldBackgroundPath.Replace("/", "\\"); if (File.Exists(OldDocumentFilePath)) { File.Delete(OldDocumentFilePath); } } string newFileName = BandBackgroundImage.FileName; string newFilePath = newFileDirectory + newFileName; BandBackgroundImage.PostedFile.SaveAs(newFilePath); newBandBackgroundPath = "Uploads/Bands/" + intBandID + "/" + BandBackgroundImage.FileName; } else { newBandBackgroundPath = sOldBackgroundPath; } if (newBandBackgroundPath.Length > 0) { var queryBands = from b in _siteContext.TBands where b.intBandID == intBandID select b; foreach (TBand tband in queryBands) { tband.strBackroundImage = newBandBackgroundPath; } _siteContext.SubmitChanges(); } Response.Redirect("/Admin/Default.aspx?&message=" + Server.UrlEncode(message)); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { SiteDCDataContext _siteContext = new SiteDCDataContext(); int intBandID = 0; if (HttpContext.Current.Session["UserDetails"] != null) { UserDetails ud = HttpContext.Current.Session["UserDetails"] as UserDetails; intBandID = ud.UserKey; } string Action = Request.QueryString["a"]; int EventKey = 0; if (!String.IsNullOrEmpty(Request.QueryString["pk"])) { EventKey = Convert.ToInt32(Request.QueryString["pk"]); } if (Action == "d") { if (EventKey > 0) // Delete a event. { var queryEvents = from ev in _siteContext.TEvents where ev.intEventID == EventKey && ev.intBandID == intBandID select ev; _siteContext.SubmitChanges(); } Response.Redirect("/admin/events.aspx?message=" + Server.UrlEncode("Event has been deleted.")); } if (EventKey == 0) { btnUpdateProduct.Text = "Add"; FormHeader.Text = "Add a Event"; } else { btnUpdateProduct.Text = "Update"; FormHeader.Text = "Update a Event"; var queryEvents = from ev in _siteContext.TEvents where ev.intEventID == EventKey && ev.intBandID == intBandID select ev; foreach (TEvent events in queryEvents) { EventTitle.Text = events.strEventName; ltrImagePath.Text = events.strImageUrl; txtEventLocation.Text = events.strLocation; txtPrice.Text = events.decEntryPrice.ToString(); lblDate.Text = events.dtmDate.ToString(); } } } }
protected void Page_Load(object sender, EventArgs e) { //lblMessage.Text = Server.UrlDecode(Request.QueryString["message"]); int intBandID = 0; if (HttpContext.Current.Session["UserDetails"] != null) { UserDetails ud = HttpContext.Current.Session["UserDetails"] as UserDetails; intBandID = ud.UserKey; } SiteDCDataContext _siteContent = new SiteDCDataContext(); StringBuilder tl = new StringBuilder(); //Ceating- Report all sales string var queryAllSales = from s in _siteContent.VCustomersPurchases orderby s.intCustomerPurchaseID where s.intBandID == intBandID select s; queryAllSales.ToList(); tl.Append("<div class='DivBorderTableWrappCustomer' style='margin-bottom:60px;'>"); tl.Append("<table class='ReportTable'>"); tl.Append("<thead>"); tl.Append("<tr class='reportTableHeader'>"); tl.Append("<th class='tableDataHeaders'>#Sale</th>"); tl.Append("<th class='tableDataHeaders'>Total</th>"); tl.Append("<th class='tableDataHeaders'>Product</th>"); tl.Append("<th class='tableDataHeaders'>Price</th>"); tl.Append("<th class='tableDataHeaders'>#Units</th>"); tl.Append("<th class='tableDataHeaders'>Product Total</th>"); tl.Append("<th class='tableDataHeaders cusnameTHeader'>Last Name</th>"); tl.Append("<th class='tableDataHeaders cusnameTHeader'>First Name</th>"); tl.Append("<th class='tableDataHeaders'>Date</th>"); tl.Append("</tr>"); tl.Append("</thead>"); tl.Append("<tbody>"); if (queryAllSales.Count() > 0) { foreach (var sale in queryAllSales) { tl.Append("<tr>"); tl.Append("<td class='datecolumnCustomer'>" + sale.intCustomerPurchaseID + " </td>"); tl.Append("<td class='datecolumnCustomer'>$" + sale.Purchase_Total + " </td>"); tl.Append("<td class='datecolumnCustomer customerName'>" + sale.strProductName + " </td>"); tl.Append("<td class='datecolumnCustomer customerName'>$" + sale.decMomentPurchaseUnitPrice + " </td>"); tl.Append("<td class='datecolumnCustomer customerName'>" + sale.intProductPurchaseCount + " </td>"); tl.Append("<td class='datecolumnCustomer customerTotal'>$" + sale.decProductTotal + " </td>"); tl.Append("<td class='datecolumnCustomer'>" + sale.strLastName + " </td>"); tl.Append("<td class='datecolumnCustomer'>" + sale.strFirstName + " </td>"); tl.Append("<td class='datecolumnCustomer'>" + sale.dtmDateTime + " </td>"); tl.Append("</tr>"); } } else { tl.Append("<tr><td colspan='9'>No Content currently available.</td></tr>"); } tl.Append("</tbody>"); tl.Append("</table>"); tl.Append("</div>"); lblAllSales.Text = tl.ToString(); }
protected void btnUpdateProduct_Click(object sender, EventArgs e) { int intBandID = 0; if (HttpContext.Current.Session["UserDetails"] != null) { UserDetails ud = HttpContext.Current.Session["UserDetails"] as UserDetails; intBandID = ud.UserKey; } string message = ""; int ProductKey = 0; if (!String.IsNullOrEmpty(Request.QueryString["pk"])) { ProductKey = Convert.ToInt32(Request.QueryString["pk"]); } string strTitle = ProductTitle.Text; int intQuantity = Int32.Parse(txtQuantity.Text); decimal decPrice = Decimal.Parse(txtPrice.Text); decimal decBandPrice = Decimal.Parse(txtPriceForBand.Text); string sOldProductPath = ""; // Get values of dropdowns and store in variable int intGender = Convert.ToInt32(ddlGender.SelectedValue); int intColor = Convert.ToInt32(ddlColor.SelectedValue); int intSize = Convert.ToInt32(ddlSize.SelectedValue); int intBaseType = Convert.ToInt32(ddlProductBaseType.SelectedValue); SiteDCDataContext _siteContext = new SiteDCDataContext(); if (ProductKey > 0) // Update the Product { var queryProducts = from p in _siteContext.TProducts where p.intProductID == ProductKey && p.intBandID == intBandID select p; // MDE Join for getting types joined to products var queryProductsandTypes = from p in _siteContext.TProducts where p.intProductID == ProductKey && p.intBandID == intBandID join t in _siteContext.TTypes on p.intTypeID equals t.intTypeID select new { p, t }; foreach (var prod in queryProductsandTypes) { prod.p.strProductName = strTitle; sOldProductPath = prod.p.strImageLink; prod.p.strImageLink = sOldProductPath; prod.p.decBandPrice = decPrice; prod.p.intAmountAvialable = intQuantity; prod.p.decCostToBand = decBandPrice; prod.p.intBandID = intBandID; prod.p.intTypeID = prod.t.intTypeID; prod.p.intIsDeleted = 0; // update type table prod.t.intGenderID = intGender; prod.t.intColorID = intColor; prod.t.intBaseTypeID = intBaseType; prod.t.intSizeID = intSize; } _siteContext.SubmitChanges(); message = strTitle + " has been updated."; } else // Add a Product { //add new entry to ttypes TType type = new TType(); type.intBaseTypeID = intBaseType; type.intColorID = intColor; type.intGenderID = intGender; type.intSizeID = intSize; type.strQrCode = ""; type.intIsDeleted = 0; _siteContext.TTypes.InsertOnSubmit(type); _siteContext.SubmitChanges(); TProduct prod = new TProduct(); prod.strProductName = strTitle; prod.strImageLink = ""; prod.decBandPrice = decPrice; prod.decCostToBand = decBandPrice; prod.intAmountAvialable = intQuantity; prod.intIsDeleted = 0; prod.intBandID = intBandID; // Get the ID of the TType entry we just created prod.intTypeID = type.intTypeID; prod.intSortLevel = 10; _siteContext.TProducts.InsertOnSubmit(prod); _siteContext.SubmitChanges(); ProductKey = prod.intProductID; message = strTitle + " has been added."; } string newFileDirectory = Request.PhysicalApplicationPath.ToString() + "Uploads\\Products\\" + ProductKey + "\\"; string newProductPath = ""; if (!Directory.Exists(newFileDirectory)) { Directory.CreateDirectory(newFileDirectory); } if ((ProductImage.HasFile) && (ProductImage.PostedFile.ContentType.ToLower() == "image/jpeg")) { if (sOldProductPath.Length > 0) { string OldDocumentFilePath = Request.PhysicalApplicationPath.ToString() + sOldProductPath.Replace("/", "\\"); if (File.Exists(OldDocumentFilePath)) { File.Delete(OldDocumentFilePath); } } string newFileName = ProductImage.FileName; string newFilePath = newFileDirectory + newFileName; ProductImage.PostedFile.SaveAs(newFilePath); newProductPath = "Uploads/Products/" + ProductKey + "/" + ProductImage.FileName; } else { newProductPath = sOldProductPath; } if (newProductPath.Length > 0) { var queryProducts = from p in _siteContext.TProducts where p.intProductID == ProductKey select p; foreach (TProduct prod in queryProducts) { prod.strImageLink = newProductPath; } _siteContext.SubmitChanges(); } Response.Redirect("/Admin/Products.aspx?message=" + Server.UrlEncode(message)); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { SiteDCDataContext _siteContext = new SiteDCDataContext(); int intBandID = 0; if (HttpContext.Current.Session["UserDetails"] != null) { UserDetails ud = HttpContext.Current.Session["UserDetails"] as UserDetails; intBandID = ud.UserKey; } string Action = Request.QueryString["a"]; int ProductKey = 0; if (!String.IsNullOrEmpty(Request.QueryString["pk"])) { ProductKey = Convert.ToInt32(Request.QueryString["pk"]); } if (Action == "d") { if (ProductKey > 0) // Delete a product. { var queryProducts = (from p in _siteContext.TProducts where p.intProductID == ProductKey select p).First(); queryProducts.intIsDeleted = 1; _siteContext.SubmitChanges(); } Response.Redirect("/admin/products.aspx?message=" + Server.UrlEncode("Product has been deleted.")); } var queryProductsandTypes = from p in _siteContext.TProducts where p.intProductID == ProductKey && p.intBandID == intBandID join t in _siteContext.TTypes on p.intTypeID equals t.intTypeID orderby t.intBaseTypeID select new { p, t }; // Populate the Drop Down Box for basetype var queryProductTypes = from type in _siteContext.TBaseTypes where type.intIsDeleted == 0 orderby type.intBaseTypeID select type; ddlProductBaseType.DataTextField = "strBaseType"; ddlProductBaseType.DataValueField = "intBaseTypeID"; ddlProductBaseType.DataSource = queryProductTypes; ddlProductBaseType.DataBind(); //ddlProductBaseType.SelectedIndex = queryProductsandTypes.First().t.intBaseTypeID-1; // Populate the Drop Down Box for color var queryColors = from color in _siteContext.TColors where color.intIsDeleted == 0 orderby color.intColorID select color; ddlColor.DataTextField = "strColor"; ddlColor.DataValueField = "intColorID"; ddlColor.DataSource = queryColors; ddlColor.DataBind(); //ddlColor.SelectedIndex = queryProductsandTypes.First().t.intColorID - 1; // Populate the Drop Down Box for Size var querySize = from size in _siteContext.TSizes where size.intIsDeleted == 0 orderby size.intSizeID select size; ddlSize.DataTextField = "strFullSize"; ddlSize.DataValueField = "intSizeID"; ddlSize.DataSource = querySize; ddlSize.DataBind(); // // Populate the Drop Down Box for Gender var queryGender = from gender in _siteContext.TGenders where gender.intIsDeleted == 0 orderby gender.intGenderID select gender; ddlGender.DataTextField = "strGender"; ddlGender.DataValueField = "intGenderID"; ddlGender.DataSource = queryGender; ddlGender.DataBind(); //ddlGender.SelectedIndex = queryProductsandTypes.First().t.intGenderID - 1; if (ProductKey == 0) { btnUpdateProduct.Text = "Add"; FormHeader.Text = "Add a Product"; } else { btnUpdateProduct.Text = "Update"; FormHeader.Text = "Update a Product"; var queryProducts = from p in _siteContext.TProducts where p.intProductID == ProductKey && p.intBandID == intBandID select p; //var queryType = from foreach (var prod in queryProductsandTypes) { ProductTitle.Text = prod.p.strProductName; ltrImagePath.Text = prod.p.strImageLink; txtPrice.Text = prod.p.decBandPrice.ToString(); txtPriceForBand.Text = prod.p.decCostToBand.ToString(); txtQuantity.Text = prod.p.intAmountAvialable.ToString(); ddlColor.SelectedIndex = prod.t.intColorID - 1; ddlGender.SelectedIndex = prod.t.intGenderID - 1; ddlProductBaseType.SelectedIndex = prod.t.intBaseTypeID - 1; ddlSize.SelectedIndex = prod.t.intSizeID - 1; } //foreach (TProduct prod in queryProducts) //{ // ProductTitle.Text = prod.strProductName; // ltrImagePath.Text = prod.strImageLink; // txtPrice.Text = prod.decBandPrice.ToString(); // txtPriceForBand.Text = prod.decCostToBand.ToString(); // txtQuantity.Text = prod.intAmountAvialable.ToString(); //} } } }
protected void LinkButtonPurchase_Click(object sender, EventArgs e) { string message = ""; string messageSold = ""; string messageNotSold = ""; SiteDCDataContext _siteContext = new SiteDCDataContext(); foreach (Hashtable htProd in productArrayList) { if (htProd.ContainsKey("Id")) { if (htProd.ContainsKey("Amount")) { var queryProduct = (from c in _siteContext.TProducts where c.intProductID == Convert.ToInt32(htProd["Id"]) select c).First(); var queryEvent = from ev in _siteContext.TEvents where ev.intBandID == intBandID && ev.dtmDate == dtmTodayDate select ev; //ben 12_9 //if (queryProduct != null && queryEvent != null) if (queryProduct != null) { if (queryProduct.intAmountAvialable >= Convert.ToInt32(htProd["Amount"])) { //Removing amount from inventory queryProduct.intAmountAvialable -= Convert.ToInt32(htProd["Amount"]); if (queryEvent.Count() > 0) { queryEvent.First().decEventSales += Convert.ToDecimal(htProd["Amount"]) * Convert.ToDecimal(htProd["Price"]); } //ben 12_9 ////Adding amount sold in this sale from booth to event sales //queryEvent.decEventSales += Convert.ToDecimal(htProd["Amount"])* Convert.ToDecimal(htProd["Price"]); messageSold += Convert.ToInt32(htProd["Amount"]) + " " + queryProduct.strProductName + " sold!."; _siteContext.SubmitChanges(); } else //If not enough in inventory for product { //sellig all products accept the one which there is not have enough in inventory messageNotSold += "We only have" + queryProduct.intAmountAvialable + queryProduct.strProductName + "."; } } } } } message = "Purchase proccesed:" + messageSold + messageNotSold; Response.Redirect("/Admin/BoothSalePoint.aspx?message=" + Server.UrlEncode(message)); //string strUrl = "../Admin/BoothSalePoint.aspx?message=Purchase complete."; //Response.RedirectPermanent(strUrl); //ScriptManager.RegisterStartupScript(this, this.GetType(), "script", "alert ('Sale Complete')", true); }
protected void btnSignUpBand_Click(object sender, EventArgs e) { SiteDCDataContext _siteContext = new SiteDCDataContext(); //First: test the band name is not being used bool blnNameFlag = false; //test the custome eamil is not being used bool blnEmailFlag = false; var queryBnads = from b in _siteContext.TBands select b; foreach (TBand bndBand in queryBnads) { if (bndBand.strBandName == txtBandName.Text) { blnNameFlag = true; break; } if (bndBand.strEmail == txtEmail.Text) { blnEmailFlag = true; break; } } if (blnNameFlag == true) { //Name used Response.Write("The band name is already used."); Response.Write("<script>alert('The band name is already used.')</script>"); txtBandName.Focus(); } else if (blnEmailFlag == true) { //Name used //Response.Write("This email is already used."); // MDE - Trying javascript alert Response.Write("<script>alert('This email is already used.')</script>"); txtEmail.Focus(); } else { string message = ""; string strMusicLink = ""; string strBandName = txtBandName.Text; string strPassword = txtPassword.Text; string strPhone = txtPhone.Text; string strEmail = txtEmail.Text; string strCity = txtCity.Text; string strAddress = txtAddress.Text; string strZip = txtZip.Text; int intState = 1; //MDE Added convert to int for ddlState intState = Convert.ToInt32(ddlState.SelectedValue); TBand band = new TBand(); band.strBandName = strBandName; band.strPassword = strPassword; band.strPhone = strPhone; band.strEmail = strEmail; band.intStateID = intState; band.strCity = strCity; band.strMusicLink = strMusicLink; band.strAddress = strAddress; band.strZip = strZip; string newBandBackgroundPath = ""; band.strHeaderImage = ""; band.strBackroundImage = newBandBackgroundPath; band.strTeamPassword = ""; _siteContext.TBands.InsertOnSubmit(band); _siteContext.SubmitChanges(); int BandKey = band.intBandID; string newFileDirectory = Request.PhysicalApplicationPath.ToString() + "Uploads\\Bands\\" + band.intBandID + "\\"; //string newBandHeaderPath = ""; if (!Directory.Exists(newFileDirectory)) { Directory.CreateDirectory(newFileDirectory); } if ((BandBackgroundImage.HasFile) && (BandBackgroundImage.PostedFile.ContentType.ToLower() == "image/jpeg")) { string newFileName = BandBackgroundImage.FileName; string newFilePath = newFileDirectory + newFileName; BandBackgroundImage.PostedFile.SaveAs(newFilePath); newBandBackgroundPath = "Uploads/Bands/" + BandKey + "/" + BandBackgroundImage.FileName; band.strBackroundImage = newBandBackgroundPath; _siteContext.SubmitChanges(); } message = "Band " + band.strBandName + " has registered."; //} //string newFileDirectory = Request.PhysicalApplicationPath.ToString() + "Uploads\\Bands\\" + BandKey + "\\"; //string newBandHeaderPath = ""; //if (!Directory.Exists(newFileDirectory)) //{ // Directory.CreateDirectory(newFileDirectory); //} //if ((BandHeaderImage.HasFile) && (BandHeaderImage.PostedFile.ContentType.ToLower() == "image/jpeg")) //{ // string newFileName = BandHeaderImage.FileName; // string newFilePath = newFileDirectory + newFileName; // BandHeaderImage.PostedFile.SaveAs(newFilePath); // newBandHeaderPath = "Uploads/Bands/" + BandKey + "/" + BandHeaderImage.FileName; //} //if (newBandHeaderPath.Length > 0) //{ // var queryBands = from b in _siteContext.TBands // where b.intBandID == BandKey // select b; // foreach (TBand tband in queryBands) // { // tband.strHeaderImage = newBandHeaderPath; // } // _siteContext.SubmitChanges(); //} //string newBandBackgroundPath = ""; //if (!Directory.Exists(newFileDirectory)) //{ // Directory.CreateDirectory(newFileDirectory); //} //if ((BandHeaderImage.HasFile) && (BandHeaderImage.PostedFile.ContentType.ToLower() == "image/jpeg")) //{ // string newFileName = BandHeaderImage.FileName; // string newFilePath = newFileDirectory + newFileName; // BandHeaderImage.PostedFile.SaveAs(newFilePath); // newBandBackgroundPath = "Uploads/Bands/" + BandKey + "/" + BandHeaderImage.FileName; //} //if (newBandBackgroundPath.Length > 0) //{ // var queryBands = from b in _siteContext.TBands // where b.intBandID == BandKey // select b; // foreach (TBand tband in queryBands) // { // tband.strBackroundImage = newBandBackgroundPath; // } // _siteContext.SubmitChanges(); //} //Response.Redirect("/Admin/Defaults.aspx?message=" + Server.UrlEncode(message)); //MDE - changed redirect to the band login page Response.Redirect("/BandSignIn.aspx?message=" + Server.UrlEncode(message)); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { SiteDCDataContext _siteContext = new SiteDCDataContext(); int intCustomerID = 0; if (HttpContext.Current.Session["UserDetails"] != null) { UserDetails ud = HttpContext.Current.Session["UserDetails"] as UserDetails; intCustomerID = ud.UserKey; } var queryCustomer = from c in _siteContext.TCustomers where c.intCustomerID == intCustomerID select c; foreach (TCustomer custumer in queryCustomer) { txtFirstName.Text = custumer.strFirstName; txtLastName.Text = custumer.strLastName; txtPassword.Text = custumer.strPassword.ToString(); txtPhone.Text = custumer.strPhone; txtEmail.Text = custumer.strEmail; ddlState.SelectedValue = custumer.intStateID.ToString(); txtCity.Text = custumer.strCity; txtAddress.Text = custumer.strAddress; txtZip.Text = custumer.strZip; ddlGender.Text = custumer.intGenderID.ToString(); } //Building the customer orders string StringBuilder tl = new StringBuilder(); var queryCustomerOrders = _siteContext.VCustomersPurchases .Where(x => x.intCustomerID == intCustomerID) .AsEnumerable() .OrderBy(x => x.intCustomerPurchaseID) .GroupBy(x => new { x.intCustomerPurchaseID, x.strProductName, x.decMomentPurchaseUnitPrice, x.intProductPurchaseCount, x.decProductTotal, x.Purchase_Total, x.dtmDateTime }) .ToList() .Select(x => new { PurchaseId = x.Key.intCustomerPurchaseID, ProductName = x.Key.strProductName, Price = x.Key.decMomentPurchaseUnitPrice, Amount = x.Key.intProductPurchaseCount, ProductTotal = x.Key.decProductTotal, Total = x.Key.Purchase_Total, Date = x.Key.dtmDateTime }) ; tl.Append("<div class='CustomerDivBorderTableWrapp'>"); tl.Append("<table class='CustomerReportTable'>"); tl.Append("<caption class='tableCaption'>Orders</caption >"); tl.Append("<thead>"); tl.Append("<tr class='reportTableHeader'>"); tl.Append("<th class='CustomerTableDataHeaders C_med'>#Purchase</th>"); tl.Append("<th class='CustomerTableDataHeaders C_large'>Product Name</th>"); tl.Append("<th class='CustomerTableDataHeaders C_med'>Price</th>"); tl.Append("<th class='CustomerTableDataHeaders C_small'>#Units</th>"); tl.Append("<th class='CustomerTableDataHeaders C_med'>Product Total</th>"); tl.Append("<th class='CustomerTableDataHeaders C_med'>Purchase Total</th>"); tl.Append("<th class='CustomerTableDataHeaders'>Date</th>"); tl.Append("</tr>"); tl.Append("</thead>"); tl.Append("<tbody>"); if (queryCustomerOrders.Count() > 0) { foreach (var order in queryCustomerOrders) { tl.Append("<tr>"); tl.Append("<td class='datecolumnCustomerGray'>" + order.PurchaseId + " </td>"); tl.Append("<td class='datecolumnCustomer productName'>" + order.ProductName + " </td>"); tl.Append("<td class='datecolumnCustomer'>$" + order.Price + " </td>"); tl.Append("<td class='datecolumnCustomer'>" + order.Amount + " </td>"); tl.Append("<td class='datecolumnCustomer productTotal'>$" + order.ProductTotal + " </td>"); tl.Append("<td class='datecolumnCustomerGray'>$" + order.Total + " </td>"); tl.Append("<td class='datecolumnCustomerGray'>" + order.Date.Month + "/" + order.Date.Day + "/" + order.Date.Year + " </td>"); tl.Append("<tr>"); } } else { tl.Append("<tr><td colspan='7'>No Content currently available.</td></tr>"); } tl.Append("</tbody>"); tl.Append("</table>"); tl.Append("</div>"); lblCustomerOrders.Text = tl.ToString(); //cart memory string cart = Server.UrlDecode(Request.QueryString["cart"]); if (cart != "" && cart != null) { hdnPassedCartItemsVariable.Value = cart; } } }
protected void Page_Load(object sender, EventArgs e) { //cart memory string cart = Server.UrlDecode(Request.QueryString["cart"]); if (cart != "" && cart != null) { hdnPassedCartItemsVariable.Value = cart; } SiteDCDataContext _siteContext = new SiteDCDataContext(); StringBuilder sb = new StringBuilder(); var queryProducts = from p in _siteContext.TProducts select p; queryProducts.ToList(); if (queryProducts.Count() > 0) { int intCount = 1; // MDE this linq to sql query does a join - joining the intBandID from tables TBands and TProducts var queryBandsProducts = from b in _siteContext.TBands join p in _siteContext.TProducts on b.intBandID equals p.intBandID where p.intIsDeleted == 0 orderby p.intBandID select new { b, p }; queryBandsProducts.ToList(); if (queryBandsProducts.Count() > 0) { string strBandName = ""; int intBandID = 1; int intPreviousBandID = 1; bool blnFirstTimeThroughLoop = true; bool blnNewBandDetected = false; // This loop will loop through each product from the queryBands query we made foreach (var item in queryBandsProducts) { //Only products with image will be displayed in page to user if (item.p.strImageLink == "" || item.p.strImageLink == null) { continue; } // MDE - item.p refrers to the 'p' in the 'select new {b, p}' part of the linq query. p represents products // we are setting the variable intBandID equal to the band ID of the item in the current loop intBandID = item.p.intBandID; // We are checking to see if a new bandID has been detected by seeing if the Band ID of the current loop does NOT equal the BandID of the previous loop if (intBandID != intPreviousBandID && blnFirstTimeThroughLoop == false) { blnNewBandDetected = true; intCount = 1; } if (blnNewBandDetected == true) { sb.Append("</div>"); } if (intCount > 4) { continue; } if (blnFirstTimeThroughLoop == true) { sb.Append("<div class='row ImageRow'>"); // MDE - Get the band name from the current loop //strBandName = item.b.strBandName; //sb.Append("<h1 class='ecBantTitle'> <strong>" + strBandName + " </strong></h1>"); strBandName = item.b.strBandName; sb.Append("<h1 class='ecBantTitle'><a id='band" + intBandID + "' style='color:darkred;' href='/Products/Product-Details/?ck=" + item.b.intBandID + "'>" + strBandName + "</a></h1>"); //ben 12/4 if (item.b.strBackroundImage != "") { sb.Append("<img class='BacroundECommerceImages' src='..\\" + item.b.strBackroundImage + "' >"); } } //Ben 12/4 changed //if (intBandID != intPreviousBandID) if (intBandID != intPreviousBandID && blnFirstTimeThroughLoop == false) { sb.Append("<div class='row ImageRow'>"); //// MDE - Get the band name from the current loop strBandName = item.b.strBandName; //// MDE - Show the band name and a header 'Products for Sale' //ben sb.Append("<h1 class='ecBantTitle'><a id='band" + intBandID + "' style='color:darkred;' href='/Products/Product-Details/?ck=" + item.b.intBandID + "'>" + strBandName + "</a></h1>"); if (item.b.strBackroundImage != "") { sb.Append("<img class='BacroundECommerceImages' src='..\\" + item.b.strBackroundImage + "' >"); } } if (blnNewBandDetected == true) { blnNewBandDetected = false; } // MDE - Here is where the product details and image are displayed if (item.p.strImageLink != "") { sb.Append("<div class='OneImage'>"); sb.Append(" <img style='display:inline;' title=' " + item.p.strProductName + "' class='image-responsive saleImage' src='../" + item.p.strImageLink + "' runat='server' onclick='addToCart(" + item.p.intProductID + "," + item.p.intTypeID + ",\"" + item.p.strImageLink + "\"," + item.p.decBandPrice + "," + 1 + ")'" + "/>"); sb.Append("<p> "); // MDE - added line for prod title - and created class (css is in site.css, very bottom) //sb.Append("<span >" + item.p.strProductName + ": </span> "); sb.Append("$" + item.p.decBandPrice); sb.Append("</p>"); sb.Append("</div>"); } intCount += 1; if (intCount > 4) { continue; } blnFirstTimeThroughLoop = false; intPreviousBandID = intBandID; } sb.Append("</div>"); } } else { sb.Append("<div class='row'><div class='col-md-12'>No products in this category are currently available.</div></div>"); } ltrProducts.Text = sb.ToString(); // MDE - check if querystring contains a message from sign in page - and then show it in a javascript alert box. string strMessage = ""; if (Request.QueryString["message"] != null) { strMessage = Request.QueryString["message"].ToString(); } if (strMessage != "") { Response.Write("<script>alert('" + strMessage + "')</script>"); //ScriptManager.RegisterClientScriptBlock((sender as Control), this.GetType(), "alert", strMessage, true); return; } }
protected void ButtonCustomerPurchase_Click(object sender, EventArgs e) { string message = ""; string messageSold = ""; string messageNotSold = ""; int intLoopCount = 0; SiteDCDataContext _siteContext = new SiteDCDataContext(); foreach (Hashtable htProd in productArrayList) { if (htProd.ContainsKey("Id")) { if (htProd.ContainsKey("Amount")) { intLoopCount += 1; var queryProduct = (from p in _siteContext.TProducts where p.intProductID == Convert.ToInt32(htProd["Id"]) select p).First(); if (intLoopCount == 1) { var quryMaxPurchaseNumber = (from p in _siteContext.TCustomerPurchases select p.intPurchaseNumber).Max(); intNewPurchaseNumber = quryMaxPurchaseNumber + 1; //this is for the intire purchas with a total that represents the sum of all products available TCustomerPurchase customerPurchase = new TCustomerPurchase(); customerPurchase.intCustomerID = intCustomerID; customerPurchase.intPurchaseNumber = intNewPurchaseNumber; customerPurchase.decTotal = 0; //This will be added for each product //indevedualy in case any product is not available customerPurchase.dtmDateTime = dtmTodayDate; //customerPurchase.intIsDeleted = 0; _siteContext.TCustomerPurchases.InsertOnSubmit(customerPurchase); _siteContext.SubmitChanges(); } if (queryProduct != null) { if (queryProduct.intAmountAvialable >= Convert.ToInt32(htProd["Amount"])) { var quryCretedCustomerPurchase = (from p in _siteContext.TCustomerPurchases where p.intCustomerID == intCustomerID && p.intPurchaseNumber == intNewPurchaseNumber select p).First(); intNewCustomerPurchaseID = quryCretedCustomerPurchase.intCustomerPurchaseID; //this is for one product in the purcahse TCustomerPurchaseProduct customerPurchaseProduct = new TCustomerPurchaseProduct(); customerPurchaseProduct.intCustomerPurchaseID = intNewCustomerPurchaseID; customerPurchaseProduct.intProductID = Convert.ToInt32(htProd["Id"]); customerPurchaseProduct.decMomentPurchaseUnitPrice = Convert.ToDecimal(htProd["Price"]); customerPurchaseProduct.intProductPurchaseCount = Convert.ToInt32(htProd["Amount"]); customerPurchaseProduct.decProductTotal = customerPurchaseProduct.decMomentPurchaseUnitPrice * Convert.ToDecimal(customerPurchaseProduct.intProductPurchaseCount); customerPurchaseProduct.strMomentPurchaseIMG = Convert.ToString(htProd["Image"]); customerPurchaseProduct.intIsDeleted = 0; _siteContext.TCustomerPurchaseProducts.InsertOnSubmit(customerPurchaseProduct); //Removing amount from inventory queryProduct.intAmountAvialable -= Convert.ToInt32(htProd["Amount"]); //if (intLoopCount > 1) //{ quryCretedCustomerPurchase.decTotal += Convert.ToDecimal(htProd["Amount"]) * Convert.ToDecimal(htProd["Price"]); //} //else //{ // //Adding amount sold in this sale to TCustomerPurchase // customerPurchase.decTotal += Convert.ToDecimal(htProd["Amount"]) * Convert.ToDecimal(htProd["Price"]); //} messageSold += Convert.ToInt32(htProd["Amount"]) + " " + queryProduct.strProductName + " sold!."; _siteContext.SubmitChanges(); } else //If not enough in inventory for product { //sellig all products accept the one which there is not have enough in inventory messageNotSold += "We only have" + queryProduct.intAmountAvialable + queryProduct.strProductName + "."; } } } } } message = "Purchase proccesed:" + messageSold + messageNotSold; Response.Redirect("/Customer/Default.aspx?message=" + Server.UrlEncode(message)); //string strUrl = "../Admin/BoothSalePoint.aspx?message=Purchase complete."; //Response.RedirectPermanent(strUrl); //ScriptManager.RegisterStartupScript(this, this.GetType(), "script", "alert ('Sale Complete')", true); }
protected void Page_Load(object sender, EventArgs e) { //lblMessage.Text = Server.UrlDecode(Request.QueryString["message"]); int intBandID = 0; if (HttpContext.Current.Session["UserDetails"] != null) { UserDetails ud = HttpContext.Current.Session["UserDetails"] as UserDetails; intBandID = ud.UserKey; } SiteDCDataContext _siteContent = new SiteDCDataContext(); //Ceating- Report yearly string var querySalesByYear = _siteContent.VCustomersPurchases .Where(x => x.intBandID == intBandID) .AsEnumerable() .OrderByDescending(x => x.dtmDateTime.Year) .GroupBy(x => x.dtmDateTime.Year) .ToList() .Select(x => new{ Total = x.Sum(b => b.decProductTotal), Year = x.Key }) ; StringBuilder tl = new StringBuilder(); tl.Append("<div class='DivBorderTableWrapp'>"); tl.Append("<table class='ReportTable'>"); tl.Append("<thead>"); tl.Append("<tr class='reportTableHeader'><th colspan='2'>Year</th></tr>"); tl.Append("</thead>"); tl.Append("<tbody>"); if (querySalesByYear.Count() > 0) { foreach (var saleYear in querySalesByYear) { tl.Append("<tr><td class='datecolumn'>" + saleYear.Year + " </td><td class='reportAmount'> $" + saleYear.Total + "</td></tr>"); } } else { tl.Append("<tr><td colspan='2'>No Content currently available.</td></tr>"); } tl.Append("</tbody>"); tl.Append("</table>"); tl.Append("</div>"); lblSalesByYear.Text = tl.ToString(); //Ceating- Monthly string tl.Clear(); var querySalesByMonth = _siteContent.VCustomersPurchases .Where(x => x.intBandID == intBandID) .AsEnumerable() .OrderByDescending(x => x.dtmDateTime) .GroupBy(x => new { x.dtmDateTime.Year, x.dtmDateTime.Month }) .ToList() .Select(x => new { Total = x.Sum(b => b.decProductTotal), Year = x.Key.Year, Month = x.Key.Month }) ; tl.Append("<div class='DivBorderTableWrapp'>"); tl.Append("<table class='ReportTable'>"); tl.Append("<thead>"); tl.Append("<tr class='reportTableHeader'><th colspan='2'>Month</th></tr>"); tl.Append("</thead>"); tl.Append("<tbody>"); if (querySalesByMonth.Count() > 0) { foreach (var saleMonth in querySalesByMonth) { tl.Append("<tr><td class='datecolumn'>" + saleMonth.Year + "-" + saleMonth.Month + " </td><td class='reportAmount'> $" + saleMonth.Total + "</td></tr>"); } } else { tl.Append("<tr><td colspan='2'>No Content currently available.</td></tr>"); } tl.Append("</tbody>"); tl.Append("</table>"); tl.Append("</div>"); lblSalesByMonth.Text = tl.ToString(); }
protected void btnSignUpCustomer_Click(object sender, EventArgs e) { SiteDCDataContext _siteContext = new SiteDCDataContext(); //First: test the custome eamil is not being used bool blnEmailFlag = false; var queryCustomers = from c in _siteContext.TCustomers select c; foreach (TCustomer cstCustomer in queryCustomers) { if (cstCustomer.strEmail == txtEmail.Text) { blnEmailFlag = true; break; } } if (blnEmailFlag == true) { //Name used //Response.Write("This email is already used."); // MDE - Trying javascript alert Response.Write("<script>alert('This email is already used.')</script>"); txtEmail.Focus(); } else { string message = ""; string strFirstName = txtFirstName.Text; string strLastName = txtLastName.Text; string strPassword = txtPassword.Text; string strPhone = txtPhone.Text; string strEmail = txtEmail.Text; string strCity = txtCity.Text; string strAddress = txtAddress.Text; string strZip = txtZip.Text; int intState = 1; //MDE Added convert to int for ddlState intState = Convert.ToInt32(ddlState.SelectedValue); int intGender = 1; //MDE added Convert to int for ddlGender intGender = Convert.ToInt32(ddlGender.SelectedValue); TCustomer customer = new TCustomer(); customer.strFirstName = strFirstName; customer.strLastName = strLastName; customer.strPassword = strPassword; customer.strPhone = strPhone; customer.strEmail = strEmail; customer.strCity = strCity; customer.strAddress = strAddress; customer.strZip = strZip; customer.intStateID = intState; customer.intGenderID = intGender; _siteContext.TCustomers.InsertOnSubmit(customer); _siteContext.SubmitChanges(); int CustomeKey = customer.intCustomerID; // MDE added a space between first and last name message = "Customer " + customer.strFirstName + " " + customer.strLastName + " has registered."; //So sending to modify product page //Response.Redirect("/Default.aspx?&message=" + Server.UrlEncode(message)); //MDE do the redirect, Show sucess message - code to show message is in default.aspx - it requests the querystring. Response.Redirect("/CustomerSignIn.aspx?message=" + Server.UrlEncode(message)); } }
protected void Page_Load(object sender, EventArgs e) { //lblMessage.Text = Server.UrlDecode(Request.QueryString["message"]); int intBandID = 0; if (HttpContext.Current.Session["UserDetails"] != null) { UserDetails ud = HttpContext.Current.Session["UserDetails"] as UserDetails; intBandID = ud.UserKey; } SiteDCDataContext _siteContent = new SiteDCDataContext(); //Ceating- Report by type string var querySalesByTypes = from sbc in _siteContent.VCustomersPurchases .Where(x => x.intBandID == intBandID) .AsEnumerable() .GroupBy(x => new { x.strBaseType }) .ToList() .Select(x => new { Total = x.Sum(b => b.decProductTotal), Count = x.Sum(c => c.intProductPurchaseCount), x.Key.strBaseType }) .OrderBy(x => x.strBaseType) select sbc; StringBuilder tl = new StringBuilder(); tl.Append("<div class='DivBorderTableWrappProduct'>"); tl.Append("<table class='ReportTable'>"); tl.Append("<thead>"); tl.Append("<tr class='reportTableHeader'>"); tl.Append("<th class='tableDataHeaders'>Type</th>"); tl.Append("<th class='tableDataHeaders'>Total</th>"); tl.Append("<th class='tableDataHeaders'>Av. Price</th>"); tl.Append("<th class='tableDataHeaders'>#Units</th>"); tl.Append("<th class='tableDataHeaders'>Selected</th>"); tl.Append("</tr>"); tl.Append("</thead>"); tl.Append("<tbody>"); int intCount = 0; string strFirsBaseType = ""; if (querySalesByTypes.Count() > 0) { foreach (var prod in querySalesByTypes) { intCount += 1; string radioButtonId = "radio" + intCount.ToString(); tl.Append("<tr>"); tl.Append("<td class='datecolumnProduct productType '>" + prod.strBaseType + " </td>"); tl.Append("<td class='datecolumnProduct productTotal'>$" + prod.Total + " </td>"); tl.Append("<td class='datecolumnProduct productAvrege'>$" + Math.Round((prod.Total / prod.Count), 2) + " </td>"); tl.Append("<td class='datecolumnProduct productAmount'>" + prod.Count + " </td>"); if (hdnSelecteType.Value.ToString() == "") { if (intCount == 1) { tl.Append("<td class='datecolumnProduct TypeSelected'><input id='" + radioButtonId + "' onclick='radioOnClick(\"" + radioButtonId + "\",\"" + prod.strBaseType + "\")' type = 'radio' name = 'basetype' checked value = '" + prod.strBaseType + "'>" + prod.strBaseType + "</td>"); //tl.Append("<td class='datecolumnProduct productAmount'><asp:RadioButton ID=\"" + prod.strBaseType + "\" runat = \"server\" GroupName = \"BaseType\" Text = \"" + prod.strBaseType + "\" OnClick=\"btnUpdateBandAccount_Click\"/></td>"); strFirsBaseType = prod.strBaseType; } else { tl.Append("<td class='datecolumnProduct TypeSelected'><input id='" + radioButtonId + "' onclick='radioOnClick(\"" + radioButtonId + "\",\"" + prod.strBaseType + "\")' type = 'radio' name = 'basetype' value = '" + prod.strBaseType + "'>" + prod.strBaseType + "</td>"); //tl.Append("<td class='datecolumnProduct productAmount'><asp:RadioButton ID=\"" + prod.strBaseType + "\" runat = \"server\" GroupName = \"BaseType\" Text = \"" + prod.strBaseType + "\" OnClick=\"btnUpdateBandAccount_Click\"/></td>"); } } else { if (hdnSelecteType.Value.ToString() == prod.strBaseType) { tl.Append("<td class='datecolumnProduct TypeSelected'><input id='" + radioButtonId + "' onclick='radioOnClick(\"" + radioButtonId + "\",\"" + prod.strBaseType + "\")' type = 'radio' name = 'basetype' checked value = '" + prod.strBaseType + "'>" + prod.strBaseType + "</td>"); //tl.Append("<td class='datecolumnProduct productAmount'><asp:RadioButton ID=\"" + prod.strBaseType + "\" runat = \"server\" GroupName = \"BaseType\" Text = \"" + prod.strBaseType + "\" OnClick=\"btnUpdateBandAccount_Click\"/></td>"); strFirsBaseType = prod.strBaseType; } else { tl.Append("<td class='datecolumnProduct TypeSelected'><input id='" + radioButtonId + "' onclick='radioOnClick(\"" + radioButtonId + "\",\"" + prod.strBaseType + "\")' type = 'radio' name = 'basetype' value = '" + prod.strBaseType + "'>" + prod.strBaseType + "</td>"); //tl.Append("<td class='datecolumnProduct productAmount'><asp:RadioButton ID=\"" + prod.strBaseType + "\" runat = \"server\" GroupName = \"BaseType\" Text = \"" + prod.strBaseType + "\" OnClick=\"btnUpdateBandAccount_Click\"/></td>"); } } tl.Append("</tr>"); } } else { tl.Append("<tr><td colspan='5'>No Content currently available.</td></tr>"); } tl.Append("</tbody>"); tl.Append("</table>"); tl.Append("</div>"); lblSalesByTypes.Text = tl.ToString(); if (hdnSelecteType.Value.ToString() == "") { populateOneTypeTable(strFirsBaseType); } else { populateOneTypeTable(hdnSelecteType.Value.ToString()); } }
protected void btnUpdateProduct_Click(object sender, EventArgs e) { int intBandID = 0; if (HttpContext.Current.Session["UserDetails"] != null) { UserDetails ud = HttpContext.Current.Session["UserDetails"] as UserDetails; intBandID = ud.UserKey; } string message = ""; int EventKey = 0; if (!String.IsNullOrEmpty(Request.QueryString["pk"])) { EventKey = Convert.ToInt32(Request.QueryString["pk"]); } string strTitle = EventTitle.Text; string strLocation = txtEventLocation.Text; DateTime dtmDate = calEventDate.SelectedDate; decimal decPrice = Decimal.Parse(txtPrice.Text); string sOldProductPath = ""; SiteDCDataContext _siteContext = new SiteDCDataContext(); if (EventKey > 0) // Update the Product { var queryEvents = from ev in _siteContext.TEvents where ev.intEventID == EventKey && ev.intBandID == intBandID select ev; foreach (var events in queryEvents) { events.strEventName = strTitle; sOldProductPath = events.strImageUrl; events.strImageUrl = sOldProductPath; events.decEntryPrice = decPrice; events.dtmDate = dtmDate; events.strLocation = strLocation; events.intBandID = intBandID; } _siteContext.SubmitChanges(); message = strTitle + " has been updated."; } else // Add a Product { TEvent events = new TEvent(); events.strEventName = strTitle; events.strImageUrl = ""; events.decEntryPrice = decPrice; events.dtmDate = dtmDate; events.strLocation = strLocation; events.intBandID = intBandID; _siteContext.TEvents.InsertOnSubmit(events); _siteContext.SubmitChanges(); EventKey = events.intEventID; message = strTitle + " has been added."; } string newFileDirectory = Request.PhysicalApplicationPath.ToString() + "Uploads\\Events\\" + EventKey + "\\"; string newProductPath = ""; if (!Directory.Exists(newFileDirectory)) { Directory.CreateDirectory(newFileDirectory); } if ((ProductImage.HasFile) && (ProductImage.PostedFile.ContentType.ToLower() == "image/jpeg")) { if (sOldProductPath.Length > 0) { string OldDocumentFilePath = Request.PhysicalApplicationPath.ToString() + sOldProductPath.Replace("/", "\\"); if (File.Exists(OldDocumentFilePath)) { File.Delete(OldDocumentFilePath); } } string newFileName = ProductImage.FileName; string newFilePath = newFileDirectory + newFileName; ProductImage.PostedFile.SaveAs(newFilePath); newProductPath = "Uploads/Events/" + EventKey + "/" + ProductImage.FileName; } else { newProductPath = sOldProductPath; } if (newProductPath.Length > 0) { var queryEvents = from p in _siteContext.TEvents where p.intEventID == EventKey select p; foreach (TEvent events in queryEvents) { events.strImageUrl = newProductPath; } _siteContext.SubmitChanges(); } Response.Redirect("/Admin/Events.aspx?message=" + Server.UrlEncode(message)); }
protected void Page_Load(object sender, EventArgs e) { //lblMessage.Text = Server.UrlDecode(Request.QueryString["message"]); int intBandID = 0; if (HttpContext.Current.Session["UserDetails"] != null) { UserDetails ud = HttpContext.Current.Session["UserDetails"] as UserDetails; intBandID = ud.UserKey; } SiteDCDataContext _siteContent = new SiteDCDataContext(); //Ceating- Report yearly string var querySalesByCustomer = from sbc in _siteContent.VCustomersPurchases .Where(x => x.intBandID == intBandID) .AsEnumerable() .GroupBy(x => new { x.intCustomerID, x.strLastName, x.strFirstName, x.strStateName, x.strCity, x.strAddress, x.strEmail, x.strPhone }) .ToList() .Select(x => new { Total = x.Sum(b => b.decProductTotal), x.Key.intCustomerID, x.Key.strLastName, x.Key.strFirstName, x.Key.strStateName, x.Key.strCity, x.Key.strAddress, x.Key.strEmail, x.Key.strPhone, }) .OrderByDescending(x => x.Total) select sbc; StringBuilder tl = new StringBuilder(); tl.Append("<div class='DivBorderTableWrappCustomerLeft' style='margin-bottom:60px;'>"); tl.Append("<table class='ReportTable'>"); tl.Append("<thead>"); tl.Append("<caption style='color:darkblue; font-size:42px;'>Sales by Customer</caption>"); tl.Append("<tr class='reportTableHeader'>"); tl.Append("<th class='tableDataHeaders cusnameTHeader'>Last Name</th>"); tl.Append("<th class='tableDataHeaders cusnameTHeader'>First Name</th>"); tl.Append("<th class='tableDataHeaders'>Total</th>"); tl.Append("<th class='tableDataHeaders'>State</th>"); tl.Append("<th class='tableDataHeaders'>City</th>"); tl.Append("<th class='tableDataHeaders'>Address</th>"); tl.Append("<th class='tableDataHeaders'>Email</th>"); tl.Append("<th class='tableDataHeaders'>Phone</th>"); tl.Append("<th class='tableDataHeaders'>Selected</th>"); tl.Append("</tr>"); tl.Append("</thead>"); tl.Append("<tbody>"); int intCount = 0; int intCustomerId = 0; if (querySalesByCustomer.Count() > 0) { foreach (var cus in querySalesByCustomer) { intCount += 1; string radioButtonId = "radio" + intCount.ToString(); tl.Append("<tr>"); tl.Append("<td class='datecolumnCustomer customerName'>" + cus.strLastName + " </td>"); tl.Append("<td class='datecolumnCustomer customerName'>" + cus.strFirstName + " </td>"); tl.Append("<td class='datecolumnCustomer customerTotal'>$" + cus.Total + " </td>"); tl.Append("<td class='datecolumnCustomer'>" + cus.strStateName + " </td>"); tl.Append("<td class='datecolumnCustomer'>" + cus.strCity + " </td>"); tl.Append("<td class='datecolumnCustomer cusAddress'>" + cus.strAddress + " </td>"); tl.Append("<td class='datecolumnCustomer'>" + cus.strEmail + " </td>"); tl.Append("<td class='datecolumnCustomer'>" + cus.strPhone + " </td>"); if (hdnSelectedCustomer.Value.ToString() == "") { if (intCount == 1) { tl.Append("<td class='datecolumnProduct TypeSelected'><input id='" + radioButtonId + "' onclick='radioOnClick(\"" + radioButtonId + "\",\"" + cus.intCustomerID + "\")' type = 'radio' name = 'customerID' checked value = '" + cus.intCustomerID + "'>" + cus.strLastName + "," + cus.strFirstName + "</td>"); intCustomerId = cus.intCustomerID; } else { tl.Append("<td class='datecolumnProduct TypeSelected'><input id='" + radioButtonId + "' onclick='radioOnClick(\"" + radioButtonId + "\",\"" + cus.intCustomerID + "\")' type = 'radio' name = 'customerID' value = '" + cus.intCustomerID + "'>" + cus.strLastName + "," + cus.strFirstName + "</td>"); } } else { if (hdnSelectedCustomer.Value.ToString() == cus.intCustomerID.ToString()) { tl.Append("<td class='datecolumnProduct TypeSelected'><input id='" + radioButtonId + "' onclick='radioOnClick(\"" + radioButtonId + "\",\"" + cus.intCustomerID + "\")' type = 'radio' name = 'customerID' checked value = '" + cus.intCustomerID + "'>" + cus.strLastName + "," + cus.strFirstName + "</td>"); intCustomerId = cus.intCustomerID; } else { tl.Append("<td class='datecolumnProduct TypeSelected'><input id='" + radioButtonId + "' onclick='radioOnClick(\"" + radioButtonId + "\",\"" + cus.intCustomerID + "\")' type = 'radio' name = 'customerID' value = '" + cus.intCustomerID + "'>" + cus.strLastName + "," + cus.strFirstName + "</td>"); } } tl.Append("</tr>"); } } else { tl.Append("<tr><td colspan='7'>No Content currently available.</td></tr>"); } tl.Append("</tbody>"); tl.Append("</table>"); tl.Append("</div>"); lblSalesByCustomer.Text = tl.ToString(); if (hdnSelectedCustomer.Value.ToString() == "") { populateOneCustomerPurchases(intCustomerId); } else { populateOneCustomerPurchases(Convert.ToInt32(hdnSelectedCustomer.Value)); } }
//protected void btnUpdateBandAccount_Click(object sender, EventArgs e) //{ // populateOneTypeTable(sender.ToString()); //} protected void populateOneTypeTable(string strBaseType) { //lblMessage.Text = Server.UrlDecode(Request.QueryString["message"]); int intBandID = 0; if (HttpContext.Current.Session["UserDetails"] != null) { UserDetails ud = HttpContext.Current.Session["UserDetails"] as UserDetails; intBandID = ud.UserKey; } SiteDCDataContext _siteContent = new SiteDCDataContext(); //Checking that basetype is in database bool blnFlagNoMatch = true; var queryBaseTypes = from bt in _siteContent.TBaseTypes select bt; foreach (var bstp in queryBaseTypes) { if (bstp.strBaseType == strBaseType) { blnFlagNoMatch = false; break; } } //Basetype is in database if (blnFlagNoMatch == false) { var querySalesByProduct = from sbc in _siteContent.VCustomersPurchases .Where(x => x.intBandID == intBandID && x.strBaseType == strBaseType) .AsEnumerable() .GroupBy(x => new { x.intProductID, x.strProductName, Average = (x.decProductTotal / x.intProductPurchaseCount), x.strImageLink }) .ToList() .Select(x => new { Total = x.Sum(b => b.decProductTotal), Count = x.Sum(c => c.intProductPurchaseCount), x.Key.strProductName, x.Key.strImageLink }) select sbc; StringBuilder tl = new StringBuilder(); tl.Append("<div class='DivBorderTableWrappProduct'>"); tl.Append("<table class='ReportTable'>"); tl.Append("<thead>"); tl.Append("<tr class='reportTableHeader'>"); tl.Append("<th class='tableDataHeaders'>Product</th>"); tl.Append("<th class='tableDataHeaders'>Total</th>"); tl.Append("<th class='tableDataHeaders'>Price</th>"); tl.Append("<th class='tableDataHeaders'>#Units</th>"); tl.Append("<th class='tableDataHeaders'>Image Link</th>"); tl.Append("</tr>"); tl.Append("</thead>"); tl.Append("<tbody>"); int intCount = 0; if (querySalesByProduct.Count() > 0) { foreach (var prod in querySalesByProduct) { intCount += 1; tl.Append("<tr>"); tl.Append("<td class='datecolumnProduct productType '>" + prod.strProductName + " </td>"); tl.Append("<td class='datecolumnProduct productTotal'>$" + prod.Total + " </td>"); tl.Append("<td class='datecolumnProduct productAvrege'>$" + Math.Round((prod.Total / prod.Count), 2) + " </td>"); tl.Append("<td class='datecolumnProduct productAmount'>" + prod.Count + " </td>"); tl.Append("<td class='datecolumnProduct'>" + prod.strImageLink + " </td>"); //if (intCount == 1) //{ // tl.Append("<td class='datecolumnProduct TypeSelected'><input onclick='radioOnClick(\"" + prod.strBaseType + "\")' type = 'radio' name = 'basetype' checked value = '" + prod.strBaseType + "'>" + prod.strBaseType + "</td>"); // //tl.Append("<td class='datecolumnProduct productAmount'><asp:RadioButton ID=\"" + prod.strBaseType + "\" runat = \"server\" GroupName = \"BaseType\" Text = \"" + prod.strBaseType + "\" OnClick=\"btnUpdateBandAccount_Click\"/></td>"); //} //else //{ // tl.Append("<td class='datecolumnProduct TypeSelected'><input onclick='radioOnClick(\"" + prod.strBaseType + "\")' type = 'radio' name = 'basetype' value = '" + prod.strBaseType + "'>" + prod.strBaseType + "</td>"); // //tl.Append("<td class='datecolumnProduct productAmount'><asp:RadioButton ID=\"" + prod.strBaseType + "\" runat = \"server\" GroupName = \"BaseType\" Text = \"" + prod.strBaseType + "\" OnClick=\"btnUpdateBandAccount_Click\"/></td>"); //} tl.Append("</tr>"); } } else { tl.Append("<tr><td colspan='5'>No Content currently available.</td></tr>"); } tl.Append("</tbody>"); tl.Append("</table>"); tl.Append("</div>"); lblProductSalesByType.Text = tl.ToString(); } }
protected void Page_Load(object sender, EventArgs e) { //lblMessage.Text = Server.UrlDecode(Request.QueryString["message"]); int intBandID = 0; if (HttpContext.Current.Session["UserDetails"] != null) { UserDetails ud = HttpContext.Current.Session["UserDetails"] as UserDetails; intBandID = ud.UserKey; } SiteDCDataContext _siteContent = new SiteDCDataContext(); // *added user entered low threshhold variable //EH 11.29.19 int intQuantity = Convert.ToInt32(hdnThreshold.Value); if (intQuantity <= 0) { intQuantity = 50; } //Ceating- Low Inventory String var queryProducts = from p in _siteContent.TProducts orderby p.intProductID where p.intBandID == intBandID && p.intAmountAvialable <= intQuantity && p.intIsDeleted == 0 select p; queryProducts.ToList(); StringBuilder tl = new StringBuilder(); tl.Append("<div class='DivBorderTableWrapp'>"); tl.Append("<table>"); tl.Append("<thead>"); tl.Append("<tr class='bandHomeTableH'><th colspan='2'>Low Inventory</th></tr>"); tl.Append("</thead>"); tl.Append("<tbody>"); if (queryProducts.Count() > 0) { foreach (var item in queryProducts) { tl.Append("<tr><td class='productLow'> <a href = '/Admin/ModifyProduct.aspx?pk=" + item.intProductID + "' >" + item.strProductName + "</a>" + " </td><td class='warning'>" + item.intAmountAvialable + "</td></tr>"); } tl.Append("<tr><td colspan='2'> </td></tr>"); } else { tl.Append("<tr><td colspan='2'>No Content currently available.</td></tr>"); } tl.Append("</tbody>"); tl.Append("</table>"); //based on *added user entered low threshhold //EH 11.29.19 tl.Append("<form action = '#' onsubmit = 'return inputOutfocus(this);'style='font-size:14px;'>"); tl.Append("<label for='Threshold'>Threshold:</label>"); tl.Append("<input type='text' id='Threshold' name='Threshold' runat='server' value='" + intQuantity.ToString() + "' onchange='changeNum()'/>"); tl.Append("</form>"); tl.Append("</div>"); lblLowInventory.Text = tl.ToString(); //Ceating- Sales String tl.Clear(); int intEventCount = 0; var queryLastEvents = from E in _siteContent.TEvents orderby E.dtmDate descending where E.dtmDate <= DateTime.Now && E.dtmDate.Year == DateTime.Now.Year && //This year only E.intBandID == intBandID select E; queryLastEvents.ToList(); tl.Append("<div class='DivBorderTableWrapp'>"); tl.Append("<table>"); tl.Append("<thead>"); tl.Append("<tr class='bandHomeTableH'><th colspan='2'>Latest Sales</th></tr>"); tl.Append("</thead>"); tl.Append("<tbody>"); if (queryLastEvents.Count() > 0) { foreach (var LastEvents in queryLastEvents) { intEventCount += 1; if (intEventCount > 3) { break; } //TODO tl.Append("<tr><td class='bandNaeSales'> <a href ='' >" + LastEvents.strEventName + "</a></td><td style='color:#7575a3'>$ " + Convert.ToInt32(LastEvents.decEventSales) + " </td></tr>"); } tl.Append("<tr><td colspan='2'> </td></tr>"); } int intCostomerPurchaseCount = 0; int intCurrentPurchaseID = 0; bool blnFirstLoop = true; var queryLastCustomerPurchases = from CP in _siteContent.VCustomersPurchases orderby CP.dtmDateTime descending where CP.intBandID == intBandID select CP; queryLastCustomerPurchases.ToList(); if (queryLastCustomerPurchases.Count() > 0) { intCurrentPurchaseID = queryLastCustomerPurchases.First().intCustomerPurchaseID; foreach (var purc in queryLastCustomerPurchases) { if (blnFirstLoop == false) { if (intCurrentPurchaseID == purc.intCustomerPurchaseID) { continue; } else { intCurrentPurchaseID = purc.intCustomerPurchaseID; intCostomerPurchaseCount += 1; } } else { blnFirstLoop = false; intCostomerPurchaseCount += 1; } if (intCostomerPurchaseCount > 3) { break; } tl.Append("<tr><td class='bandNaeSales'> <a href ='' >" + purc.strLastName + ", " + purc.strFirstName + "</a></td><td style='color:#7575a3'>$ " + Convert.ToInt32(purc.Purchase_Total) + " </td></tr>"); } tl.Append("<tr><td colspan='2'> </td></tr>"); } if (queryLastCustomerPurchases.Count() <= 0 && queryLastEvents.Count() <= 0) { tl.Append("<tr><td colspan='2'>No Content currently available.</td></tr>"); } tl.Append("</tbody>"); tl.Append("</table>"); tl.Append("</div>"); lblSales.Text = tl.ToString(); //Ceating- Reports String tl.Clear(); tl.Append("<div class='DivBorderTableWrapp'>"); tl.Append("<table>"); tl.Append("<thead>"); tl.Append("<tr class='bandHomeTableH'><th >Reports</th></tr>"); tl.Append("</thead>"); tl.Append("<tbody>"); tl.Append("<tr><td class='reports'> <a href ='/Admin/Reports/AllSales/' >All Sales</a></d></tr>"); tl.Append("<tr><td class='reports'> </td></tr>"); tl.Append("<tr><td class='reports'> <a href ='/Admin/Reports/SalesByCustomer/' >Sales by Customer</a></td></tr>"); tl.Append("<tr><td class='reports'> <a href ='/Admin/Reports/SalesByProduct/' >Sales by Product</a></d></tr>"); tl.Append("<tr><td class='reports'> </td></tr>"); tl.Append("<tr><td class='reports'> <a href ='/Admin/Reports/ByYearMonth/' >By Year/Month</a></td></tr>"); tl.Append("</tbody>"); tl.Append("</table>"); tl.Append("</div>"); lblReports.Text = tl.ToString(); //Ceating- Upcoming Events String tl.Clear(); var queryEvents = from E in _siteContent.TEvents orderby E.dtmDate where E.dtmDate >= DateTime.Now && E.intBandID == intBandID select E; queryEvents.ToList(); tl.Append("<div class='DivBorderTableWrapp'>"); tl.Append("<table>"); tl.Append("<thead>"); tl.Append("<tr class='bandHomeTableH'><th colspan='2'>Upcoming Events</th></tr>"); tl.Append("</thead>"); tl.Append("<tbody>"); if (queryEvents.Count() > 0) { foreach (var Event in queryEvents) { //TODO tl.Append("<tr><td class='upcomming'> <a href ='' >" + Event.strEventName + "</a></td><td style='color:#7575a3'>" + Event.dtmDate.Month + "/" + Event.dtmDate.Day + " </td></tr>"); } tl.Append("<tr><td colspan='2'> </td></tr>"); } else { tl.Append("<tr><td colspan='2'>No Content currently available.</td></tr>"); } tl.Append("</tbody>"); tl.Append("</table>"); tl.Append("</div>"); lblUpcoming.Text = tl.ToString(); }
protected void Page_Load(object sender, EventArgs e) { int intBandID = 0; lblMessage.Text = Server.UrlDecode(Request.QueryString["message"]); if (HttpContext.Current.Session["UserDetails"] != null) { UserDetails ud = HttpContext.Current.Session["UserDetails"] as UserDetails; intBandID = ud.UserKey; } string strMessage = ""; if (Request.QueryString["message"] != null) { strMessage = Request.QueryString["message"].ToString(); } if (strMessage != "") { Response.Write("<script>alert('" + strMessage + "')</script>"); } //string strUrl = HttpContext.Current.Request.Url.AbsoluteUri; //int index1 = strUrl.LastIndexOf('/'); //strUrl = strUrl.Substring(0, index1); //index1 += 1; //strUrl = strUrl.Substring(0, index1); //A connection to the database to be used when geting or updatinh data SiteDCDataContext _siteContext = new SiteDCDataContext(); //A tool that we use to bild the html fof each data item comig in from the database StringBuilder sb = new StringBuilder(); var queryProducts = from p in _siteContext.TProducts where p.intBandID == intBandID && p.intIsDeleted == 0 join tp in _siteContext.TTypes on p.intTypeID equals tp.intTypeID join tbp in _siteContext.TBaseTypes on tp.intBaseTypeID equals tbp.intBaseTypeID orderby tp.intBaseTypeID select new { p, tp, tbp }; //get band object with ID for background images EH 12.11.2019 var queryBand = (from b in _siteContext.TBands where b.intBandID == intBandID select b).First(); queryProducts.ToList(); if (queryProducts.Count() > 0) { sb.Append("<div class='BoothProductPAGE'>"); //sb.Append("<h1 class='ecBantTitle'>" + queryBand.strBandName + "</h1>"); if (queryBand.strBackroundImage != "") { sb.Append("<img class='Booth_BackgroundImage' src='/" + queryBand.strBackroundImage + "' >"); } sb.Append("<div style='margin-top:25px;'>"); sb.Append("<div class='row'style='margin-left:40px;'>"); //sb.Append("<div class='row'><div class='col-md-12'><hr /></div></div>"); int intPreviousBaseType = queryProducts.First().tbp.intBaseTypeID; int intCurrentBaseType = queryProducts.First().tbp.intBaseTypeID; foreach (var prod in queryProducts) { //Only products with image will be displayed in page to customer if (prod.p.strImageLink == "" || prod.p.strImageLink == null) { continue; } intCurrentBaseType = prod.tbp.intBaseTypeID; if (intCurrentBaseType != intPreviousBaseType) { intPreviousBaseType = intCurrentBaseType; sb.Append("</div>"); sb.Append("<div class='row'style='margin-left:40px;'>"); } sb.Append(" <img style='display:inline; margin-right:100px;' title=' " + prod.p.strProductName + "' class='image-responsiveBooth saleImageBooth' src='/" + prod.p.strImageLink + "' runat='server' onclick='addToCart(" + prod.p.intProductID + "," + prod.p.intTypeID + ",\"" + prod.p.strImageLink + "\"," + prod.p.decBandPrice + "," + 1 + ")'" + "/>"); sb.Append("<p style='display:inline; z-index:15; color:darkred;position:relative; top:7px; right:200px; background-color:white; font-weight:bold;'>$ "); sb.Append(prod.p.decBandPrice); sb.Append("</p>"); } sb.Append("</div>"); sb.Append("</div>"); sb.Append("</div>"); } else { sb.Append("<div class='row'><div class='col-md-12'>No products for this band are currently available.</div></div>"); } ltrProducts.Text += sb.ToString(); }
protected void populateOneCustomerPurchases(int intCustomerId) { //lblMessage.Text = Server.UrlDecode(Request.QueryString["message"]); int intBandID = 0; if (HttpContext.Current.Session["UserDetails"] != null) { UserDetails ud = HttpContext.Current.Session["UserDetails"] as UserDetails; intBandID = ud.UserKey; } SiteDCDataContext _siteContent = new SiteDCDataContext(); //Checking that basetype is in database bool blnFlagNoMatch = true; var queryuCustomer = from ct in _siteContent.TCustomers select ct; foreach (var c in queryuCustomer) { if (c.intCustomerID == intCustomerId) { blnFlagNoMatch = false; break; } } //Basetype is in database if (blnFlagNoMatch == false) { var queryCustomerPurchases = from cos in _siteContent.VCustomersPurchases orderby cos.intCustomerPurchaseID where cos.intBandID == intBandID && cos.intCustomerID == intCustomerId select cos; StringBuilder tl = new StringBuilder(); tl.Append("<div class='DivBorderTableWrappProduct'>"); tl.Append("<table class='ReportTable'>"); tl.Append("<caption style='color:darkblue; font-size:38px;'>" + queryCustomerPurchases.First().strLastName + "," + queryCustomerPurchases.First().strFirstName + "</caption>"); tl.Append("<thead>"); tl.Append("<tr class='reportTableHeader'>"); tl.Append("<th class='CustomerTableDataHeaders C_med'>#Purchase</th>"); tl.Append("<th class='CustomerTableDataHeaders C_large'>Product Name</th>"); tl.Append("<th class='CustomerTableDataHeaders C_med'>Price</th>"); tl.Append("<th class='CustomerTableDataHeaders C_small'>#Units</th>"); tl.Append("<th class='CustomerTableDataHeaders C_med'>Product Total</th>"); tl.Append("<th class='CustomerTableDataHeaders C_med'>Purchase Total</th>"); tl.Append("<th class='CustomerTableDataHeaders'>Date</th>"); tl.Append("</tr>"); tl.Append("</thead>"); tl.Append("<tbody>"); int intCount = 0; if (queryCustomerPurchases.Count() > 0) { foreach (var prod in queryCustomerPurchases) { intCount += 1; tl.Append("<tr>"); tl.Append("<tr>"); tl.Append("<td class='datecolumnCustomerGray'>" + prod.intCustomerPurchaseID + " </td>"); tl.Append("<td class='datecolumnCustomer productName'>" + prod.strProductName + " </td>"); tl.Append("<td class='datecolumnCustomer'>$" + prod.decMomentPurchaseUnitPrice + " </td>"); tl.Append("<td class='datecolumnCustomer'>" + prod.intProductPurchaseCount + " </td>"); tl.Append("<td class='datecolumnCustomer productTotal'>$" + prod.decProductTotal + " </td>"); tl.Append("<td class='datecolumnCustomerGray'>$" + prod.Purchase_Total + " </td>"); tl.Append("<td class='datecolumnCustomerGray'>" + prod.dtmDateTime + " </td>"); tl.Append("<tr>"); tl.Append("</tr>"); } } else { tl.Append("<tr><td colspan='7'>No Content currently available.</td></tr>"); } tl.Append("</tbody>"); tl.Append("</table>"); tl.Append("</div>"); lblSelectedCustomerPurchases.Text = tl.ToString(); } }