public List<MedicineQuantity> GetdicineQuantities() { List<MedicineQuantity> medicines = new List<MedicineQuantity>(); SqlConnection connection = new SqlConnection(connectionstring); string query = "SELECT * FROM Table_MedicineQuantity"; SqlCommand command = new SqlCommand(query, connection); connection.Open(); SqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { MedicineQuantity medicine = new MedicineQuantity(); medicine.Id = int.Parse(reader["medicineQuantity_Id"].ToString()); medicine.Name = reader["medicineQuantity_Name"].ToString(); medicine.Quantity = int.Parse(reader["medicineQuantity_Quantity"].ToString()); medicine.CenterId = int.Parse(reader["medicineQuantity_CenterId"].ToString()); medicines.Add(medicine); } return medicines; }
public string InsertMedicineQunatity(MedicineQuantity medicineQuantity) { int value=centerGateway.MedicineQuantityEntry(medicineQuantity); if (value > 0) { return "medicine quantity saved successfully"; } else { return "Operation Failed"; } }
public int MedicineQuantityEntry(MedicineQuantity medicineQuantity) { SqlConnection connection = new SqlConnection(connectionstring); string query = "INSERT INTO Table_MedicineQuantity VALUES('" + medicineQuantity.Name + "','" + medicineQuantity.Quantity + "','" + medicineQuantity.CenterId + "')"; SqlCommand command = new SqlCommand(query, connection); connection.Open(); int rowsAffected = command.ExecuteNonQuery(); connection.Close(); return rowsAffected; }