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);
                    }
                }
            }
        }
Example #2
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();
                    }
                }
            }
        }
Example #3
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);
                    }
                }
            }
        }
Example #4
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();
                    }
                }
            }
        }