コード例 #1
0
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            var desk      = new Desk();
            var deskQuote = new DeskQuote();

            try
            {
                desk.Width      = width.Value;
                desk.Depth      = width.Value;
                desk.NumDrawers = int.Parse(numDrawers.SelectedItem.ToString());
                desk.Material   = (Desk.DesktopMaterial)comDesktopMaterials.SelectedValue;

                deskQuote.Desk            = desk;
                deskQuote.CustomerName    = txtCustomerName.Text;
                deskQuote.NumShippingDays = int.Parse(comShipping.SelectedItem.ToString());
                deskQuote.QuoteDate       = DateTime.Now;
                deskQuote.ShippingCost    = deskQuote.GetShippingCost();
                deskQuote.StructureCost   = deskQuote.GetStructureCost();
                deskQuote.SurfaceCost     = deskQuote.GetSurfaceCost();
                deskQuote.Quote           = deskQuote.GetQuote();
            }
            catch (Exception ex)
            {
            }
            lblStructureCost.Text = deskQuote.GetStructureCost().ToString();
            lblSurfaceCost.Text   = deskQuote.GetSurfaceCost().ToString();
            lblShippingCost.Text  = deskQuote.GetShippingCost().ToString();
            lblTotalCost.Text     = deskQuote.GetQuote().ToString();

            AddQuotetoFile(deskQuote);
            var mainMenu = (MainMenu)Tag;

            mainMenu.Show();
        }
コード例 #2
0
ファイル: AddQuote.cs プロジェクト: BryanLCrowder/MegaDesk
        //Get Quote Button
        private void GetQuote_Click(object sender, EventArgs e)
        {
            var desk      = new Desk();
            var deskQuote = new DeskQuote();

            try
            {
                desk.WidthUpDown  = WidthUpDown.Value;
                desk.HeightUpDown = HeightUpDown.Value;
                desk.NumDrawers   = int.Parse(numericUpDownDrawers.Value.ToString());

                desk.Material = (Desk.DeskMaterial)materialBox.SelectedValue;

                deskQuote.Desk          = desk;
                deskQuote.CustomerName  = customerName.Text;
                deskQuote.ShippingDays  = int.Parse(deliveryBox.SelectedItem.ToString());
                deskQuote.QuoteDate     = DateTime.Now;
                deskQuote.ShippingCost  = deskQuote.GetShippingCost();
                deskQuote.StructureCost = deskQuote.GetStructureCost();
                deskQuote.SurfaceCost   = deskQuote.GetSurfaceCost();
                deskQuote.Quote         = deskQuote.GetQuote();

                System.Diagnostics.Debug.WriteLine(desk.NumDrawers);
                System.Diagnostics.Debug.WriteLine(deskQuote.StructureCost);
                System.Diagnostics.Debug.WriteLine(deskQuote.ShippingCost);
                System.Diagnostics.Debug.WriteLine(deskQuote.SurfaceCost);
            }
            catch (Exception ex)
            {
            }
            structCostlbl.Text   = deskQuote.GetStructureCost().ToString();
            surfaceCostlbl.Text  = deskQuote.GetSurfaceCost().ToString();
            shippingCostlbl.Text = deskQuote.GetShippingCost().ToString();
            finalCostlbl.Text    = deskQuote.GetQuote().ToString();



            List <DeskQuote> deskQuotes = new List <DeskQuote>();

            if (!File.Exists(@"quotes.json"))
            {
                deskQuotes.Add(deskQuote);
                var list = JsonConvert.SerializeObject(deskQuotes);
                File.WriteAllText(@"quotes.json", JsonConvert.SerializeObject(deskQuotes));
            }
            else
            {
                using (StreamReader reader = new StreamReader(@"quotes.json"))
                {
                    string allQuotes = reader.ReadToEnd();
                    deskQuotes = JsonConvert.DeserializeObject <List <DeskQuote> >(allQuotes);
                }
                deskQuotes.Add(deskQuote);
                var list = JsonConvert.SerializeObject(deskQuotes);
                File.WriteAllText(@"quotes.json", list);
            }
        }
コード例 #3
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();
        }
コード例 #4
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();
        }
コード例 #5
0
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            var desk      = new Desk();
            var deskQuote = new DeskQuote();

            try
            {
                desk.Width      = width.Value;
                desk.Depth      = width.Value;
                desk.NumDrawers = int.Parse(numDrawers.SelectedItem.ToString());

                desk.Material = (Desk.DesktopMaterial)comDesktopMaterials.SelectedValue;

                deskQuote.Desk            = desk;
                deskQuote.CustomerName    = txtCustomerName.Text;
                deskQuote.NumShippingDays = int.Parse(comShipping.SelectedItem.ToString());
                deskQuote.QuoteDate       = DateTime.Now;
                deskQuote.ShippingCost    = deskQuote.GetShippingCost();
                deskQuote.StructureCost   = deskQuote.GetStructureCost();
                deskQuote.SurfaceCost     = deskQuote.GetSurfaceCost();
                deskQuote.Quote           = deskQuote.GetQuote();

                System.Diagnostics.Debug.WriteLine(desk.NumDrawers);
                System.Diagnostics.Debug.WriteLine(deskQuote.StructureCost);
                System.Diagnostics.Debug.WriteLine(deskQuote.ShippingCost);
                System.Diagnostics.Debug.WriteLine(deskQuote.SurfaceCost);
            }
            catch (Exception ex)
            {
            }
            lblStructureCost.Text = deskQuote.GetStructureCost().ToString();
            lblSurfaceCost.Text   = deskQuote.GetSurfaceCost().ToString();
            lblShippingCost.Text  = deskQuote.GetShippingCost().ToString();
            lblTotalCost.Text     = deskQuote.GetQuote().ToString();



            List <DeskQuote> deskQuotes = new List <DeskQuote>();

            if (!File.Exists(@"quotes.json"))
            {
                deskQuotes.Add(deskQuote);
                var list = JsonConvert.SerializeObject(deskQuotes);
                File.WriteAllText(@"quotes.json", JsonConvert.SerializeObject(deskQuotes));
            }
            else
            {
                using (StreamReader reader = new StreamReader(@"quotes.json"))
                {
                    string allQuotes = reader.ReadToEnd();
                    deskQuotes = JsonConvert.DeserializeObject <List <DeskQuote> >(allQuotes);
                }
                deskQuotes.Add(deskQuote);
                var list = JsonConvert.SerializeObject(deskQuotes);
                File.WriteAllText(@"quotes.json", list);
            }

            var mainMenu = (MainMenu)Tag;

            mainMenu.Show();
            Close();
        }