예제 #1
0
        // Delete the data from the inventory
        // check if id is avilable in the inventery data table

        public void deletInventory(int id)
        {
            DataRow row = _inventory.Rows.Find(id);

            if (row == null)
            {
                Console.WriteLine("-------------WARNING--------------\n" +
                                  "This id is not in the inventory list\n" +
                                  "-------------------------------------");
            }
            else
            {
                string        cs   = GetConnectionString("CarrepairMdf");
                SqlConnection conn = new SqlConnection(cs);
                conn.Open();
                string     query   = "SELECT id FROM repair WHERE inventoryID = " + id + "";
                SqlCommand cummand = new SqlCommand(query, conn);
                var        read    = cummand.ExecuteReader();
                if (read.Read())
                {
                    int repairid         = (int)read[0];
                    dataHelperRepair one = new dataHelperRepair();
                    one.deletRepair(repairid);
                    conn.Close();
                }

                row.Delete();
                _sadapter.DeleteCommand = _scmdbuilder.GetDeleteCommand();
                _sadapter.Update(_inventory);
                FillDataSet();
            }
        }
예제 #2
0
        // For the Update and insert for the repair collaction
        // check if input is valid
        public void opOnRepair(int cases)
        {
            string           watToRepair;
            int              inventoryId = 0;
            int              id          = 0;
            dataHelperRepair one         = new dataHelperRepair();

            if (cases == 3 || cases == 4)
            {
                while (id == 0)
                {
                    try
                    {
                        Console.WriteLine("Enter the id of the repairList");
                        id = Int32.Parse(Console.ReadLine());
                    }
                    catch
                    {
                        Console.WriteLine("Please Enter Valid input");
                    }
                }
                if (cases == 4)
                {
                    one.deletRepair(id);
                }
            }
            if (cases == 2 || cases == 3)
            {
                while (inventoryId == 0)
                {
                    try
                    {
                        Console.WriteLine("Please Enter inventory id\n ");
                        inventoryId = Int32.Parse(Console.ReadLine());
                    }
                    catch
                    {
                        Console.WriteLine("Please Enter the Valid input");
                    }
                }
                do
                {
                    Console.WriteLine("Please Enter what repair? \n");
                    watToRepair = Console.ReadLine();
                    if (isStringValid(watToRepair))
                    {
                        if (cases == 2)
                        {
                            one.insertRepar(inventoryId, watToRepair);
                        }
                        if (cases == 3)
                        {
                            one.updateRepair(id, watToRepair);
                        }
                    }
                }while (!isStringValid(watToRepair));
            }
        }
예제 #3
0
        static void Main(string[] args)
        {
            DisplayMenu         display   = new DisplayMenu();                          // class for the Dispay all the Menue and user input testing
            DataHelper          one       = new DataHelper();                           // Class for vehical table handel all the vehical table manipulation
            dataHelperInventory inventory = new dataHelperInventory();                  //Class for inventory table handel all the inventory table data manipulation
            dataHelperRepair    repair    = new dataHelperRepair();                     //Class for repair table handel all the repair table data manioulation

            do
            {
                int  choice = display.mainMenu();
                bool menu   = true;
                switch (choice)
                {
                case 1:                                                                     // Case for the vehical

                    do
                    {
                        String input = "vehicle";

                        choice = display.vehicleMenu(input);
                        switch (choice)
                        {
                        case 1:
                            one.PrintCars();
                            break;

                        case 2:
                            one.PrintCars();
                            display.opOnVehicle(choice);
                            break;

                        case 3:
                            one.PrintCars();
                            display.opOnVehicle(choice);
                            break;

                        case 4:
                            one.PrintCars();
                            display.opOnVehicle(choice);
                            one.PrintCars();
                            break;

                        case 5:
                            menu = false;
                            break;
                        }
                    }while (menu);
                    break;

                case 2:                                                                                            // case for the Inventory

                    do
                    {
                        string input = "Inventory";

                        choice = display.vehicleMenu(input);
                        //choice = display.inventoryMenu();
                        switch (choice)
                        {
                        case 1:
                            inventory.pritInventory();
                            break;

                        case 2:
                            inventory.pritInventory();
                            display.opOnInventory(choice);
                            break;

                        case 3:
                            inventory.pritInventory();
                            Console.WriteLine("-----------------------------WARNING------------------------\n" +
                                              "Update will not update vehicalID to avoid duplicate record\n" +
                                              "--------------------------------------------------------------");
                            display.opOnInventory(choice);
                            break;

                        case 4:
                            inventory.pritInventory();
                            display.opOnInventory(choice);
                            inventory.pritInventory();
                            break;

                        case 5:
                            menu = false;
                            break;
                        }
                    }while (menu);
                    break;

                case 3:                                                                                                // case for the repair
                    do
                    {
                        string input = "Repair";

                        choice = display.vehicleMenu(input);
                        switch (choice)
                        {
                        case 1:
                            repair.pritRepair();
                            break;

                        case 2:
                            repair.pritRepair();
                            display.opOnRepair(choice);
                            break;

                        case 3:
                            repair.pritRepair();
                            Console.WriteLine("-----------------------------WARNING------------------------\n" +
                                              "Update will not update inventoryID to avoid duplicate record\n" +
                                              "--------------------------------------------------------------");
                            display.opOnRepair(choice);
                            break;

                        case 4:
                            repair.pritRepair();
                            display.opOnRepair(choice);
                            repair.pritRepair();
                            break;

                        case 5:
                            menu = false;
                            break;
                        }
                    }while (menu);
                    break;

                case 4:
                    Environment.Exit(0);
                    break;
                }
            } while (true);
        }