private void GetOrderAdons(BusinessEntities.OrderDetails orderdetail, decimal adonpricefromOptionType) { RadListViewDataItemCollection adoncollection = txtAdonsList.Items; List <BusinessEntities.OrderDetailAdOns> list = new List <BusinessEntities.OrderDetailAdOns>(); foreach (RadListViewDataItem mainitem in adoncollection) { Label txtAdonType = mainitem.FindControl("txtAdonTypeName") as Label; RadListView txtAdons = mainitem.FindControl("txtAdons") as RadListView; long productadontypeid = (long)mainitem.GetDataKeyValue("ProductsAdOnTypeId"); AdOnTypeInProduct adontypeinproduct = (from ATP in entities.AdOnTypeInProducts where ATP.ProductsAdOnTypeId == productadontypeid select ATP).FirstOrDefault(); RadListViewDataItemCollection childadoncollection = txtAdons.Items; foreach (RadListViewDataItem childitem in childadoncollection) { long id = (long)childitem.GetDataKeyValue("ProductAdOnID"); ProductAdon productadonObj = (from PA in entities.ProductAdons where PA.ProductAdOnID == id select PA).FirstOrDefault(); if (productadonObj != null) { BusinessEntities.OrderDetailAdOns orderdetailadon = new BusinessEntities.OrderDetailAdOns(); orderdetailadon.AdOnId = productadonObj.Adon.AdOnID; orderdetailadon.AdonName = productadonObj.Adon.AdOnName; orderdetailadon.AdonTypeName = txtAdonType.Text; if (productadonObj.AdOnTypeInProduct.DisplayFormat == 1) { HiddenField SelectedSize = childitem.FindControl("SelectedSize") as HiddenField; HiddenField IsDouble = childitem.FindControl("IsDouble") as HiddenField; short selectedoption = 0, isDouble = 0; selectedoption = short.Parse(SelectedSize.Value); isDouble = short.Parse(IsDouble.Value); if (selectedoption != 0) { orderdetailadon.SelectedAdonOption = (BusinessEntities.SelectedOption)selectedoption; if (productadonObj.DefaultSelected == 0 && (selectedoption == 1 || selectedoption == 2 || selectedoption == 3)) { if (!productadonObj.Adon.AdonType1.IsFreeAdonType) { if (isDouble == 1) { if (adonpricefromOptionType > 0) { orderdetail.Price += Convert.ToDouble(2 * adonpricefromOptionType); } else { orderdetail.Price += Convert.ToDouble(2 * (decimal)adontypeinproduct.Price); } orderdetailadon.IsDoubleSelected = true; } else { if (adonpricefromOptionType > 0) { orderdetail.Price += Convert.ToDouble(adonpricefromOptionType); } else { orderdetail.Price += Convert.ToDouble((decimal)adontypeinproduct.Price); } orderdetailadon.IsDoubleSelected = false; } } else { orderdetail.Price += Convert.ToDouble(adontypeinproduct.Price); } list.Add(orderdetailadon); } else if (isDouble == 1) { if (adonpricefromOptionType > 0) { orderdetail.Price += Convert.ToDouble(adonpricefromOptionType); } else { orderdetail.Price += Convert.ToDouble((decimal)adontypeinproduct.Price); } orderdetailadon.IsDoubleSelected = true; list.Add(orderdetailadon); } else if (productadonObj.DefaultSelected == 1) { orderdetail.Price += 0; orderdetailadon.IsDoubleSelected = false; list.Add(orderdetailadon); } } } else if (productadonObj.AdOnTypeInProduct.DisplayFormat == 2) { list.Add(orderdetailadon); } else if (productadonObj.AdOnTypeInProduct.DisplayFormat == 4) { HiddenField SelectedSize = childitem.FindControl("SelectedSize") as HiddenField; short selectedoption = 0; selectedoption = short.Parse(SelectedSize.Value); orderdetailadon.SelectedAdonOption = (BusinessEntities.SelectedOption)selectedoption; if (productadonObj.DefaultSelected == 0 && selectedoption == 1) { if (!productadonObj.Adon.AdonType1.IsFreeAdonType) { orderdetail.Price += Convert.ToDouble((decimal)adontypeinproduct.Price); } } list.Add(orderdetailadon); } } } } SessionOrderAdonList.Add(list); }
private decimal GetOrderOptions(BusinessEntities.OrderDetails orderdetail, decimal adonpricefromOptionType) { RadListViewDataItemCollection optioncollection = txtOptions.Items; List <BusinessEntities.OrderDetailOptions> list = new List <BusinessEntities.OrderDetailOptions>(); foreach (RadListViewDataItem item in optioncollection) { long id = (long)item.GetDataKeyValue("ProductsOptionTypeId"); OptionTypesInProduct OTP = (from otp in entities.OptionTypesInProducts where otp.ProductsOptionTypeId == id select otp).FirstOrDefault(); if (OTP.IsSamePrice && !OTP.IsMultiSelect) { RadioButtonList radioList = item.FindControl("RadioButtonList") as RadioButtonList; foreach (ListItem listitem in radioList.Items) { if (listitem.Selected) { long POP_ID = long.Parse(listitem.Value); ////Product Option In Product ID ProductOptionsInProduct POP_obj = (from pop in entities.ProductOptionsInProducts where pop.ProductOptionsInProductID == POP_ID select pop).FirstOrDefault(); if (OTP.IsProductPriceChangeType) { orderdetail.Price = Convert.ToDouble(POP_obj.Price); } if ((bool)OTP.IsProductPriceChangeType && OTP.IsAdonPriceVary) { if (POP_obj.ToppingPrice != null) { adonpricefromOptionType = (decimal)POP_obj.ToppingPrice; } } BusinessEntities.OrderDetailOptions orderdetailoption = new BusinessEntities.OrderDetailOptions(); orderdetailoption.ProductOptionId = POP_obj.ProductOptionID; orderdetailoption.ProductOptionName = POP_obj.ProductOption.OptionName; orderdetailoption.ProductOptionTypeName = POP_obj.OptionTypesInProduct.OptionType.OptionDisplayText; if (OTP.IsProductPriceChangeType) { orderdetailoption.Price = Convert.ToDouble(POP_obj.Price.Value); } list.Add(orderdetailoption); } } } else { if (OTP.IsMultiSelect) { #region CheckBox List CheckBoxList chkList = item.FindControl("CheckBoxList") as CheckBoxList; foreach (ListItem listitem in chkList.Items) { if (listitem.Selected) { long POP_ID = long.Parse(listitem.Value); ////Product Option In Product ID ProductOptionsInProduct POP_obj = (from pop in entities.ProductOptionsInProducts where pop.ProductOptionsInProductID == POP_ID select pop).FirstOrDefault(); orderdetail.Price += Convert.ToDouble(POP_obj.Price); BusinessEntities.OrderDetailOptions orderdetailoption = new BusinessEntities.OrderDetailOptions(); orderdetailoption.ProductOptionId = POP_obj.ProductOptionID; orderdetailoption.ProductOptionName = POP_obj.ProductOption.OptionName; orderdetailoption.Price = Convert.ToDouble(POP_obj.Price.Value); orderdetailoption.ProductOptionTypeName = POP_obj.OptionTypesInProduct.OptionType.OptionDisplayText; list.Add(orderdetailoption); } } #endregion } else { RadioButtonList radioList = item.FindControl("RadioButtonList") as RadioButtonList; foreach (ListItem listitem in radioList.Items) { #region if (listitem.Selected) { long POP_ID = long.Parse(listitem.Value); ////Product Option In Product ID ProductOptionsInProduct POP_obj = (from pop in entities.ProductOptionsInProducts where pop.ProductOptionsInProductID == POP_ID select pop).FirstOrDefault(); orderdetail.Price = Convert.ToDouble(POP_obj.Price); if ((bool)OTP.IsProductPriceChangeType) { if (POP_obj.ToppingPrice != null) { adonpricefromOptionType = (decimal)POP_obj.ToppingPrice; } } BusinessEntities.OrderDetailOptions orderdetailoption = new BusinessEntities.OrderDetailOptions(); orderdetailoption.ProductOptionId = POP_obj.ProductOptionID; orderdetailoption.ProductOptionName = POP_obj.ProductOption.OptionName; orderdetailoption.ProductOptionTypeName = POP_obj.OptionTypesInProduct.OptionType.OptionDisplayText; orderdetailoption.Price = Convert.ToDouble(POP_obj.Price); list.Add(orderdetailoption); } #endregion } } } } SessionOrderDetailOptionList.Add(list); return(adonpricefromOptionType); }
private void GetPrice() { try { long branchproductid = long.Parse(Request.QueryString["BPID"]); ProductsInBranch bpObj = (from bp in entities.ProductsInBranches where bp.BranchProductID == branchproductid select bp).FirstOrDefault(); if (bpObj != null) { if (bpObj.AddToCheckOut != null && bpObj.AddToCheckOut.Value) { productprice = (Decimal)bpObj.CheckOutPrice; } else { productprice = (Decimal)bpObj.Price; } #region Options RadListViewDataItemCollection optioncollection = txtOptions.Items; decimal adonpricefromOptionType = 0; foreach (RadListViewDataItem item in optioncollection) { long id = (long)item.GetDataKeyValue("ProductsOptionTypeId"); OptionTypesInProduct OTP = (from otp in entities.OptionTypesInProducts where otp.ProductsOptionTypeId == id select otp).FirstOrDefault(); if (OTP.IsSamePrice) { if (OTP.IsProductPriceChangeType) { productprice = (decimal)OTP.ProductOptionsInProducts.ToList()[0].Price; } } else { if (OTP.IsMultiSelect) { CheckBoxList chkList = item.FindControl("CheckBoxList") as CheckBoxList; foreach (ListItem listitem in chkList.Items) { if (listitem.Selected) { long POP_ID = long.Parse(listitem.Value); ////Product Option In Product ID ProductOptionsInProduct POP_obj = (from pop in entities.ProductOptionsInProducts where pop.ProductOptionsInProductID == POP_ID select pop).FirstOrDefault(); productprice += (decimal)POP_obj.Price; } } } else { RadioButtonList radioList = item.FindControl("RadioButtonList") as RadioButtonList; foreach (ListItem listitem in radioList.Items) { if (listitem.Selected) { long POP_ID = long.Parse(listitem.Value); ////Product Option In Product ID ProductOptionsInProduct POP_obj = (from pop in entities.ProductOptionsInProducts where pop.ProductOptionsInProductID == POP_ID select pop).FirstOrDefault(); if ((bool)OTP.IsProductPriceChangeType) { productprice = (decimal)POP_obj.Price; if (POP_obj.ToppingPrice != null) { adonpricefromOptionType = (decimal)POP_obj.ToppingPrice; } } } } } } } #endregion RadListViewDataItemCollection adoncollection = txtAdonsList.Items; foreach (RadListViewDataItem mainitem in adoncollection) { RadListView txtAdons = mainitem.FindControl("txtAdons") as RadListView; long productadontypeid = (long)mainitem.GetDataKeyValue("ProductsAdOnTypeId"); AdOnTypeInProduct adontypeinproduct = (from ATP in entities.AdOnTypeInProducts where ATP.ProductsAdOnTypeId == productadontypeid select ATP).FirstOrDefault(); RadListViewDataItemCollection childadoncollection = txtAdons.Items; foreach (RadListViewDataItem childitem in childadoncollection) { long id = (long)childitem.GetDataKeyValue("ProductAdOnID"); ProductAdon productadonObj = (from PA in entities.ProductAdons where PA.ProductAdOnID == id select PA).FirstOrDefault(); if (productadonObj != null) { if (productadonObj.AdOnTypeInProduct.DisplayFormat == 1) { HiddenField SelectedSize = childitem.FindControl("SelectedSize") as HiddenField; HiddenField IsDouble = childitem.FindControl("IsDouble") as HiddenField; short selectedoption = 0, isDouble = 0; selectedoption = short.Parse(SelectedSize.Value); isDouble = short.Parse(IsDouble.Value); if (selectedoption != 0) { if (productadonObj.DefaultSelected == 0 && (selectedoption == 1 || selectedoption == 2 || selectedoption == 3)) { if (!productadonObj.Adon.AdonType1.IsFreeAdonType) { if (isDouble == 1) { if (adonpricefromOptionType > 0) { productprice += 2 * adonpricefromOptionType; } else { productprice += (2 * (decimal)adontypeinproduct.Price); } } else { if (adonpricefromOptionType > 0) { productprice += adonpricefromOptionType; } else { productprice += (decimal)adontypeinproduct.Price; } } } else { if (isDouble == 1) { if (adonpricefromOptionType > 0) { productprice += adonpricefromOptionType; } else { productprice += (decimal)adontypeinproduct.Price; } } } } else if (isDouble == 1) { if (adonpricefromOptionType > 0) { productprice += adonpricefromOptionType; } else { productprice += (decimal)adontypeinproduct.Price; } } } else { ImageButton Double = childitem.FindControl("Double") as ImageButton; IsDouble = childitem.FindControl("IsDouble") as HiddenField; Double.ImageUrl = "~/image/Double_NotSelected.png"; IsDouble.Value = "0"; } UnSelectOtherSize(childitem, selectedoption); } else if (productadonObj.AdOnTypeInProduct.DisplayFormat == 2 || productadonObj.AdOnTypeInProduct.DisplayFormat == 3) { if (!productadonObj.Adon.AdonType1.IsFreeAdonType) { if (adonpricefromOptionType > 0) { productprice += adonpricefromOptionType; } else { productprice += (decimal)adontypeinproduct.Price; } } } else if (productadonObj.AdOnTypeInProduct.DisplayFormat == 4) { HiddenField SelectedSize = childitem.FindControl("SelectedSize") as HiddenField; HiddenField IsDouble = childitem.FindControl("IsDouble") as HiddenField; short selectedoption = 0, isDouble = 0; selectedoption = short.Parse(SelectedSize.Value); isDouble = short.Parse(IsDouble.Value); if (productadonObj.DefaultSelected == 0 && selectedoption == 1) { if (!productadonObj.Adon.AdonType1.IsFreeAdonType) { productprice += (decimal)adontypeinproduct.Price; } } UnSelectOtherSize(childitem, selectedoption); } } } } txtNetPrice.Text = Decimal.Round(productprice, 2).ToString(); } } catch (Exception ex) { throw ex; } }