예제 #1
0
        public override void Edit()
        {
            if (!HasSelection)
            {
                return;
            }

            CustomerForm.Text = Resources.CustomerFormStrings.TitleEdit;

            if (int.TryParse(ListView.SelectedItems[0].Text, out int customerId))
            {
                CustomerForm.Customer = UnitOfWork.Data.Customers.GetById(customerId);
                var customer = CustomerForm.Customer;
                var result   = CustomerForm.ShowDialog();

                if (result == DialogResult.OK)
                {
                    customer.LastUpdateBy = Dashboard.Username;

                    customer.CreateDate = customer.CreateDate;

                    UnitOfWork.Data.Save();

                    CustomerForm.Reset();
                }
                else
                {
                    UnitOfWork.Data.Customers.Reset(customer);
                }
            }

            RefreshAll();
        }