private void selectCmbo_SelectedIndexChanged(object sender, EventArgs e) { CrimeType ct = new CrimeType(); for (int i = 0; i < LC.Count; i++) { if (selectCmbo.Text == LC[i].C_id) { c = LC[i]; } } for (int i = 0; i < LCT.Count; i++) { if (c.C_Tid == LCT[i].T_id) { ct = LCT[i]; } } typeCmbo.Text = ct.T_name; textBox2.Text = c.C_desc; statusCmbo.Text = c.C_Stat.ToString(); officerCmbo.Text = c.C_offId; areaCmbo.Text = c.C_Area; ImgsUpdate = c.C_Imgs; count = 0; if (ImgsUpdate.Count != 0) { MemoryStream ms = new MemoryStream(ImgsUpdate[0]); pictureBox1.Image = Image.FromStream(ms); } }
private void comboBox2_SelectedIndexChanged(object sender, EventArgs e) { CrimeType ct = new CrimeType(); for (int i = 0; i < LC.Count; i++) { if (comboBox2.Text == LC[i].C_id) { c = LC[i]; } } for (int i = 0; i < LCT.Count; i++) { if (c.C_Tid == LCT[i].T_id) { ct = LCT[i]; } } typeCmbo.Text = ct.T_name; textBox2.Text = c.C_desc; statusCmbo.Text = c.C_Stat.ToString(); areaCmbo.Text = c.C_Area; for (int i = 0; i < c.C_item.Count; i++) { itemsCmbo.Items.Add(c.C_item[i]); } comboBox6.Items.Clear(); for (int i = 0; i < c.C_IP.Count; i++) { comboBox6.Items.Add(c.C_IP[i].IP_name); } ImgsUpdate = c.C_Imgs; count = 0; if (ImgsUpdate.Count != 0) { MemoryStream ms = new MemoryStream(); ms = new MemoryStream(ImgsUpdate[0]); pictureBox1.Image = Image.FromStream(ms); } }
private void doneBtn_Click(object sender, EventArgs e) { if (selectCmbo.Text == "Select Crime ID") { MessageBox.Show("Please select crime.", "Tips", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { Crime cs = new Crime(); for (int i = 0; i < LC.Count; i++) { if (selectCmbo.Text == LC[i].C_id) { cs = LC[i]; break; } } List <involved> ListPeople = new List <involved>(); for (int i = 0; i < cs.C_IP.Count; i++) { involved pp = new involved(); pp.score = 0; pp.person = cs.C_IP[i].IP_name; if (cs.C_IP[i].IP_disp == true) { pp.score++; } for (int j = 0; j < LCT.Count; j++) { if (cs.C_Tid == LCT[i].T_id) { if (cs.C_IP[i].Pasthist == LCT[j].T_name) { pp.score++; break; } } } if (cs.C_IP[i].IP_locatoin == cs.C_Area) { pp.score++; } ListPeople.Add(pp); } for (int i = 0; i < ListPeople.Count; i++) { for (int j = i; j < ListPeople.Count; j++) { if (ListPeople[j].score < ListPeople[i].score) { involved tmp = ListPeople[j]; ListPeople[j] = ListPeople[i]; ListPeople[i] = tmp; } } } int max = ListPeople[ListPeople.Count - 1].score; label2.Text = ""; label2.Visible = true; for (int i = 0; i < ListPeople.Count; i++) { if (ListPeople[i].score == max && label2.Text == "") { label2.Text += ListPeople[i].person; } else if (ListPeople[i].score == max && label2.Text != "") { label2.Text += (" and " + ListPeople[i].person); } } } }
private void button7_Click(object sender, EventArgs e) { if (button7.Text == "Add") { Officer officer = new Officer(); officer.O_id = LO.Count.ToString(); officer.O_name = bunifuMetroTextbox1.Text; officer.assigNum = 0; officer.O_Password = bunifuMetroTextbox3.Text; officer.write(); LO.Add(officer); MessageBox.Show("Added"); } else if (button7.Text == "Delete") { Officer officer = new Officer(); Crime crime = new Crime(); foreach (Crime obj in LC) { if (obj.C_offId == comboBox6.Text) { obj.C_offId = ""; } } foreach (Officer item in LO) { if (item.O_id == comboBox6.Text) { LO.Remove(item); break; } } FileStream FS = new FileStream("Officer.xml", FileMode.Truncate); XmlSerializer ser = new XmlSerializer(LO.GetType()); ser.Serialize(FS, LO); FS.Close(); FileStream fS = new FileStream("Crime.xml", FileMode.Truncate); fS.Close(); fS = new FileStream("Crime.xml", FileMode.Append); XmlSerializer Ser = new XmlSerializer(LC.GetType()); Ser.Serialize(fS, LC); fS.Close(); MessageBox.Show("Deleted"); } else if (button7.Text == "Update") { for (int i = 0; i < LO.Count; i++) { if (comboBox6.Text == LO[i].O_id) { LO[i].O_name = bunifuMetroTextbox1.Text; break; } } FileStream FS = new FileStream("Officer.xml", FileMode.Truncate); FS.Close(); FS = new FileStream("Officer.xml", FileMode.Append); XmlSerializer ser = new XmlSerializer(LO.GetType()); ser.Serialize(FS, LO); FS.Close(); MessageBox.Show("Updated"); } comboBox6.Items.Clear(); officerCmbo.Items.Clear(); for (int i = 0; i < LO.Count; i++) { if (LO[i].assigNum < 10) { officerCmbo.Items.Add(LO[i].O_id); } comboBox6.Items.Add(LO[i].O_id); } }
private void doneBtn_Click(object sender, EventArgs e) { if (doneBtn.Text == "Add") { Crime crime = new Crime(); string cName = typeCmbo.Text; for (int i = 0; i < LCT.Count; i++) { if (LCT[i].T_name == cName) { crime.C_Tid = LCT[i].T_id; } } crime.C_offId = officerCmbo.Text; for (int j = 0; j < LO.Count; j++) { if (officerCmbo.Text == LO[j].O_id) { LO[j].assigNum++; } } List <Crime> clist = crime.read(); crime.C_id = clist.Count.ToString(); crime.C_Area = areaCmbo.Text; string boolean = statusCmbo.Text; if (boolean == "Opened") { crime.C_Stat = true; } else { crime.C_Stat = false; } crime.C_desc = textBox2.Text; crime.C_item = itemsFound; crime.C_Imgs = Imgs; crime.C_IP = ipl; crime.write(); LC.Add(crime); ipl.Clear(); itemsFound.Clear(); Imgs.Clear(); FileStream FS = new FileStream("Officer.xml", FileMode.Truncate); FS.Close(); FS = new FileStream("Officer.xml", FileMode.Append); XmlSerializer ser = new XmlSerializer(LO.GetType()); ser.Serialize(FS, LO); FS.Close(); pictureBox1.Image = DefaultImage; MessageBox.Show("Added"); } else if (doneBtn.Text == "Delete") { for (int i = 0; i < LC.Count; i++) { if (LC[i].C_id == selectCmbo.Text) { for (int j = 0; j < LO.Count; j++) { if (LC[i].C_offId == LO[j].O_id) { LO[j].assigNum--; } } LC.RemoveAt(i); } } FileStream fS = new FileStream("Officer.xml", FileMode.Truncate); fS.Close(); fS = new FileStream("Officer.xml", FileMode.Append); XmlSerializer Ser = new XmlSerializer(LO.GetType()); Ser.Serialize(fS, LO); fS.Close(); FileStream FS = new FileStream("Crime.xml", FileMode.Truncate); FS.Close(); FS = new FileStream("Crime.xml", FileMode.Append); XmlSerializer ser = new XmlSerializer(LC.GetType()); ser.Serialize(FS, LC); FS.Close(); MessageBox.Show("Deleted"); } else if (doneBtn.Text == "Update") { CrimeType ct = new CrimeType(); for (int i = 0; i < LC.Count; i++) { if (selectCmbo.Text == LC[i].C_id) { for (int j = 0; j < LCT.Count; j++) { if (LCT[j].T_name == typeCmbo.Text) { LC[i].C_Tid = LCT[j].T_id; break; } } LC[i].C_desc = textBox2.Text; string b = statusCmbo.Text; if (b == "Opened") { LC[i].C_Stat = true; } else { LC[i].C_Stat = false; } for (int j = 0; j < LO.Count; j++) { if (LC[i].C_offId == LO[j].O_id) { LO[j].assigNum--; } } for (int j = 0; j < itemsFound.Count; j++) { LC[i].C_item.Add(itemsFound[j]); } for (int j = 0; j < Imgs.Count; j++) { LC[i].C_Imgs.Add(Imgs[j]); } for (int j = 0; j < ipl.Count; j++) { LC[i].C_IP.Add(ipl[j]); } LC[i].C_offId = officerCmbo.Text; for (int j = 0; j < LO.Count; j++) { if (LC[i].C_offId == LO[j].O_id) { LO[j].assigNum++; } } LC[i].C_Area = areaCmbo.Text; break; } } FileStream fS = new FileStream("Officer.xml", FileMode.Truncate); fS.Close(); fS = new FileStream("Officer.xml", FileMode.Append); XmlSerializer Ser = new XmlSerializer(LO.GetType()); Ser.Serialize(fS, LO); fS.Close(); FileStream FS = new FileStream("Crime.xml", FileMode.Truncate); FS.Close(); FS = new FileStream("Crime.xml", FileMode.Append); XmlSerializer ser = new XmlSerializer(LC.GetType()); ser.Serialize(FS, LC); FS.Close(); MessageBox.Show("Updated"); ipl.Clear(); itemsFound.Clear(); Imgs.Clear(); } officerCmbo.Items.Clear(); comboBox6.Items.Clear(); selectCmbo.Items.Clear(); for (int i = 0; i < LO.Count; i++) { if (LO[i].assigNum < 10) { officerCmbo.Items.Add(LO[i].O_id); } } for (int i = 0; i < LO.Count; i++) { comboBox6.Items.Add(LO[i].O_id); } for (int i = 0; i < LC.Count; i++) { selectCmbo.Items.Add(LC[i].C_id); } }