Пример #1
0
        private void btn_Delete_Click(object sender, EventArgs e)
        {
            CarDesign carDesign = FormToCarDesign();

            OrderBuyArr orderBuyArr = new OrderBuyArr();

            orderBuyArr.Fill();


            if (carDesign.Id == 0)
            {
            }
            else
            {
                if (orderBuyArr.DoesExist(carDesign))
                {
                    MessageBox.Show("You can not delete this  Car Design, it is connected" +
                                    " to 1 or more Orders", "Can not delete Car Design",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    if (MessageBox.Show("Are you sure you want to delete this" +
                                        " Car Design? ", "Warning", MessageBoxButtons.YesNo,
                                        MessageBoxIcon.Warning) == DialogResult.Yes)
                    {
                        carDesign.Delete();
                        ClearForm();
                        CarDesignArrToForm(null);
                    }
                }
            }
        }
Пример #2
0
        public double GetBonus(DateTime dateTime, Employee employee)
        {
            double      Bonus       = 0;
            OrderBuyArr orderBuyArr = new OrderBuyArr();

            orderBuyArr.Fill();

            OrderRentArr orderRentArr = new OrderRentArr();

            orderRentArr.Fill();

            orderBuyArr  = orderBuyArr.Filter(employee, dateTime);
            orderRentArr = orderRentArr.Filter(employee, dateTime);

            for (int i = 0; i < orderBuyArr.Count; i++)
            {
                Bonus += (orderBuyArr[i] as OrderBuy).TotalPrice * 0.01;
            }
            for (int i = 0; i < orderRentArr.Count; i++)
            {
                Bonus += (orderRentArr[i] as OrderRent).TotalPrice * 0.01;
            }


            return(Bonus);
        }
Пример #3
0
        public OrderBuyArr GetOrderBuy()
        {
            int Id = 0;

            if (txt_Id.Text != "")
            {
                Id = int.Parse(txt_Id.Text);
            }
            //אם המשתמש רשם ערך בשדה המזהה
            DateTime Form, To;

            Form = dtp_Form.Value;
            To   = dtp_To.Value;

            //מייצרים אוסף של כלל הלקוחות
            OrderBuyArr orderBuy = new OrderBuyArr();

            orderBuy.Fill();

            //מסננים את אוסף  לפי שדות הסינון שרשם המשתמש
            orderBuy = orderBuy.Filter(Id, txt_Name.ToString(), Form, To);


            return(orderBuy);
        }
Пример #4
0
        private void btn_Delete_Click(object sender, EventArgs e)
        {
            Employee employee = FormtoEmployee();

            OrderBuyArr orderBuyArr = new OrderBuyArr();

            orderBuyArr.Fill();

            OrderRentArr orderRentArr = new OrderRentArr();

            orderRentArr.Fill();

            if (employee.Id == 0)
            {
            }
            else
            {
                if (orderRentArr.DoesExist(employee) || orderBuyArr.DoesExist(employee))
                {
                    MessageBox.Show("You can not delete this employee, it is connected" +
                                    " to 1 or more orders", "Can not delete employee",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    if (MessageBox.Show("Are you sure you want to delete this employee? ", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
                    {
                        employee.Delete();
                        ClearForm();
                        EmployeeArrToForm();
                    }
                }
            }
        }
Пример #5
0
        public void DateBuyToChart()
        {
            RadioButton(false);

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

            chart1.Titles.Clear();
            chart1.Titles.Add("Months Purchased In");

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

            orderArr.Fill();

            DateTime dateTime = new DateTime(DateTime.Now.Year, 1, 1);

            while (dateTime < DateTime.Now.Date)
            {
                dictionary.Add(dateTime.ToString("MMM", CultureInfo.InvariantCulture), orderArr.Filter(dateTime).Count);

                dateTime = dateTime.AddMonths(1);
            }

            Series series = new Series("Month", orderArr.Count);

            series.ChartType = SeriesChartType.Column;

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

            chart1.Series.Clear();
            chart1.Series.Add(series);
        }
Пример #6
0
        private void btn_Delete_Click(object sender, EventArgs e)
        {
            Client client = FormtoClient();

            OrderBuyArr orderBuyArr = new OrderBuyArr();

            orderBuyArr.Fill();

            OrderRentArr orderRentArr = new OrderRentArr();

            orderRentArr.Fill();

            if (client.Id == 0)
            {
            }
            else
            {
                if (orderRentArr.DoesExist(client) || orderBuyArr.DoesExist(client))
                {
                    MessageBox.Show("You can not delete this client, it is connected" +
                                    " to 1 or more orders", "Can not delete client",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    if (MessageBox.Show("Are you sure you want to delete this client? ", "Warning",
                                        MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
                    {
                        client.Delete();
                        ClearForm();
                        ClientArrToForm(null);
                    }
                }
            }
        }
Пример #7
0
        public void SetMinDate()
        {
            OrderBuyArr orderBuyArr = new OrderBuyArr();

            orderBuyArr.Fill();

            dtp_Form.Value = orderBuyArr.GetMinDate();
        }
Пример #8
0
        private void OrderBuyArrToForm()
        {
            OrderBuyArr orderBuyArr = new OrderBuyArr();

            orderBuyArr.Fill();

            listbox_Orders.DataSource = orderBuyArr;

            listbox_Orders.ValueMember   = "Id";
            listbox_Orders.DisplayMember = "FullName";
        }
Пример #9
0
        public void CarBuyToChart(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();

            ProductArr productArr = orderArr.GetProductArr();
            CarArr     carArr     = productArr.GetCarArr();

            foreach (Car car in carArr)
            {
                Count = orderArr.Filter(car, dt).Count;
                if (Count > 0)
                {
                    dictionary.Add(car.Category + "" + car.Model, Count);
                }
            }

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

            series.ChartType = SeriesChartType.Column;

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

            chart1.Series.Clear();
            chart1.Series.Add(series);
        }
Пример #10
0
        private void TopOrderBuyClients()
        {
            ClientArr   clientArr_new = new ClientArr();
            OrderBuyArr orderArr      = new OrderBuyArr();

            orderArr.Fill();

            ClientArr clientArr = orderArr.GetClientArr();

            foreach (Client c in clientArr)
            {
                c.Count = orderArr.Filter(c).Count;
                clientArr_new.Add(c);
            }
            clientArr_new.Sort();

            clientArr = new ClientArr();
            for (int i = 0; i < 5; i++)
            {
                clientArr.Add(clientArr_new[i]);
            }
            listBox_Data.DataSource = clientArr;
        }
Пример #11
0
        public void EmployeeBuyToChart(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 detailsBuy = new OrderBuyArr();

            detailsBuy.Fill();

            EmployeeArr employeeArr = detailsBuy.GetEmployeeArr();

            foreach (Employee employee in employeeArr)
            {
                Count = detailsBuy.Filter(employee, dt).Count;
                if (Count > 0)
                {
                    dictionary.Add(employee.Fullname, Count);
                }
            }

            Series series = new Series("Employee", employeeArr.Count);

            series.ChartType = SeriesChartType.Column;

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

            chart1.Series.Clear();
            chart1.Series.Add(series);
        }
Пример #12
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();
                    }
                }
            }
        }