void OnEnable() { Colection c = manager.ds.GetColection(coleccao_id); name_text.text = c.name; if (c.pacotes_in_collection < c.total_pacotes) { pacotes_total.text = c.pacotes_in_collection + "/" + c.total_pacotes; } foreach (Transform child in todos.transform) { Destroy(child.gameObject); } pacotes = manager.ds.GetPacotesInColection(coleccao_id); foreach (Pacote p in pacotes) { GameObject pacote = (GameObject)Instantiate(pacote_prefab, pacote_prefab.transform.position, pacote_prefab.transform.rotation); pacote.transform.SetParent(todos.transform, false); PacotePrefab pa = pacote.GetComponent <PacotePrefab>(); pa.toggle.isOn = p.in_collection; pa.num_pacote.text = "" + p.number; pa.collection_id = p.collection_id; pa.pacote_id = p.Id; } todos_btn.color = selected; em_falta_btn.color = unselected; adquiridos_btn.color = unselected; }
public void AdicionarRemoverPacote() { GameObject manager_object = GameObject.FindGameObjectWithTag("Manager"); Manager manager = manager_object.GetComponent <Manager>(); if (toggle.isOn) { manager.ds.AddPacoteToCollection(collection_id, pacote_id); } else { manager.ds.RemovePacoteFromCollection(collection_id, pacote_id); } GameObject vercoleccao_object = GameObject.Find("VerColeccao"); VerColeccao ver_coleccao = vercoleccao_object.GetComponent <VerColeccao>(); Colection c = manager.ds.GetColection(collection_id); if (c != null) { if (c.pacotes_in_collection < c.total_pacotes) { ver_coleccao.pacotes_total.text = c.pacotes_in_collection + "/" + c.total_pacotes; } else { ver_coleccao.pacotes_total.text = "Completa"; } } }
public virtual string Remove() { string element = Colection[Colection.Count - 1]; Colection.RemoveAt(Colection.Count - 1); return(element); }
public void Guardar() { if (nome.text.Length > 0 && total.text.Length > 0) { Colection c = manager.ds.InsertCollection(nome.text, Int32.Parse(total.text)); manager.GotoVerColeccao(c.Id); } }
public void AddPacoteToCollection(int collection_id, int pacote_id) { if (_connection.Table <Pacote>().Where(x => x.Id == pacote_id).FirstOrDefault() != null) { Colection c = _connection.Table <Colection>().Where(x => x.Id == collection_id).FirstOrDefault(); c.AddPacote(pacote_id, _connection); } }
public bool RemoveRabbit(string name) { bool check = false; if (Colection.ContainsKey(name)) { Colection.Remove(name); check = true; } return(check); }
public void DeleteColection(int collection_id) { IEnumerable <Pacote> pacotes = _connection.Table <Pacote>().Where(x => x.collection_id == collection_id); foreach (Pacote p in pacotes) { _connection.Delete(p); } Colection collection = _connection.Table <Colection>().Where(x => x.Id == collection_id).FirstOrDefault(); _connection.Delete(collection); }
public List <Colection> GetService() { List <Colection> listcolection = new List <Colection>(); // khoi tao doi tuong conection String conectionDB = "Data Source=DESKTOP-T9F2UQQ;Initial Catalog=MysterArtStudio;Integrated Security=True"; SqlConnection sqlConnection = new SqlConnection(conectionDB); // khoi tao doi tuong sqlcommand cho phep thao tac voi csdl SqlCommand sqlCommand = sqlConnection.CreateCommand(); sqlCommand.CommandText = "SElECT * FROM Colection "; //Mo ket noi DB sqlConnection.Open(); //sqlConnection1.Open(); // thuc thi cau truy van SqlDataReader sqlDataReader = sqlCommand.ExecuteReader(); while (sqlDataReader.Read()) { var colection = new Colection(); for (int i = 0; i < sqlDataReader.FieldCount; i++) { // lay ten cot du lieu dang doc var colName = sqlDataReader.GetName(i); // lay gia tri cot dang doc var value = sqlDataReader.GetValue(i); // lay property co ten giong voi gia tri lay ra o tren var property = colection.GetType().GetProperty(colName); if (property != null) { property.SetValue(colection, value); } } listcolection.Add(colection); } return(listcolection); }
public string Report() { Dictionary <string, Rabbit> report = new Dictionary <string, Rabbit>(); report = Colection.Where(x => x.Value.Available != false).ToDictionary(x => x.Key, x => x.Value); StringBuilder sb = new StringBuilder(); sb.AppendLine($"Rabbit available at {Name}"); foreach (var item in report) { sb.AppendLine(item.Value.ToString()); } return(sb.ToString()); }
public Rabbit[] SellRabbitsBySpecies(string species) { Rabbit[] rabbits = new Rabbit[20]; foreach (var item in Colection) { if (item.Value.Species == species) { item.Value.Available = false; } } Colection. rabbits = Colection.Where(x => x.Value.Available == false).Select(x => x.Value).ToArray(); return(rabbits); }
public Colection InsertCollection(string name_collection, int total_pacotes_collection) { var colection = new Colection { name = name_collection, total_pacotes = total_pacotes_collection, pacotes_in_collection = 0 }; _connection.Insert(colection); Debug.Log(colection.Id); for (int i = 0; i < total_pacotes_collection; i++) { colection.AddPacoteEntry(i + 1, _connection); } return(colection); }
public bool PostColection([FromBody] Colection colection) { String conectionDB = "Data Source=DESKTOP-T9F2UQQ;Initial Catalog=MysterArtStudio;Integrated Security=True"; SqlConnection sqlConnection = new SqlConnection(conectionDB); SqlCommand sqlCommand = sqlConnection.CreateCommand(); sqlCommand.CommandType = System.Data.CommandType.Text; sqlCommand.CommandText = "INSERT INTO Colection(Name,ServiceID)VALUES(@Name,@ServiceID)"; sqlCommand.Parameters.AddWithValue("@Name", colection.Name); sqlCommand.Parameters.AddWithValue("@ServiceID", colection.Service.ServiceID); sqlConnection.Open(); var result = sqlCommand.ExecuteNonQuery(); sqlConnection.Close(); return(true); }
public override int Add(string element) { Colection.Insert(0, element); return(0); }
public void RemoveSpecies(string species) { Colection = Colection.Where(x => x.Value.Species != species).ToDictionary(x => x.Key, x => x.Value); }
public void RemovePacoteFromCollection(int collection_id, int pacote_id) { Colection c = _connection.Table <Colection>().Where(x => x.Id == collection_id).FirstOrDefault(); c.RemovePacote(pacote_id, _connection); }
public List <Image> GetAllImage() { List <Image> listImage = new List <Image>(); // khoi tao doi tuong conection String conectionDB = "Data Source=DESKTOP-T9F2UQQ;Initial Catalog=MysterArtStudio;Integrated Security=True"; SqlConnection sqlConnection = new SqlConnection(conectionDB); // khoi tao doi tuong sqlcommand cho phep thao tac voi csdl SqlCommand sqlCommand = sqlConnection.CreateCommand(); sqlCommand.CommandText = "SElECT * FROM images AS i ,Colection AS c WHERE c.ColectionID = i.ColectionID "; //Mo ket noi DB sqlConnection.Open(); //sqlConnection1.Open(); // thuc thi cau truy van SqlDataReader sqlDataReader = sqlCommand.ExecuteReader(); // xu ly ket qua tra ve while (sqlDataReader.Read()) { var image = new Image(); var colection = new Colection(); for (int i = 0; i < sqlDataReader.FieldCount; i++) { // lay ten cot du lieu dang doc var colName = sqlDataReader.GetName(i); // lay gia tri cot dang doc var value = sqlDataReader.GetValue(i); // lay property co ten giong voi gia tri lay ra o tren var property = image.GetType().GetProperty(colName); if (colName == "ColectionID") { colection.ColectionID = Int32.Parse(value.ToString()); } if (colName == "Name") { colection.Name = value.ToString(); var propertyColection = image.GetType().GetProperty("Colection"); propertyColection.SetValue(image, colection); } if (property != null) { property.SetValue(image, value); } } // them doi tuong vao list listImage.Add(image); } //dong ket noi sqlConnection.Close(); return(listImage); }