Esempio n. 1
0
 public void Save(Medicine medicine)
 {
     SqlConnection sqlConnection = new SqlConnection(connectionString);
     string query = "INSERT INTO medicine VALUES('" + medicine.MedicineName + "','" + medicine.Quantity + "','" + medicine.unit + "','" + medicine.companyID + "','" + medicine.price + "')";
     SqlCommand sqlCommand = new SqlCommand(query, sqlConnection);
     sqlConnection.Open();
     sqlCommand.ExecuteNonQuery();
     sqlConnection.Close();
 }
Esempio n. 2
0
        private void medicineSaveButton_Click(object sender, EventArgs e)
        {
            Medicine medicine = new Medicine();
            medicine.MedicineName = medicineNameTextBox.Text;

            medicine.companyName = companyComboBox.Text;
            medicine.unit = unitTextBox.Text;
            medicine.price = Convert.ToInt32(priceTextBox.Text);

            medicine.Quantity = int.Parse(quantityTextBox.Text.ToString());

            myMedicineManager.Save(medicine);

            ShowAll();
        }
Esempio n. 3
0
        public List<Medicine> ShowAll()
        {
            List<Medicine> medicines = new List<Medicine>();
            SqlConnection sqlConnection = new SqlConnection(connectionString);
            string query = "SELECT m.m_id m_id,m.m_name m_name,c.company_name company_name,m.qty qty,m.unit unit,m.price price FROM medicine m, company c where m.company_id = c.company_id";
            SqlCommand command = new SqlCommand(query, sqlConnection);
            sqlConnection.Open();
            SqlDataReader myReader = command.ExecuteReader();
            while (myReader.Read())
            {
                Medicine medicine = new Medicine();

                medicine.medicineID = Convert.ToInt32(myReader["m_id"].ToString());
                medicine.MedicineName = myReader["m_name"].ToString();
                medicine.companyName = myReader["company_name"].ToString();
                medicine.Quantity = Convert.ToInt32(myReader["qty"].ToString());
                medicine.unit = myReader["unit"].ToString();
                medicine.price = Convert.ToInt32(myReader["price"].ToString());

                medicines.Add(medicine);
            }
            return medicines;
        }
Esempio n. 4
0
 public void Save(Medicine medicine)
 {
     myMedicineGateWay.Save(medicine);
 }