protected void btnSaveClonePriceMarkupLabel_Click(object sender, EventArgs e) { if (this.IsNotRefresh) { ReturnIntViewBO objReturnInt = new ReturnIntViewBO(); if (this.ddlExistDistributors.SelectedValue != null && this.txtMarkupLabel.Text != string.Empty) { objReturnInt = PriceMarkupLabelBO.CloneLabelPriceMarkup(int.Parse(this.ddlExistDistributors.SelectedValue), this.txtMarkupLabel.Text); if (objReturnInt.RetVal == 1) { ViewState["ClonePriceMarkup"] = false; Response.Redirect("~/ViewPriceMarckups.aspx"); } else { CustomValidator customValidator = new CustomValidator(); customValidator.ErrorMessage = "Insertion Failed Price Markup Label"; customValidator.IsValid = false; customValidator.EnableClientScript = false; this.ClonevalidationSummary.Controls.Add(customValidator); ViewState["ClonePriceMarkup"] = true; } } } }
/// <summary> /// Process the page data. /// </summary> private void ProcessForm(int distributorID, bool isDelete, bool isEdit, string isType) { try { using (TransactionScope ts = new TransactionScope()) { if (isEdit) { //Delete Statment if (isDelete) { ReturnIntViewBO objReturnIntView = new ReturnIntViewBO(); if (isType == "distributor") { objReturnIntView = DistributorPriceMarkupBO.DeleteDistributorPriceMarkup(distributorID); if (objReturnIntView.RetVal == 0) { return; } } if (isType == "label") { objReturnIntView = PriceMarkupLabelBO.DeleteLabelPriceMarkup(distributorID); if (objReturnIntView.RetVal == 0) { return; } } } else { if (isType == "distributor") { foreach (RepeaterItem item in this.rptPriceLevels.Items) { HiddenField hdnCellID = (HiddenField)item.FindControl("hdnCellID"); TextBox txtCellData = (TextBox)item.FindControl("txtCellData"); int markup = int.Parse(hdnCellID.Value); DistributorPriceMarkupBO objPriceMarckup = new DistributorPriceMarkupBO(this.ObjContext); if (markup > 0) { objPriceMarckup.ID = int.Parse(hdnCellID.Value.Trim()); objPriceMarckup.GetObject(); } if (isEdit) { objPriceMarckup.Distributor = (distributorID > 0) ? distributorID : 0; } objPriceMarckup.PriceLevel = int.Parse(txtCellData.Attributes["qid"].ToString()); objPriceMarckup.Markup = Convert.ToDecimal(decimal.Parse(txtCellData.Text.Trim()).ToString("0.00")); } } if (isType == "label") { foreach (RepeaterItem item in this.rptPriceLevels.Items) { HiddenField hdnCellID = (HiddenField)item.FindControl("hdnCellID"); TextBox txtCellData = (TextBox)item.FindControl("txtCellData"); int Labelmarkup = int.Parse(hdnCellID.Value); LabelPriceMarkupBO objLabelPriceMarkup = new LabelPriceMarkupBO(this.ObjContext); if (Labelmarkup > 0) { objLabelPriceMarkup.ID = int.Parse(hdnCellID.Value.Trim()); objLabelPriceMarkup.GetObject(); } objLabelPriceMarkup.Label = distributorID; objLabelPriceMarkup.PriceLevel = int.Parse(txtCellData.Attributes["qid"].ToString()); objLabelPriceMarkup.Markup = Convert.ToDecimal(decimal.Parse(txtCellData.Text.Trim()).ToString("0.00")); } } } } else { foreach (RepeaterItem item in this.rptPriceLevels.Items) { int distributor = int.Parse(this.ddlDistributors.SelectedValue); HiddenField hdnCellID = (HiddenField)item.FindControl("hdnCellID"); TextBox txtCellData = (TextBox)item.FindControl("txtCellData"); int markup = int.Parse(hdnCellID.Value); DistributorPriceMarkupBO objPriceMarckup = new DistributorPriceMarkupBO(this.ObjContext); if (markup > 0) { objPriceMarckup.ID = int.Parse(hdnCellID.Value.Trim()); objPriceMarckup.GetObject(); } if (distributor > 0) { objPriceMarckup.Distributor = (int?)distributor; } objPriceMarckup.PriceLevel = int.Parse(txtCellData.Attributes["qid"].ToString()); objPriceMarckup.Markup = Convert.ToDecimal(decimal.Parse(txtCellData.Text.Trim()).ToString("0.00")); } } this.ObjContext.SaveChanges(); ts.Complete(); } } catch (Exception ex) { // Log the error IndicoLogging.log.Error("Error occured while Adding, upadting and deleting the PriceMarkups", ex); } }