Ejemplo n.º 1
0
        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);
            }
        }
Ejemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            bool b = true;

            foreach (CrimeType CT in LCT)
            {
                if (CT.T_name == textBox1.Text)
                {
                    b = false;
                }
            }
            if (b)
            {
                CrimeType CT = new CrimeType();
                CT.T_name = textBox1.Text;
                CT.T_id   = LCT.Count.ToString();
                CT.write();
                if (!LCT.Contains(CT))
                {
                    LCT.Add(CT);
                }
                listBox1.Items.Add(CT.T_name);
                comboBox9.Items.Add(CT.T_name);
                typeCmbo.Items.Add(CT.T_name);
            }
            else
            {
                MessageBox.Show("Already exist");
            }
        }
Ejemplo n.º 3
0
        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);
            }
        }
Ejemplo n.º 4
0
        private void button1_Click(object sender, EventArgs e)
        {
            CrimeType ct = new CrimeType();

            for (int i = 0; i < LC.Count; i++)
            {
                if (comboBox2.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 < 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]);
                    }
                    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");
            itemsFound.Clear();
            Imgs.Clear();

            selectCmbo.Items.Clear();
            comboBox2.Items.Clear();
            for (int i = 0; i < LC.Count; i++)
            {
                if (LC[i].C_offId == officer.O_id && LC[i].C_Stat == true)
                {
                    comboBox2.Items.Add(LC[i].C_id);
                    selectCmbo.Items.Add(LC[i].C_id);
                }
            }
            MessageBox.Show("Updated");
        }
Ejemplo n.º 5
0
        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);
            }
        }