Ejemplo n.º 1
0
		public JsonResult Update(EditCustomerForm form)
		{
			var target = _context.Customers.Find(form.Id);

			Mapper.Map(form, target);

			_context.SaveChanges();

			var updatedCustomer = _context.Customers.Project().To<CustomerViewModel>().Single(x => x.Id == form.Id);

			return BetterJson(updatedCustomer);
		}
        public JsonResult Update(EditCustomerForm form)
        {
            var target = _context.Customers.Find(form.Id);

            Mapper.Map(form, target);

            _context.SaveChanges();

            var updatedCustomer = _context.Customers.Project().To <CustomerViewModel>().Single(x => x.Id == form.Id);

            return(BetterJson(updatedCustomer));
        }
Ejemplo n.º 3
0
        private void btn_Customer_Edit_Click(object sender, EventArgs e)
        {
            if (this.CustomerInfoListView.SelectedRows.Count <= 0)
            {
                MessageBox.Show("请选择要编辑的人员信息");
            }

            EditCustomerForm editcutomerform = new EditCustomerForm(this.CustomerInfoListView.SelectedRows[0].Cells[0].Value.ToString());

            if (editcutomerform.ShowDialog() == DialogResult.OK)
            {
            }
        }
Ejemplo n.º 4
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            var customer = new Customer();

            var dialogResult = new EditCustomerForm(customer).ShowDialog();

            if (dialogResult == DialogResult.OK)
            {
                _cutomerService.Add(customer);
                MetroMessageBox.Show(this, $"Клиент успешно добавлен", "Справка", MessageBoxButtons.OK, MessageBoxIcon.Information);
                UpdateDataGrid();
                UpdateCounter();
            }
        }
Ejemplo n.º 5
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            var customer = _cutomerService.Find(Convert.ToInt32(dataGrid.SelectedRows[0].Cells[0].Value));

            if (customer != null)
            {
                var dialogResult = new EditCustomerForm(customer).ShowDialog();

                if (dialogResult == DialogResult.OK)
                {
                    _cutomerService.Update(customer);
                    MetroMessageBox.Show(this, $"Данные клиента изменены", "Справка", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    UpdateDataGrid();
                }
            }
        }
Ejemplo n.º 6
0
        private void ShowEditForm(int?customerID)
        {
            var form = new EditCustomerForm(customerID);

            form.FormClosed += EditFormClosed;
            var documentManager = DocumentManager.FromControl(MdiParent);

            if (documentManager != null)
            {
                documentManager.View.AddDocument(form);
            }
            else
            {
                try {
                    form.ShowDialog();
                } finally {
                    form.Dispose();
                }
            }
        }