protected void btnSaveFabric_Click(object sender, EventArgs e) { int fabric = int.Parse(this.ddlEditFabric.SelectedValue); int price = int.Parse(this.hdnSelectedID.Value); if (fabric > 0 && price > 0) { try { using (TransactionScope ts = new TransactionScope()) { PriceBO objPrice = new PriceBO(this.ObjContext); objPrice.ID = price; objPrice.GetObject(); objPrice.FabricCode = fabric; objPrice.Modifier = LoggedUser.ID; objPrice.ModifiedDate = DateTime.Now; this.ObjContext.SaveChanges(); ts.Complete(); } } catch (Exception ex) { IndicoLogging.log.Error("Error occured while Changing Fabric in AddPatternFabric.aspx page", ex); } } this.Search(); }
protected void btnSave_Click(object sender, EventArgs e) { int price = int.Parse(((System.Web.UI.WebControls.WebControl)(sender)).Attributes["priceid"]); if (price > 0) { try { using (TransactionScope ts = new TransactionScope()) { PriceBO objPrice = new PriceBO(this.ObjContext); objPrice.ID = price; objPrice.GetObject(); objPrice.Remarks = txtAddNote.Text; objPrice.Modifier = LoggedUser.ID; objPrice.ModifiedDate = DateTime.Now; ObjContext.SaveChanges(); ts.Complete(); } } catch (Exception ex) { IndicoLogging.log.Error("Error occured while ading/updating note(btnSaveNote_Click()) AddPatternFabricPricePage", ex); } } ViewState["populateaddNewNote"] = false; this.PopulatePatternFabrics(); }
/// <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); } } }
protected void btnAddNote_Click(object sender, EventArgs e) { int price = int.Parse(((System.Web.UI.WebControls.WebControl)(sender)).Attributes["pid"]); btnSave.Attributes.Add("priceid", price.ToString()); if (price > 0) { PriceBO objPrice = new PriceBO(); objPrice.ID = price; objPrice.GetObject(); lblNoteHeading.Text = string.IsNullOrEmpty(objPrice.Remarks) ? "Add New Note" : "Edit Note"; txtAddNote.Text = objPrice.Remarks; } ViewState["populateaddNewNote"] = true; }
/// <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); } }