Ejemplo n.º 1
0
        private void saveButton_Click(object sender, EventArgs e)
        {
            Purchase purchase = new Purchase();

            purchase.PurchaseDate = purchasedateTimePicker.Text;

            purchase.Quantity = int.Parse(quantityTextBox.Text);

            purchase.MedicineName = medicineNameTextBox.Text;

            MessageBox.Show("Saved successfully");
        }
Ejemplo n.º 2
0
        public List<Purchase> ShowAll()
        {
            List<Purchase> purchases = new List<Purchase>();
            SqlConnection sqlConnection = new SqlConnection(connectionString);
            string query = "SELECT p.id id,m.m_name name,p.qty qty,p.p_date date1,p.price price FROM purchase p, medicine m";
            SqlCommand command = new SqlCommand(query, sqlConnection);
            sqlConnection.Open();
            SqlDataReader myReader = command.ExecuteReader();
            while (myReader.Read())
            {
                Purchase purchase = new Purchase();

                purchase.PurchaseId = Convert.ToInt32(myReader["id"].ToString());
                purchase.PurchaseDate = myReader["date1"].ToString();
                purchase.MedicineName = myReader["name"].ToString();
                purchase.Quantity = Convert.ToInt32(myReader["qty"].ToString());
                purchase.price = Convert.ToInt32(myReader["price"].ToString());

                purchases.Add(purchase);
            }
            return purchases;
        }