Пример #1
0
        private void button3_Click(object sender, EventArgs e)
        {
            int position = OrderBindingSource.Position;

            os.RemoveOrder(Convert.ToUInt32(dataGridView1.Rows[position].Cells[0].Value));
            OrderBindingSource.ResetBindings(false);
        }
Пример #2
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            int selectedIndex = DetailGridView.CurrentCell.RowIndex;

            orderModified.RemoveDetails(orderModified.OrderDetails[selectedIndex]);
            OrderBindingSource.ResetBindings(false);
            OrderDetailBindingSource.ResetBindings(false);
        }
Пример #3
0
        private void button5_Click(object sender, EventArgs e)
        {
            Form3 f3 = new Form3(this.orders);

            f3.Owner        = this; //设置查找窗体的父窗体为本窗体
            f3.UpdateOrder += new Form3.UpdateOrderHandler(UpdateOrder);
            f3.ShowDialog();
            OrderBindingSource.ResetBindings(false);
        }
Пример #4
0
 private void btnImport_Click(object sender, EventArgs e)
 {
     if (openFileDialog.ShowDialog() == DialogResult.OK)
     {
         String fileName = openFileDialog.FileName;
         service.Import(fileName);
         OrderBindingSource.ResetBindings(true);
     }
 }
Пример #5
0
        private void button2_Click(object sender, EventArgs e)
        {
            Form2 f = new Form2();

            f.Owner        = this; //设置查找窗体的父窗体为本窗体
            f.CreateOrder += new Form2.CreateOrderHandler(CreateOrder);
            f.ShowDialog();
            OrderBindingSource.ResetBindings(false);
        }
Пример #6
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            EditForm form1 = new EditForm(new Order());

            if (form1.ShowDialog() == DialogResult.OK)
            {
                service.AddOrders(form1.CurrentOrder);
                OrderBindingSource.ResetBindings(false);
            }
        }
Пример #7
0
 private void btnModify_Click(object sender, EventArgs e)
 {
     for (int i = 0; i < DetailGridView.Rows.Count - 1; i++)
     {
         orderModified.OrderDetails[i].Goods.GoodsName = DetailGridView.Rows[i].Cells[0].Value.ToString();
         orderModified.OrderDetails[i].Num             = int.Parse(DetailGridView.Rows[i].Cells[1].Value.ToString());
         orderModified.OrderDetails[i].GoodsTotalPrice = double.Parse(DetailGridView.Rows[i].Cells[2].Value.ToString());
     }
     OrderBindingSource.ResetBindings(false);
     OrderDetailBindingSource.ResetBindings(false);
 }
Пример #8
0
        private void btnCreateOrder_Click(object sender, EventArgs e)
        {
            Form2 form2 = new Form2(new Order());

            if (form2.ShowDialog() == DialogResult.OK)
            {
                os.AddOrder(form2.currentOrder);
                OrderBindingSource.DataSource = os.orders;
                OrderBindingSource.ResetBindings(false);
            }
        }
Пример #9
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            Order order = OrderBindingSource.Current as Order;

            if (order == null)
            {
                MessageBox.Show("请选择一个订单进行删除");
                return;
            }
            service.DeleteOrders(order);
            OrderBindingSource.ResetBindings(true);
        }
Пример #10
0
        private void btnDeleteItem_Click(object sender, EventArgs e)
        {
            OrderItem item = ItemBindingSource.Current as OrderItem;

            if (item == null)
            {
                MessageBox.Show("请选择一件商品进行删除");
                return;
            }
            CurrentOrder.DeleteItem(item);
            OrderBindingSource.ResetBindings(true);
        }
Пример #11
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            FormAdd formAdd = (FormAdd)this.Owner;

            formAdd.Show();
            textBoxID.DataBindings.Add("Text", OrderDetailBindingSource, "OrderID");
            cbBoxMerchant.DataBindings.Add("SelectedItem", OrderDetailBindingSource, "Mechant");
            cbBoxCustomer.DataBindings.Add("SelectedItem", OrderDetailBindingSource, "Customer");
            orderModified.OrderDetails.Add(orderDetails);
            OrderBindingSource.ResetBindings(false);
            OrderDetailBindingSource.ResetBindings(false);
        }
Пример #12
0
 private void btnCustomerQuery_Click(object sender, EventArgs e)
 {
     if (KeyWord == null || KeyWord == "")
     {
         OrderBindingSource.DataSource = os.orders;
     }
     else
     {
         OrderBindingSource.DataSource = os.orders
                                         .Where(s => s.Customer == KeyWord);
     }
     OrderBindingSource.ResetBindings(true);
 }
Пример #13
0
        private void btnDeleteOrder_Click(object sender, EventArgs e)
        {
            Order currentOrder = OrderBindingSource.Current as Order;

            if (currentOrder == null)
            {
                MessageBox.Show("请选择一个订单进行删除");
                return;
            }
            os.RemoveOrder(currentOrder.OrderId);
            OrderBindingSource.DataSource = os.orders;
            OrderBindingSource.ResetBindings(false);
        }
Пример #14
0
        private void OptionList_SelectedIndexChanged(object sender, EventArgs e)
        {
            switch (ModeList.SelectedIndex)
            {
            case 1:
                OrderBindingSource.DataSource = service.SelectByOrderID(OptionList.Text);
                break;

            case 2:
                OrderBindingSource.DataSource = service.SelectByCustomer(OptionList.Text);
                break;
            }
            OrderBindingSource.ResetBindings(true);
        }
Пример #15
0
        private void btnAddItem_Click(object sender, EventArgs e)
        {
            ItemEditForm form2 = new ItemEditForm(new OrderItem());

            try
            {
                if (form2.ShowDialog() == DialogResult.OK)
                {
                    CurrentOrder.AddItem(form2.CurrentItem);
                    OrderBindingSource.ResetBindings(true);
                }
            }
            catch (Exception ee)
            {
                MessageBox.Show(ee.Message);
            }
        }
Пример #16
0
        private void btnEditItem_Click(object sender, EventArgs e)
        {
            OrderItem item = ItemBindingSource.Current as OrderItem;

            if (item == null)
            {
                MessageBox.Show("请选择一件商品进行修改");
                return;
            }
            ItemEditForm form2 = new ItemEditForm(item, true);

            if (form2.ShowDialog() == DialogResult.OK)
            {
                CurrentOrder.AddItem(item);
                OrderBindingSource.ResetBindings(true);
            }
        }
Пример #17
0
        private void btnMedifyOrder_Click(object sender, EventArgs e)
        {
            Order currentOrder = OrderBindingSource.Current as Order;

            if (currentOrder == null)
            {
                MessageBox.Show("请选择一个订单进行修改");
                return;
            }
            Form2 form2 = new Form2();

            if (form2.ShowDialog() == DialogResult.OK)
            {
                os.UpdateOrder(currentOrder, form2.currentOrder);
                OrderBindingSource.DataSource = os.orders;
                OrderBindingSource.ResetBindings(false);
            }
        }
Пример #18
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            Order order = OrderBindingSource.Current as Order;

            service.Get(order.ID, out Order t, out int index);
            if (order == null)
            {
                MessageBox.Show("请选择一个订单进行修改");
                return;
            }
            EditForm form1 = new EditForm(order, true);

            if (form1.ShowDialog() == DialogResult.OK)
            {
                service.EditOrders(order, index);
                OrderBindingSource.ResetBindings(true);
            }
        }
Пример #19
0
        private void button1_Click(object sender, EventArgs e)
        {
            switch (SearchWay.SelectedItem)
            {
            case "商品名称":
                if (KeyWord == null || KeyWord == "")
                {
                    OrderBindingSource.DataSource = orders;
                }
                else
                {
                    OrderBindingSource.DataSource =
                        os.QueryOrdersByGoodsName(KeyWord);
                }
                OrderBindingSource.ResetBindings(false);
                itemsBindingSource.ResetBindings(false);
                break;

            case "客户名称":
                if (KeyWord == null || KeyWord == "")
                {
                    OrderBindingSource.DataSource = orders;
                }
                else
                {
                    OrderBindingSource.DataSource =
                        os.QueryOrdersByCustomerName(KeyWord);
                }
                OrderBindingSource.ResetBindings(false);
                itemsBindingSource.ResetBindings(false);
                break;

            case "订单价格":
            default:

                os.Sort((o1, o2) => o1.TotalPrice.CompareTo(o2.TotalPrice));
                orders = os.Orders;
                OrderBindingSource.DataSource = orders;
                OrderBindingSource.ResetBindings(false);
                itemsBindingSource.ResetBindings(false);
                break;
            }
        }