Пример #1
0
 private void GetQuoteById()
 {
     Business.Sales.Quote Obj   = new Business.Sales.Quote();
     Entity.Sales.Quote   Quote = Obj.GetQuoteById(QuoteId);
     if (Quote.Id != 0)
     {
         txtActualCloseDate.Text      = Quote.ActualCloseDate == null ? string.Empty : Quote.ActualCloseDate.GetValueOrDefault().ToString("dd MMM yyyy");
         txtDateShipped.Text          = Quote.DateShipped == null ? string.Empty : Quote.DateShipped.GetValueOrDefault().ToString("dd MMM yyyy");
         txtValidTillDate.Text        = Quote.ValidTillDate == null ? string.Empty : Quote.ValidTillDate.GetValueOrDefault().ToString("dd MMM yyyy");
         txtOriginalPODate.Text       = Quote.OriginalPODate == null ? string.Empty : Quote.OriginalPODate.GetValueOrDefault().ToString("dd MMM yyyy");
         txtQuoteNumber.Text          = Quote.QuoteNumber;
         txtPurchaseOrderNo.Text      = Quote.PurchaseOrderNo;
         txtShippingProvider.Text     = Quote.ShippingProvider;
         txtCurrencyCode.Text         = Quote.CurrencyCode;
         txtCurrencyName.Text         = Quote.CurrencyName;
         txtTaxRate.Text              = Quote.TaxRate == null ? string.Empty : Quote.TaxRate.ToString();
         ddlOpportunity.SelectedValue = Quote.OpportunityId == null ? "0" : Quote.OpportunityId.ToString();
         ddlPaymentTerm.SelectedValue = Quote.PaymentTermId == null ? "0" : Quote.PaymentTermId.ToString();
         ddlQuoteStage.SelectedValue  = Quote.QuoteStageId == null ? "0" : Quote.QuoteStageId.ToString();
         JavaScriptSerializer ser = new JavaScriptSerializer();
         List <Entity.Sales.QuoteLineItem> lst = ser.Deserialize <List <Entity.Sales.QuoteLineItem> >(Quote.QuoteLineItem);
         ListtoDataTable lsttodt = new ListtoDataTable();
         _ItemsList = lsttodt.ToDataTable(lst);
         LoadItemList();
     }
 }
Пример #2
0
        public int SaveQuote(Entity.Sales.Quote Model)
        {
            QuoteDbModel DbModel = new QuoteDbModel();

            Model.CopyPropertiesTo(DbModel);
            return(QuoteDataAccess.SaveQuotes(DbModel));
        }
        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();
                }
            }
        }
Пример #4
0
 private void Save()
 {
     if (QuoteControlValidation())
     {
         List <Entity.Sales.QuoteLineItem> lineItem = new List <Entity.Sales.QuoteLineItem>();
         foreach (DataRow drItem in _ItemsList.Rows)
         {
             lineItem.Add(new Entity.Sales.QuoteLineItem
             {
                 ItemId     = Convert.ToInt32(drItem["ItemId"].ToString().Split('|')[0]),
                 Discount   = (!string.IsNullOrEmpty(drItem["Discount"].ToString())) ? Convert.ToDecimal(drItem["Discount"].ToString()) : 0,
                 Quantity   = (!string.IsNullOrEmpty(drItem["Quantity"].ToString())) ? Convert.ToDecimal(drItem["Quantity"].ToString()) : 0,
                 PartNumber = drItem["PartNumber"].ToString(),
                 ItemName   = drItem["ItemName"].ToString(),
                 IsActive   = true,
                 UnitPrice  = (!string.IsNullOrEmpty(drItem["UnitPrice"].ToString())) ? Convert.ToDecimal(drItem["UnitPrice"].ToString()) : 0
             });
         }
         JavaScriptSerializer jss   = new JavaScriptSerializer();
         string items               = jss.Serialize(lineItem);
         Business.Sales.Quote Obj   = new Business.Sales.Quote();
         Entity.Sales.Quote   Model = new Entity.Sales.Quote
         {
             Id                    = QuoteId,
             CreatedBy             = Convert.ToInt32(HttpContext.Current.User.Identity.Name),
             QuoteNumber           = txtQuoteNumber.Text,
             PurchaseOrderNo       = txtPurchaseOrderNo.Text,
             ShippingProvider      = txtShippingProvider.Text,
             CurrencyCode          = txtCurrencyCode.Text,
             CurrencyName          = txtCurrencyName.Text,
             OpportunityId         = ddlOpportunity.SelectedValue == "" ? (int?)null : Convert.ToInt32(ddlOpportunity.SelectedValue),
             PaymentTermId         = ddlPaymentTerm.SelectedValue == "" ? (int?)null : Convert.ToInt32(ddlPaymentTerm.SelectedValue),
             QuoteStageId          = ddlQuoteStage.SelectedValue == "" ? (int?)null : Convert.ToInt32(ddlQuoteStage.SelectedValue),
             OriginalPODate        = txtOriginalPODate.Text == "" ? (DateTime?)null : Convert.ToDateTime(txtOriginalPODate.Text),
             ActualCloseDate       = txtActualCloseDate.Text == "" ? (DateTime?)null : Convert.ToDateTime(txtActualCloseDate.Text),
             DateShipped           = txtDateShipped.Text == "" ? (DateTime?)null : Convert.ToDateTime(txtDateShipped.Text),
             ValidTillDate         = txtValidTillDate.Text == "" ? (DateTime?)null : Convert.ToDateTime(txtValidTillDate.Text),
             IsActiveQuote         = true,
             IsActiveQuoteHistory  = true,
             IsActiveQuoteSettings = true,
             TaxRate               = txtTaxRate.Text == "" ? (decimal?)null : Convert.ToDecimal(txtTaxRate.Text),
             QuoteLineItem         = items
         };
         Model.QuoteJSON = jss.Serialize(Model);
         int rows = Obj.SaveQuote(Model);
         if (rows > 0)
         {
             ClearControls();
             LoadQuoteList();
             QuoteId           = 0;
             Message.IsSuccess = true;
             Message.Text      = "Saved Successfully";
         }
         else
         {
             Message.IsSuccess = false;
             Message.Text      = "Unable to save data.";
         }
         Message.Show = true;
     }
 }
Пример #5
0
 public Entity.Sales.Quote GetQuoteById(int Id)
 {
     Entity.Sales.Quote Quote = new Entity.Sales.Quote();
     QuoteDataAccess.GetQuoteById(Id).CopyPropertiesTo(Quote);
     return(Quote);
 }