private void cancel_btn_Click(object sender, EventArgs e)
        {
            int newID = service.addOrder();

            service.addDetails(newID, 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();
        }
        public void renewCell(int index, OrderDetails details, int detailID)
        {
            orderView.Rows[index].Cells[1].Value = details.objectID;
            orderView.Rows[index].Cells[2].Value = details.objectName;
            orderView.Rows[index].Cells[3].Value = details.supplier;
            orderView.Rows[index].Cells[4].Value = details.buyer;
            orderView.Rows[index].Cells[5].Value = details.num;
            orderView.Rows[index].Cells[6].Value = details.unitPrice;
            orderView.Rows[index].Cells[7].Value = details.totalPrice;
            int orderID = int.Parse(orderView.Rows[index].Cells[0].Value.ToString());

            service.changeDetail(orderID, detailID, details);
            order_management_system system = (order_management_system)this.Owner;

            system.renewService(service);
        }
        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;
            }
        }
Пример #4
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();
            }
        }
        private void importButton_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Title = "Choose a xml file";
            //初始目录
            ofd.InitialDirectory = @"C:\";
            //设定文件类型
            ofd.Filter = "文本文件 | *.txt";
            ofd.ShowDialog();

            //获得在打开文件对话框中选择的文件的路径
            string path = ofd.FileName;

            if (path == "")
            {
                return;
            }

            service.import(path);
            order_management_system system = (order_management_system)this.Owner;

            system.renewService(service);
        }