/// <summary> /// Process the page data. /// </summary> private void ProcessForm(int fabricCode) { try { using (TransactionScope ts = new TransactionScope()) { List <PriceBO> lstPrices = (from o in (new PriceBO()).SearchObjects() where o.Pattern == this.ActivePattern.ID && o.FabricCode == fabricCode select o).ToList(); PriceBO objPrice = new PriceBO(this.ObjContext); if (lstPrices.Count > 0) { objPrice.ID = lstPrices[0].ID; objPrice.GetObject(); } else { objPrice.Pattern = int.Parse(this.hdnPattern.Value.Trim()); objPrice.FabricCode = fabricCode; objPrice.EnableForPriceList = false; objPrice.Creator = this.LoggedUser.ID; objPrice.CreatedDate = Convert.ToDateTime(DateTime.Now.ToString("g")); } objPrice.Modifier = this.LoggedUser.ID; objPrice.ModifiedDate = Convert.ToDateTime(DateTime.Now.ToString("g")); this.ObjContext.SaveChanges(); if (lstPrices.Count == 0) { foreach (int priceLevel in (new PriceLevelBO()).GetAllObject().Select(o => o.ID)) { PriceLevelCostBO objPriceLevelCost = new PriceLevelCostBO(this.ObjContext); objPriceLevelCost.FactoryCost = 0; objPriceLevelCost.IndimanCost = 0; objPriceLevelCost.Creator = this.LoggedUser.ID; objPriceLevelCost.CreatedDate = DateTime.Now; objPriceLevelCost.Modifier = this.LoggedUser.ID; objPriceLevelCost.ModifiedDate = DateTime.Now; objPriceLevelCost.PriceLevel = priceLevel; objPrice.PriceLevelCostsWhereThisIsPrice.Add(objPriceLevelCost); this.ObjContext.SaveChanges(); } } //this.ObjContext.SaveChanges(); ts.Complete(); } } catch (Exception ex) { // Log the error IndicoLogging.log.Error("Error occured while Adding the Item", ex); } }
protected void btnDelete_Click(object sender, EventArgs e) { int fabricCode = int.Parse(this.hdnSelectedID.Value.Trim()); if (Page.IsValid) { try { List <PriceBO> lstPrices = (from o in (new PriceBO()).SearchObjects() where o.Pattern == int.Parse(this.hdnPattern.Value.Trim()) && o.FabricCode == fabricCode select o).ToList(); if (lstPrices.Count > 0) { using (TransactionScope ts = new TransactionScope()) { PriceBO objPrice = new PriceBO(this.ObjContext); objPrice.ID = lstPrices[0].ID; objPrice.GetObject(); foreach (PriceLevelCostBO itemPLC in objPrice.PriceLevelCostsWhereThisIsPrice) { PriceLevelCostBO objPLC = new PriceLevelCostBO(this.ObjContext); objPLC.ID = itemPLC.ID; objPLC.GetObject(); foreach (DistributorPriceLevelCostBO itemDPLC in objPLC.DistributorPriceLevelCostsWhereThisIsPriceLevelCost) { DistributorPriceLevelCostBO objDPLC = new DistributorPriceLevelCostBO(this.ObjContext); objDPLC.ID = itemDPLC.ID; objDPLC.GetObject(); objDPLC.Delete(); } objPLC.Delete(); } objPrice.Delete(); this.ObjContext.SaveChanges(); ts.Complete(); } } // Populate active pattern fabrics this.PopulatePatternFabrics(); } catch (Exception ex) { // Log the error IndicoLogging.log.Error("btnDelete_Click : Error occured while Adding the Item", ex); } } }
/// <summary> /// Process the page data. /// </summary> private void ProcessForm(int queryId, bool isDelete) { try { using (TransactionScope ts = new TransactionScope()) { PatternBO objPattern = new PatternBO(this.ObjContext); if (queryId > 0) { objPattern.ID = queryId; objPattern.GetObject(); } if (isDelete) { List <PriceBO> lstPrces = objPattern.PricesWhereThisIsPattern; foreach (PriceBO price in lstPrces) { PriceBO objPrice = new PriceBO(this.ObjContext); objPrice.ID = price.ID; objPrice.GetObject(); foreach (PriceLevelCostBO priceLevelCost in objPrice.PriceLevelCostsWhereThisIsPrice) { PriceLevelCostBO objPriceLevelCost = new PriceLevelCostBO(this.ObjContext); objPriceLevelCost.ID = priceLevelCost.ID; objPriceLevelCost.GetObject(); objPriceLevelCost.Delete(); } objPrice.Delete(); } } this.ObjContext.SaveChanges(); ts.Complete(); } } catch (Exception ex) { // Log the error //IndicoLogging.log("Error occured while Adding the Item", ex); } }
/// <summary> /// Process the page data. /// </summary> private void ProcessForm(Repeater dataRepeater, int fabricCode) { try { using (TransactionScope ts = new TransactionScope()) { this.ActivePattern.ConvertionFactor = Convert.ToDecimal(decimal.Parse(this.txtConvertionFactor.Text.Trim()).ToString("0.00")); this.ActivePattern.PriceRemarks = this.txtRemarks.Text.Trim(); List <PriceBO> lstPrices = (from o in (new PriceBO()).SearchObjects() where o.Pattern == this.ActivePattern.ID && o.FabricCode == fabricCode select o).ToList(); PriceBO objPrice = new PriceBO(this.ObjContext); if (lstPrices.Count > 0) { objPrice.ID = lstPrices[0].ID; objPrice.GetObject(); } else { objPrice.Pattern = int.Parse(this.hdnPattern.Value.Trim()); objPrice.FabricCode = fabricCode; objPrice.Creator = this.LoggedUser.ID; objPrice.CreatedDate = Convert.ToDateTime(DateTime.Now.ToString("g")); } objPrice.Modifier = this.LoggedUser.ID; objPrice.ModifiedDate = Convert.ToDateTime(DateTime.Now.ToString("g")); foreach (RepeaterItem item in dataRepeater.Items) { HiddenField hdnCellID = (HiddenField)item.FindControl("hdnCellID"); TextBox txtCIFPrice = (TextBox)item.FindControl("txtCIFPrice"); int priceLevel = int.Parse(txtCIFPrice.Attributes["level"].ToString().Trim()); int priceLevelCost = int.Parse(hdnCellID.Value.Trim()); PriceLevelCostBO objPriceLevelCost = new PriceLevelCostBO(this.ObjContext); if (priceLevelCost > 0) { objPriceLevelCost.ID = priceLevelCost; objPriceLevelCost.GetObject(); } else { objPriceLevelCost.PriceLevel = priceLevel; objPrice.PriceLevelCostsWhereThisIsPrice.Add(objPriceLevelCost); } objPriceLevelCost.IndimanCost = Convert.ToDecimal(decimal.Parse(txtCIFPrice.Text.Trim()).ToString("0.00")); } this.ObjContext.SaveChanges(); ts.Complete(); } } catch (Exception ex) { // Log the error IndicoLogging.log.Error("Error occured while Adding the Item", ex); } }
protected void rptPriceLevelCost_ItemDataBound(object sender, RepeaterItemEventArgs e) { RepeaterItem item = e.Item; if (item.ItemIndex > -1 && item.DataItem is DistributorPriceMarkupBO) { DistributorPriceMarkupBO objPriceMarkup = (DistributorPriceMarkupBO)item.DataItem; Literal litCellHeader = (Literal)item.FindControl("litCellHeader"); litCellHeader.Text = objPriceMarkup.objPriceLevel.Name + "<em>( " + objPriceMarkup.objPriceLevel.Volume + " )</em>"; HiddenField hdnCellID = (HiddenField)item.FindControl("hdnCellID"); hdnCellID.Value = "0"; TextBox txtCIFPrice = (TextBox)item.FindControl("txtCIFPrice"); txtCIFPrice.Attributes.Add("level", objPriceMarkup.PriceLevel.ToString()); txtCIFPrice.Text = "0.00"; txtCIFPrice.Enabled = false; Label lblFOBPrice = (Label)item.FindControl("lblFOBPrice"); lblFOBPrice.Text = "0.00"; Label lblMarkup = (Label)item.FindControl("lblMarkup"); lblMarkup.Text = objPriceMarkup.Markup + "%"; Label lblCIFCost = (Label)item.FindControl("lblCIFCost"); lblCIFCost.Text = "$0.0"; Label lblFOBCost = (Label)item.FindControl("lblFOBCost"); lblFOBCost.Text = "$0.0"; } else if (item.ItemIndex > -1 && item.DataItem is PriceLevelCostBO) { PriceLevelCostBO objPriceLevelCost = (PriceLevelCostBO)item.DataItem; DistributorPriceMarkupBO objPriceMarkup = objPriceLevelCost.objPriceLevel.DistributorPriceMarkupsWhereThisIsPriceLevel.SingleOrDefault(o => (int)o.Distributor == int.Parse(this.ddlDistributors.SelectedValue.Trim())); decimal convertion = objPriceLevelCost.objPrice.objPattern.ConvertionFactor; decimal factoryCost = objPriceLevelCost.FactoryCost; decimal indimanCIFCost = (factoryCost == 0) ? 0 : Math.Round(Convert.ToDecimal((factoryCost * (100 + objPriceMarkup.Markup)) / 100), 2); Literal litCellHeader = (Literal)item.FindControl("litCellHeader"); litCellHeader.Text = objPriceLevelCost.objPriceLevel.Name + "<em>( " + objPriceLevelCost.objPriceLevel.Volume + " )</em>"; HiddenField hdnCellID = (HiddenField)item.FindControl("hdnCellID"); hdnCellID.Value = objPriceLevelCost.ID.ToString(); TextBox txtCIFPrice = (TextBox)item.FindControl("txtCIFPrice"); txtCIFPrice.Attributes.Add("level", objPriceLevelCost.PriceLevel.ToString()); txtCIFPrice.Text = objPriceLevelCost.IndimanCost.ToString("0.00"); txtCIFPrice.Enabled = isEnableIndimanCost; Label lblFOBPrice = (Label)item.FindControl("lblFOBPrice"); lblFOBPrice.Text = ((objPriceLevelCost.IndimanCost != 0) ? (objPriceLevelCost.IndimanCost - objPriceLevelCost.objPrice.objPattern.ConvertionFactor).ToString("0.00") : "0.00"); Label lblMarkup = (Label)item.FindControl("lblMarkup"); lblMarkup.Text = objPriceMarkup.Markup.ToString() + "%"; Label lblCIFCost = (Label)item.FindControl("lblCIFCost"); lblCIFCost.Text = "$" + indimanCIFCost.ToString("0.00"); Label lblFOBCost = (Label)item.FindControl("lblFOBCost"); lblFOBCost.Text = "$" + ((indimanCIFCost == 0) ? 0 : Convert.ToDecimal(indimanCIFCost - convertion)).ToString("0.00"); } }