/// <summary> /// Method that tries to register the patient into the database /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void registerBtn_Click(object sender, EventArgs e) { if (string.IsNullOrWhiteSpace(nameTxt.Text) || string.IsNullOrWhiteSpace(addressTxt.Text) || string.IsNullOrWhiteSpace(pstCodeTxt.Text) || string.IsNullOrWhiteSpace(pstCodeTxt.Text) || string.IsNullOrWhiteSpace(cityTxt.Text) || string.IsNullOrWhiteSpace(dobTimePick.Text) || string.IsNullOrWhiteSpace(phoneNumberTxt.Text)) { // Message box MessageBox.Show("Please fill all Fields"); } else { try { Logger.Instance.Log("RegisterPatientUserControl:registerBtn_Click() -> Registering a patient"); //Try to register patient by getting the data from the user input textboxes //Convert the date time from the value picker to a desired value string dobTemp = dobTimePick.Value.ToString("yyyy/MM/dd"); DBConnection.getDBConnectionInstance().SqlStatementExecute(Constants.RegisterPatient(nameTxt.Text, addressTxt.Text, pstCodeTxt.Text, cityTxt.Text, dobTemp, phoneNumberTxt.Text)); //Show success message and close form MessageBox.Show("Patient added successfully!"); PatientUserControl.RemoveRegister(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
//https://www.youtube.com/watch?v=ao4HwEpW7eg //C# Tutorial : How to load User control dynamically | FoxLearn private void patientBtn_Click(object sender, EventArgs e) { //put the sidescroll panel in the correct place, selection SidePanelScroll.Height = patientBtn.Height; SidePanelScroll.Top = patientBtn.Top; //remove register patient if it is present in the panel. PatientUserControl.RemoveRegister(); if (!userControlPanel.Controls.Contains(PatientUserControl.Instance)) { userControlPanel.Controls.Add(PatientUserControl.Instance); PatientUserControl.Instance.Dock = DockStyle.Fill; PatientUserControl.Instance.BringToFront(); } else { PatientUserControl.Instance.BringToFront(); PatientUserControl.Instance.PatientUserControlRefresh(); } }