private void OK_btn_Click(object sender, EventArgs e)
        {
            object index = orderBox.SelectedItem;

            if (index != null)
            {
                service.addDetails(int.Parse(index.ToString()), newDetail.objectID, newDetail.objectName, newDetail.supplier, newDetail.buyer, newDetail.num, newDetail.unitPrice);
                order_management_system system = (order_management_system)this.Owner;
                system.renewService(service);
                warning warningWindow = new warning();
                warningWindow.setText("Succeeded", "Data has been entered");
                warningWindow.Show();
                this.Close();
            }
            else
            {
                warning_label.Text      = "Click it to choose!";
                warning_label.ForeColor = Color.Red;
            }
        }
Beispiel #2
0
        private void confirm_btn_Click(object sender, EventArgs e)
        {
            string objID            = objID_text.Text;
            string objName          = objName_text.Text;
            string supplier         = supllier_text.Text;
            string buyer            = buyer_text.Text;
            bool   numConvert       = int.TryParse(num_text.Text, out int num);
            bool   unitPriceConvert = float.TryParse(unitPrice_text.Text, out float unitPrice);

            if (numConvert && unitPriceConvert)
            {
                OrderDetails newDetails = new OrderDetails(objID, objName, supplier, buyer, num, unitPrice);
                int          sameID     = service.isSameDetailsExsist(newDetails);
                if (sameID == -1)
                {
                    int newID = service.addOrder();
                    service.addDetails(newID, objID, objName, supplier, buyer, num, unitPrice);
                    warning warningWindow = new warning();
                    warningWindow.setText("Succeeded", "Data has been entered");
                    warningWindow.Show();
                    order_management_system system = (order_management_system)this.Owner;
                    system.renewService(service);
                    this.Close();
                }

                else
                {
                    ChooseOrder             chooseWindow = new ChooseOrder(service, newDetails);
                    order_management_system system       = (order_management_system)this.Owner;
                    chooseWindow.Show(system);
                    this.Close();
                }
            }

            else
            {
                warning warningWindow = new warning();
                warningWindow.setText("Warning!", "Character illegal.");
                warningWindow.Show();
            }
        }