protected void EditCarrier(int id) { CarrierObject carrier = carrDal.GetCarrierById(id); TextBox_carrier.Text = carrier.carrier; TextBox_Service.Text = carrier.service; TextBox_price.Text = carrier.price.ToString("#.##"); }
protected void UpdateCarrier(int id) { CarrierObject carrier = new CarrierObject(); carrier.carrier = TextBox_carrier.Text; carrier.service = TextBox_Service.Text; carrier.price = decimal.Parse(TextBox_price.Text); carrDal.UppdateCarier(carrier, id); Response.Redirect("~/Admin/List_Carrier.aspx"); }
protected void AddNewCarrier() { CarrierObject carrier = new CarrierObject(); carrier.carrier = TextBox_carrier.Text; carrier.service = TextBox_Service.Text; carrier.price = decimal.Parse(TextBox_price.Text); carrDal.AddCarrier(carrier); Response.Redirect("~/Admin/List_Carrier.aspx"); }
public void BuildCart() { Product pruDal = new Product(); tableFill.InnerHtml = @"<h4>Kundkorgen är tom</h4>"; HiddenField hdnID = (HiddenField)Page.Master.FindControl("Cart"); OrderObject cart = (OrderObject)Session["Cart"]; Button_checkout.Visible = false; Button1.Visible = false; if (!string.IsNullOrWhiteSpace(hdnID.Value)) { cart = JsonConvert.DeserializeObject <OrderObject>(hdnID.Value); Session["Cart"] = cart; } List <ProductObject> deletes = new List <ProductObject>(); cart.priceGroup = pricegroup; if (cart.products.Count > 0) { Button_checkout.Visible = true; Button1.Visible = true; Button_upd.Visible = false; StringBuilder str = new StringBuilder(); str.Append("<table class=\"table table-striped\">"); str.Append(@"<tr> <th>Art.nr</th> <th>Artikel</th> <th>Attribut</th> <th>Pris</th> <th>Antal</th> <th>Summa</th> <th></th> </tr>"); foreach (ProductObject product in cart.products) { if (product.quantity > 0) { decimal price = product.priceB2C; if (pricegroup != 1) { price = product.priceB2B; } string atr = string.Empty; Dictionary <string, string> atribbut = pruDal.GetAttribute(product); if (atribbut != null) { foreach (KeyValuePair <string, string> val in atribbut) { atr += val.Value + ", "; } } str.Append($@"<tr> <td>{product.artNr}</td> <td>{product.name}</td> <td>{atr}</td> <td>{price.ToString("#.##")}kr</td> <td><input id='{product.ID}' class='quantity btn-p' style='width: 70px;' type='number' value='{product.quantity}' min='0'/></td> <td>{(product.quantity * price).ToString("#.##")}kr</td> <td><button id='{product.ID}' class='delete btn-p'><span class='glyphicon glyphicon-remove' aria-hidden='true'></span></button></td> </tr>"); } else { deletes.Add(product); } } str.Append("</table>"); tableFill.InnerHtml = str.ToString(); } foreach (ProductObject delete in deletes) { cart.products.Remove(delete); } if (cart.paymentID > 0) { Payment pay = new Payment(); PaymentObject payObject = pay.GetPaymentById(cart.paymentID); cart.paymentPrice = payObject.price; } if (cart.carrierID > 0) { Carrier car = new Carrier(); CarrierObject carrierObject = car.GetCarrierById(cart.carrierID); cart.carrierPrice = carrierObject.price; } cart.priceGroup = pricegroup; cart.sum = cart.CalculatePrice(); Session["Cart"] = cart; }