public ICollection <Buse> ListerTotaleBusesUsine() { ICollection <Buse> Buses = new List <Buse>(); try { ICollection <Feeder> F_Energie = new List <Feeder>(); //textBox5.Text = DateTime.Now.Month.ToString(); SqlConnection conn = new SqlConnection(global::feeder.Properties.Settings.Default.connn); conn.Open(); SqlDataReader reader; SqlCommand cmd = new SqlCommand(String.Format(" SELECT [TB1],[TB2],[TB3],[TB4],[TB5],[TB6],[TB7],[TB8],[TB9],[TB10],[TB11],[TB12],[TB13],[TB14],[TB15],[TB16],[TB17],[TB18],[TB19],[TB20],[TB21],[TB22],[TB23],[TB24],[TB25],[TB26],[TB27],[TB28],[TB29],[TB30],[TB31],[TB32],[TB33] FROM [dbo].[prod] WHERE UF='Usine'"), conn); reader = cmd.ExecuteReader(); while (reader.Read()) { for (int i = 0; i < 33; i++) { Buse Buse = new Buse(); Buse.Quantite = Convert.ToInt32(reader.GetValue(i).ToString()); Buse.BuseID = "TB" + (i + 1); Buses.Add(Buse); } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } return(Buses); }
public ICollection <Buse> ListerBuses(string NomProduit) { ICollection <Buse> Buses = new List <Buse>(); try { //textBox5.Text = DateTime.Now.Month.ToString(); SqlConnection conn = new SqlConnection(global::feeder.Properties.Settings.Default.connn); conn.Open(); SqlDataReader reader; SqlCommand cmd = new SqlCommand(String.Format("SELECT * from dbo.prod WHERE nom ='{0}';", NomProduit), conn); reader = cmd.ExecuteReader(); while (reader.Read()) { for (int i = 7; i < 40; i++) { Buse Buse = new Buse(); Buse.Quantite = Convert.ToInt32(reader.GetValue(i).ToString()); Buse.BuseID = "TB" + (i - 6); Buses.Add(Buse); } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } return(Buses); }
public Etat EtatPrevision() { Etat e = new Etat(); e.Feeders = new List <Feeder>(); try { //textBox5.Text = DateTime.Now.Month.ToString(); SqlConnection conn = new SqlConnection(global::feeder.Properties.Settings.Default.connn); conn.Open(); SqlDataReader reader; SqlCommand cmd = new SqlCommand(String.Format(" SELECT [id],[jour],[TF1],[TF2],[TF3],[TF4],[TF5],[TF6],[TB1],[TB2],[TB3],[TB4],[TB5],[TB6],[TB7],[TB8],[TB9],[TB10],[TB11],[TB12],[TB13],[TB14],[TB15],[TB16],[TB17],[TB18],[TB19],[TB20],[TB21],[TB22],[TB23],[TB24],[TB25],[TB26],[TB27],[TB28],[TB29],[TB30],[TB31],[TB32],[TB33] FROM [dbo].[Prevision_etat] WHERE (ID=5) ;"), conn); int j = 2; int h = 8; reader = cmd.ExecuteReader(); while (reader.Read()) { e.Feeders = new List <Feeder>(); e.Buses = new List <Buse>(); e.EtatID = Convert.ToInt32(reader.GetValue(0)); e.NumEquipe = Convert.ToInt32(reader.GetValue(8)); for (int i = 0; i < 6; i++) { Feeder f = new Feeder { FedderID = "TF" + (i + 1), Quantite = Convert.ToInt32(reader.GetValue(j)) }; e.Feeders.Add(f); j++;// Convert.ToInt32(reader.GetValue(0)); } j = 2; for (int i = 0; i < 33; i++) { Buse b = new Buse { BuseID = "TB" + (i + 1), Quantite = Convert.ToInt32(reader.GetValue(h)) }; e.Buses.Add(b); h++;// Convert.ToInt32(reader.GetValue(0)); } h = 8; } conn.Close(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } return(e); }
public static void ChangeStatusAndAddMechanic() { Buse bus = new Buse { Id = busId, MechanicId = Guid.Empty, Status = "Исправен" }; busRepository = new BusRepository(); busRepository.Update(bus); }
//public void Delete(Guid busId) //{ // string query = $"Delete from Buses where Id={busId};"; // using (var connection = new SqlConnection(configurationService.connectionString)) // { // var rowsAffected = connection.Execute(query); // if (rowsAffected != 1) // { // throw new Exception("Error"); // } // } //} public void Update(Buse bus) { string query = "Update Buses set Status=@Status,MechanicId=@MechanicId where Id=@Id"; using (var connection = new SqlConnection(configurationService.connectionString)) { var rowsAffected = connection.Execute(query, bus); if (rowsAffected != 1) { throw new Exception("Error"); } } }
public void Add(Buse bus) { string query = "Insert into Buses values(@Id, @CreationDate, @DeletedDate,@BusNumber, @Numberplate,@Status,@MechanicId)"; using (var connection = new SqlConnection(configurationService.connectionString)) { var rowsAffected = connection.Execute(query, bus); if (rowsAffected != 1) { throw new Exception("Error"); } } }
public static void ChangeStatusAndAddMechanic(int mechanicNumber) { mechanicsRepository = new MechanicsRepository(); var allMechanics = mechanicsRepository.GetAll(); var mechanic = allMechanics.Skip(mechanicNumber - 1).Take(1).ToList(); Buse bus = new Buse { Id = busId, MechanicId = mechanic.FirstOrDefault().Id, Status = "На ремонте" }; busRepository = new BusRepository(); busRepository.Update(bus); }
public ICollection <Buse> ConfigBuse(string UF) { ICollection <Buse> Buses = new List <Buse>(); var buse_text = ""; for (int i = 1; i < 34; i++) { if (i < 33) { buse_text = buse_text + "[TB" + i + "],"; } else { buse_text = buse_text + "[TB" + i + "]"; } } try { //textBox5.Text = DateTime.Now.Month.ToString(); SqlConnection conn = new SqlConnection(global::feeder.Properties.Settings.Default.connn); conn.Open(); SqlDataReader reader; SqlCommand cmd = new SqlCommand(String.Format(" SELECT " + buse_text + " FROM [dbo].[reel] WHERE UF='" + UF + "' ;"), conn); reader = cmd.ExecuteReader(); while (reader.Read()) { for (int i = 0; i < 33; i++) { Buse b = new Buse { coordonnee = "TB" + (i + 1), Quantite = Convert.ToInt32(reader.GetValue(i)) }; Buses.Add(b); } } conn.Close(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } return(Buses); }
private static void CreateBusData() { firstBus = new Buse { BusNumber = "21", Numberplate = "845KGN", Status = "На ремонте", MechanicId = secondMechanic.Id }; secondBus = new Buse { BusNumber = "5A", Numberplate = "845KFN", Status = "Сломан" }; thirdBus = new Buse { BusNumber = "51", Numberplate = "153HFM", Status = "Сломан" }; }
public Etat RechercherDernierEtat(string UF, string type) { Etat e = new Etat(); e.Feeders = new List <Feeder>(); try { //textBox5.Text = DateTime.Now.Month.ToString(); SqlConnection conn = new SqlConnection(global::feeder.Properties.Settings.Default.connn); conn.Open(); SqlDataReader reader; SqlCommand cmd = new SqlCommand(String.Format(" SELECT [id],[jour],[TF1],[TF2],[TF3],[TF4],[TF5],[TF6],[TB1],[TB2],[TB3],[TB4],[TB5],[TB6],[TB7],[TB8],[TB9],[TB10],[TB11],[TB12],[TB13],[TB14],[TB15],[TB16],[TB17],[TB18],[TB19],[TB20],[TB21],[TB22],[TB23],[TB24],[TB25],[TB26],[TB27],[TB28],[TB29],[TB30],[TB31],[TB32],[TB33] FROM [dbo].[nouveau_etat] WHERE UF='" + UF + "' AND type='" + type + "' ;"), conn); int j = 2; int h = 8; reader = cmd.ExecuteReader(); while (reader.Read()) { e.Buses = new List <Buse>(); e.Feeders = new List <Feeder>(); e.EtatID = Convert.ToInt32(reader.GetValue(0)); for (int i = 0; i < 6; i++) { if (reader.IsDBNull(j)) { Feeder f = new Feeder { Coordonnee = "TF" + (i + 1), Quantite = 0 }; e.Feeders.Add(f); } else { Feeder f = new Feeder { Coordonnee = "TF" + (i + 1), Quantite = Convert.ToInt32(reader.GetValue(j)) }; e.Feeders.Add(f); } j++;// Convert.ToInt32(reader.GetValue(0)); } j = 2; for (int i = 0; i < 33; i++) { if (reader.IsDBNull(h)) { Buse b = new Buse { coordonnee = "TB" + (i + 1), Quantite = 0 }; e.Buses.Add(b); } else { Buse b = new Buse { coordonnee = "TB" + (i + 1), Quantite = Convert.ToInt32(reader.GetValue(h)) }; e.Buses.Add(b); } h++;// Convert.ToInt32(reader.GetValue(0)); } h = 8; } conn.Close(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } return(e); }