protected override async System.Threading.Tasks.Task OnInitializedAsync() { soferi = new List <Models.FirmaCurierat.Soferi>(); client = new Models.FirmaCurierat.Clienti(); comanda = new Models.FirmaCurierat.Comenzi(); tip = new List <Models.FirmaCurierat.TipComenzi>(); coordsList = new List <Models.FirmaCurierat.Dispeceri>(); tip_selected = new Models.FirmaCurierat.TipComenzi(); // SqlConnection scn = new SqlConnection(); string ServerName = Environment.MachineName; string database = "CurieratVladProiect"; string ConnectionString = String.Format(@"Server={0}\SQLEXPRESS;Initial Catalog={1}; Integrated Security = SSPI", ServerName, database); //lista de dispeceri pentur a putea atribuii comenzii coordsList = new List <Models.FirmaCurierat.Dispeceri>(); string sqlCommand = "select * from dispeceri"; dataHelper = new DataBaseManagement.DataManagement(); coordsList = await dataHelper.LoadData <Models.FirmaCurierat.Dispeceri, dynamic>(sqlCommand, new { }, ConnectionString); //ce tipuri de comenzi am sqlCommand = "select * from tip_comenzi"; tip = await dataHelper.LoadData <Models.FirmaCurierat.TipComenzi, dynamic>(sqlCommand, new { }, ConnectionString); //soferii sqlCommand = "select * from soferi"; soferi = await dataHelper.LoadData <Models.FirmaCurierat.Soferi, dynamic>(sqlCommand, new { }, ConnectionString); }
protected async Task loadClientsandOrders() { comenzi = new List <Models.FirmaCurierat.Comenzi>(); dataHelper = new DataBaseManagement.DataManagement(); clients = new List <Models.FirmaCurierat.Clienti>(); client = new Models.FirmaCurierat.Clienti(); SqlConnection scn = new SqlConnection(); string ServerName = Environment.MachineName; string database = "CurieratVladProiect"; string ConnectionString = String.Format(@"Server={0}\SQLEXPRESS;Initial Catalog={1}; Integrated Security = SSPI", ServerName, database); scn.ConnectionString = ConnectionString; SqlCommand scmd = new SqlCommand("select * from clienti where id_client = @id", scn); scmd.Parameters.Clear(); scmd.Parameters.AddWithValue("@id", client_id); scn.Open(); // var inserted_Client = (Models.FirmaCurierat.Clienti)scmd.ExecuteScalar(); using (SqlDataReader reader = scmd.ExecuteReader()) { if (reader.Read()) { client.id_client = (int)reader["id_client"]; client.mail = (string)reader["mail"]; client.nume = (string)reader["nume"]; client.prenume = (string)reader["prenume"]; client.adresa = (string)reader["adresa"]; } } // SqlConnection scn = new SqlConnection(); // scn.ConnectionString = @"Data Source=DESKTOP-I3NIEPL\SQLEXPRESS;Initial Catalog=login_database;database=CurieratVladProiect;integrated security=SSPI"; // string ConnectionString = @"Data Source=DESKTOP-I3NIEPL\SQLEXPRESS;Initial Catalog=login_database;database=CurieratVladProiect;integrated security=SSPI"; comanda = new Models.FirmaCurierat.Comenzi(); scmd = new SqlCommand("select * from comenzi where id_client = @id", scn); scmd.Parameters.Clear(); scmd.Parameters.AddWithValue("@id", client_id); using (SqlDataReader reader = scmd.ExecuteReader()) { if (reader.Read()) { comanda.awb = (string)reader["awb"]; comanda.data_livrare = (string)reader["data_livrare"]; comanda.id_client = (int)reader["id_client"]; comanda.id_comanda = (int)reader["id_comanda"]; comanda.id_dispecer = (int)reader["id_dispecer"]; } } comanda = comenzi.Where(i => i.id_client == Convert.ToInt32(client_id)).FirstOrDefault(); }
protected async Task loadClientsandOrders() { //initializare liste tip = new List <Models.FirmaCurierat.TipComenzi>(); tip_selected = new Models.FirmaCurierat.TipComenzi(); comenzi = new List <Models.FirmaCurierat.Comenzi>(); dataHelper = new DataBaseManagement.DataManagement(); clients = new List <Models.FirmaCurierat.Clienti>(); client = new Models.FirmaCurierat.Clienti(); SqlConnection scn = new SqlConnection(); string ServerName = Environment.MachineName; string database = "CurieratVladProiect"; string ConnectionString = String.Format(@"Server={0}\SQLEXPRESS;Initial Catalog={1}; Integrated Security = SSPI", ServerName, database); scn.ConnectionString = ConnectionString; scn.Open(); // string ConnectionString = @"Data Source=DESKTOP-I3NIEPL\SQLEXPRESS;Initial Catalog=login_database;database=CurieratVladProiect;integrated security=SSPI"; comanda = new Models.FirmaCurierat.Comenzi(); //selecteaza comenzile clientului cu id-ul cliend_id SqlCommand scmd = new SqlCommand("select * from comenzi where id_client = @id", scn); scmd.Parameters.Clear(); scmd.Parameters.AddWithValue("@id", client_id); using (SqlDataReader reader = scmd.ExecuteReader()) { //ia informatiile despre comanda if (reader.Read()) { comanda.awb = (string)reader["awb"]; comanda.data_livrare = (string)reader["data_livrare"]; comanda.id_client = (int)reader["id_client"]; comanda.id_comanda = (int)reader["id_comanda"]; comanda.id_dispecer = (int)reader["id_dispecer"]; } } //selectam id-ul tipului comenzii scmd = new SqlCommand("select id_tip from tipul_comenzii where id_comanda = @id;;SELECT SCOPE_IDENTITY()", scn); scmd.Parameters.AddWithValue("@id", comanda.id_comanda); int tip_id = Convert.ToInt32(scmd.ExecuteScalar()); //selectam tipul comenzii scmd = new SqlCommand("select * from tip_comenzi where id_tip = @id", scn); scmd.Parameters.Clear(); scmd.Parameters.AddWithValue("@id", tip_id); using (SqlDataReader reader = scmd.ExecuteReader()) { //luam datele despre tip si specificatiile if (reader.Read()) { tip_selected.id_tip = (int)reader["id_tip"]; tip_selected.specificatii = (string)reader["specificatii"]; tip_selected.tip = (string)reader["tip"]; } } string sqlCommand = "select * from tip_comenzi"; tip = await dataHelper.LoadData <Models.FirmaCurierat.TipComenzi, dynamic>(sqlCommand, new { }, ConnectionString); }