示例#1
0
        public DisplayQuote(DeskQuote quote, decimal basePrice, decimal shippingCost, decimal drawersCost, decimal surfaceDecimal, decimal weight)
        {
            InitializeComponent();

            lblDeliveriFill.Text = quote.ShippingType;
            lblFillTotal.Text    = lblFillTotal.Text + quote.QuotePrice.ToString();
            lblAreaCost.Text     = "$" + weight.ToString();
            lblFillName.Text     = quote.CustomerName;
            lblFillShipping.Text = "$" + shippingCost.ToString();
            lblFillDrawers.Text  = "$" + drawersCost.ToString();
            lblSurfaceCost.Text  = "$" + surfaceDecimal.ToString();
            lblBaseCost.Text     = "$" + basePrice.ToString();
        }
示例#2
0
        public DisplayQuote(DeskQuote quote)
        {
            InitializeComponent();

            customerName.Text        = quote.CustomerName;
            numWidth.Value           = quote.Desk.Width;
            numDepth.Value           = quote.Desk.Depth;
            surfaceMaterialText.Text = Convert.ToString(quote.Desk.SurfaceMaterial);
            shippingTypeText.Text    = Convert.ToString(quote.ShippingType);
            numDrawers.Value         = quote.Desk.NumberOfDrawers;

            quotePriceBox.Text = Convert.ToString(quote.QuotePrice);
        }
 public void Add(DeskQuote quote)
 {
     quotes.Add(quote);
     string[] lines = quotes.ConvertAll(x => x.MakeFileRecord()).ToArray();
     try
     {
         File.WriteAllLines(fileName, lines);
     }
     catch (System.Exception e)
     {
         throw new System.Exception("Can't write to " + fileName + ". " + e.Message);
     }
 }
示例#4
0
        private void CalcQuote_Click(object sender, EventArgs e)
        {
            try
            {
                CustomerName    = textBoxCustomerName.Text;
                DeskWidth       = int.Parse(WidthTextBox.Text);
                DeskDepth       = int.Parse(DepthTextBox.Text);
                Drawers         = int.Parse(NumDrawersComboBox.SelectedItem.ToString());;
                DesktopMaterial = (DesktopMaterial)comboBoxSurfaceMaterial.SelectedValue;

                //rush order selection
                if (radioRush3.Checked)
                {
                    RushOrderDays = 3;
                }
                if (radioRush5.Checked)
                {
                    RushOrderDays = 3;
                }
                if (radioRush5.Checked)
                {
                    RushOrderDays = 3;
                }
                if (noRush.Checked)
                {
                    RushOrderDays = 0;
                }


                //Create New quote
                DeskQuote NewQuote = new DeskQuote(CustomerName, DateTime.Now, DeskWidth, DeskDepth, Drawers, DesktopMaterial, RushOrderDays);
                DeskQuoteTotal = NewQuote.CalculateQuoteTotal();

                //build CSV output
                var    DeskRecord = CustomerName + ", " + DateTime.Now + ", " + DeskWidth + ", " + DeskDepth + ", " + Drawers + ", " + DesktopMaterial + ", " + RushOrderDays + ", $" + DeskQuoteTotal;
                string cFile      = @"quotes.txt";
                if (!File.Exists(cFile))
                {
                    using (StreamWriter sw = File.CreateText("quotes.txt")) { }
                }
                using (StreamWriter swa = File.AppendText("quotes.txt")) { swa.WriteLine(DeskRecord); }

                ThankYouMessage.Text  = "Thank you for Submitting a quote!";
                DisplayDeskQuote.Text = "Your quote is: " + DeskRecord;
                cancelQuote.Text      = "Main Menu";
            }
            catch (Exception ex)
            {
                MessageBox.Text = ex.Message;
            }
        }
示例#5
0
        public static DeskQuote GetLastDeskQuote()
        {
            // GETS THE LAST DESK QUOTE ADDED TO THE QUOTES.JSON FILE
            // THIS CAN BE USED IN THE DISPLAY QUOTE VIEW BECAUSE THE LAST QUOTE WILL BE THE ONE YOU WANT TO SHOW
            List <DeskQuote> deskQuotes = GetAllJsonQuotes();

            if (deskQuotes.Count > 0)
            {
                return(deskQuotes[deskQuotes.Count - 1]);
            }
            DeskQuote deskQuote = new DeskQuote();

            return(deskQuote);
        }
示例#6
0
        //public DeskQuote Quote { get; }

        public DisplayQuote(DeskQuote quote)
        {
            InitializeComponent();
            //Quote = quote;
            fullNameOutput.Text        = quote.CustomerName;
            widthOutput.Text           = $"{quote.Desk.width}in";
            depthOutput.Text           = $"{quote.Desk.depth}in";
            numberOfDrawersOutput.Text = quote.Desk.numberOfDrawers.ToString();
            surfaceMaterialOutput.Text = quote.Desk.SurfaceMaterial.ToString();
            rushOrderOutput.Text       = (Attribute.GetCustomAttribute(quote.RushOrderType.GetType().GetField(quote.RushOrderType.ToString()), typeof(DescriptionAttribute)) as DescriptionAttribute)?.Description
                                         ?? quote.RushOrderType.ToString();
            dateOutput.Text       = quote.Date.ToShortDateString();
            quotePriceOutput.Text = quote.QuotePrice.ToString("C");
        }
示例#7
0
        private void Btn_submit_Click(object sender, EventArgs e)
        {
            var temp_desk = new Desk()
            {
                width          = Convert.ToInt32(deskWidth.Value),
                depth          = Convert.ToInt32(deskDepth.Value),
                numberOfDrawer = (int)numDrawers.Value,
                desktop        = (Material)MaterialsCombo.SelectedValue
            };

            var deskQuote = new DeskQuote
            {
                desk         = temp_desk,
                customerName = txtcustomerName.Text,
                quoteDate    = DateTime.Now,
                shipping     = (Shipping)comShipping.SelectedValue,
                quotePrice   = 0
            };

            deskQuote.setPrice();
            var quotesFile = @"quotes.json";
            List <DeskQuote> deskquotes = new List <DeskQuote>();

            //read existing quotes if any
            if (File.Exists(quotesFile))
            {
                using (StreamReader reader = new StreamReader(quotesFile))
                {
                    //load existing quotes
                    string quotes = reader.ReadToEnd();

                    if (quotes.Length > 0)
                    {
                        // deserialization time!
                        deskquotes = JsonConvert.DeserializeObject <List <DeskQuote> >(File.ReadAllText(quotesFile)) ?? new List <DeskQuote>();
                    }
                }
            }
            deskquotes.Add(deskQuote);
            string jsonDesks = JsonConvert.SerializeObject(deskquotes);

            File.WriteAllText(quotesFile, jsonDesks);

            //var newQuoteString = deskquotes[2];
            //MessageBox.Show(newQuoteString);

            DisplayQuote displayQuote = new DisplayQuote(deskQuote);

            displayQuote.Show();
        }
示例#8
0
        private void WriteToFile()
        {
            // First time adding text to the file
            if (!File.Exists(FILE_PATH))
            {
                string header = DeskQuote.CSVHeader();
                File.WriteAllText(FILE_PATH, header + Environment.NewLine + deskQuote.ToString() + Environment.NewLine);
            }


            // This text is always added, making the file longer over time
            // if it is not deleted.
            File.AppendAllText(FILE_PATH, deskQuote.ToString() + Environment.NewLine);
        }
示例#9
0
        public DisplayQuote(DeskQuote deskQuote)
        {
            InitializeComponent();

            _deskQuote = deskQuote;

            customerName.Text  = deskQuote.customerName;
            customerPrice.Text = "$ " + deskQuote.quotePrice.ToString();
            numDrawers.Text    = deskQuote.desk.numberOfDrawer.ToString();
            numDepth.Text      = deskQuote.desk.depth.ToString();
            numWidth.Text      = deskQuote.desk.width.ToString();
            numMaterial.Text   = deskQuote.desk.desktop.ToString();
            numShipping.Text   = deskQuote.shipping.ToString();
        }
示例#10
0
        /// <summary>
        /// Calculates all the inputs and set the class properties
        /// to be displayed in the DisplayQuote.
        /// </summary>
        public void CalculateQuote()
        {
            // Gettomg the Desk and DeskQuote properties
            Desk      desk      = new Desk();
            DeskQuote deskQuote = new DeskQuote();

            // Getting the values from NumericUpDown control and ComboBox
            int drawers = (int)deskDrawers.Value;

            int material = (int)cmbMat.SelectedValue;

            int rushDays = (int)cmbRushDays.SelectedValue;

            //Setting the Customer property
            deskQuote.CustomerName = txtName.Text;

            Customer = deskQuote.CustomerName;

            // Making all the calculations and setting other properties
            desk.CalcArea((int)deskWidth.Value, (int)deskDepth.Value);

            DeskWidth = desk.DeskWidth;

            DeskDepth = desk.DeskDepth;

            AreaCost = deskQuote.CalcAreaCost(desk.DeskArea);

            DrawerCost = deskQuote.CalcDrawerCost(drawers);

            DeskDrawer = desk.DeskDrawer;

            MaterialCost = deskQuote.CalcSufCost(material);

            MaterialType = deskQuote.MaterialTypeDef(material);

            RushDaysCost = deskQuote.CalcAdditionalCost(rushDays, desk.DeskArea);

            Total = deskQuote.CalcDeskQuote(deskQuote.AreaCost, deskQuote.SufMatCost, deskQuote.DrawerCost, deskQuote.AdditionalCost);

            // Estamite the delivery date
            deskQuote.CurrentDate = DateTime.Now;

            deskQuote.EstimateShip = deskQuote.CurrentDate.AddDays(rushDays);

            deskQuote.DisplayDate = deskQuote.EstimateShip.ToString("dd MMMM yyyy", CultureInfo.CreateSpecificCulture("en-US"));

            Estimated = deskQuote.DisplayDate;
        }
示例#11
0
 private void changeNameButton_Click(object sender, EventArgs e)
 {
     nameSelection = nameComboBox.Text;
     displayList.Clear();
     for (int i = 0; i < list.Count; i++)
     {
         if (list[i].FirstName == nameSelection)
         {
             quoteToShow = list[i];
             displayList.Add(quoteToShow);
         }
     }
     searchGrid.DataSource = null;
     searchGrid.DataSource = displayList;
     searchGrid.Refresh();
 }
示例#12
0
        private void searchGrid_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            int selectedRow = e.RowIndex;

            // Get the selected row and material type
            quoteToShow = list[selectedRow];
            newMaterial = (DesktopMaterial)materialComboBox.SelectedItem;

            // Add the price difference between the two selections to the total
            int priceDiff = quoteToShow.changeMaterialCost(quoteToShow, newMaterial.ToString());

            quoteToShow.TotalCost        += priceDiff;
            quoteToShow.Desk.MaterialType = newMaterial;

            displaySearchQuoteButton.Enabled = true;
        }
示例#13
0
        public DisplayQuote()
        {
            InitializeComponent();
            DeskQuote deskQuote = new DeskQuote();
            Desk      desk      = deskQuote.Desk;

            theDate.Text     = deskQuote.PurchaseDate;
            theCustomer.Text = $"{deskQuote.FirstName} {deskQuote.LastName}";
            theWidth.Text    = desk.Width.ToString();
            theDepth.Text    = desk.Depth.ToString();
            theArea.Text     = (desk.Width * desk.Depth).ToString();
            theDrawers.Text  = desk.DrawerNum.ToString();
            theMaterial.Text = desk.MaterialType.ToString();
            theRush.Text     = deskQuote.RushCost.ToString();
            theTotal.Text    = deskQuote.TotalCost.ToString();
        }
示例#14
0
        private void AddQuotetoFile(DeskQuote deskQuote)
        {
            string quotesFile = "quotes.txt";

            using (StreamWriter streamwriter = File.AppendText(quotesFile))
            {
                streamwriter.WriteLine(
                    $"{deskQuote.CustomerName}, " +
                    $"{deskQuote.QuoteDate}, " +
                    $"{deskQuote.Desk.Depth}, " +
                    $"{deskQuote.Desk.Width}, " +
                    $"{deskQuote.Desk.NumDrawers}, " +
                    $"{deskQuote.Desk.Material}, " +
                    $"{deskQuote.NumShippingDays} Days, " +
                    $"{deskQuote.Quote}");
            }
        }
示例#15
0
        private void submitAddNewQuoteBtn_Click(object sender, EventArgs e)
        {
            try
            {
                if (nameInput.Text == "" || surfaceInput.SelectedItem == null || timeInput.SelectedItem == null)
                {
                    throw new ArgumentNullException();
                }
            }
            catch (ArgumentNullException f)
            {
                MessageBox.Show("Fields cannot be empty.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            widthInput.ReadOnly   = true;
            depthInput.ReadOnly   = true;
            drawersInput.ReadOnly = true;
            surfaceInput.Enabled  = false;
            timeInput.Enabled     = false;
            nameInput.ReadOnly    = true;

            decimal width   = widthInput.Value;
            decimal depth   = depthInput.Value;
            int     drawers = (int)drawersInput.Value;

            Desk.SurfaceMaterial deskMaterial = (Desk.SurfaceMaterial)surfaceInput.SelectedItem;
            DeskQuote.Delivery   shipping     = (DeskQuote.Delivery)timeInput.SelectedItem;
            string   name = nameInput.Text;
            DateTime date = new DateTime();

            Desk      desk  = new Desk(width, depth, drawers, deskMaterial);
            DeskQuote quote = new DeskQuote(desk, shipping, name, date);

            decimal price = quote.GetQuote(desk, quote);

            priceOutput.Text    = price.ToString();
            priceOutput.Visible = true;
            priceLabel.Visible  = true;

            TextWriter file = new StreamWriter(@"../quotes.txt", true);

            file.WriteLine(quote.Shipping + "," + quote.Customer + "," + quote.Date + "," + desk.Width + "," + desk.Depth + "," + desk.Drawers + "," + desk.Material + "," + price);
            file.Close();
        }
示例#16
0
        public DeskQuoteView(DeskQuote dq)
        {
            this.Quote = dq;

            try
            {
                this.CustomerName   = dq.CustomerName;
                this.Dimensions     = String.Format("{0:0.}W by {1:0.}D", dq.Desk.Width, dq.Desk.Depth);
                this.DrawerCount    = dq.Desk.DrawerCount;
                this.Material       = dq.Desk.Material.ToString();
                this.ShippingMethod = dq.Shipping.Key;
                this.QuotePrice     = String.Format("${0,10:0.00}", dq.QuotePrice);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error converting DeskQuote ID " + dq.Id + " to a DeskQuoteView.  : " + ex.Message, "MegaDesk 2.0");
                throw;
            }
        }
示例#17
0
        public DisplayQuote(DeskQuote fromDeskQuote)
        {
            InitializeComponent();
            deskQuote = fromDeskQuote;
            Desk desk = deskQuote.Desk;

            theDate.Text     = deskQuote.PurchaseDate;
            theCustomer.Text = $"{deskQuote.FirstName} {deskQuote.LastName}";
            theMaterial.Text = $"{desk.MaterialType.ToString()}  (${(int)desk.MaterialType})";

            theDate.Text     = String.Format("{0,10:dd-MMM-yy}", deskQuote.PurchaseDate);
            theWidth.Text    = String.Format("{0,0:0} in", desk.Width);
            theDepth.Text    = String.Format("{0,0:0} in", desk.Depth);
            theArea.Text     = String.Format("{0,0:0} in\xB2 ({1,0:$0.00})", desk.getArea(), desk.getArea() * 1);
            theDrawers.Text  = String.Format("{0,0:0} ({1,0:$0.00})", desk.DrawerNum.ToString(), desk.DrawerNum * 50);
            theRush.Text     = String.Format("{0,0:$0.00}", deskQuote.RushCost);
            theTotal.Text    = String.Format("{0,0:$0.00}", deskQuote.TotalCost);
            theBaseCost.Text = String.Format("{0,0:$0.00}", DeskQuote.BASECOST);
        }
示例#18
0
        private void BtnAdd_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(rushOptionsForm.Text) && String.IsNullOrEmpty(materialForm.Text) && String.IsNullOrEmpty(fullNameBox.Text))
            {
                MessageBox.Show("\"Rush options\", \"Materials\", and \"Full name\" cannot be empty!");
            }
            else if (String.IsNullOrEmpty(rushOptionsForm.Text) && String.IsNullOrEmpty(materialForm.Text))
            {
                MessageBox.Show("\"Rush options\" and \"Materials\" cannot be empty!");
            }
            else if (String.IsNullOrEmpty(rushOptionsForm.Text) && String.IsNullOrEmpty(fullNameBox.Text))
            {
                MessageBox.Show("\"Rush options\" and \"Full name\" cannot be empty!");
            }
            else if (String.IsNullOrEmpty(materialForm.Text) && String.IsNullOrEmpty(fullNameBox.Text))
            {
                MessageBox.Show("\"Materials\" and \"Full name\" cannot be empty!");
            }
            else if (String.IsNullOrEmpty(materialForm.Text))
            {
                MessageBox.Show("\"Materials\" cannot be empty!");
            }
            else if (String.IsNullOrEmpty(rushOptionsForm.Text))
            {
                MessageBox.Show("\"Rush options\" cannot be empty!");
            }
            else if (String.IsNullOrEmpty(fullNameBox.Text))
            {
                MessageBox.Show("\"Full name\" cannot be empty!");
            }
            else
            {
                var my_desk  = new Desk((float)numWidthForm.Value, (float)numDepthForm.Value, Decimal.ToInt16(numDrawersForm.Value), materialForm.Text);
                var my_quote = new DeskQuote(fullNameBox.Text, rushOptionsForm.Text, my_desk, DateTime.Now);

                var json_my_quote = Newtonsoft.Json.JsonConvert.SerializeObject(my_quote);
                File.AppendAllText(orderPath, json_my_quote);
                File.AppendAllText(orderPath, "\n\n");

                clearForms();
            }
        }
示例#19
0
        public JObject saveFileFormat(DeskQuote DeskQuoteParse)
        {
            JObject savefile = new JObject(
                new JProperty("id", DeskQuoteParse.id),
                new JProperty("date", DeskQuoteParse.date),
                new JProperty("depth", DeskQuoteParse.depth),
                new JProperty("width", DeskQuoteParse.width),
                new JProperty("drawers", DeskQuoteParse.drawers),
                new JProperty("drawerCost", DeskQuoteParse.drawerCost),
                new JProperty("area", DeskQuoteParse.area),
                new JProperty("areaCost", DeskQuoteParse.areaCost),
                new JProperty("material", DeskQuoteParse.material),
                new JProperty("materialCost", DeskQuoteParse.materialCost),
                new JProperty("customerName", DeskQuoteParse.customerName),
                new JProperty("rush", DeskQuoteParse.rush),
                new JProperty("shippingCost", DeskQuoteParse.shippingCost),
                new JProperty("quote", DeskQuoteParse.quote));

            return(savefile);
        }
示例#20
0
        //btn that shows summary of choice before submitting for price
        private void btnSummary_Click(object sender, EventArgs e)
        {
            string quote;
            int    deskarea = width * depth;

            label2.Text = DateTime.Now.ToString("MM/dd/yyyy");;
            label3.Text = Convert.ToString(InputCustomerName.Text);


            label15.Text = Convert.ToString(drawers);
            label14.Text = Convert.ToString(material);
            label17.Text = Convert.ToString(deskarea);
            label18.Text = Convert.ToString(materialcost);
            label19.Text = Convert.ToString(rushday);
            // label20.Text = quote;

            Desk desk = new Desk
            {
                depth        = depth,
                width        = width,
                drawers      = drawers,
                materialcost = materialcost,
                rushday      = rushday,
            };

            DeskQuote deskquote = new DeskQuote();

            {
                deskquote.desk         = desk;
                deskquote.customerName = InputCustomerName.Text;
                //  deskquote.quoteDate = DateTime.Now.ToLongDateString;
                deskquote.quoteTotal = DeskQuote.getQuotePrice(desk.depth, desk.width, desk.drawers, desk.rushday, desk.materialcost);
            }

            quote = Convert.ToString(deskquote.quoteTotal);



            // DeskQuote newDeskQuote = new DeskQuote(desk, customerName); //quoteDate ?
            // quotetotal = Convert.ToString(quote);
        }
示例#21
0
        void fillData()
        {
            string orderPath            = @"..\orders.txt";
            IEnumerable <String> orders = File.ReadLines(orderPath);

            foreach (String line in orders)
            {
                try
                {
                    DeskQuote jObject = Newtonsoft.Json.JsonConvert.DeserializeObject <DeskQuote>(line);
                    if (jObject != null && jObject.Desk.SurfaceMaterial == materialForm.Text)
                    {
                        quotes.Add(jObject);
                    }
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.ToString());
                }
            }
        }
示例#22
0
        private void btnSaveQuote_Click(object sender, EventArgs e)
        {
            var desk = new Desk
            {
                Depth           = numDeskDepth.Value,
                Width           = numDeskWidth.Value,
                NumberOfDrawers = (int)numNumberOfDrawers.Value,
                Material        = (Desk.DesktopMaterial)comSurfaceMaterial.SelectedValue
            };

            var deskQuote = new DeskQuote
            {
                Desk         = desk,
                CustomerName = txtCustomerName.Text,
                QuoteDate    = DateTime.Now,
                DeliveryType = (DeskQuote.Delivery)comDelivery.SelectedValue
            };

            try
            {
                // get quote amount
                var price = deskQuote.GetQuotePrice();

                // add amount to quote
                deskQuote.QuotePrice = price;

                // add quote to file
                AddQuoteToFile(deskQuote);

                // show 'DisplayQuote' form
                DisplayQuote frmDisplayQuote = new DisplayQuote(_mainMenu, deskQuote);
                frmDisplayQuote.Show();
                Hide();
            }
            catch (Exception err)
            {
                MessageBox.Show("There was an error creating the quote. {0}", err.InnerException.ToString());
            }
        }
示例#23
0
 public decimal CalcCost(ref DeskQuote dq)
 {
     try
     {
         //Tabulate quote Cost
         decimal tempCost = baseCost;
         //Add surface area Cost if > surface area threshold (i.e. 1,000)
         decimal surfaceArea = dq.Desk.Width * dq.Desk.Depth;
         if (surfaceArea > surfaceCostThreshold)
         {
             tempCost += surfaceArea * surfaceCost;
         }
         //Add drawer Cost
         tempCost += dq.Desk.Drawers * drawerCost;
         //Add surface material Cost
         //tempCost += dq.Desk.surfaceMaterial.Cost;
         //Add rush shipping costs based on tier and values in RushType dataset
         //TODO: Fix rush type addition
         //if (surfaceArea < tier1Max)
         //{
         //    tempCost += dq.rushType.Tier1Cost;
         //}
         //else if (surfaceArea < tier2Max)
         //{
         //    tempCost += dq.rushType.Tier2Cost;
         //}
         //else
         //{
         //    tempCost += dq.rushType.Tier3Cost;
         //}
         return(tempCost);
     }
     catch (Exception ex)
     {
         System.Console.WriteLine("Error in updating price, check to ensure all required fields are populated: " + ex.Message);
         return(0);
     }
 }
示例#24
0
        private void btnAddQuote_Click(object sender, EventArgs e)
        {
            // create desk class
            Desk desk = new Desk();

            desk.Width           = (int)this.widthUpDown.Value;
            desk.Depth           = (int)this.depthUpDown.Value;
            desk.NumberOfDrawers = (int)this.drawersUpDown.Value;
            desk.SurfaceMaterial = (DesktopMaterial)this.cmbSurfaceMaterial.SelectedItem;

            // create desk quote class
            DeskQuote deskQuote = new DeskQuote();

            deskQuote.CustomerName = this.txtboxName.Text;
            deskQuote.Desk         = desk;
            deskQuote.QuoteDate    = DateTime.Now;
            deskQuote.Delievery    = (Delivery)this.cmbDelivery.SelectedItem;
            deskQuote.QuotePrice   = deskQuote.GetQuotePrice();

            try
            {
                // add quote to file
                addQuoteToFile(deskQuote);
                //addQuoteToFile(deskQuote);
            }
            catch (Exception err)
            {
                MessageBox.Show("There is an error when you create a quote. {0}",
                                err.InnerException.ToString());
            }

            var displayQuote = new DisplayQuotes();

            displayQuote.Tag = this;
            displayQuote.Show();
            //displayQuote.DisplayQuote(deskQuote);
            this.Hide();
        }
        private void GetQuoteButton_Click(object sender, EventArgs e)
        {
            Desk desk = new Desk
            {
                Width           = (int)widthNumericUpDown.Value,
                Depth           = (int)depthNumericUpDown.Value,
                NumberOfDrawers = (int)numberOfDrawersNumericUpDown.Value,
                SurfaceMaterial = (Desk.DesktopSurfaceMaterial)surfaceMaterialSelectionComboBox.SelectedItem
            };

            DeskQuote deskQuote = new DeskQuote
            {
                Desk          = desk,
                CustomerName  = customerNameTextBox.Text,
                ShippingSpeed = GetRushShippingChoice(),
                QuoteDate     = DateTime.Now
            };

            totalPriceAmountLabel.Text = $@"${deskQuote.CalculateQuote()}";
            shippingPriceLabel.Text    = $@"${deskQuote.GetShippingPrice()}";

            DisplayQuote();
        }
示例#26
0
        private void parsefields(DeskQuote DeskQuoteParse)
        {
            dateDisplay.Text = (DeskQuoteParse.date).ToString("dddd, dd MMMM yyyy");
            quoteInput.Text  = DeskQuoteParse.id.ToString();

            depthInput.Text = (DeskQuoteParse.depth).ToString("C2");
            widthInput.Text = (DeskQuoteParse.width).ToString("C2");

            drawerCost.Text   = (DeskQuoteParse.drawerCost).ToString("C2");
            drawerInput.Value = DeskQuoteParse.drawers;

            materialInput.Text = DeskQuoteParse.material;
            materialCost.Text  = (DeskQuoteParse.materialCost).ToString("C2");

            nameInput.Text  = DeskQuoteParse.customerName;
            areaCost.Text   = (DeskQuoteParse.areaCost).ToString("C2");
            areaOutput.Text = "Area: " + (DeskQuoteParse.area).ToString() + " in\xB2";

            shippingCost.Text  = (DeskQuoteParse.shippingCost).ToString("C2");
            shippingInput.Text = DeskQuoteParse.rush;

            quoteTotal.Text = (DeskQuoteParse.quote).ToString("C2");
        }
示例#27
0
        private void AddQuoteToFile(DeskQuote deskQuote)
        {
            var quotesFile = @"quotes.json";
            List <DeskQuote> deskQuotes = new List <DeskQuote>();

            // read existing quotes
            if (File.Exists(quotesFile))
            {
                using (StreamReader reader = new StreamReader(quotesFile))
                {
                    // load existing quotes
                    string quotes = reader.ReadToEnd();

                    if (quotes.Length > 0)
                    {
                        // deserialize quotes
                        deskQuotes = JsonConvert.DeserializeObject <List <DeskQuote> >(quotes);
                    }

                    // add a new quote
                    deskQuotes.Add(deskQuote);
                }

                // save to file
                SaveQuotes(deskQuotes);
            }
            else
            {
                // create quote list
                deskQuotes = new List <DeskQuote> {
                    deskQuote
                };

                // save to file
                SaveQuotes(deskQuotes);
            }
        }
示例#28
0
        private void DisplayQuote_Load(object sender, EventArgs e)
        {
            customerQuote = Program.Quotes.GetLatest();

            /* string[] prices = File.ReadAllLines(@"RushOrderPrices.txt");
             * testRushOrder.Text = "";
             * foreach (string rushprice in prices)
             * {
             *
             *   // Use a tab to indent each line of the file.
             *   testRushOrder.Text += "\t" + rushprice + " ";
             * }*/
            try
            {
                int Area  = customerQuote.GetWidth() * customerQuote.GetDepth();
                int rDays = customerQuote.GetRushDays();
                OrderDateLabel.Text         = customerQuote.GetDate();
                ResultsCustomerName.Text    = customerQuote.GetName();
                ResultsRushDays.Text        = customerQuote.GetRushDays().ToString();
                ResultsWidth.Text           = customerQuote.GetWidth().ToString();
                ResultsDepth.Text           = customerQuote.GetDepth().ToString();
                ResultsTotalPrice.Text      = customerQuote.GetPrice().ToString();
                ResultsNumDrawers.Text      = customerQuote.GetNumDrawers().ToString();
                ResultsSurfaceMaterial.Text = customerQuote.GetMaterial().ToString();
                ResultRushOrder.Text        = customerQuote.GetRushOrder(rDays, Area).ToString();
            }
            catch
            {
                ResultsCustomerName.Text    = "";
                ResultsRushDays.Text        = "";
                ResultsWidth.Text           = "";
                ResultsDepth.Text           = "";
                ResultsNumDrawers.Text      = "";
                ResultsSurfaceMaterial.Text = "";
                ResultsTotalPrice.Text      = "Problem calculating total price.";
            }
        }
示例#29
0
        private void BtnSaveQuote_Click(object sender, EventArgs e)
        {
            Desk userDesk = new Desk();

            userDesk.Width           = (int)(NumDeskWidth.Value);
            userDesk.Depth           = (int)(NumDeskDepth.Value);
            userDesk.NumberOfDrawers = (int)(NumNumberOfDrawers.Value);
            userDesk.DesktopMaterial = (DesktopMaterial)ComDesktopMaterial.SelectedItem;
            DeskQuote userQuote = new DeskQuote();

            userQuote.CustomerName   = TxtCustomerName.Text;
            userQuote.DaysToComplete = (DaysToComplete)(ComDaysToComplete.SelectedValue);
            // OutputBox.Text = userQuote.DaysToComplete.ToString();
            userQuote.Desk = userDesk;
            userQuote.getRushOrderPrices();
            userQuote.CalculateQuotePrice();

            var quotesFile = @"quotes.json";
            var finalJson  = " ";

            using (StreamReader reader = new StreamReader(quotesFile))
            {
                string quotes = reader.ReadToEnd();
                var    list   = (JsonConvert.DeserializeObject <List <DeskQuote> >(quotes));
                list.Add(userQuote);
                finalJson = JsonConvert.SerializeObject(list, Formatting.Indented);
            }

            using (StreamWriter writer = new StreamWriter(quotesFile))
            {
                writer.Write(finalJson);
            }

            this.Hide();
            this.mainMenu.Show();
        }
示例#30
0
        private void SaveQuoteButton_Click(object sender, EventArgs e)
        {
            List <DeskQuote> quotes = _quoteFileManager.GetSavedQuotes();

            if (string.IsNullOrWhiteSpace(fullNameInput.Text))
            {
                nameRequiredErrorMessage.Text = Resources.Required;
                return;
            }

            Desk desk = new Desk()
            {
                depth           = (int)depthUpDown.Value,
                width           = (int)widthUpDown.Value,
                numberOfDrawers = (int)numberOfDrawersUpDown.Value,
                SurfaceMaterial = (DesktopMaterial)materialSelect.SelectedItem
            };

            DeskQuote quote = new DeskQuote()
            {
                CustomerName  = fullNameInput.Text,
                Desk          = desk,
                RushOrderType = (RushOrderType)rushOrderSelect.SelectedValue,
                Date          = DateTime.Now
            };

            quote.QuotePrice = quote.GetQuote();

            quotes.Add(quote);

            _quoteFileManager.SaveQuotes(quotes);

            DisplayQuote displayQuote = new DisplayQuote(quote);

            displayQuote.ShowDialog();
        }