Exemplo n.º 1
0
        private void EditDetail()
        {
            OrderDetail detail = detailbindingSource.Current as OrderDetail;

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

            if (formDetailEdit.ShowDialog() == DialogResult.OK)
            {
                detailbindingSource.ResetBindings(false);
            }
        }
Exemplo n.º 2
0
        private void btnAddItem_Click(object sender, EventArgs e)
        {
            DetailEditForm formItemEdit = new DetailEditForm(new OrderDetail());

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