Esempio n. 1
0
    public static String SaveQuotation(App.CustomModels.CustomQuotation customQuotation, IList <App.CustomModels.CustomQuotationPricingLine> pricingLineItems)
    {
        OMMDataContext dataContext = new OMMDataContext();
        Quotation      quotation   = new Quotation();

        if (customQuotation.ID == 0)
        {
            dataContext.Quotations.InsertOnSubmit(quotation);
        }
        else
        {
            quotation = dataContext.Quotations.SingleOrDefault(P => P.ID == customQuotation.ID);
        }
        MapObject(quotation, customQuotation, dataContext);
        ProcessAndSaveQuotation(quotation, pricingLineItems, dataContext);
        //dataContext.SubmitChanges();
        return(String.Format("{0}:{1}", quotation.ID, quotation.Number));
    }
Esempio n. 2
0
    private static void MapObject(Quotation quotation, App.CustomModels.CustomQuotation customQuotation, OMMDataContext dataContext)
    {
        if (customQuotation.ID == 0)
        {
            quotation.CreatedByUserID   = SessionCache.CurrentUser.ID;
            quotation.CreatedByUsername = SessionCache.CurrentUser.UserName;
            quotation.CreatedOn         = DateTime.Now;
            quotation.Number            = dataContext.GenerateNewQuotationNumber(quotation.EnquiryID, false);
            quotation.StatusID          = App.CustomModels.QuotationStatus.NotSubmitted;
        }
        quotation.ChangedByUserID   = SessionCache.CurrentUser.ID;
        quotation.ChangedByUsername = SessionCache.CurrentUser.UserName;
        quotation.ChangedOn         = DateTime.Now;

        quotation.EnquiryID      = customQuotation.EnquiryID;
        quotation.Subcontractor  = customQuotation.Subcontractor;
        quotation.ScopeOfWork    = customQuotation.ScopeOfWork;
        quotation.MainEquipment  = customQuotation.MainEquipment;
        quotation.Schedule       = customQuotation.Scheduel;
        quotation.ValidityDays   = customQuotation.ValidityDays;
        quotation.SubmissionDate = WebUtil.GetDate(customQuotation.SubmissionDate);
        if (customQuotation.DecisionDate.IsNullOrEmpty())
        {
            quotation.DecisionDate = null;
        }
        else
        {
            quotation.DecisionDate = WebUtil.GetDate(customQuotation.DecisionDate);
        }

        quotation.CurrencyID  = customQuotation.CurrencyID;
        quotation.ProjectYear = customQuotation.ProjectYear;


        //var currency = dataContext.Currencies.SingleOrDefault(C => C.Description == ddlCurrency.SelectedValue);
        //if(currency != null)
        //    quotation.CurrencyID = currency.ID;
    }