コード例 #1
0
ファイル: SearchQuotes.cs プロジェクト: Stavista/CIT365
        private void search_material_SelectionChangeCommitted(object sender, EventArgs e)
        {
            Desk.Material material = (Desk.Material)search_material.SelectedItem;

            DataTable grid = new DataTable();

            grid.Columns.Add("Shipping");
            grid.Columns.Add("Name");
            grid.Columns.Add("Date");
            grid.Columns.Add("Width");
            grid.Columns.Add("Depth");
            grid.Columns.Add("Drawers");
            grid.Columns.Add("Material");
            grid.Columns.Add("Price");

            StreamReader file = new StreamReader(@"../QuoteHistory.txt");

            while (!file.EndOfStream)
            {
                string[] col = file.ReadLine().Split(',');
                if (col[6] == material.ToString())
                {
                    grid.Rows.Add(col[0], col[1], col[2], col[3], col[4], col[5], col[6], col[7]);
                }
            }

            dataGridView1.DataSource = grid;
            file.Close();
        }
コード例 #2
0
        public double makeDesk(string first, string last, int width, int depth,
                               int nDrawers, char days, Desk.Material mat, int numDesks)
        {
            // Make our desk
            DeskStruct = new Desk(first, last, width, depth, nDrawers, days, mat);

            // Give back the price
            return(calcPrice(numDesks));
        }
コード例 #3
0
ファイル: AddQuote.cs プロジェクト: Lava84flow/MegaDesk
        private void buttonSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                CustomerName = boxName.Text;
                DeskWidth    = int.Parse(boxWidth.Text);
                DeskDepth    = int.Parse(boxDepth.Text);
                Drawers      = int.Parse(comboBoxDrawers.SelectedItem.ToString());
                Material     = (Desk.Material)comboBoxMaterial.SelectedValue;

                // Get rush order days base on radio box selections
                if (radioRushNone.Checked)
                {
                    RushDays = 0;
                }
                if (radioRush3.Checked)
                {
                    RushDays = 3;
                }
                if (radioRush5.Checked)
                {
                    RushDays = 5;
                }
                if (radioRush7.Checked)
                {
                    RushDays = 7;
                }

                // create new deskOrder and calcQuote
                DeskQuote NewQuote = new DeskQuote(CustomerName, DateTime.Now, DeskWidth, DeskDepth, Drawers, Material, RushDays);
                QuoteTotal = NewQuote.CalcQuote();

                //build string to quote save to file
                //var DeskFileWrite = CustomerName + "," + DateTime.Now + "," + DeskWidth + "," + DeskDepth + "," + Drawers + "," + Material + "," + RushDays + "," + QuoteTotal;
                //var DeskFileWrite = NewQuote;

                // ask how to do this without making all of the properties public because I know they are in and can be used
                // I just have no idea how to get the Serializer to get them when they are "private".
                string jsonWrite = JsonConvert.SerializeObject(NewQuote);
                string jsonFile  = @"quotes.json";

                if (!File.Exists(jsonFile))
                {
                    using (StreamWriter sw = File.CreateText(jsonFile)) { }
                }
                using (StreamWriter swa = File.AppendText(jsonFile)) { swa.WriteLine(jsonWrite); }

                MessageBox.Show("Quote Submitted");
                confirmQuotePanel.Visible = false;
            }
            catch (Exception)
            {
                throw;
            }
        }
コード例 #4
0
        private void submitButton_Click(object sender, EventArgs e)
        {
            try
            {
                customerName = boxName.Text;
                width        = int.Parse(boxWidth.Text);
                depth        = int.Parse(boxDepth.Text);
                drawers      = int.Parse(boxDrawer.Text);
                Material     = (Desk.Material)boxMaterial.SelectedValue;

                // Get rush order days base on radio box selections
                if (radioNone.Checked)
                {
                    rushDays = 0;
                }
                if (radio3.Checked)
                {
                    rushDays = 3;
                }
                if (radio5.Checked)
                {
                    rushDays = 5;
                }
                if (radio7.Checked)
                {
                    rushDays = 7;
                }

                // create new deskOrder and calcQuote
                DeskQuote NewQuote = new DeskQuote(customerName, DateTime.Now, width, depth, drawers, Material, rushDays);
                QuoteTotal = NewQuote.CalcQuote();

                //build string to quote save to file
                string DeskFileWrite = customerName + "," + DateTime.Now + "," + width + "," + depth + "," + drawers + "," + Material + "," + rushDays + "," + QuoteTotal;

                // ask how to do this without making all of the properties public because I know they are in and can be used
                // I just have no idea how to get the Serializer to get them when they are "private".
                string jsonWrite = JsonConvert.SerializeObject(NewQuote);

                if (!File.Exists(QUOTEFILE))
                {
                    using (StreamWriter sw = File.CreateText(QUOTEFILE)) { }
                }
                else
                {
                    using (StreamWriter swa = File.AppendText(QUOTEFILE)) { swa.WriteLine(DeskFileWrite); }

                    MessageBox.Show("Quote Submitted");
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
コード例 #5
0
 /// <summary>
 /// Construct a desk with the given parameters
 /// </summary>
 /// <param name="width"></param>
 /// <param name="depth"></param>
 /// <param name="nDrawers"></param>
 /// <param name="days"></param>
 /// <param name="mat"></param>
 public Desk(string fir, string las, int width, int depth,
             int nDrawers, int days, Desk.Material mat)
 {
     this.first           = fir;
     this.last            = las;
     this.Width           = width;
     this.Depth           = depth;
     this.NumDrawers      = nDrawers;
     this.RushDays        = days;
     this.SurfaceMaterial = mat;
 }
コード例 #6
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                name         = customerName.Text;
                deskWidth    = int.Parse(width.Text);
                deskDepth    = int.Parse(depth.Text);
                totalDrawers = int.Parse(drawers.Text);
                Materials    = (Desk.Material)Material.SelectedValue;

                // Get rush order days base on radio box selections
                if (radioNone.Checked)
                {
                    rushDays = 0;
                }
                if (radio3.Checked)
                {
                    rushDays = 3;
                }
                if (radio5.Checked)
                {
                    rushDays = 5;
                }
                if (radio7.Checked)
                {
                    rushDays = 7;
                }

                // create new deskOrder and calcQuote
                DeskQuote NewQuote = new DeskQuote(name, DateTime.Now, deskWidth, deskDepth, totalDrawers, Materials, rushDays);
                QuoteTotal = NewQuote.CalcQuote();

                //build string to quote save to file
                string DeskFileWrite = customerName + "," + DateTime.Now + "," + width + "," + depth + "," + drawers + "," + Material + "," + rushDays + "," + QuoteTotal;

                if (!File.Exists(QUOTEFILE))
                {
                    using (StreamWriter writer = File.CreateText(QUOTEFILE)) { writer.WriteLine(DeskFileWrite); }
                }
                else
                {
                    using (StreamWriter writer = File.AppendText(QUOTEFILE)) { writer.WriteLine(DeskFileWrite); }

                    MessageBox.Show("Quote Submitted");
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Saving Quote Failed");
            }
        }
コード例 #7
0
        public void getQuote_Click(object sender, EventArgs e)
        {
            Desk.Material selectedSurface = (Desk.Material)surface_comboBox.SelectedItem;

            //var selectedSurface = surface_comboBox.ValueMember;
            Desk newDesk = new Desk((int)numericUpDown_Width.Value, (int)numericUpDown_Depth.Value, (int)numericUpDown_Drawers.Value, selectedSurface);

            int       rush  = getSelectedRush();
            DeskQuote quote = new DeskQuote(rush, userName.Text, newDesk);
            double    price = quote.calculateQuotePrice();

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

            file.WriteLine(quote.rush + "," + quote.UserName + "," + quote.date + "," + newDesk.width + "," + newDesk.depth + "," + newDesk.drawers + "," + newDesk.surfaceMaterial + "," + price);
            file.Close();

            DisplayQuote displayQuoteForm = new DisplayQuote(quote);

            displayQuoteForm.Tag = this;
            displayQuoteForm.Show(this);
            Hide();
        }
コード例 #8
0
        private void showQuotes(Desk.Material material)
        {
            string csvFile = "quotes.txt";

            try
            {
                string[] quotes = File.ReadAllLines(csvFile);

                foreach (string quote in quotes)
                {
                    string[] row = quote.Split(',');

                    if (row[4].Equals(material.ToString()))
                    {
                        dataGridView1.Rows.Add(row);
                    }
                }
            }
            catch (FileNotFoundException e)
            {
            }
        }
コード例 #9
0
ファイル: DeskQuote.cs プロジェクト: lwestern2/megadesk1.1
        public DeskQuote(string customerName, DateTime quoteDate, int width, int depth, int drawers, Desk.Material material, int rushDay)
        {
            customerName         = customerName;
            quoteDate            = quoteDate;
            Desk.width           = width;
            Desk.depth           = depth;
            Desk.numberOfDrawers = drawers;
            Desk.deskMaterial    = material;
            rushDays             = rushDays;

            //calc area and store
            Desk.area = Desk.width * Desk.depth;
        }
コード例 #10
0
        //private int calcMaterial(material)
        //{
        //    var material = material;

        //    switch (material)
        //    {
        //        case Desk.Material.Oak:
        //            materialCost = 200;
        //            break;
        //        case Desk.Material.Laminate:
        //            materialCost = 100;
        //            break;
        //        case Desk.Material.Pine:
        //            materialCost = 50;
        //            break;
        //        case Desk.Material.Rosewood:
        //            materialCost = 300;
        //            break;
        //        case Desk.Material.Veneer:
        //            materialCost = 125;
        //            break;
        //    }
        //    return materialCost;
        //}

        public DeskQuote(string customterName, DateTime quoteDate, int width, int depth, int drawers, Desk.Material material, int rushDays)
        {
            CustomerName      = customterName;
            QuoteDate         = quoteDate;
            Desk.Width        = width;
            Desk.Depth        = depth;
            Desk.Drawers      = drawers;
            Desk.DeskMaterial = material;
            RushDays          = rushDays;

            //calcarea and store
            Desk.Area = Desk.Width * Desk.Depth;
        }