public ActionResult InterogareUnu(List <Interogare1> x) { List <Interogare1> clienti = new List <Interogare1>(); SqlConnection connection = new SqlConnection("data source = DESKTOP-IBNRKP3\\SQLEXPRESS; initial catalog = BD_Project; integrated security = True"); SqlCommand cmd = new SqlCommand(@" select c1.Nume, c1.Prenume, cl1.Pret from Client c1 inner join Comenzi cl1 on c1.IdClient = cl1.IdClient where " + x[0].count + @" > (select count(*) from Client c2 inner join Comenzi cl2 on cl2.IdClient = c2.IdClient where cl1.Pret < cl2.Pret) ", connection); connection.Open(); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { Interogare1 interogare = new Interogare1(); Client y = new Client(); Comenzi z = new Comenzi(); y.Nume = reader.GetString(0); y.Prenume = reader.GetString(1); z.Pret = reader.GetDecimal(2); interogare.client = y; interogare.comanda = z; clienti.Add(interogare); } reader.Close(); return(View(clienti)); }
//clientii cu pretul comenzii > media tuturor comenzilor public ActionResult InterogareDoi() { List <Interogare1> clienti = new List <Interogare1>(); SqlConnection connection = new SqlConnection("data source = DESKTOP-IBNRKP3\\SQLEXPRESS; initial catalog = BD_Project; integrated security = True"); SqlCommand cmd = new SqlCommand(@" select cl.Nume, cl.Prenume, c.IdComenzi, c.TimpStart, c.TimpStop, c.Pret from Comenzi c inner join Client cl on cl.IdClient = c.IdClient where c.Pret > (select avg(Pret) from Comenzi )", connection); connection.Open(); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { Interogare1 x = new Interogare1(); Client y = new Client(); Comenzi z = new Comenzi(); y.Nume = reader.GetString(0); y.Prenume = reader.GetString(1); z.IdComenzi = reader.GetInt32(2); z.TimpStart = reader.GetDateTime(3); z.TimpStop = reader.GetDateTime(4); z.Pret = reader.GetDecimal(5); x.client = y; x.comanda = z; clienti.Add(x); } reader.Close(); return(View(clienti)); }
public ClientDetailsDTO Get(int id) { Client Client = IClientRepository.Get(id); ClientDetailsDTO MyClient = new ClientDetailsDTO() { Nume = Client.Nume, DataNasterii = Client.DataNasterii, Email = Client.Email, Adresa = Client.Adresa, TipId = Client.TipId }; IEnumerable <Comenzi> MyComenzi = IComenziRepository.GetAll().Where(x => x.ClientId == Client.Id); if (MyComenzi != null) { List <float> ComenziSumaList = new List <float>(); foreach (Comenzi myComanda in MyComenzi) { Comenzi comanda = IComenziRepository.GetAll().SingleOrDefault(x => x.Id == myComanda.Id); ComenziSumaList.Add(comanda.SumaTotala); } MyClient.SumaTotala = ComenziSumaList; } return(MyClient); }
public Comenzi Delete(Comenzi Comenzi) { var result = _context.Remove(Comenzi); _context.SaveChanges(); return(result.Entity); }
public Comenzi Create(Comenzi comenzi) { var result = _context.Add <Comenzi>(comenzi); _context.SaveChanges(); return(result.Entity); }
public ActionResult ListaComenziExpiratePerClient(int?id = null) { List <Comenzi> comenzi = new List <Comenzi>(); DateTime azi = DateTime.Now; SqlConnection connection = new SqlConnection("data source = DESKTOP-IBNRKP3\\SQLEXPRESS; initial catalog = BD_Project; integrated security = True"); SqlCommand cmd = new SqlCommand(@" select c.IdComenzi, c.TimpStart, c.TimpStop, c.IdClient from Comenzi c inner join Comenzi_Biciclete cb on c.IdComenzi = cb.IdComenzi where IdClient = " + id + " group by c.IdComenzi, c.TimpStart, c.TimpStop, c.IdClient", connection); connection.Open(); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { Comenzi comanda = new Comenzi(); comanda.IdComenzi = reader.GetInt32(0); comanda.TimpStart = reader.GetDateTime(1); comanda.TimpStop = reader.GetDateTime(2); if (comanda.TimpStop != null && azi > comanda.TimpStop) { comenzi.Add(comanda); } } reader.Close(); return(View(comenzi)); }
public Comenzi Put(int id, ComenziDTO value) { Comenzi model = IComenziRepository.Get(id); if (value.ComenziId != 0) { model.Id = value.ComenziId; } if (value.MagazinId != 0) { model.MagazinId = value.MagazinId; } if (value.ClientId != 0) { model.ClientId = value.ClientId; } if (value.SumaTotala != 0) { model.SumaTotala = value.SumaTotala; } return(IComenziRepository.Update(model)); }
public ActionResult InterogareDoi(List <IntergareCompelxa4> x) { List <IntergareCompelxa4> comenzi = new List <IntergareCompelxa4>(); SqlConnection connection = new SqlConnection("data source = DESKTOP-IBNRKP3\\SQLEXPRESS; initial catalog = BD_Project; integrated security = True"); SqlCommand cmd = new SqlCommand(@" Select c.IdComenzi, c.TimpStart, c.TimpStop from Comenzi c where c.IdComenzi in ( select cb.IdComenzi from Comenzi_Biciclete cb inner join Bicicleta b on b.IdBicicleta = cb.IdBicicleta where b.Pret_h > " + x[0].pret + " group by cb.IdComenzi)", connection); connection.Open(); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { IntergareCompelxa4 interogare = new IntergareCompelxa4(); Comenzi z = new Comenzi(); z.IdComenzi = reader.GetInt32(0); z.TimpStart = reader.GetDateTime(1); z.TimpStop = reader.GetDateTime(2); interogare.coamnda = z; comenzi.Add(interogare); } reader.Close(); return(View(comenzi)); }
public void AnuleazaComanda(IOrder comanda, IPerson client) { if (Comenzi.Exists(c => c.Number == comanda.Number)) { Comenzi.Remove(Comenzi.Find(c => c.Number == comanda.Number)); client.Comenzi.Remove(client.Comenzi.Find(c => c.Magazin == comanda.Magazin && c.Number == comanda.Number)); } }
public ModAdministrativViewModel() { cuvantCurent = new Cuvant(); _listaCuvinte = ObjCuvantList; comUpdate = new Comenzi(Upd); comAdauga = new Comenzi(adauga); comStergere = new Comenzi(sterge); }
private void btnSaveComanda_Click(object sender, RoutedEventArgs e) { Comenzi com = null; if (actionComenzi == ActionState.New) { try { Ospatari o = (Ospatari)oidComboBox.SelectedItem; Mese m = (Mese)midComboBox.SelectedItem; com = new Comenzi() { mid = m.mid, oid = o.oid, datac = DateTime.ParseExact(datacDatePicker.Text.Trim(), "dd/mm/yyyy", null) }; ctx.Comenzis.Add(com); meseComenzisViewSource.View.Refresh(); ctx.SaveChanges(); } catch (DataException ex) { MessageBox.Show(ex.Message); } } else if (actionComenzi == ActionState.Edit) { try { com = (Comenzi)comenzisDataGrid.SelectedItem; com.datac = DateTime.ParseExact(datacDatePicker.Text.Trim(), "dd/mm/yyyy", null); com.mid = ((Mese)midComboBox.SelectedItem).mid; com.oid = ((Ospatari)oidComboBox.SelectedItem).oid; ctx.SaveChanges(); } catch (DataException ex) { MessageBox.Show(ex.Message); } meseComenzisViewSource.View.Refresh(); meseComenzisViewSource.View.MoveCurrentTo(com); } else if (action == ActionState.Delete) { try { com = (Comenzi)comenzisDataGrid.SelectedItem; ctx.Comenzis.Remove(com); ctx.SaveChanges(); } catch (DataException ex) { MessageBox.Show(ex.Message); } meseComenzisViewSource.View.Refresh(); } turnOnComenzi(); }
public ModDivertismentViewModel() { lista5Cuvinte = new List <Cuvant>(); _listaCuvinte = ObjCuvantList; nume = new List <string>(); cuvantCurent = new Cuvant(); comStart = new Comenzi(Upd); comNext = new Comenzi(Next); comFinish = new Comenzi(Finish); }
private void AddOrderToSettings(Comenzi order) { if (order == null) { Phases.Clear(); return; } _settingsService.CommessaFromBarcode = order.NrComanda; _settingsService.CommessaIdSettings = order.Id.ToString(); }
public void Comanda(IVehicle masina, IPerson client) { if (Masini.Exists(m => m.Manufacturer == masina.Manufacturer && m.Model == masina.Model)) { IOrder comanda = new Order(client, masina, this, Timp); comanda.Number = ++lastNumber; comanda.Masina = Masini.Find(m => m.Manufacturer == masina.Manufacturer && m.Model == masina.Model); Comenzi.Add(comanda); client.Comenzi.Add(comanda); } }
private void comenzisDataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e) { try { Comenzi com = (Comenzi)comenzisDataGrid.SelectedItem; midComboBox.SelectedIndex = com.mid - 1; oidComboBox.SelectedIndex = com.oid - 1; } catch (Exception ex) { } }
public int IdUltimaComandaInregistrata() { int rez = 0; if (Comenzi.Count > 0) { rez = Comenzi.OrderByDescending(x => x.Id).ToList()[0].Id; } return(rez); }
public Comenzi Post(ComenziDTO value) { Comenzi model = new Comenzi() { Id = value.ComenziId, MagazinId = value.MagazinId, ClientId = value.ClientId, SumaTotala = value.SumaTotala }; return(IComenziRepository.Create(model)); }
internal void AddComenzi(Comenzi comanda) { using (SqlConnection connection = DALHelper.Connection) { SqlCommand cmd = new SqlCommand("spComenzi_Insert", connection); cmd.CommandType = System.Data.CommandType.StoredProcedure; SqlParameter paramClientId = new SqlParameter("@ClientId", comanda.ClientId); cmd.Parameters.Add(paramClientId); connection.Open(); cmd.ExecuteNonQuery(); } }
public void Put(int id, ClientDTO value) { Client model = IClientRepository.Get(id); if (value.Nume != null) { model.Nume = value.Nume; } if (value.DataNasterii != null) { model.DataNasterii = value.DataNasterii; } if (value.Email != null) { model.Email = value.Email; } if (value.Adresa != null) { model.Adresa = value.Adresa; } if (value.TipId != 0) { model.TipId = value.TipId; } IClientRepository.Update(model); if (value.ComenziId != null) { IEnumerable <Comenzi> myComenzi = IComenziRepository.GetAll().Where(x => x.ClientId == id); foreach (Comenzi comanda in myComenzi) { IComenziRepository.Delete(comanda); } for (int i = 0; i <= value.ComenziId.Count; i++) { Comenzi comanda = new Comenzi { ClientId = model.Id, Id = value.ComenziId[i] }; IComenziRepository.Create(comanda); } } }
internal void AddMeniuInComanda(Comenzi comanda, Meniu meniu, int cantitate) { using (SqlConnection connection = DALHelper.Connection) { SqlCommand cmd = new SqlCommand("spMeniuri_InsertMeniuInMeniuriComandate", connection); cmd.CommandType = System.Data.CommandType.StoredProcedure; SqlParameter paramComandaId = new SqlParameter("@ComandaId", comanda.ComandaId); SqlParameter paramMeniuId = new SqlParameter("@MeniuId", meniu.MeniuId); SqlParameter paramCantitate = new SqlParameter("@Cantitate", cantitate); cmd.Parameters.Add(paramComandaId); cmd.Parameters.Add(paramMeniuId); cmd.Parameters.Add(paramCantitate); connection.Open(); cmd.ExecuteNonQuery(); } }
public ActionResult AdaugaComanda() { Comenzi_Final model = new Comenzi_Final(); List <Bicicleta> bic = new List <Bicicleta>(); #region biciclete SqlConnection connection = new SqlConnection("data source = DESKTOP-IBNRKP3\\SQLEXPRESS; initial catalog = BD_Project; integrated security = True"); SqlCommand cmd = new SqlCommand(@" select b.IdBicicleta, b.Categorie, b.Model, b.Pret_h from Bicicleta b ", connection); connection.Open(); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { Bicicleta bicicleta = new Bicicleta(); try { bicicleta.IdBicicleta = reader.GetInt32(0); } catch (Exception e) { } try { bicicleta.Categorie = reader.GetString(1); } catch (Exception e) { } try { bicicleta.Model = reader.GetString(2); } catch (Exception e) { } try { bicicleta.Pret_h = reader.GetDecimal(3); } catch (Exception e) { } bic.Add(bicicleta); } reader.Close(); #endregion //dropdownlist centre CentreDisponibile(); model.biciclete = bic; Comenzi pret = new Comenzi(); pret.Pret = 0; model.comanda = pret; return(View(model)); }
internal void AddPreparatComandat(Comenzi comanda, Preparate preparat, int cantitate) { using (SqlConnection connection = DALHelper.Connection) { SqlCommand cmd = new SqlCommand("spPreparateComandate_Insert", connection); cmd.CommandType = System.Data.CommandType.StoredProcedure; SqlParameter paramComandaId = new SqlParameter("ComandaId", comanda.ComandaId); SqlParameter paramPreparatId = new SqlParameter("PreparatId", preparat.Id); SqlParameter paramCantitate = new SqlParameter("Cantitate", cantitate); cmd.Parameters.Add(paramComandaId); cmd.Parameters.Add(paramPreparatId); cmd.Parameters.Add(paramCantitate); connection.Open(); cmd.ExecuteNonQuery(); } }
internal Comenzi GetComandaIdForCliendId(Client client) { using (SqlConnection connection = DALHelper.Connection) { SqlCommand cmd = new SqlCommand("spComenzi_GetComandaIdForClientId", connection); cmd.CommandType = System.Data.CommandType.StoredProcedure; SqlParameter paramClientId = new SqlParameter("@ClientId", client.Id); cmd.Parameters.Add(paramClientId); connection.Open(); SqlDataReader reader = cmd.ExecuteReader(); Comenzi comanda = null; while (reader.Read()) { comanda = new Comenzi() { ComandaId = reader["comandaId"] as int? }; } return(comanda); } }
public void Post(ClientDTO value) { Client model = new Client() { Nume = value.Nume, DataNasterii = value.DataNasterii, Email = value.Email, Adresa = value.Adresa, TipId = value.TipId }; IClientRepository.Create(model); for (int i = 0; i < value.ComenziId.Count; i++) { Comenzi comanda = new Comenzi() { ClientId = model.Id, Id = value.ComenziId[i] }; IComenziRepository.Create(comanda); } }
public ActionResult InterogareUnu() { List <Interogare1> clienti = new List <Interogare1>(); SqlConnection connection = new SqlConnection("data source = DESKTOP-IBNRKP3\\SQLEXPRESS; initial catalog = BD_Project; integrated security = True"); SqlCommand cmd = new SqlCommand(@" select co.IdComenzi, c.Nume, c.Prenume, co.Pret from Client c inner join Comenzi co on co.IdClient = c.IdClient inner join Comenzi_Biciclete cb on cb.IdComenzi = co.IdComenzi where co.Pret > 90 group by c.Nume, c.Prenume, co.Pret, co.IdComenzi", connection); connection.Open(); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { Interogare1 x = new Interogare1(); Comenzi y = new Comenzi(); Client z = new Client(); y.IdComenzi = reader.GetInt32(0); z.Nume = reader.GetString(1); z.Prenume = reader.GetString(2); y.Pret = reader.GetDecimal(3); x.client = z; x.comanda = y; clienti.Add(x); } reader.Close(); return(View(clienti)); }
private void btnSalvareC_Click(object sender, RoutedEventArgs e) { Comenzi order = null; Comenzi selectedOrder = null; if (actionComenzi == ActionState.New) { try { //instantiem Comenzi entity Clienti customer = (Clienti)cmbClienti.SelectedItem; Inventar book = (Inventar)cmbInventar.SelectedItem; order = new Comenzi() { ClientID = customer.ClientId, CarteID = book.CarteId, }; //adaugam entitatea nou creata in context ctx.Comenzis.Add(order); clientiComenzisViewSource.View.Refresh(); //salvam modificarile ctx.SaveChanges(); } //using System.Data; catch (DataException ex) { MessageBox.Show(ex.Message); } btnNouC.IsEnabled = true; btnEditareC.IsEnabled = true; btnSalvareC.IsEnabled = false; btnAnulareC.IsEnabled = false; btnStergereC.IsEnabled = true; btnPrecedentulC.IsEnabled = true; btnUrmatorulC.IsEnabled = true; } else if (actionComenzi == ActionState.Edit) { selectedOrder = (Comenzi)comenzisDataGrid.SelectedItem; //customer = (Clienti)clientiDataGrid.SelectedItem; //customer.Nume = numeTextBox.Text.Trim(); //customer.Prenume = prenumeTextBox.Text.Trim(); //customer.Telefon = telefonTextBox.Text.Trim(); try { int curr_id = selectedOrder.ComandaId; var editedOrder = ctx.Comenzis.FirstOrDefault(s => s.ComandaId == curr_id); if (editedOrder != null) { Clienti customer = (Clienti)cmbClienti.SelectedItem; Inventar book = (Inventar)cmbInventar.SelectedItem; editedOrder.ClientID = customer.ClientId; // int.Parse(cmbClienti.SelectedValue.ToString()); editedOrder.CarteID = book.CarteId; // int.Parse(cmbInventar.SelectedValue.ToString()); ctx.SaveChanges(); } //Clienti customer = (Clienti)cmbClienti.SelectedItem; //Inventar book = (Inventar)cmbInventar.SelectedItem; //order = (Comenzi)comenzisDataGrid.SelectedItem; //order.ClientID = customer; //order.Autor = autorTextBox.Text.Trim(); //order.Pret = int.Parse(pretTextBox.Text); //salvam modificarile } catch (DataException ex) { MessageBox.Show(ex.Message); } // pozitionarea pe item-ul curent clientiComenzisViewSource.View.Refresh(); clientiComenzisViewSource.View.MoveCurrentTo(selectedOrder); btnNouC.IsEnabled = true; btnEditareC.IsEnabled = true; btnSalvareC.IsEnabled = false; btnAnulareC.IsEnabled = false; btnStergereC.IsEnabled = true; btnPrecedentulC.IsEnabled = true; btnUrmatorulC.IsEnabled = true; } else if (actionComenzi == ActionState.Delete) { try { selectedOrder = (Comenzi)comenzisDataGrid.SelectedItem; int curr_id = selectedOrder.ComandaId; var deletedOrder = ctx.Comenzis.FirstOrDefault(s => s.ComandaId == curr_id); if (deletedOrder != null) { ctx.Comenzis.Remove(deletedOrder); ctx.SaveChanges(); MessageBox.Show("Comanda stearsa cu succes!", "Message"); } } catch (DataException ex) { MessageBox.Show(ex.Message); } clientiComenzisViewSource.View.Refresh(); btnNouC.IsEnabled = true; btnEditareC.IsEnabled = true; btnSalvareC.IsEnabled = false; btnAnulareC.IsEnabled = false; btnPrecedentulC.IsEnabled = true; btnUrmatorulC.IsEnabled = true; } }
internal void AddComanda(Comenzi comanda) { comenziDAL.AddComenzi(comanda); //UserList.Add(user); }
private void btnSalveaza2_Click(object sender, RoutedEventArgs e) { Comenzi order = null; Comenzi selectedOrder = null; if (actionComenzi == ActionState.New) { try { //instantiem entitatea Comenzi Clienti customer = (Clienti)cmbClienti.SelectedItem; Inventar video = (Inventar)cmbInventar.SelectedItem; order = new Comenzi() { ClientId = customer.ClientId, VideoId = video.VideoId, }; //adaugam entitatea nou creata ctx.Comenzis.Add(order); clientiComenzisViewSource.View.Refresh(); //salvam ctx.SaveChanges(); } //using System.Data; catch (DataException ex) { MessageBox.Show(ex.Message); } btnNou2.IsEnabled = true; btnModifica2.IsEnabled = true; btnSalveaza2.IsEnabled = false; btnAnuleaza2.IsEnabled = false; btnSterge2.IsEnabled = true; btnInapoi2.IsEnabled = true; btnInainte2.IsEnabled = true; } else if (actionComenzi == ActionState.Edit) { selectedOrder = (Comenzi)comenzisDataGrid.SelectedItem; try { int curr_id = selectedOrder.ComandaId; var editedOrder = ctx.Comenzis.FirstOrDefault(s => s.ComandaId == curr_id); if (editedOrder != null) { Clienti customer = (Clienti)cmbClienti.SelectedItem; Inventar video = (Inventar)cmbInventar.SelectedItem; editedOrder.ClientId = customer.ClientId; editedOrder.VideoId = video.VideoId; ctx.SaveChanges(); } //salvam } catch (DataException ex) { MessageBox.Show(ex.Message); } // pozitionarea pe item clientiComenzisViewSource.View.Refresh(); clientiComenzisViewSource.View.MoveCurrentTo(selectedOrder); btnNou2.IsEnabled = true; btnModifica2.IsEnabled = true; btnSalveaza2.IsEnabled = false; btnAnuleaza2.IsEnabled = false; btnSterge2.IsEnabled = true; btnInapoi2.IsEnabled = true; btnInainte2.IsEnabled = true; } else if (actionComenzi == ActionState.Delete) { try { selectedOrder = (Comenzi)comenzisDataGrid.SelectedItem; int curr_id = selectedOrder.ComandaId; var deletedOrder = ctx.Comenzis.FirstOrDefault(s => s.ComandaId == curr_id); if (deletedOrder != null) { ctx.Comenzis.Remove(deletedOrder); ctx.SaveChanges(); MessageBox.Show("Comanda a fost stearsa!", "Message"); } } catch (DataException ex) { MessageBox.Show(ex.Message); } clientiComenzisViewSource.View.Refresh(); btnNou2.IsEnabled = true; btnModifica2.IsEnabled = true; btnSalveaza2.IsEnabled = false; btnAnuleaza2.IsEnabled = false; btnInapoi2.IsEnabled = true; btnInainte2.IsEnabled = true; } }
internal void AddMeniuInComanda(Comenzi comanda, Meniu meniu, int cantitate) { meniuDAL.AddMeniuInComanda(comanda, meniu, cantitate); }
public Comenzi Update(Comenzi Comenzi) { _context.Entry(Comenzi).State = Microsoft.EntityFrameworkCore.EntityState.Modified; _context.SaveChanges(); return(Comenzi); }