Exemplo n.º 1
0
        private void UpdateMedicationButton_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_UpdateMedication(Convert.ToInt32(MedicationsComboBox.SelectedValue),
                                                         MedicationNameBox.Text.ToString(),
                                                         Convert.ToInt32(PriceTextBox.Text.ToString()),
                                                         (ExpiaryDateTimePicker.Value).ToString("yyyy-MM-dd"));

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

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