protected void rep_ItemCommand(Object source, RepeaterCommandEventArgs e) { SaveQuote(); //hopefully temporary, but ensures address info persists //would like to replace by making these buttons update the UpdatePanel instead of the whole page if (e.CommandName == "Delete") { int index = Convert.ToInt32(e.CommandArgument); string category = ((HiddenField)e.Item.FindControl("Category")).Value.ToString(); quote.RemoveLineItem(category,index); session.Store(quote); session.SaveChanges(); Response.Redirect(Request.RawUrl); } if(e.CommandName == "Add") { if (true) //(EmptyFieldCheck(e)) { LineItem line = new LineItem(); line.Product.Category = ((HiddenField)e.Item.FindControl("AddCategory")).Value.ToString(); line.Product.Name = ((RadComboBox)e.Item.FindControl("AddProduct")).SelectedItem.Text; line.Product.PartNumber = ((TextBox)e.Item.FindControl("AddPartNumber")).Text; line.Product.Cost = Convert.ToDouble(((TextBox)e.Item.FindControl("AddPartCost")).Text); line.Product.Price = Convert.ToDouble(((TextBox)e.Item.FindControl("AddUnitPrice")).Text); line.Quantity = Convert.ToInt32(((TextBox)e.Item.FindControl("AddQuantity")).Text); line.Total = line.Product.Price * line.Quantity; quote.AddLineItem(line); session.SaveChanges(); Response.Redirect(Request.RawUrl); } } }
public void AddLineItem(LineItem line) { switch (line.Product.Category) { case "Hardware": this.linesHW.Add(line); break; case "Accessories": this.linesAcc.Add(line); break; case "Software": this.linesSW.Add(line); break; case "ContentCreation": this.linesCC.Add(line); break; case "Installation": this.linesInst.Add(line); break; case "Recurring": this.linesRec.Add(line); break; default: //just to find anything that doesn't get put where it should be. line.Product.Name += " (ERROR)"; this.linesHW.Add(line); break; } }