private void btnAdd_Click(object sender, EventArgs e) { if (dialog.ShowDialog() == DialogResult.OK) { try { addressbook.FKStateId = dialog.FKSatteId; addressbook.FKUserId = dialog.FKuserID; addressbook.FirstName = dialog.FirstName; addressbook.LastName = dialog.LastName; addressbook.EmailId = dialog.EmailId; addressbook.PhoneNo = dialog.PhoneNo; addressbook.Address1 = dialog.Address1; addressbook.Address2 = dialog.Address2; addressbook.Street = dialog.Street; addressbook.City = dialog.City; addressbook.ZipCode = dialog.ZipCode; addressbook.IsActive = dialog.IsActive; interaction.AddData(addressbook, 4); } catch (Exception) { MessageBox.Show("problem in the add of addressform"); } } dgvAddressBook.DataSource = interaction.Getdetails(4); }
protected override async Task ExecuteAsync(object parameter) { if (_addressVM.AddressSelected != null) { AddressDialog dialog = new AddressDialog(); List <City> allCities = await _cityRepository.GetAll().ConfigureAwait(true); AddressVM VM = new AddressVM(_repository, allCities, CUD.Update, new Action(() => dialog.Close()), _user, _addressVM.AddressSelected); dialog.DataContext = VM; bool?result = dialog.ShowDialog(); if (dialog.DialogResult.HasValue && dialog.DialogResult.Value) { _addressVM.AllAddresses = await _addressVM.GetAllAddresses().ConfigureAwait(true); _addressVM.Addresses.Clear(); foreach (Address address in _addressVM.AllAddresses) { _addressVM.Addresses.Add(address); } } } }
private void btnEdit_Click(object sender, EventArgs e) { AddressDialog dlgAddress = new AddressDialog(); dlgAddress.FillInCombo(); int AddressId = (int)(dgvAddressBook.SelectedRows[0].Cells[0].Value); dlgAddress.StateName = (dgvAddressBook.SelectedRows[0].Cells[2].Value).ToString(); dlgAddress.UserName = (dgvAddressBook.SelectedRows[0].Cells[4].Value).ToString(); dlgAddress.FirstName = (dgvAddressBook.SelectedRows[0].Cells[5].Value).ToString(); dlgAddress.LastName = (dgvAddressBook.SelectedRows[0].Cells[6].Value).ToString(); dlgAddress.EmailId = (dgvAddressBook.SelectedRows[0].Cells[7].Value).ToString(); dlgAddress.PhoneNo = (dgvAddressBook.SelectedRows[0].Cells[8].Value).ToString(); dlgAddress.Address1 = (dgvAddressBook.SelectedRows[0].Cells[9].Value).ToString(); dlgAddress.Address2 = (dgvAddressBook.SelectedRows[0].Cells[10].Value).ToString(); dlgAddress.Street = (dgvAddressBook.SelectedRows[0].Cells[11].Value).ToString(); dlgAddress.City = (dgvAddressBook.SelectedRows[0].Cells[12].Value).ToString(); dlgAddress.ZipCode = (long)(dgvAddressBook.SelectedRows[0].Cells[13].Value); dlgAddress.IsActive = (bool)(dgvAddressBook.SelectedRows[0].Cells[14].Value); AddressData objAddressdata = new AddressData(); if (dlgAddress.ShowDialog() == DialogResult.OK) { objAddressdata.PKAddressId = AddressId; objAddressdata.FKStateId = (int)(dgvAddressBook.SelectedRows[0].Cells[1].Value); objAddressdata.FKUserId = (int)(dgvAddressBook.SelectedRows[0].Cells[3].Value); objAddressdata.FirstName = dlgAddress.FirstName; objAddressdata.LastName = dlgAddress.LastName; objAddressdata.EmailId = dlgAddress.EmailId; objAddressdata.PhoneNo = dlgAddress.PhoneNo; objAddressdata.Address1 = dlgAddress.Address1; objAddressdata.Address2 = dlgAddress.Address2; objAddressdata.Street = dlgAddress.Street; objAddressdata.City = dlgAddress.City; objAddressdata.ZipCode = dlgAddress.ZipCode; objAddressdata.IsActive = dlgAddress.IsActive; AddressBO.UpdateInAddress(objAddressdata); } else { MessageBox.Show("please check the Details again"); } dgvAddressBook.DataSource = AddressBO.GetAddress(); }
private void btnAdd_Click(object sender, EventArgs e) { AddressDialog dlgAddress = new AddressDialog(); AddressData objAddressdata = new AddressData(); dlgAddress.FillInCombo(); if (dlgAddress.ShowDialog() == DialogResult.OK) { objAddressdata.FKStateId = dlgAddress.FKSatteId; objAddressdata.FKUserId = dlgAddress.FKuserID; objAddressdata.FirstName = dlgAddress.FirstName; objAddressdata.LastName = dlgAddress.LastName; objAddressdata.EmailId = dlgAddress.EmailId; objAddressdata.PhoneNo = dlgAddress.PhoneNo; objAddressdata.Address1 = dlgAddress.Address1; objAddressdata.Address2 = dlgAddress.Address2; objAddressdata.Street = dlgAddress.Street; objAddressdata.City = dlgAddress.City; objAddressdata.ZipCode = dlgAddress.ZipCode; objAddressdata.IsActive = dlgAddress.IsActive; AddressBO.InsertInAddress(objAddressdata); dgvAddressBook.DataSource = AddressBO.GetAddress(); } }