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)); }
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) { 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 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 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 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 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 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 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); }