Пример #1
0
 public int GetMedicineIdByName(string name)
 {
     string query = string.Format("SELECT MedicineId FROM Medicine Where MedicineName='{0}'", name);
     SqlConnection connection=new SqlConnection(connectionString);
     SqlCommand command=new SqlCommand(query,connection);
     connection.Open();
     Medicine aMedicine=new Medicine();
       aMedicine.Serial= Convert.ToInt32(command.ExecuteScalar());
     connection.Close();
     return aMedicine.Serial;
 }
Пример #2
0
        public string Save(Medicine aMedicine)
        {
            if (aGateway.IsMedicineNameExists(aMedicine))
            {
                return "Medicine Already Exist.";
            }
            else if (aGateway.Save(aMedicine) > 0)
            {
                return "Successfully Saved.";

            }
            else
            {
                return "Saving Failed.";
            }
        }
        public List<Medicine> PopulateMedicineDropDownList(int centerId)
        {
            List<Medicine> medicineList = new List<Medicine>();
            SqlConnection connection = new SqlConnection(connectionString);
            string query = string.Format("SELECT Medicine.MedicineId,Medicine.MedicineName FROM DistributeMedicine INNER JOIN Medicine ON Medicine.MedicineId=DistributeMedicine.MedicineId Where CenterId='{0}'", centerId);

            connection.Open();
            SqlCommand command = new SqlCommand(query, connection);

            SqlDataReader reader = command.ExecuteReader();

            while (reader.Read())
            {
                Medicine medicine = new Medicine();
                medicine.Serial = Convert.ToInt32(reader["MedicineId"]);
                medicine.MedicineName = reader["MedicineName"].ToString();
                medicineList.Add(medicine);

            }
            reader.Close();
            connection.Close();
            return medicineList;
        }
Пример #4
0
        public List<Medicine> PopulateMedicineDropDownList()
        {
            List<Medicine> medicineList = new List<Medicine>();
            SqlConnection connection = new SqlConnection(connectionString);
            string query = string.Format("SELECT * FROM Medicine");

            connection.Open();
            SqlCommand command = new SqlCommand(query, connection);

            SqlDataReader reader = command.ExecuteReader();

            while (reader.Read())
            {
                Medicine aMedicine = new Medicine();
                aMedicine.Serial = Convert.ToInt32(reader["MedicineId"]);
                aMedicine.MedicineName= reader["MedicineName"].ToString();
                medicineList.Add(aMedicine);

            }
            reader.Close();
            connection.Close();
            return medicineList;
        }