private void _btnAdd_Click(object sender, EventArgs e)
        {
            var name  = _txtCustomName.Text;
            var items = gridControl1.DataSource as IList <SaleBillItem>;

            if (!_txtCustomName.Validate(string.IsNullOrWhiteSpace(name)) ||
                !gridControl1.Validate(items == null || !items.Any()))
            {
                return;
            }

            if (_isAddingNew)
            {
                saleBill.CustomeName = name;
                saleBill.BillNo      = SequenseNoGenerator.GetNextCode("XS");
                saleBill.Date        = DateTime.Now;
                _service.AddSaleBill(saleBill);
            }
            else
            {
                saleBill.CustomeName = name;
                saleBill.Items       = gridControl1.DataSource as IList <SaleBillItem>;

                _service.SaveSaleBill(saleBill);
            }

            DialogResult = DialogResult.OK;
        }
        private void AddBatchForm_Load(object sender, EventArgs e)
        {
            _service = ApplicationService.Instanse;

            _cbProducts.Properties.DataSource    = _productList = ApplicationService.Instanse.GetAllProducts();
            _cbProducts.Properties.DisplayMember = "Name";
            _cbProducts.Properties.ValueMember   = "Id";

            if (_isAddingNew)
            {
                _txtBatchNo.Text = SequenseNoGenerator.GetNextCode("PC");

                Text = "添加批次";
            }
            else
            {
                var batch = _service.GetBatch(_batchId);
                if (batch == null)
                {
                    MessageBoxHelper.Warn("批次不存在。");
                    DialogResult = System.Windows.Forms.DialogResult.Abort;
                    return;
                }

                var product = _productList.FirstOrDefault(x => x.Id == batch.ProductId);

                _cbProducts.ItemIndex   = product == null ? -1 : _productList.IndexOf(product);
                _txtBatchNo.Text        = batch.No;
                _seExpectedAmount.Value = batch.ExpectedAmount;

                Text         = "编辑批次";
                _btnAdd.Text = "保存";
            }
        }