/// <summary>
        /// Called when a cell in the DataGridView (which is displaying search results) is clicked. It is used to open the UserDetail form.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void userDetails(object sender, DataGridViewCellEventArgs e)
        {
            //Getting the value of clicked row
            DataGridView button = sender as DataGridView;
            DataGridViewCellCollection selectedUser = button.CurrentRow.Cells as DataGridViewCellCollection;

            //Returns the selected customer ID
            int selectedCustomerId = Int32.Parse(selectedUser["CustomerId"].Value.ToString());

            UserDetail.setCustomerId(selectedCustomerId);

            //If this user has been deleted in another window, display error message.
            CustomerDetail selectedCustomer = db.CustomerDetails.Where(x => x.CustomerId == selectedCustomerId && x.isDeleted.Equals("N")).FirstOrDefault();
            if (selectedCustomer == null)
            {
                MessageBox.Show("User not found. He/She may have been deleted.", "Error");
                return;
            }

            //Invoke the UserDetails form.
            UserDetail userDetail = new UserDetail();
            userDetail.Show();
        }
示例#2
0
        private void linkLabel_thisUsersDetails_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            UserDetail.setCustomerId(selectedCustomerId);

            //If this user has been deleted in another window, display error message.
            CustomerDetail selectedCustomer = db.CustomerDetails.Where(x => x.CustomerId == selectedCustomerId && x.isDeleted.Equals("N")).FirstOrDefault();
            if (selectedCustomer == null)
            {
                MessageBox.Show("User not found. He/She may have been deleted.", "Error");
                return;
            }

            //Invoke the UserDetails form.
            UserDetail userDetail = new UserDetail();
            userDetail.Show();
        }