Example #1
0
        // DB Viewer
        private void DataSourceCon(String cmd)
        {
            NumOfPatients2.Text = NumberOfPatients.ToString();

            // Automatically generate the DataGridView columns.
            dataGridView1.AutoGenerateColumns      = true;
            dataGridView1.AllowUserToResizeColumns = true;
            dataGridView1.AllowUserToResizeRows    = true;


            try
            {
                // Set up the data source.
                newBS.DataSource         = myDSconnection.GetData(cmd);
                dataGridView1.DataSource = newBS.DataSource;
                // Set the DataGridView control's border.
                dataGridView1.BorderStyle = BorderStyle.Fixed3D;

                // Put the cells in edit mode when user enters them.
                dataGridView1.EditMode = DataGridViewEditMode.EditOnEnter;
            }
            catch (SqlException)
            {
                MessageBox.Show("To run this sample replace connection.ConnectionString" +
                                " with a valid connection string to a Your DB" +
                                " database accessible to your system.", "ERROR",
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                System.Threading.Thread.CurrentThread.Abort();
            }
        }
Example #2
0
        // Fill the Comboboxes with Data
        public void FillComboBoxes()
        {
            // Diagnosis and Treatment Plans Grid
            string SqlCommand = "SELECT DISTINCT Diagnose FROM DiagnosisList";

            BSS.DataSource                = Con.GetData(SqlCommand);
            Login_Form.DiagList           = (DataTable)BSS.DataSource;
            DiagnosisColumn.DataSource    = Login_Form.DiagList;
            DiagnosisColumn.DisplayMember = "Diagnose";

            // Dates and Procedures Grid
            SqlCommand                     = "SELECT DISTINCT Procedures FROM ProcedureList";
            BSS.DataSource                 = Con.GetData(SqlCommand);
            Login_Form.ProcList            = (DataTable)BSS.DataSource;
            Dates_Procedures.DataSource    = Login_Form.ProcList;
            Dates_Procedures.DisplayMember = "Procedures";
        }
        // View the data of the result search
        public void ViewData()
        {
            // Automatically generate the DataGridView columns.
            DataTable Check = new DataTable();

            try
            {
                Search_Result_dataGridView.AutoGenerateColumns      = true;
                Search_Result_dataGridView.AllowUserToResizeColumns = true;
                Search_Result_dataGridView.AllowUserToResizeRows    = true;
                // Set up the data source.
                BS.DataSource = myDSC.GetData(sqlCommand);
                Check         = myDSC.GetData(sqlCommand);

                if (Check.Rows.Count == 0)
                {
                    ShowForm = false;
                    MessageBox.Show("This Search key is not exist in the database\nPlease try again with different Search Key/s");
                    return;
                }
                Search_Result_dataGridView.DataSource = BS.DataSource;
                // Set the DataGridView control's border.
                Search_Result_dataGridView.BorderStyle = BorderStyle.Fixed3D;

                // Put the cells in edit mode when user enters them.
                Search_Result_dataGridView.EditMode = DataGridViewEditMode.EditOnEnter;
            }
            catch (SqlException)
            {
                MessageBox.Show("To run this sample replace connection.ConnectionString" +
                                " with a valid connection string to a Your DB" +
                                " database accessible to your system.", "ERROR",
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                System.Threading.Thread.CurrentThread.Abort();
            }
        }
        private void IntializeComboboxes()
        {
            String SqlCommand = "SELECT DISTINCT Procedures FROM ProcedureList";

            BS.DataSource = con.GetData(SqlCommand);
            if (Login_Form.ProcList.Rows.Count != 0)
            {
                Procedures_comboBox.DataSource = Login_Form.ProcList;
            }
            else
            {
                Procedures_comboBox.DataSource = BS;
            }

            Procedures_comboBox.DisplayMember = "Procedures";
            Procedures_comboBox.SelectedIndex = -1;
        }
        // Check if Search key is exist
        private bool Check_IfExist(String Option, String SearchKey)
        {
            DataSourceConnection Check = new DataSourceConnection();
            DataTable _Check = new DataTable();
            if (Option == "Diagnose")
            {

                _Check = Check.GetData("Select Diagnose from Diagnosis where Diagnose LIKE '%" + SearchKey + "%'");
                
                if (_Check.Rows.Count == 0)
                {
                    MessageBox.Show("This Diagnose is not exist on your database");
                    return false;
                }

            }
            else if (Option == "Procedures")
            {
                _Check = Check.GetData("Select Procedures from Dates where Procedures LIKE '%" + SearchKey + "%'");
                if (_Check.Rows.Count == 0)
                {
                    MessageBox.Show("This Procedure is not exist on your database");
                    return false;
                }
            }
            if (Option == "Visit_date")
            {
                DateTime temp = DateTime.Parse(SearchKey);
                if (!SearchContext.Patient_info.Any(i => i.Visit_date == temp))
                {
                    MessageBox.Show("This Visit date is not exist on your database");
                    return false;
                }
            }
            else if (Option == "Doctor_name")
            {
                _Check = Check.GetData("Select Doctor_name from Dates where Doctor_name LIKE '%" + SearchKey + "%'");
                if (_Check.Rows.Count == 0)
                {
                    MessageBox.Show("This Doctor Name is not exist on your database");
                    return false;
                }
            }
            else if (Option == "Sex")
            {
                if (!SearchContext.Patient_info.Any(i => i.Sex == SearchKey))
                {
                    MessageBox.Show("This Sex is not exist on your database");
                    return false;
                }
            }
            else if (Option == "Relative_marriage")
            {
                if (!SearchContext.Patient_info.Any(i => i.Relative_marriage == SearchKey))
                {
                    MessageBox.Show("This Relative Marriage is not exist on your database");
                    return false;
                }
            }
            else if (Option == "Patient_name")
            {
                _Check = Check.GetData("Select Patient_name from Patient_info where Patient_name LIKE '%" + SearchKey + "%'");
                if (_Check.Rows.Count == 0)
                {
                    MessageBox.Show("This Patient Name is not exist on your database");
                    return false;
                }
            }
            else if (Option == "Age")
            {
                int temp = Int32.Parse(SearchKey);
                if (!SearchContext.Patient_info.Any(i => i.Age == temp))
                {
                    MessageBox.Show("This Age is not exist on your database");
                    return false;
                }
            }
            return true;

        }
Example #6
0
        // Intialize DiagList And ProcList
        private void IntializeLists()
        {
            string SqlCommand = "SELECT DISTINCT Diagnose FROM DiagnosisList";

            BS.DataSource = con.GetData(SqlCommand);
            if (Login_Form.DiagList.Rows.Count != 0)
            {
                Set_Search_Diagnosis_comboBox.DataSource = Login_Form.DiagList;
                SetK_P1_Diagnosis_comboBox.DataSource    = Login_Form.DiagList;
                SetK_P2_Diagnosis_comboBox.DataSource    = Login_Form.DiagList;
            }
            else
            {
                Set_Search_Diagnosis_comboBox.DataSource = BS.DataSource;
                SetK_P1_Diagnosis_comboBox.DataSource    = BS.DataSource;
                SetK_P2_Diagnosis_comboBox.DataSource    = BS.DataSource;
            }

            Set_Search_Diagnosis_comboBox.DisplayMember = "Diagnose";
            Set_Search_Diagnosis_comboBox.SelectedIndex = -1;
            SetK_P1_Diagnosis_comboBox.DisplayMember    = "Diagnose";
            SetK_P1_Diagnosis_comboBox.SelectedIndex    = -1;
            SetK_P2_Diagnosis_comboBox.DisplayMember    = "Diagnose";
            SetK_P2_Diagnosis_comboBox.SelectedIndex    = -1;

            SqlCommand    = "SELECT DISTINCT Procedures FROM ProcedureList";
            BS.DataSource = con.GetData(SqlCommand);
            if (Login_Form.ProcList.Rows.Count != 0)
            {
                Set_Search_Procedures_comboBox.DataSource = Login_Form.ProcList;
                SetK_P1_DAP_comboBox.DataSource           = Login_Form.ProcList;
                SetK_P2_DAP_comboBox.DataSource           = Login_Form.ProcList;
            }

            else
            {
                Set_Search_Procedures_comboBox.DataSource = BS.DataSource;
                SetK_P1_DAP_comboBox.DataSource           = BS.DataSource;
                SetK_P2_DAP_comboBox.DataSource           = BS.DataSource;
            }

            Set_Search_Procedures_comboBox.DisplayMember = "Procedures";
            Set_Search_Procedures_comboBox.SelectedIndex = -1;
            SetK_P1_DAP_comboBox.DisplayMember           = "Procedures";
            SetK_P1_DAP_comboBox.SelectedIndex           = -1;
            SetK_P2_DAP_comboBox.DisplayMember           = "Procedures";
            SetK_P2_DAP_comboBox.SelectedIndex           = -1;

            //---------------------
            TableNames.Add("Diagnose", "Diagnosis");
            TableNames.Add("Procedures", "Dates");
            TableNames.Add("Visit_date", "Patient_info");
            TableNames.Add("Sex", "Patient_info");
            TableNames.Add("Relative_marriage", "Patient_info");
            TableNames.Add("Patient_name", "Patient_info");
            TableNames.Add("Age", "Patient_info");
            TableNames.Add("Doctor_name", "Dates");
            //---------------------------------
            SearchOptions.Add("Diagnose");
            SearchOptions.Add("Procedures");
            SearchOptions.Add("Visit_date");
            SearchOptions.Add("Sex");
            SearchOptions.Add("Relative_marriage");
            SearchOptions.Add("Patient_name");
            SearchOptions.Add("Age");
            SearchOptions.Add("Doctor_name");
        }
Example #7
0
        // Check if Search key is exist
        private bool Check_IfExist(String Option, String SearchKey)
        {
            DataSourceConnection Check  = new DataSourceConnection();
            DataTable            _Check = new DataTable();

            if (Option == "Diagnose")
            {
                _Check = Check.GetData("Select Diagnose from Diagnosis where Diagnose LIKE '%" + SearchKey + "%'");

                if (_Check.Rows.Count == 0)
                {
                    MessageBox.Show("This Diagnose is not exist on your database");
                    return(false);
                }
            }
            else if (Option == "Procedures")
            {
                _Check = Check.GetData("Select Procedures from Dates where Procedures LIKE '%" + SearchKey + "%'");
                if (_Check.Rows.Count == 0)
                {
                    MessageBox.Show("This Procedure is not exist on your database");
                    return(false);
                }
            }
            if (Option == "Visit_date")
            {
                DateTime temp = DateTime.Parse(SearchKey);
                if (!SearchContext.Patient_info.Any(i => i.Visit_date == temp))
                {
                    MessageBox.Show("This Visit date is not exist on your database");
                    return(false);
                }
            }
            else if (Option == "Doctor_name")
            {
                _Check = Check.GetData("Select Doctor_name from Dates where Doctor_name LIKE '%" + SearchKey + "%'");
                if (_Check.Rows.Count == 0)
                {
                    MessageBox.Show("This Doctor Name is not exist on your database");
                    return(false);
                }
            }
            else if (Option == "Sex")
            {
                if (!SearchContext.Patient_info.Any(i => i.Sex == SearchKey))
                {
                    MessageBox.Show("This Sex is not exist on your database");
                    return(false);
                }
            }
            else if (Option == "Relative_marriage")
            {
                if (!SearchContext.Patient_info.Any(i => i.Relative_marriage == SearchKey))
                {
                    MessageBox.Show("This Relative Marriage is not exist on your database");
                    return(false);
                }
            }
            else if (Option == "Patient_name")
            {
                _Check = Check.GetData("Select Patient_name from Patient_info where Patient_name LIKE '%" + SearchKey + "%'");
                if (_Check.Rows.Count == 0)
                {
                    MessageBox.Show("This Patient Name is not exist on your database");
                    return(false);
                }
            }
            else if (Option == "Age")
            {
                int temp = Int32.Parse(SearchKey);
                if (!SearchContext.Patient_info.Any(i => i.Age == temp))
                {
                    MessageBox.Show("This Age is not exist on your database");
                    return(false);
                }
            }
            return(true);
        }