예제 #1
0
 private void editOfficerButton_Click(object sender, EventArgs e)
 {
     if (officerIDTextBox.Text != string.Empty)
     {
         List <UserInfo> temp = DataQuery.runQuery(officerIDTextBox.Text);
         try {
             UserInfo officer = temp.First();
             officerID = officer.UserInfoID;
             officerFirstNameTextBox.Text = officer.First_name;
             officerLastNameTextBox.Text  = officer.Last_name;
             officerPictureBox.Image      = ImageTools.Base64ToImage(officer.Link);
             officerPictureBox.SizeMode   = PictureBoxSizeMode.StretchImage;
             var appPath = Application.StartupPath;
             Console.WriteLine(appPath + "Hello");
             var constring = @"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=" +
                             appPath + "\\CriminalRecord.mdf;Integrated Security=True";
             var    con = new SqlConnection(constring);
             string sql = "SELECT Department_Name FROM Department WHERE Department_ID=" + officer.Officer_Department;
             var    com = new SqlCommand(sql, con);
             con.Open();
             var read = com.ExecuteReader();
             while (read.Read())
             {
                 officerDepartmentComboBox.Text = read.GetString(0);
             }
             con.Close();
         } catch {
             MessageBox.Show("No Officer found", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     else
     {
         MessageBox.Show("Please enter officer ID", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
예제 #2
0
        private void fillInData(string id)
        {
            var appPath   = Application.StartupPath;
            var constring = @"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=" +
                            appPath + "\\CriminalRecord.mdf;Integrated Security=True;";
            var con = new SqlConnection(constring);

            if (con.State != ConnectionState.Open)
            {
                con.Open();
            }
            var sql     = "SELECT * FROM Committed_Target WHERE Committed_Target_ID =" + id;
            var command = new SqlCommand(sql, con);
            var read    = command.ExecuteReader();

            while (read.Read())
            {
                idTextBox.Text              = read.GetInt32(0).ToString();
                firstNameTextBox.Text       = read.GetString(1);
                lastNameTextBox.Text        = read.GetString(1);
                birthdayDatePicker.DateTime = read.GetDateTime(2);
                genderComboBox.Text         = read.GetString(9);
                trialDayDatePicker.DateTime = read.GetDateTime(7);
                jailNumberTextBox.Text      = read.GetString(6);
                buildTextBox.Text           = read.GetString(10);
                crimesTextBox.Text          = read.GetString(8);
                heightTextBox.Text          = read.GetString(11);
                eyesTextBox.Text            = read.GetString(12);
                hairTextBox.Text            = read.GetString(13);
                image = read.GetString(14);
                suspectPictureBox.Image = ImageTools.Base64ToImage(read.GetString(14));
            }
            con.Close();
        }