public static List <string> getAllSellerMail() { List <string> allsellers = new List <string>(); string cmd = "SELECT mail FROM Seller"; //Seller tmpSeller = new Seller(); //List<Seller> seller = new List<Seller>(); using (DataTable table = DataBaseConnect.ExecuteSelectCommand(cmd, CommandType.Text)) { if (table.Rows.Count > 0) { //seller = MapSellers(table.Rows); //List<DataRow> rows = table.Rows.Cast<DataRow>().ToList(); //IEnumerable<DataRow> sequence = table.AsEnumerable(); allsellers = table.AsEnumerable().Select(x => x[0].ToString()).ToList(); //List<DataRow> list = table.AsEnumerable().ToList(); //allsellers = table.AsEnumerable() // .Select(r=> r.Field<string>("UserCode")) // .ToList(); } } return(allsellers); }
/* * public static void Insert(string title, string author, string isbn, string date, string price, string adtext, string course, string mail) * { * string cmd = String.Format("INSERT INTO BookAd VALUES('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}')", title, author, isbn, date, price, adtext, course, mail); * DataBaseConnect.ExecuteSelectCommand(cmd, CommandType.Text); * } */ public static int Insert(string title, string author, string isbn, string date, int price, string adtext, string course, string mail) { string cmd = String.Format("INSERT INTO BookAd VALUES('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}')", title, isbn, author, date, price, adtext, course, mail); //String.Format för att underlätta inmatning int rowsAffected = 0; rowsAffected = DataBaseConnect.ExecuteNonQuery(cmd, CommandType.Text); return(rowsAffected); }
//Lägger till en ny användare i databasen public static int Insert(string LName, string FName, string PhoneNbr, string Mail, string City, string Password) { string cmd = String.Format("INSERT INTO Seller VALUES('{0}','{1}','{2}','{3}','{4}','{5}')", LName, FName, PhoneNbr, Mail, City, Password); //String.Format för att underlätta inmatning int rowsAffected = 0; rowsAffected = DataBaseConnect.ExecuteNonQuery(cmd, CommandType.Text); return(rowsAffected); }
public static List <BookAd> Read(string cmd) { List <BookAd> bookAds = null; using (DataTable table = DataBaseConnect.ExecuteSelectCommand(cmd, CommandType.Text)) { if (table.Rows.Count > 0) { bookAds = MapBooks(table.Rows); } } return(bookAds); }
public static List <Course> Read(string cmd) { List <Course> courses = null; using (DataTable table = DataBaseConnect.ExecuteSelectCommand(cmd, CommandType.Text)) { if (table.Rows.Count > 0) { courses = MapCourses(table.Rows); } } return(courses); }
public static List <Seller> Read(string cmd) { List <Seller> sellers = null; using (DataTable table = DataBaseConnect.ExecuteSelectCommand(cmd, CommandType.Text)) { if (table.Rows.Count > 0) { sellers = MapSellers(table.Rows); } } return(sellers); }
public static List <Inst> Read(string cmd) { List <Inst> insts = null; using (DataTable table = DataBaseConnect.ExecuteSelectCommand(cmd, CommandType.Text)) { if (table.Rows.Count > 0) { insts = MapInsts(table.Rows); } } return(insts); }
static void ain(string[] args) { System.Console.WriteLine("0 = Thomas, 1 = Ramy, 2 = Andreas, 3 = Robin"); i = int.Parse(Console.ReadLine()); DataBaseConnect dbConn = new DataBaseConnect(); //dbConn.ConnectDb TestClass.TestBooksRead(); TestClass.TestCourseRead(); //TestClass.TestInstRead(cmd); TestClass.TestSellerRead(); Console.Read(); }
//Hämtar säljare från databasen (mail nyckel) public static Seller getSeller(string Mail) { string cmd = String.Format("SELECT * FROM Seller WHERE Mail = '{0}'", Mail); //String.Format för att underlätta inmatning Seller tmpSeller = new Seller(); List <Seller> seller = new List <Seller>(); seller.Insert(0, tmpSeller); using (DataTable table = DataBaseConnect.ExecuteSelectCommand(cmd, CommandType.Text)) { if (table.Rows.Count > 0) { seller = MapSellers(table.Rows); } } tmpSeller = seller.ElementAt(0); return(tmpSeller); }
public static void Delete(string Title, string Author, string Isbn, string Date, string Price, string AdText, string Course, string Mail) { string cmd = String.Format("DELETE FROM BookAd WHERE isbn = '" + Isbn + "' ;"); DataBaseConnect.ExecuteSelectCommand(cmd, CommandType.Text); }
public static DataTable ReadDt(string cmd) { DataTable table = DataBaseConnect.ExecuteSelectCommand(cmd, CommandType.Text); return(table); }
public static void Delete(string LName, string FName, string PhoneNbr, string Mail, string City, string Password) { string cmd = String.Format("DELETE FROM Seller WHERE Mail = '" + Mail + "' ;"); DataBaseConnect.ExecuteSelectCommand(cmd, CommandType.Text); }