コード例 #1
0
        /// <summary>
        /// event method of delete button
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DeleteButton_Click(object sender, EventArgs e)
        {
            //assertion of text box
            if (DeleteIdTextBox.Text != "")
            {
                //variables needed to delete criminal
                var selectedCriminalIndex = Int32.Parse(DeleteIdTextBox.Text);
                var deleteCriminal        = _criminals.GetById(selectedCriminalIndex);

                //asssertion of index
                if (deleteCriminal != null)
                {
                    //delete criminal
                    _criminals.DeleteById(deleteCriminal.Id);
                    _criminals.Save();



                    LoadCriminals();
                }
                else
                {
                    MessageBox.Show("Insert proper ID");
                }
            }
            else
            {
                MessageBox.Show("Insert ID");
            }
            //clear text box
            DeleteIdTextBox.Text = "";
        }
コード例 #2
0
        //event of delete button method
        private void DeleteButton_Click(object sender, EventArgs e)
        {
            //assertion of text box
            if (DeleteIdTextBox.Text != "")
            {
                var selectedAgentIndex = Int32.Parse(DeleteIdTextBox.Text);
                var deleteAgent        = _agentsUndercover.GetById(selectedAgentIndex);

                //assertion of non exsting ID
                if (deleteAgent != null)
                {
                    var deleteCriminal = _criminalsUndercover.GetById(deleteAgent.AgentCriminalId);


                    _criminalsUndercover.DeleteById(deleteCriminal.Id);
                    _criminalsUndercover.Save();



                    LoadAgents();
                    LoadCriminals();
                }
                else
                {
                    MessageBox.Show("Insert proper ID");
                }
            }
            else
            {
                MessageBox.Show("Insert ID");
            }

            //clear text box
            DeleteIdTextBox.Text = "";
        }
コード例 #3
0
        /// <summary>
        /// event method of delete button
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DeleteButton_Click(object sender, EventArgs e)
        {
            //assertion text box
            if (DeleteIdTextBox.Text != "")
            {
                //variables needed to delete agentfrom table
                var selectedAgentIndex = Int32.Parse(DeleteIdTextBox.Text);
                var deleteAgent        = _agents.GetById(selectedAgentIndex);

                //assertio n of index
                if (deleteAgent != null)
                {
                    //delete agent
                    _agents.DeleteById(deleteAgent.Id);
                    _agents.Save();



                    LoadAgents();
                }
                else
                {
                    MessageBox.Show("Insert proper ID");
                }
            }
            else
            {
                MessageBox.Show("Insert ID");
            }
            //clear text box
            DeleteIdTextBox.Text = "";
        }