예제 #1
0
 private void btnAdd_Click(object sender, EventArgs e)
 {
     try
     {
         AddressbookDialog dlgAddressDialog = new AddressbookDialog();
         if (dlgAddressDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
         {
             Address       objAddbook   = new Address();
             AddressBookBO objAddbookBO = new AddressBookBO();
             objAddbookBO.InsertAddress(Convert.ToInt32(dlgAddressDialog.StateName), Helper.UserId, dlgAddressDialog.FirstName, dlgAddressDialog.LastName, dlgAddressDialog.EmailId, dlgAddressDialog.phoneNo, dlgAddressDialog.Address1, dlgAddressDialog.Address2, dlgAddressDialog.Street, dlgAddressDialog.City, dlgAddressDialog.ZipCode, dlgAddressDialog.IsActive);
             if (Helper.Role == "Admin")
             {
                 BindDataToGrid();
                 btnAdd.Enabled = false;
             }
             else
             {
                 BindUserDataToGrid();
                 btnAdd.Enabled = true;
             }
         }
     }
     catch (ApplicationException ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
예제 #2
0
 private void btnEdit_Click(object sender, EventArgs e)
 {
     if (dgvAddress.RowCount != 0)
     {
         int addressId;
         addressId = (int)(dgvAddress.SelectedRows[0].Cells[0].Value);
         AddressBookBO     objAddbookBO     = new AddressBookBO();
         Address           objAddbook       = objAddbookBO.GetAddress(addressId);
         AddressbookDialog dlgAddressDialog = new AddressbookDialog(objAddbook.CountryID.ToString());
         dlgAddressDialog.StateName = objAddbook.StateId.ToString();
         dlgAddressDialog.FirstName = objAddbook.FirstName.ToString();
         dlgAddressDialog.LastName  = objAddbook.LastName.ToString();
         dlgAddressDialog.EmailId   = objAddbook.EmailId.ToString();
         dlgAddressDialog.phoneNo   = objAddbook.PhoneNo.ToString();
         dlgAddressDialog.Address1  = objAddbook.Address1.ToString();
         dlgAddressDialog.Address2  = objAddbook.Address2.ToString();
         dlgAddressDialog.Street    = objAddbook.Street.ToString();
         dlgAddressDialog.City      = objAddbook.City.ToString();
         dlgAddressDialog.ZipCode   = objAddbook.ZipCode;
         dlgAddressDialog.IsActive  = objAddbook.IsActive;
         if (dlgAddressDialog.ShowDialog() == DialogResult.OK)
         {
             objAddbookBO.UpdateAddress(objAddbook.AddressId, Convert.ToInt32(dlgAddressDialog.StateName), objAddbook.UserId, dlgAddressDialog.FirstName, dlgAddressDialog.LastName, dlgAddressDialog.EmailId, dlgAddressDialog.phoneNo, dlgAddressDialog.Address1, dlgAddressDialog.Address2, dlgAddressDialog.City, dlgAddressDialog.Street, dlgAddressDialog.ZipCode, Convert.ToBoolean(dlgAddressDialog.IsActive));
             if (Helper.Role == "Admin")
             {
                 BindDataToGrid();
                 btnAdd.Enabled = false;
             }
             else
             {
                 BindUserDataToGrid();
                 btnAdd.Enabled = true;
             }
         }
     }
 }