private TextBox Focused()
 {
     if (NameTb.Focus())
     {
         return(NameTb);
     }
     else if (ValueTb.Focus())
     {
         return(ValueTb);
     }
     else if (DescriptionTb.Focus())
     {
         return(DescriptionTb);
     }
     else if (SearchTB.Focus())
     {
         return(SearchTB);
     }
     else
     {
         return(NameTb);
     }
 }
 private void DescriptionTb_MouseDown(object sender, MouseButtonEventArgs e)
 {
     DescriptionTb.Focusable  = true;
     DescriptionTb.CaretIndex = DescriptionTb.CaretIndex;
     DescriptionTb.Focus();
 }
Ejemplo n.º 3
0
        // This Button Click Event when clicked will create a Record within the Database for the specific Patient Created
        private void CreateBtn_Click(object sender, EventArgs e)
        {
            var dForm = Application.OpenForms.OfType <DashboardForm>().Single();
            int i     = dForm.currentPage;

            string queryType = "";

            if (i == 1)
            {
                queryType = "CreateChronicRecord";
            }
            else if (i == 2)
            {
                queryType = "CreateAddictionRecord";
            }
            else if (i == 3)
            {
                queryType = "CreateCounselingRecord";
            }

            using (SqlConnection conn = new SqlConnection(GlobalConfig.ConnectionString))
            {
                conn.Open();

                using (SqlCommand cmd = new SqlCommand(queryType, conn))
                {
                    // Define Command Type
                    cmd.CommandType = CommandType.StoredProcedure;

                    // Adding the Parameters to the SP we calling
                    cmd.Parameters.AddWithValue("@IDNumber", IDNumber);
                    cmd.Parameters.AddWithValue("ReasonForVisit", RFVTb.Text);
                    cmd.Parameters.AddWithValue("@DateOfVisit", DateDp.Text);
                    cmd.Parameters.AddWithValue("@RecordDescription", DescriptionTb.Text);
                    cmd.Parameters.AddWithValue("@Condition", conditionTxt.Text);
                    cmd.Parameters.AddWithValue("@Medication", medicationTxt.Text.Replace("\r\n", "<br />"));

                    //Label1.Text = someDatabaseText.Replace("\r\n", "<br />");

                    cmd.ExecuteNonQuery();

                    MessageBox.Show("New Record Created!");

                    RFVTb.Clear();
                    DescriptionTb.Clear();

                    if (queryType == "CreateChronicRecord")
                    {
                        var chronicForm = Application.OpenForms.OfType <ChronicPatients>().Single();
                        chronicForm.RefreshRecordList();
                    }
                    else if (queryType == "CreateAddictionRecord")
                    {
                        var aForm = Application.OpenForms.OfType <AddictionForm>().Single();
                        aForm.RefreshRecordList();
                    }
                    else if (queryType == "CreateCounselingRecord")
                    {
                        var cForm = Application.OpenForms.OfType <CounselingForm>().Single();
                        cForm.RefreshRecordList();
                    }
                }
            }
        }