Exemplo n.º 1
0
        // Delete Set of patients
        private void Delete_patients_button_Click(object sender, EventArgs e)
        {
            String From, To;
            int    FromID, ToID;

            From = Delete_from_textBox.Text;
            To   = Delete_to_textBox.Text;

            if (!ValidateData.ValidateIDField(From))
            {
                Error.SetError(Delete_from_textBox, "sdgd");
                return;
            }
            Error.Clear();

            if (!ValidateData.ValidateIDField(To))
            {
                Error.SetError(Delete_to_textBox, "sdgd");
                return;
            }
            Error.Clear();

            FromID = Int32.Parse(From);
            ToID   = Int32.Parse(To);

            //------------------------------------
            string            message = "Are you sure you want to delete these patients?";
            string            caption = "Warning";
            MessageBoxButtons buttons = MessageBoxButtons.YesNoCancel;
            MessageBoxIcon    Icon    = MessageBoxIcon.Warning;
            DialogResult      result;

            // Displays the MessageBox.

            result = MessageBox.Show(message, caption, buttons, Icon);
            if (result == DialogResult.Yes)
            {
                Delete.Database.ExecuteSqlCommand("DELETE FROM Diagnosis WHERE Patient_ID BETWEEN {0} AND {1} ", FromID, ToID);
                Delete.Database.ExecuteSqlCommand("DELETE FROM Dates WHERE Patient_ID BETWEEN {0} AND {1} ", FromID, ToID);
                Delete.Database.ExecuteSqlCommand("DELETE FROM [X-ray_images] WHERE Patient_ID BETWEEN {0} AND {1} ", FromID, ToID);
                int Number_of_rows_Affected = Delete.Database.ExecuteSqlCommand("DELETE FROM Patient_info WHERE Patient_ID BETWEEN {0} AND {1} ", FromID, ToID);

                Delete.SaveChanges();

                MessageBox.Show(Number_of_rows_Affected + " Patients was deleted.\n Please check your DB browser");

                if (Number_of_rows_Affected != 0)
                {
                    ValidateData.ReorderXray_table();
                    ValidateData.ReorderDiagnosis_table();
                    ValidateData.ReorderDates_table();
                }
                Delete_from_textBox.Text = "";
                Delete_to_textBox.Text   = "";
            }
        }
Exemplo n.º 2
0
        // Search In ranges
        private void Search_In_Range_button_Click(object sender, EventArgs e)
        {
            String Option = Search_In_Range_comboBox.Text;
            String SearchKeyFROM, SearchKeyTO, SQLcommand;

            #region Data Validation
            if (!ValidateData.ValidateComboBoxItem(Option, new List <String> {
                "Patient_ID", "Age", "Visit_date", "Birth_date", "DMF", "_dmf", "DEF"
            }))
            {
                Error.SetError(Search_In_Range_comboBox, "Please");
                return;
            }
            Error.Clear();

            SearchKeyFROM = Search_IR_from_textBox.Text;
            SearchKeyTO   = Search_IR_to_textBox.Text;

            if (Option == "Patient_ID" && (!ValidateData.ValidateIDField(SearchKeyFROM) || !ValidateData.ValidateIDField(SearchKeyTO)))
            {
                Error.SetError(SIR_SK_Label, "Enter valid ID");
                return;
            }
            else if (Option == "Age" && (!ValidateData.ValidateAge(SearchKeyFROM) || !ValidateData.ValidateAge(SearchKeyTO)))
            {
                Error.SetError(SIR_SK_Label, "Enter Valid age");
                return;
            }
            else if (Option == "Visit_date" && (!ValidateData.ValidateDate(SearchKeyFROM) || !ValidateData.ValidateDate(SearchKeyTO)))
            {
                MessageBox.Show("Please enter valid Visit date, ex: 1/2/2002 ");
                Error.SetError(SIR_SK_Label, "Enter valid visit date");
                return;
            }
            else if (Option == "Birth_date" && (!ValidateData.ValidateDate(SearchKeyFROM) || !ValidateData.ValidateDate(SearchKeyTO)))
            {
                MessageBox.Show("Please enter valid Birth date, ex: 1/2/2002 ");
                Error.SetError(SIR_SK_Label, "Enter valid visit date");
                return;
            }
            else if (Option == "DMF" && (!ValidateData.ValidateDoubleSearchKEy(SearchKeyFROM) || !ValidateData.ValidateDoubleSearchKEy(SearchKeyTO)))
            {
                MessageBox.Show("Please enter valid DMF values");
                Error.SetError(SIR_SK_Label, "Enter valid DMF values");
                return;
            }
            else if (Option == "_dmf" && (!ValidateData.ValidateDoubleSearchKEy(SearchKeyFROM) || !ValidateData.ValidateDoubleSearchKEy(SearchKeyTO)))
            {
                MessageBox.Show("Please enter valid dmf values");
                Error.SetError(SIR_SK_Label, "Enter valid DMF values");
                return;
            }
            else if (Option == "DEF" && (!ValidateData.ValidateDoubleSearchKEy(SearchKeyFROM) || !ValidateData.ValidateDoubleSearchKEy(SearchKeyTO)))
            {
                MessageBox.Show("Please enter valid DEF values");
                Error.SetError(SIR_SK_Label, "Enter valid DEF values");
                return;
            }
            Error.Clear();
            #endregion

            /////////////////////////////////////
            // Fetch Data from DB

            SQLcommand = Get_Search_InRange_SQLcommand(Option, SearchKeyFROM, SearchKeyTO);

            if (SQLcommand.Length != 0)
            {
                Search_Result newResult = new Search_Result(SQLcommand);

                if (newResult.ShowForm == true)
                {
                    newResult.Show();
                }
                else
                {
                    Error.SetError(Set_Search_2P_Button, "Search keys is not exist in your database");
                    return;
                }
            }
            else
            {
                MessageBox.Show("SQL COMMAND STRING IS EMPTY");
            }
            Error.Clear();
        }