Ejemplo n.º 1
0
        private void EditItem()
        {
            OrderItem orderItem = itemsBindingSource.Current as OrderItem;

            if (orderItem == null)
            {
                MessageBox.Show("请选择一个订单项进行修改");
                return;
            }
            FormItemEdit formItemEdit = new FormItemEdit(orderItem);

            if (formItemEdit.ShowDialog() == DialogResult.OK)
            {
                itemsBindingSource.ResetBindings(false);
            }
        }
Ejemplo n.º 2
0
        private void btnAddItem_Click(object sender, EventArgs e)
        {
            FormItemEdit formItemEdit = new FormItemEdit(new OrderItem());

            try
            {
                if (formItemEdit.ShowDialog() == DialogResult.OK)
                {
                    uint index = 0;
                    if (CurrentOrder.Items.Count != 0)
                    {
                        index = CurrentOrder.Items.Max(i => i.ItemId) + 1;
                    }
                    formItemEdit.OrderItem.ItemId = index;
                    CurrentOrder.AddItem(formItemEdit.OrderItem);
                    itemsBindingSource.ResetBindings(false);
                }
            }
            catch (Exception e2)
            {
                MessageBox.Show(e2.Message);
            }
        }