Пример #1
0
        private void AddMedicationButton_Click(object sender, EventArgs e)
        {
            if (MedicationNameBox.Text == "" || PriceTextBox.Text == "")
            {
                MessageBox.Show("Please, enter at least the medication name and price.");
            }
            else
            {
                int r = controllerObj.A_AddMedication(MedicationNameBox.Text.ToString(),
                                                      Convert.ToInt32(PriceTextBox.Text.ToString()),
                                                      (ExpiaryDateTimePicker.Value).ToString("yyyy-MM-dd"));

                if (r > 0)
                {
                    MessageBox.Show("Medication added successfully.");

                    DataTable dt1 = controllerObj.SelectMedsIDsNames();
                    MedicationsComboBox.DataSource    = dt1;
                    MedicationsComboBox.DisplayMember = "Name";
                    MedicationsComboBox.ValueMember   = "MID";
                }
                else
                {
                    MessageBox.Show("Error in adding medication.");
                }
            }
        }