public static List <clsReports> select(int ID) { List <clsReports> x = new List <clsReports>(); int i = 0; using (SqlConnection conn = new SqlConnection(clsMain.sqlconnstring)) { conn.Open(); SqlCommand cmd = new SqlCommand("shop.spSelectReports", conn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@id", ID); SqlDataReader rdr = cmd.ExecuteReader(); while (rdr.Read()) { clsReports y = new clsReports(); y.ID = Convert.ToInt32((i += 1)); y.Product = Convert.ToString(rdr["Product"]); y.Price = Convert.ToDouble(rdr["Price"]); y.Qty = Convert.ToInt32(rdr["Qty"]); y.DateCreated = Convert.ToString(rdr["DateCreated"]); y.PaymentMethod = Convert.ToString(rdr["PaymentMethod"]); x.Add(y); } } return(x); }
public static int insert(clsReports x) { using (SqlConnection conn = new SqlConnection()) { conn.ConnectionString = clsMain.sqlconnstring; conn.Open(); SqlCommand cmd = new SqlCommand("shop.spInsertReports", conn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@pt", x.Product); cmd.Parameters.AddWithValue("@pr", x.Price); cmd.Parameters.AddWithValue("@q", x.Qty); cmd.Parameters.AddWithValue("@d", DateTime.Now.ToShortDateString().ToString()); int r = cmd.ExecuteNonQuery(); return(r); } }
public static int update(clsReports x) { using (SqlConnection conn = new SqlConnection()) { conn.ConnectionString = clsMain.sqlconnstring; conn.Open(); SqlCommand cmd = new SqlCommand("shop.spUpdateReports", conn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@id", x.ID); cmd.Parameters.AddWithValue("@pt", x.Product); cmd.Parameters.AddWithValue("@pr", x.Price); cmd.Parameters.AddWithValue("@q", x.Qty); cmd.Parameters.AddWithValue("@d", x.DateCreated); int r = cmd.ExecuteNonQuery(); return(r); } }