Ejemplo n.º 1
0
        private void btn_UpdateShow_Click(object sender, EventArgs e)
        {
            try
            {
                CustController cust = new CustController();
                Customer       c;
                if (dataGridView1.SelectedCells.Count > 0 && txt_custID.Text == "")
                {
                    DataGridViewRow selectedRow = dataGridView1.Rows[dataGridView1.SelectedCells[0].RowIndex];
                    c = cust.GetCustomer(Convert.ToInt32(selectedRow.Cells["CustomerID"].Value.ToString()));
                    txt_custID.Text = c.customerID.ToString();
                }
                else
                {
                    c = cust.GetCustomer(Convert.ToInt32(txt_custID.Text));
                }


                txt_updateName.Text   = c.name;
                txt_updateAdress.Text = c.adress;
                txt_updateZip.Text    = c.zipCode.ToString();
            }
            catch
            {
            }
        }
Ejemplo n.º 2
0
        private void btn_OrderChoose_Click(object sender, EventArgs e)
        {
            int orderID;
            int customerID;

            if (dataGridView1.SelectedCells.Count > 0)
            {
                DataGridViewRow selectedRow = dataGridView1.Rows[dataGridView1.SelectedCells[0].RowIndex];
                orderID    = Convert.ToInt32(selectedRow.Cells["OrdreID"].Value);
                customerID = Convert.ToInt32(selectedRow.Cells["CustomerID"].Value);
                CustController cust = new CustController();
                UC_Order1.ShowCustInfo(cust.GetCustomer(customerID));
                UC_Order1.txt_orderID.Text = orderID.ToString();

                UC_Order1.dataGridView1.DataSource = order.GetAllProductLines(orderID);
                this.Controls.Clear();
                this.InitializeComponent();
                UC_Order1.BringToFront();
                UC_Order1.cbb_discount.Text = "0";
                double pris = order.TotalPrice(Convert.ToDouble(UC_Order1.cbb_discount.Text), Convert.ToInt32(orderID));
                UC_Order1.lbl_pris.Text = $"{pris:C}";
            }
            else
            {
                MessageBox.Show("Ingen ordre valgt");
            }
        }
Ejemplo n.º 3
0
 public UnionController(RandData rand)
 {
     this.rand  = rand;
     carHandle  = new CarController(rand);
     custHandle = new CustController(rand);
     sellHandle = new SellController(rand);
 }
Ejemplo n.º 4
0
        private void btn_ShowAllCustomers(object sender, EventArgs e)
        {
            CustController  cust = new CustController();
            List <Customer> cList;

            cList = cust.GetAllCustomer("");
            dataGridView1.DataSource = cList;
        }
Ejemplo n.º 5
0
        private void btn_searchCust_Click(object sender, EventArgs e)
        {
            CustController  cust  = new CustController();
            List <Customer> cList = new List <Customer>();

            cList = cust.GetAllCustomer($"{txt_searchName.Text}");

            dataGridView1.DataSource = cList;
        }
Ejemplo n.º 6
0
 private void btn_saveCustChanges_Click(object sender, EventArgs e)
 {
     try
     {
         CustController cust = new CustController();
         cust.UpdateCustomer(Convert.ToInt32(txt_custID.Text), txt_updateName.Text, txt_updateAdress.Text, Convert.ToInt32(txt_updateZip.Text));
         txt_custID.Clear();
         txt_updateName.Clear();
         txt_updateAdress.Clear();
         txt_updateZip.Clear();
     }
     catch
     {
         MessageBox.Show("Oplysninger ikke udfyldt korrekt");
     }
 }
Ejemplo n.º 7
0
 private void btn_CrCust_Click(object sender, EventArgs e)
 {
     try
     {
         CustController cust = new CustController();
         cust.OpretKunde(txt_CrName.Text, txt_CrAdress.Text, Convert.ToInt32(txt_CrZip.Text));
         txt_CrName.Clear();
         txt_CrAdress.Clear();
         txt_CrZip.Clear();
         MessageBox.Show("Kunde oprettet");
     }
     catch
     {
         MessageBox.Show("Alle felter skal udfyldes");
     }
 }
Ejemplo n.º 8
0
 private void btn_newOrder_Click(object sender, EventArgs e)
 {
     try
     {
         order.CreateOrder(Convert.ToInt32(txt_custID.Text));
         o = order.GetLastOrder();
         txt_orderID.Text         = o.ordreID.ToString();
         dataGridView1.DataSource = order.GetAllProductLines(o.ordreID);
         CustController cust = new CustController();
         Customer       c    = cust.GetCustomer(o.customerID);
         ShowCustInfo(c);
     }
     catch
     {
         MessageBox.Show("Angiv gyldigt kundenummer");
     }
 }
Ejemplo n.º 9
0
        private void btn_chooseSelected_Click(object sender, EventArgs e)
        {
            if (dataGridView1.SelectedCells.Count > 0)
            {
                int customerID = 0;
                if (dataGridView1.SelectedCells.Count > 0)
                {
                    DataGridViewRow selectedRow = dataGridView1.Rows[dataGridView1.SelectedCells[0].RowIndex];
                    customerID = Convert.ToInt32(selectedRow.Cells["CustomerID"].Value.ToString());
                }

                UC_Cust1.txt_custID.Text = customerID.ToString();
                CustController cust = new CustController();
                UC_Cust1.ShowCustInfo(cust.GetCustomer(customerID));
                this.Controls.Clear();
                this.InitializeComponent();
                UC_Cust1.BringToFront();
            }
        }
Ejemplo n.º 10
0
        static void Main(string[] args)
        {
            RandData      rand   = new RandData();
            Menu          menu   = new Menu();
            CarController carCon =
                new CarController(rand);
            CustController custCon =
                new CustController(rand);
            SellController sellCon =
                new SellController(rand);

            while (true)
            {
                switch (menu.mainMenu())
                {
                case Menu.MENU_MAIN_RAND:
                    carCon.insRandData(menu.getRandSize());
                    custCon.insRandData(menu.getRandSize());
                    sellCon.insRandData(menu.getRandSize());
                    break;

                case Menu.MENU_MAIN_DEL_ALL:
                    carCon.removeAll();
                    custCon.removeAll();
                    sellCon.removeAll();
                    break;

                case Menu.MENU_MAIN_VIEW:
                    carCon.carView();
                    custCon.custView();
                    sellCon.sellView();
                    break;

                case Menu.MENU_MAIN_ADD:
                    switch (menu.subAddMenu())
                    {
                    case Menu.MENU_SUB_ADD_CAR:
                        carCon.addCarItem(
                            menu.addCarMenu2());
                        break;

                    case Menu.MENU_SUB_ADD_CUST:
                        custCon.addCustItem(
                            menu.addCustMenu());
                        break;

                    case Menu.MENU_SUB_ADD_SELL:
                        sellCon.addSellItem(
                            menu.addSellMenu());
                        break;

                    case Menu.MENU_SUB_ADD_EXIT:
                        break;
                    }
                    break;

                case Menu.MENU_MAIN_DEL:
                    carCon.delCarItem(menu.delCarMenu());
                    custCon.delCustItem(menu.delCustMenu());
                    sellCon.delSellItem(menu.delSellMenu());
                    break;

                case Menu.MENU_MAIN_UPDATE:
                    carCon.updateCarItem(menu.updateCarMenu());
                    custCon.updateCustItem(menu.updateCustMenu());
                    sellCon.updateSellItem(menu.updateSellMenu());
                    break;

                case Menu.MENU_MAIN_EXIT:
                    Environment.Exit(0);
                    break;
                }
            }
        }
Ejemplo n.º 11
0
 public UnionController(CarController carHandle, CustController custHandle, SellController sellHandle)
 {
     this.carHandle  = carHandle;
     this.custHandle = custHandle;
     this.sellHandle = sellHandle;
 }
Ejemplo n.º 12
0
        static void Main(string[] args)
        {
            RandData rand = new RandData();

            Menu           menu    = new Menu(); // 객체생성 - instance 메소드를 불러오기 위함.
            CarContoller   carCon  = new CarContoller(rand);
            CustController custCon = new CustController(rand);
            SellController selCon  = new SellController(rand);

            while (true)
            {
                switch (menu.mainMenu())  //class변수는 객체 생성 후 불러오기
                {
                case Menu.MENU_MAIN_RAND: // instance 변수는
                    carCon.InsRandDate(menu.getRandSize());
                    custCon.InsRandDate_cus(menu.getRandSize());
                    selCon.InsRandDate_sell(menu.getRandSize());
                    break;

                case Menu.MENU_MAIN_DEL_ALL:
                    carCon.removeAll();
                    custCon.removeAll();
                    selCon.removeAll();
                    break;

                case Menu.MENU_MAIN_VIEW:
                    carCon.carView();
                    custCon.custView();
                    selCon.SellView();
                    break;

                case Menu.MENU_MAIN_ADD:
                    switch (menu.subAddMenu())
                    {
                    case Menu.MENU_SUB_ADD_CAR:
                        carCon.addCarItem(menu.addCarMenu2());
                        break;

                    case Menu.MENU_SUB_ADD_CUST:
                        custCon.addCustItem(menu.addCustMenu());
                        break;

                    case Menu.MENU_SUB_ADD_SELL:
                        selCon.addSellItem(menu.addSellMenu());
                        break;

                    case Menu.MENU_SUB_ADD_EXIT:
                        break;
                    }
                    break;

                case Menu.MENU_MAIN_DEL:
                    carCon.delCarItem(menu.delCarMenu());
                    custCon.delCustItem(menu.delCustMenu());
                    selCon.delSellItem(menu.delSellMenu());
                    break;

                case Menu.MENU_MAIN_UPDATE:
                    carCon.updateCarItem(menu.updateCarMenu());
                    custCon.updateCarItem(menu.updateCustMenu());
                    selCon.updateSellItem(menu.updateSellMenu());
                    break;

                case Menu.MENU_MAIN_EXIT:
                    Console.WriteLine("프로그램이 종료되었습니다.");
                    Environment.Exit(0);
                    break;

                default:
                    break;
                }
            }
        }