Esempio n. 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            quote = session.Load<Quote>(session.Load<ApplicationUser>(User.Identity.GetUserId()).ActiveQuote);
            QuoteID = quote.Id;

            if (!IsPostBack)
            {
                if(quote.linesHW.Count > 0)
                {
                    repHW.DataSource = quote.linesHW;
                    repHW.DataBind();
                }

                if (quote.linesSW.Count > 0)
                {
                    repSW.DataSource = quote.linesSW;
                    repSW.DataBind();
                }

                if (quote.linesCC.Count > 0)
                {
                    repCC.DataSource = quote.linesCC;
                    repCC.DataBind();
                }

                if (quote.linesInst.Count > 0)
                {
                    repInst.DataSource = quote.linesInst;
                    repInst.DataBind();
                }

                if (quote.linesRec.Count > 0)
                {
                    repRec.DataSource = quote.linesRec;
                    repRec.DataBind();
                }
            }

            //Totals
            GrandTotal.Text = quote.GetGrandTotal().ToString();
            GrandMargin.Text = quote.GetGrandMargin().ToString();
            GrandMarginPercent.Text = Math.Round((quote.GetGrandMargin()/quote.GetGrandTotal())*100,2).ToString();
        }
Esempio n. 2
0
        protected void CopyQuote(Object source, EventArgs e)
        {
            Quote temp = new Quote(quote);

            var user = session.Load<ApplicationUser>(User.Identity.GetUserId());
                user.ActiveQuote = temp.Id;

            session.Store(temp);

            session.SaveChanges();
        }
Esempio n. 3
0
        protected void SaveQuote()
        {
            if (quote == null)
                {
                    quote = new Quote();
                    session.Store(quote);
                }
                else
                {
                    quote.Owner = Owner.Text;
                    quote.Date = Date.Text;
                    quote.PhoneNumber = PhoneNumber.Text;
                    quote.Email = manager.FindById(User.Identity.GetUserId()).Email.ToString();
                    if (QuoteLength.Text != "") quote.QuoteLength = Convert.ToInt32(QuoteLength.Text);
                    quote.PaymentTerms = PaymentTermsDDL.SelectedValue;

                    quote.Customer = new Address();
                    quote.Customer.Contact = CustContact.Text;
                    quote.Customer.Company = CustCompany.Text;
                    quote.Customer.Address1 = CustAddress1.Text;
                    quote.Customer.Address2 = CustAddress2.Text;
                    quote.Customer.CityState = CustCityState.Text;
                    quote.Customer.Fax = CustFax.Text;
                    quote.Customer.Phone = CustPhone.Text;
                    quote.Customer.Email = CustEmail.Text;

                    quote.Billing = new Address();
                    quote.Billing.Contact = BillContact.Text;
                    quote.Billing.Company = BillCompany.Text;
                    quote.Billing.Address1 = BillAddress1.Text;
                    quote.Billing.Address2 = BillAddress2.Text;
                    quote.Billing.CityState = BillCityState.Text;
                    quote.Billing.Fax = BillFax.Text;
                    quote.Billing.Phone = BillPhone.Text;
                    quote.Billing.Email = BillEmail.Text;

                    quote.Shipping = new Address();
                    quote.Shipping.Contact = ShipContact.Text;
                    quote.Shipping.Company = ShipCompany.Text;
                    quote.Shipping.Address1 = ShipAddress1.Text;
                    quote.Shipping.Address2 = ShipAddress2.Text;
                    quote.Shipping.CityState = ShipCityState.Text;
                    quote.Shipping.Fax = ShipFax.Text;
                    quote.Shipping.Phone = ShipPhone.Text;
                    quote.Shipping.Email = ShipEmail.Text;

                    quote.Source = SourceDDL.SelectedValue;
                    quote.SpecificSource = SpecificSource.Text;
                    if (LocationCount.Text != "") quote.LocationCount = Convert.ToInt32(LocationCount.Text);
                    quote.POSProvidor = POSProvidor.Text;
                    quote.InstallDate = InstallDate.Text;
                    quote.BusinessUnit = BusinessUnitDDL.SelectedValue;

                    quote.NewLocation = NewLocation.Checked;
                    quote.Dealer = Dealer.Checked;

                    quote.TaxExempt = TaxStatusDDL.SelectedValue;

                    if (Freight.Text != "") quote.Freight = Convert.ToDouble(Freight.Text);
                        else quote.Freight = 0;
                    if (SalesTax.Text != "") quote.SalesTax = Convert.ToDouble(SalesTax.Text);
                    else quote.SalesTax = 0;

                    quote.InternalNotes = InternalNotes.InnerText;
                    quote.ExternalNotes = ExternalNotes.InnerText;
                }

                session.SaveChanges();
        }
Esempio n. 4
0
        protected void Page_Load(Object sender, EventArgs e)
        {
            //var active = manager.FindById(userID).ActiveQuote;
               //this usermanager is crap ever since I went to users in RavenDB

            var user = session.Load<ApplicationUser>(User.Identity.GetUserId());

            //load active quote for current user
            if (user.ActiveQuote != null)
            {
                quote = session.Load<Quote>(user.ActiveQuote);
                if(quote != null) QuoteID = quote.Id;
            }
            if(quote == null) //catch all for deleted quotes, new users, etc
                NewQuote();

            if (!IsPostBack)
            {
                LoadQuote(QuoteID);
                repHW.DataSource = quote.linesHW;
                repHW.DataBind();

                repSW.DataSource = quote.linesSW;
                repSW.DataBind();

                repCC.DataSource = quote.linesCC;
                repCC.DataBind();

                repInst.DataSource = quote.linesInst;
                repInst.DataBind();

                repRec.DataSource = quote.linesRec;
                repRec.DataBind();
            }
        }
Esempio n. 5
0
        protected void NewQuote()
        {
            var user = session.Load<ApplicationUser>(User.Identity.GetUserId());

                quote = new Quote();

            session.Store(quote);

            user.ActiveQuote = quote.Id;
            QuoteID = quote.Id;

            session.SaveChanges();
            Response.Redirect(Request.RawUrl);
        }
Esempio n. 6
0
        public Quote(Quote q)
        {
            this.Id = null;
            this.Owner = q.Owner;
            this.Date = q.Date;

            this.QuoteLength = q.QuoteLength;
            this.PaymentTerms = q.PaymentTerms;

            this.Customer = q.Customer;
            this.Billing = q.Billing;
            this.Shipping = q.Shipping;

            this.Source = q.Source;
            this.SpecificSource = q.SpecificSource;
            this.LocationCount = q.LocationCount;
            this.POSProvidor = q.POSProvidor;
            this.InstallDate = q.InstallDate;
            this.BusinessUnit = q.BusinessUnit;

            this.NewLocation = q.NewLocation;
            this.Dealer = q.Dealer;
            this.TaxExempt = q.TaxExempt;

            this.linesHW = q.linesHW;
            this.linesAcc = q.linesAcc;
            this.linesSW = q.linesSW;
            this.linesCC = q.linesCC;
            this.linesInst = q.linesInst;
            this.linesRec = q.linesRec;
        }
Esempio n. 7
0
 public string GetGrandTotalString(Quote q)
 {
     return q.GetGrandTotal().ToString("C2");
 }