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(); } }
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(); } }
public LostChild(Size pSize, Hat pHat, Color pColor, StolenItem pStolenItem) { size = pSize; hat = pHat; color = pColor; stolenItem = pStolenItem; }
//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()); }
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()); }
protected override void OnTarget(Mobile from, object target) { Item stolen = null; object root = null; bool caught = false; if (target is Item) { root = ((Item)target).RootParent; stolen = TryStealItem((Item)target, ref caught); } else { m_Thief.SendLocalizedMessage(502710); // You can't steal that! } if (stolen != null) { from.AddToBackpack(stolen); StolenItem.Add(stolen, m_Thief, root as Mobile); } if (caught) { if (root is Mobile) { Mobile mobRoot = (Mobile)root; string message = String.Format("Vous remarquer {0} voler un objet de {1}.", m_Thief.Name, mobRoot.Name); foreach (NetState ns in m_Thief.GetClientsInRange(8)) { if (ns.Mobile != m_Thief) { NubiaPlayer obs = ns.Mobile as NubiaPlayer; if (obs.Competences[CompType.Detection].roll(10 + (int)obs.GetDistanceToSqrt(m_Thief), true)) { ns.Mobile.SendMessage(message); } } } } } }