예제 #1
0
        private void btn_Delete_Click(object sender, EventArgs e)
        {
            BodyDesign bodyDesign = FormToBodyDesign();

            CarDesignArr carDesignArr = new CarDesignArr();

            carDesignArr.Fill();

            if (bodyDesign.Id == 0)
            {
            }
            else
            {
                if (carDesignArr.DoesExist(bodyDesign))
                {
                    MessageBox.Show("You can not delete this Body Design, it is connected" +
                                    " to 1 or more Orders", "Can not delete Car color",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    if (MessageBox.Show("Are you sure you want to delete this" +
                                        " Body Design? ", "Warning", MessageBoxButtons.YesNo,
                                        MessageBoxIcon.Warning) == DialogResult.Yes)
                    {
                        bodyDesign.Delete();
                        ClearForm();
                        BodyDesignArrToForm(null);
                    }
                }
            }
        }
예제 #2
0
        public CarDesignArr GetDesigns()
        {
            CarColor   carColor   = null;
            ColorType  colorTypes = null;
            BodyDesign bodyDesign = null;

            CarDesignArr carDesignArr = new CarDesignArr();

            carDesignArr.Fill();

            if (cmb_Color.SelectedIndex != -1)
            {
                carColor = cmb_Color.SelectedItem as CarColor;
            }
            if (cmb_ColorType.SelectedIndex != -1)
            {
                colorTypes = cmb_ColorType.SelectedItem as ColorType;
            }
            if (cmb_Body.SelectedIndex != -1)
            {
                bodyDesign = cmb_Body.SelectedItem as BodyDesign;
            }

            return(carDesignArr.Filter(carColor, colorTypes, bodyDesign));
        }
예제 #3
0
        private void btn_Delete_Click(object sender, EventArgs e)
        {
            ColorType colorType = FormToColorTypes();

            CarDesignArr carDesignArr = new CarDesignArr();

            carDesignArr.Fill();

            if (colorType.Id == 0)
            {
            }
            else
            {
                if (carDesignArr.DoesExist(colorType))
                {
                    MessageBox.Show("You can not delete this Car color, it is connected" +
                                    " to 1 or more Orders", "Can not delete Color Type",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    if (MessageBox.Show("Are you sure you want to delete this" +
                                        " Color Type? ", "Warning", MessageBoxButtons.YesNo,
                                        MessageBoxIcon.Warning) == DialogResult.Yes)
                    {
                        colorType.Delete();
                        ClearForm();
                        ColorTypesArrToForm(null);
                    }
                }
            }
        }
예제 #4
0
        private void CarDesignArrToForm(CarDesign curCarDesign)
        {
            CarDesignArr carDesignArr = new CarDesignArr();

            carDesignArr.Fill();

            listbox_Designs.ValueMember   = "ID";
            listbox_Designs.DisplayMember = "FullDesign";
            listbox_Designs.DataSource    = carDesignArr;

            if (curCarDesign != null)
            {
                listbox_Designs.SelectedValue = curCarDesign.Id;
            }
        }
예제 #5
0
        private void btn_Save_Click(object sender, EventArgs e)
        {
            if (CheckForm())
            {
                CarDesign carDesign = new CarDesign();
                carDesign = FormToCarDesign();

                CarDesignArr oldCarDesignArr = new CarDesignArr();
                oldCarDesignArr.Fill();

                if (!oldCarDesignArr.IsContain(carDesign.ToString()))
                {
                    if (carDesign.Id == 0)
                    {
                        if (carDesign.Insert())
                        {
                            MessageBox.Show("Data saved successfully", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            ClearForm();

                            CarDesignArr carDesignArr = new CarDesignArr();
                            carDesignArr.Fill();
                            carDesign = carDesignArr.GetCarDesignWithMaxId();

                            CarDesignArrToForm(carDesign);
                        }
                    }
                    else
                    {
                        if (carDesign.Update())
                        {
                            MessageBox.Show("Data updated successfully", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            ClearForm();

                            CarDesignArr carDesignArr = new CarDesignArr();
                            carDesignArr.Fill();
                            carDesign = carDesignArr.GetCarDesignWithMaxId();
                            CarDesignArrToForm(null);
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Car Design already exsits", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    ClearForm();
                }
            }
        }
예제 #6
0
        public void DesignToChart(DateTime dt)
        {
            RadioButton(true);


            chart1.Palette = ChartColorPalette.SeaGreen;
            chart1.ChartAreas[0].AxisX.LabelStyle.Interval = 1;

            chart1.Titles.Clear();
            chart1.Titles.Add("Distribution");

            SortedDictionary <string, int> dictionary = new SortedDictionary <string, int>();
            OrderBuyArr orderArr = new OrderBuyArr();

            orderArr.Fill();

            CarDesignArr carDesignArr = orderArr.GetCarDesignArr();

            foreach (CarDesign car in carDesignArr)
            {
                Count = orderArr.Filter(car, dt).Count;
                if (Count > 0)
                {
                    dictionary.Add(car.FullDesign, Count);
                }
            }

            Series series = new Series("Products", carDesignArr.Count);

            series.ChartType = SeriesChartType.Column;

            series.Label = "[#PERCENT{P0}]";
            series.Points.DataBindXY(dictionary.Keys, dictionary.Values);

            chart1.Series.Clear();
            chart1.Series.Add(series);
        }