Ejemplo n.º 1
0
        private void btn_candidate_details_Click(object sender, RoutedEventArgs e)
        {
            BallotData   ballotData   = ((FrameworkElement)sender).DataContext as BallotData;
            BallotWindow ballotWindow = new BallotWindow(ballotData);

            ballotWindow.ShowDialog();
        }
Ejemplo n.º 2
0
        private void dgBallotMaster_SelectedCellsChanged(object sender, SelectedCellsChangedEventArgs e)   //selected cell event to perform edit delete and add candidate details
        {
            //SelectedCellsChanged="dgBallotMaster_SelectedCellsChanged" in xaml
            string selectedColumnHeader;

            try
            {
                selectedColumnHeader = (string)dgBallotMaster.SelectedCells[0].Column.Header;   // getting header of selected cell in datgrid
            }
            catch
            {
                return;
            }
            // var currentRowIndex = dgBallotMaster.Items.IndexOf(dgBallotMaster.CurrentItem);
            BallotData ballotData = (BallotData)dgBallotMaster.CurrentItem;  // getting all ballot data as class object of selected row

            //  BallotData ballotData = ((FrameworkElement)sender).DataContext as BallotData;  // for button click event
            // code to delete record
            if (selectedColumnHeader == "Delete")
            {
                MessageBoxResult messageBoxResult = MessageBox.Show("Are you sure you want to permanently delete this record?", "Delete record", MessageBoxButton.YesNo, MessageBoxImage.Question);
                //  MessageBoxResult messageBoxResult1 = MessageBox.Show("Are you sure you want to permanently delete this record?", "Delete record",me)
                if (messageBoxResult == MessageBoxResult.Yes)
                {
                    int ballotId = ballotData.BallotID;
                    deleteRow(ballotId);
                }
                else if (messageBoxResult == MessageBoxResult.No)
                {
                    return;
                }
            }

            // code to edit record
            if (selectedColumnHeader == "Edit")
            {
                btnUpdate.IsEnabled        = true;
                btnMasterDetails.IsEnabled = false;
                if (AddMasterBallot.Visibility == Visibility.Hidden)
                {
                    AddMasterBallot.Visibility = Visibility.Visible;
                }
                ballotIdToUpdate = ballotData.BallotID;
                if (ballotData.constituency == "Assembly")
                {
                    constituencyCombo.SelectedIndex = 1;
                }
                language2Combo.SelectedIndex = 1;
                stateCombo.SelectedValue     = ballotData.state;
                language1Combo.SelectedValue = ballotData.language1;
            }

            // code to open Ballot window
            if (selectedColumnHeader == "Candidate Details")
            {
                BallotWindow ballotWindow = new BallotWindow(ballotData);
                ballotWindow.ShowDialog();
            }
        }