public suppliers supplierLogin(SqlCommand com, string user, string pass, suppliers s) { com.CommandText = ($"SELECT * FROM suppliers WHERE username={user} and password={pass};"); SqlDataReader reader1 = com.ExecuteReader(CommandBehavior.Default); while (reader1.Read() == true) { s.UserName = user; s.Password = pass; s.Company = (string)reader1[3]; supid = (int)reader1[0]; return(s); } return(s); }
private static void ExistSup(SqlCommand com) { Console.WriteLine("Please enter your username :"******"Please enter your password :"******"Add new product (1)"); Console.WriteLine("Show me all avalabile items (2)"); int input = int.Parse(Console.ReadLine()); switch (input) { case (1): Product o = new Product(); Console.WriteLine("please enter the product name : "); o.name = (Console.ReadLine()); Console.WriteLine("please enter the product price : "); o.price = int.Parse(Console.ReadLine()); Console.WriteLine("please enter the product amounts : "); o.quantity = int.Parse(Console.ReadLine()); com.CommandText = $"INSERT INTO products (productName,supID,price,avalable) VALUES ({o.name},{sup.supid},{o.price},{o.quantity});"; break; case (2): com.CommandText = $"SELECT * FROM products WHERE avalable>0 and supID={sup.supid}; "; SqlDataReader reader1 = com.ExecuteReader(CommandBehavior.Default); Product p = new Product(); while (reader1.Read() == true) { p.name = (string)reader1[1]; p.price = (int)reader1[3]; p.quantity = (int)reader1[4]; Console.WriteLine(p); } break; } } Console.WriteLine("the username and the password dont match !!!!!!!!!"); return; }
private static void supplierRegister(SqlCommand com) { Console.WriteLine("***********Regiusteration***********"); suppliers s = new suppliers(); Console.WriteLine("Username : "******" Password : "******"Company : "); s.Company = Console.ReadLine(); if (s.Password == null || s.UserName == null) { Console.WriteLine("illegal input "); return; } else { s.InsertTDataBase(com); } }