Exemplo n.º 1
0
        public void shto(Shoferi shof)
        {
            using (SqlConnection conn = new SqlConnection(connectionString))
            {
                SqlCommand cmd = new SqlCommand("insert into Shoferet (UserId,EmriShoferi,MbiemriShoferi,Password,Aktiv,Id_dispecher,Detyrimi,Id_klienti) values (@perd,@emri,@mbiemri,@pass,@aktiv,@iddispecher,@detyrimi,@idklienti)", conn);
                cmd.Parameters.Add("@perd", System.Data.SqlDbType.VarChar);
                cmd.Parameters["@perd"].Value = shof.perdoruesi;
                cmd.Parameters.Add("@emri", System.Data.SqlDbType.VarChar);
                cmd.Parameters["@emri"].Value = shof.emri;
                cmd.Parameters.Add("@mbiemri", System.Data.SqlDbType.VarChar);
                cmd.Parameters["@mbiemri"].Value = shof.mbiemri;
                cmd.Parameters.Add("@pass", System.Data.SqlDbType.VarChar);
                cmd.Parameters["@pass"].Value = shof.password;
                cmd.Parameters.Add("@aktiv", System.Data.SqlDbType.Bit);
                cmd.Parameters["@aktiv"].Value = true;

                cmd.Parameters.Add("@iddispecher", System.Data.SqlDbType.BigInt);
                cmd.Parameters["@iddispecher"].Value = shof.IdDispecher;

                cmd.Parameters.Add("@detyrimi", System.Data.SqlDbType.Decimal);
                cmd.Parameters["@detyrimi"].Value = 0;


                cmd.Parameters.Add("@idklienti", System.Data.SqlDbType.BigInt);
                cmd.Parameters["@idklienti"].Value = shof.IdKlienti;
                conn.Open();
                cmd.ExecuteNonQuery();
                conn.Close();
            }
        }
Exemplo n.º 2
0
        public void modifiko(Shoferi shofer)
        {
            using (SqlConnection conn = new SqlConnection(connectionString))
            {
                SqlCommand cmd = new SqlCommand("update Shoferet set UserId = '" + shofer.perdoruesi + "', EmriShoferi = '" + shofer.emri + "', MbiemriShoferi = '" + shofer.mbiemri + "', Password = '******', Aktiv = '" + shofer.aktiv + "',Detyrimi = " + shofer.Detyrimi + ", Id_dispecher = " + shofer.IdDispecher + ", Id_klienti = " + shofer.IdKlienti + " where Id_shoferi = @Id", conn);
                cmd.Parameters.Add("@Id", System.Data.SqlDbType.BigInt);
                cmd.Parameters["@Id"].Value = shofer.Id;

                conn.Open();
                cmd.ExecuteNonQuery();
                conn.Close();
            }
        }
Exemplo n.º 3
0
        public List <Shoferi> Shoferet(Int64 idKlienti)
        {
            //gjen listen e shofereve qe i perkasin agjensise
            List <Shoferi> shof = new List <Shoferi>();

            using (SqlConnection conn = new SqlConnection(connectionString))
            {
                SqlCommand cmd = new SqlCommand("SELECT Id_shoferi,EmriShoferi,MbiemriShoferi FROM Shoferet where Id_klienti = " + idKlienti + " And Shoferet.Aktiv = 'True" + "'", conn);
                conn.Open();
                SqlDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    Shoferi s = new Shoferi();
                    s.id = Convert.ToInt64(reader["Id_shoferi"].ToString());


                    s.emri = reader["EmriShoferi"].ToString() + " " + reader["MbiemriShoferi"].ToString();
                    shof.Add(s);
                }
                return(shof);
            }
        }