Esempio n. 1
0
        public Form2(Admin a)
        {
            count = 0;
            admin = a;
            LO    = o.read();
            LC    = c.read();
            LCT   = cT.read();
            InitializeComponent();
            DefaultImage = pictureBox1.Image;
            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);
            }

            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 < LCT.Count; i++)
            {
                typeCmbo.Items.Add(LCT[i].T_name);
                comboBox9.Items.Add(LCT[i].T_name);
                listBox1.Items.Add(LCT[i].T_name);
            }
        }
Esempio n. 2
0
        public Form3(Officer o)
        {
            officer = o;
            count   = 0;
            LO      = officer.read();
            LC      = c.read();
            LCT     = cT.read();
            InitializeComponent();

            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);
                }
            }

            for (int i = 0; i < LCT.Count; i++)
            {
                typeCmbo.Items.Add(LCT[i].T_name);
            }
        }
Esempio n. 3
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);
            }
        }