private void BindQuote(int Id) { Business.Sales.Quote Obj = new Business.Sales.Quote(); string QuoteJson = Obj.GetQuoteJsonByStageId(Id); if (QuoteJson != null && QuoteJson != string.Empty) { Entity.Sales.Quote Quote = JsonConvert.DeserializeObject <Entity.Sales.Quote>(QuoteJson); lblQuoteNo.Text = Quote.QuoteNumber; lblDate.Text = System.DateTime.Today.ToString("dd MMM yyyy"); List <Entity.Sales.QuoteLineItem> lineItem = JsonConvert.DeserializeObject <List <Entity.Sales.QuoteLineItem> >(Quote.QuoteLineItem); decimal total = 0; for (int i = 0; i < lineItem.Count; i++) { if (lineItem[i].Quantity > 0 && lineItem[i].UnitPrice > 0) { lineItem[i].Amount = Math.Round(Convert.ToDecimal(lineItem[i].Quantity), 2) * Math.Round(Convert.ToDecimal(lineItem[i].UnitPrice), 2); if (lineItem[i].Discount > 0) { lineItem[i].Amount = lineItem[i].Amount - (lineItem[i].Amount * lineItem[i].Discount / 100); } total = total + Math.Round(Convert.ToDecimal(lineItem[i].Amount), 2); } } lblSubtotal.Text = Math.Round(total, 2).ToString(); if (Quote.TaxRate != null || Quote.TaxRate == 0) { lblTaxRate.Text = "0.00"; lblGST.Text = "0.00"; lblTotal.Text = Math.Round(total, 2).ToString(); } else { lblTaxRate.Text = Quote.TaxRate.ToString(); lblGST.Text = Math.Round(total * Convert.ToDecimal(Quote.TaxRate / 100), 2).ToString(); lblTotal.Text = Math.Round(total + total * Convert.ToDecimal(Quote.TaxRate / 100), 2).ToString(); } Business.Sales.Opportunity opportunity = new Business.Sales.Opportunity(); lblCustomer.Text = opportunity.GetOpportunityById(Convert.ToInt32(Quote.OpportunityId), Convert.ToInt32(ActityType.Lead), Convert.ToInt32(ActityType.Opportunity)).Name; if (lineItem.Count > 0) { rptrRepeatLineItem.DataSource = lineItem.ToList(); rptrRepeatLineItem.DataBind(); } } }
private void GetOpportunityById() { Business.Sales.Opportunity Obj = new Business.Sales.Opportunity(); Entity.Sales.Opportunity Opportunity = Obj.GetOpportunityById(OpportunityId, Convert.ToInt32(ActityType.Lead), Convert.ToInt32(ActityType.Opportunity)); if (Opportunity.Id != 0) { txtName.Text = Opportunity.Name; txtDescription.Text = Opportunity.Description; txtExpectedCloseDate.Text = Opportunity.ExpectedCloseDate == null ? string.Empty : Opportunity.ExpectedCloseDate.GetValueOrDefault().ToString("dd MMM yyyy"); txtLikelyPrice.Text = Opportunity.LikelyPrice == null ? string.Empty : Opportunity.LikelyPrice.ToString(); txtBestPrice.Text = Opportunity.BestPrice == null ? string.Empty : Opportunity.BestPrice.ToString(); txtWorstPrice.Text = Opportunity.WorstPrice == null ? string.Empty : Opportunity.WorstPrice.ToString(); txtSourceName.Text = Opportunity.SourceName; ddlCampaign.SelectedValue = Opportunity.CampaignId == null ? "0" : Opportunity.CampaignId.ToString(); ddlCommitStage.SelectedValue = Opportunity.CommitStageId == null ? "0" : Opportunity.CommitStageId.ToString(); ddlLeadSource.SelectedValue = Opportunity.LeadSource == null ? "0" : Opportunity.LeadSource.ToString(); ddlLinkName.SelectedValue = Opportunity.SourceActivityId == null ? "0" : Opportunity.SourceActivityId.ToString(); ActivityLinkId = Opportunity.ActivityLinkId; } }