示例#1
0
 public Victim(String name, String date_of_birth, StolenItem[] items_stolen, String gender, bool is_student, int crime_id)
 {
     this.name = name;
     this.date_of_birth = date_of_birth;
     this.items_stolen = items_stolen;
     this.gender = gender;
     this.is_a_student = is_student;
     this.crime_id = crime_id;
 }
示例#2
0
        public static StolenItem[] GetVictimsStolenItems(int victim_id)
        {
            List<StolenItem> stolen_items = new List<StolenItem>();
            try
            {
                //SELECT SQL
                String select_sql               = "SELECT * FROM " + TABLE_NAME + " WHERE VICTIM_ID=@id";

                sql_command                     = new MySqlCommand();
                sql_command.Connection          = (MySqlConnection)database.OpenConnection();
                sql_command.CommandText         = select_sql;
                sql_command.Parameters.AddWithValue("@id",victim_id);
                sql_command.Prepare();

                //GET RESULTS IN ENUM OBJECT
                data_reader                     = database.Select(sql_command);

                //LOOP THRU EM
                while (data_reader.Read())
                {
                    //CREATE STOLEN ITEM
                    int id                      = data_reader.GetInt32(ID);
                    String name_of_item         = data_reader.GetString(NAME_OF_ITEM);

                    StolenItem stolen_item              = new StolenItem(id,name_of_item,victim_id);

                    //ADD ITEM TO LIST
                    stolen_items.Add(stolen_item);
                }

            }
            catch (Exception e)
            {
                Debug.WriteLine(e.Message);

            }
            finally
            {
                CloseDatabaseConnection();
            }

            //RETURN ARRAY OF RESULTS
            return stolen_items.ToArray();
        }
示例#3
0
        public static bool Save(StolenItem item)
        {
            try
            {
                String insert_sql = "INSERT INTO " + TABLE_NAME + " (NAME_OF_ITEM,VICTIM_ID) VALUES(@name_of_item,@victim_id)";

                //Sql command
                sql_command = new MySqlCommand();
                sql_command.Connection = (MySqlConnection)database.OpenConnection();
                sql_command.CommandText = insert_sql;

                sql_command.Parameters.AddWithValue("@name_of_item", item.name_of_item);
                sql_command.Parameters.AddWithValue("@victim_id", item.victims_id);
                sql_command.Prepare();

                database.Insert(sql_command);

                item.id = Convert.ToInt32(sql_command.LastInsertedId);
                return true;
            }
            catch (Exception)
            {
                return false;
            }
            finally
            {
                CloseDatabaseConnection();
            }
        }
示例#4
0
        public static bool Update(StolenItem item)
        {
            try
            {
                //sql statement
                String update_sql = "UPDATE ITEMS_STOLEN SET NAME=@item_name AND VICTIM_ID=@victim_id WHERE ID=@id";

                //Sql command
                sql_command = new MySqlCommand();
                sql_command.Connection = (MySqlConnection)database.OpenConnection();
                sql_command.CommandText = update_sql;

                sql_command.Parameters.AddWithValue("@id", item.id);
                sql_command.Parameters.AddWithValue("@victim_id", item.victims_id);
                sql_command.Parameters.AddWithValue("@name", item.name_of_item);

                sql_command.Prepare();

                //execute command
                database.Update(sql_command);

                return true;
            }
            catch (Exception)
            {
                return false;
            }
            finally
            {
                CloseDatabaseConnection();
            }
        }
示例#5
0
        //GETS THE ITEMS LOST OR STOLEN FROM THE VICTIM
        private StolenItem[] GetItemsLost()
        {
            String items_stolen                               = items_lost_textbox.Text;
            String[] items                                    = items_stolen.Split(new string[]{","}, StringSplitOptions.RemoveEmptyEntries);
            List<StolenItem> stolen                           = new List<StolenItem>();

            foreach (var item in items)
            {
                StolenItem stolen_item                        = new StolenItem(item, -1);
                stolen.Add(stolen_item);
            }

            return stolen.ToArray();
        }