public void CreatePaymentMethod(PaymentMethod pm) { SqlParameter[] param = new SqlParameter[] { SqlUtilities.GenerateInputNVarcharParameter("@name", 50, pm.Name) }; string sql = "INSERT INTO payment_methods(name) VALUES(@name)"; SqlHelper.ExecuteNonQuery(CommandType.Text, sql, param); }
public static bool CreatePaymentMethod(PaymentMethod pm) { if (dal.GetPaymentMethodByName(pm.Name) != null) { return false; } dal.CreatePaymentMethod(pm); return true; }
public List<PaymentMethod> GetPaymentMethod() { List<PaymentMethod> result = new List<PaymentMethod>(); string sql = "SELECT id, name FROM payment_methods"; using (SqlDataReader dr = SqlHelper.ExecuteReader(CommandType.Text, sql, null)) { while (dr.Read()) { PaymentMethod pm = new PaymentMethod(); pm.Id = dr.GetInt32(0); pm.Name = dr.GetString(1); result.Add(pm); } } return result; }
public PaymentMethod GetPaymentMethodByName(string name) { PaymentMethod pm = null; SqlParameter[] param = new SqlParameter[] { SqlUtilities.GenerateInputNVarcharParameter("@name", 50, name) }; string sql = "SELECT id, name FROM payment_methods WHERE name = @name"; using (SqlDataReader dr = SqlHelper.ExecuteReader(CommandType.Text, sql, param)) { while (dr.Read()) { pm = new PaymentMethod(); pm.Id = dr.GetInt32(0); pm.Name = dr.GetString(1); } } return pm; }
public static void UpdatePaymentMethod(PaymentMethod pm) { dal.UpdatePaymentMethod(pm); }
public void UpdatePaymentMethod(PaymentMethod pm) { SqlParameter[] param = new SqlParameter[] { SqlUtilities.GenerateInputIntParameter("@id", pm.Id), SqlUtilities.GenerateInputNVarcharParameter("@name", 50, pm.Name) }; string sql = "UPDATE payment_methods SET name = @name WHERE id = @id"; SqlHelper.ExecuteNonQuery(CommandType.Text, sql, param); }