예제 #1
0
        private void listbox_Orders_DoubleClick(object sender, EventArgs e)
        {
            OrderBuy orderBuy = listbox_Orders.SelectedItem as OrderBuy;

            OrderBuyToForm(orderBuy);
            ClientToForm(orderBuy.Client);
            ProductToForm(orderBuy.Product);
            DesignToForm(orderBuy.CarDesign);

            listbox_Clients.SelectedValue = orderBuy.Client.Id;
            listbox_Cars.SelectedValue    = orderBuy.Product.Id;
            listbox_Designs.SelectedValue = orderBuy.CarDesign.Id;

            CarExtraArr carExtraArrInOrder = new CarExtraArr();

            OrderDetailsBuyArr orderDetailsBuyArr = new OrderDetailsBuyArr();

            orderDetailsBuyArr.Fill();

            orderDetailsBuyArr = orderDetailsBuyArr.Filter(orderBuy);

            carExtraArrInOrder = orderDetailsBuyArr.GetCarExtraArr();
            CarExtraArrToForm(carExtraArrInOrder, listbox_InOrder);

            CarExtraArr carExtraArrNotInOrder = new CarExtraArr();

            carExtraArrNotInOrder.Fill();

            carExtraArrNotInOrder.Remove(carExtraArrInOrder);
            CarExtraArrToForm(carExtraArrNotInOrder, listbox_Potential);
        }
예제 #2
0
        public CarExtraArr GetCarExtraBuy(PayBuy payBuy)
        {
            OrderBuy           order = payBuy.Order;
            OrderDetailsBuyArr orderDetailsBuyArr = new OrderDetailsBuyArr();

            orderDetailsBuyArr.Fill();
            orderDetailsBuyArr = orderDetailsBuyArr.Filter(order);

            return(orderDetailsBuyArr.GetCarExtraArr());
        }
예제 #3
0
        public void CarExtraBuyToChart(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>();
            OrderDetailsBuyArr             detailsBuy = new OrderDetailsBuyArr();

            detailsBuy.Fill();

            CarExtraArr carExtraArr = detailsBuy.GetCarExtraArr();

            foreach (CarExtra extra in carExtraArr)
            {
                Count = detailsBuy.Filter(extra, dt).Count;
                if (Count > 0)
                {
                    dictionary.Add(extra.Name, Count);
                }
            }


            Series series = new Series("Car Extra", carExtraArr.Count);

            series.ChartType = SeriesChartType.Column;

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

            chart1.Series.Clear();
            chart1.Series.Add(series);
        }
예제 #4
0
        private void btn_Delete_Click(object sender, EventArgs e)
        {
            CarExtra carExtra = FormToCarExtra();

            OrderDetailsBuyArr orderDetailsBuyArr = new OrderDetailsBuyArr();

            orderDetailsBuyArr.Fill();

            OrderDetailsRentArr orderDetailsRentArr = new OrderDetailsRentArr();

            orderDetailsRentArr.Fill();

            if (carExtra.Id == 0)
            {
            }
            else
            {
                if (orderDetailsBuyArr.DoesExist(carExtra) || orderDetailsRentArr.DoesExist(carExtra))
                {
                    MessageBox.Show("You can not delete this Car Extra, it is connected" +
                                    " to 1 or more Orders", "Can not delete Car Extra",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    if (MessageBox.Show("Are you sure you want to delete this" +
                                        " CarExtra? ", "Warning", MessageBoxButtons.YesNo,
                                        MessageBoxIcon.Warning) == DialogResult.Yes)
                    {
                        carExtra.Delete();
                        ClearForm();
                        CarExtraArrToForm(null);
                    }
                }
            }
        }
예제 #5
0
        private void btn_Save_Click(object sender, EventArgs e)
        {
            if (CheckForm())
            {
                OrderBuy           orderBuy = FormToOrderBuy();
                OrderDetailsBuyArr orderDetailsBuyArr_New;
                OrderDetailsBuyArr orderDetailsBuyArr_Old = new OrderDetailsBuyArr();

                OrderBuyArr orderBuyArr_New = new OrderBuyArr();
                orderBuyArr_New.Fill();


                if (orderBuy.Id == 0)
                {
                    if (!orderBuyArr_New.DoesExist(orderBuy.Product))
                    {
                        if (orderBuy.Insert() && orderBuy.Product.Update())
                        {
                            OrderBuyArr orderBuyArr = new OrderBuyArr();
                            orderBuyArr.Fill();
                            orderBuy = orderBuyArr.GetOrderBuyWithMaxId();

                            orderDetailsBuyArr_New = FormToOrderDetailsBuyArr(orderBuy);
                            orderDetailsBuyArr_New.Insert();


                            CarExtraArr carExtraArrInOrder = orderDetailsBuyArr_New.GetCarExtraArr();
                            carExtraArrInOrder.Update();



                            foreach (TabPage tp in this.tbc_Order.Controls)
                            {
                                ClearForm(tp);
                            }
                            LoadNew();

                            Form_Pay newform = new Form_Pay(orderBuy);
                            newform.ShowDialog();
                        }
                    }
                    else
                    {
                        MessageBox.Show("This car already sold", "Information", MessageBoxButtons.OK,
                                        MessageBoxIcon.Information);
                    }
                }
                else
                {
                    if (orderBuy.Update() && orderBuy.Product.Update())
                    {
                        orderDetailsBuyArr_New = FormToOrderDetailsBuyArr(orderBuy);
                        orderDetailsBuyArr_Old.Fill();
                        orderDetailsBuyArr_Old = orderDetailsBuyArr_Old.Filter(orderBuy);

                        orderDetailsBuyArr_Old.Delete();
                        orderDetailsBuyArr_New.Insert();

                        (listbox_InOrder.DataSource as CarExtraArr).Update();
                        (listbox_Potential.DataSource as CarExtraArr).Update();

                        MessageBox.Show("Your Cerdit Card will be charged accordingly", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        foreach (TabPage tp in this.tbc_Order.Controls)
                        {
                            ClearForm(tp);
                        }
                        LoadNew();
                    }
                }
            }
        }