public static List <clsSuppliers> GetAllSuppliers() { List <clsSuppliers> x = new List <clsSuppliers>(); using (SqlConnection conn = new SqlConnection(clsMain.sqlconnstring)) { conn.Open(); SqlCommand cmd = new SqlCommand("shop.spSelectAllSuppliers", conn); cmd.CommandType = CommandType.StoredProcedure; SqlDataReader rdr = cmd.ExecuteReader(); while (rdr.Read()) { clsSuppliers y = new clsSuppliers(); y.ID = Convert.ToInt32(rdr["ID"]); y.Name = Convert.ToString(rdr["Name"]); y.Email = Convert.ToString(rdr["Email"]); y.Tel = Convert.ToString(rdr["Tel"]); y.City = Convert.ToString(rdr["City"]); y.CAddress = Convert.ToString(rdr["CAddress"]); y.Remarks = Convert.ToString(rdr["Remarks"]); y.Flag = Convert.ToString(rdr["Flag"]); x.Add(y); } } return(x); }
//[NotMapped] //public Image Picture //{ // get // { // if (!String.IsNullOrEmpty(Flag)) // { // if(File.Exists(Flag)) // { // return Image.FromFile(Flag); // } // } // return null; // } //} public static int insert(clsSuppliers x) { using (SqlConnection conn = new SqlConnection(clsMain.sqlconnstring)) { conn.Open(); SqlCommand cmd = new SqlCommand("shop.spInsertSuppliers", conn); cmd.CommandType = CommandType.StoredProcedure; string f = "Unknown"; cmd.Parameters.AddWithValue("@fn", x.Name); cmd.Parameters.AddWithValue("@em", x.Email); cmd.Parameters.AddWithValue("@tel", x.Tel); cmd.Parameters.AddWithValue("@city", x.City); cmd.Parameters.AddWithValue("@ca", x.CAddress); cmd.Parameters.AddWithValue("@remarks", x.Remarks); cmd.Parameters.AddWithValue("@flag", f); int r = cmd.ExecuteNonQuery(); return(r); } }