protected void btnOk_Click(object sender, EventArgs e)
    {
        try
        {
            int              selected_userId;
            UserClass        uc  = new UserClass();
            PatientClass     pc  = new PatientClass();
            UserPatientClass upc = new UserPatientClass();
            LogUserClass     luc = new LogUserClass();
            LogPatientClass  lpc = new LogPatientClass();

            /*Delete Users' and Patient's record
             * Insert values on Log_UsersWholeFieldWithName and Log_PatientWholeFieldWithName table*/
            /*Getting userId from username from Users table*/
            DataTable dt = uc.SelectAllUsersFromUsername(Session["selectedRow_Username"].ToString());
            if (dt.Rows.Count > 0)
            {
                Session["selected_userId"] = dt.Rows[0]["userId"].ToString();
                selected_userId            = Convert.ToInt32(Session["selected_userId"]);

                /*Getting patientRecord from userId from Patient table*/
                DataTable dtPatient = pc.SelectAllPatientFromUserId(selected_userId);
                if (dtPatient.Rows.Count > 0)
                {
                    Session["selected_patientId"] = dtPatient.Rows[0]["patientId"].ToString();
                    int selected_patientId = Convert.ToInt32(Session["selected_patientId"]);

                    String selected_patientFirstName  = dtPatient.Rows[0]["patientFirstName"].ToString();
                    String selected_patientMiddleName = dtPatient.Rows[0]["patientMiddleName"].ToString();
                    String selected_patientLastName   = dtPatient.Rows[0]["patientLastName"].ToString();
                    Session["selected_patientName"] = selected_patientFirstName + " "
                                                      + selected_patientMiddleName + " " + selected_patientLastName;

                    luc.insertOn_Log_UsersWholeFieldWithName_WithDeleteOperation(selected_userId, Session["selectedRow_Username"].ToString());
                    lpc.insertOn_Log_PatientWholeFieldWithName_WithDeleteOperation(selected_userId, selected_patientId, Session["selected_patientName"].ToString());
                    uc.delete_UsersFrom_userId(selected_userId);
                    pc.delete_PatientFrom_userId(selected_userId);
                }
                //else { ltrMessage.Text = "Error 2nd if"; }
            }
            //else { ltrMessage.Text += "Error 1st if"; }
        }
        catch (Exception ex)
        {
            ltrMessage.Text = ex.Message;
        }
        finally
        {
            ltrDelMsg.Visible = false;
            btnOk.Visible     = false;
            loadData();
        }
    }
    protected void btn_Ok_Click(object sender, EventArgs e)
    {
        try
        {
            PatientClass    pc  = new PatientClass();
            LogPatientClass lpc = new LogPatientClass();
            DiseaseClass    dc  = new DiseaseClass();
            EntryUserClass  euc = new EntryUserClass();

            /*Current date and time calculated*/
            DateTime currentDateNTime = DateTime.Now;
            String   checkedPatDate   = currentDateNTime.ToString("dd/MM/yyyy hh:mm:ss tt");

            int checkedPatBy = Convert.ToInt32(Session["userId"]);

            /*selectPatientIdFromPatientUsername*/
            String    selected_PatUsername = Session["selectedRow_Username"].ToString();
            DataTable dt = pc.selectPatientIdFromPatientUsername(selected_PatUsername);
            if (dt.Rows.Count > 0)
            {
                int selectedRow_patientId = Convert.ToInt32(dt.Rows[0]["patientId"].ToString());

                /*selectEntryUserHospitalFrom_EntryUserUsername*/
                String    entryUser_username = Session["username"].ToString();
                DataTable dt2 = euc.selectEntryUserHospitalFrom_EntryUserUsername(entryUser_username);
                if (dt2.Rows.Count > 0)
                {
                    String entryUserHospital = dt2.Rows[0]["entryUserHospital"].ToString();

                    ltrMessage1.Text = "";
                    /*insertIn_CheckedPat*/
                    pc.insertIn_CheckedPat(selectedRow_patientId, checkedPatDate, txtbox_DiseaseName.Text,
                                           txtbox_Remarks.Text, entryUserHospital, checkedPatBy);
                }
                else
                {
                    ltrMessage1.Text = "No data found!";
                }
            }
            else
            {
                ltrMessage1.Text = "No data found!";
            }

            /*get_checkedPatIdFrom_checkedPatDateNcheckedPatBy*/
            DataTable dt1 = pc.get_checkedPatIdFrom_checkedPatDateNcheckedPatBy(checkedPatDate, checkedPatBy);
            if (dt1.Rows.Count > 0)
            {
                int checkedPatId = Convert.ToInt32(dt1.Rows[0]["checkedPatId"].ToString());
                //Session["checkedPatId"] = dt.Rows[0]["checkedPatId"].ToString();
                /*insertIn_Log_CheckedPatWholeField*/
                lpc.insertIn_Log_CheckedPatWholeField(checkedPatDate, checkedPatId);
            }
            else
            {
                ltrMessage1.Text = "No data found!";
            }
            /*insertIn_Disease*/
            dc.insertIn_Disease(txtbox_DiseaseName.Text, txtbox_Remarks.Text, checkedPatBy,
                                checkedPatDate);

            Response.Redirect("Patient_CheckupWithHistory_EntryUserMaster.aspx");
            //txtbox_DiseaseName.Text = "";
            //txtbox_Remarks.Text = "";
        }
        catch (Exception ex)
        {
            ltrMessage.Text = ex.Message;
        }
    }
    protected void btnRegister_Click(object sender, EventArgs e)
    {
        try
        {
            UserPatientClass upc = new UserPatientClass();
            LogUserClass     luc = new LogUserClass();
            LogPatientClass  lpc = new LogPatientClass();

            /*Check normal conditions*/
            //1. Checking Patient Age Group if not <1
            DateTime currentDateNTime = DateTime.Now;
            int      currentYear      = currentDateNTime.Year; //Getting current year

            DateTime dob;
            dob = Convert.ToDateTime(txtboxDob.Text);
            int dobYear = dob.Year; //Getting dob year

            int age = currentYear - dobYear;

            if (age < 1)
            {
                ltrMessage.Text = "Invalid Date of Birth!";
            }

            /*Passwords matching checking*/
            else if (txtboxPassword.Text != txtboxConfirmPassword.Text)
            {
                ltrMessage.Text = "The Passwords did not match!";
            }

            /*2 emails matching checking*/
            else if (txtboxEmail.Text == txtboxSecEmail.Text)
            {
                ltrMessage.Text = "The 2 Email addresses you provided should not be same!";
            }

            /*2 contacts matching checking*/
            else if (txtboxContact.Text == txtboxSecContact.Text)
            {
                ltrMessage.Text = "The 2 Contact Numbers you provided should not be same!";
            }

            else
            {
                ltrMessage.Text = "";
                upc.RegisterPatient_Users(txtboxUsername.Text, txtboxPassword.Text, txtboxEmail.Text, txtboxSecEmail.Text);

                /*Putting Country as Nepal by default*/
                String country;
                if (txtboxCountry.Text == "")
                {
                    country = "Nepal";
                    //Console.WriteLine("Went to this condition!");
                }
                else
                {
                    country = txtboxCountry.Text;
                }
                upc.RegisterPatient_Patient(txtboxUsername.Text, txtboxFirstName.Text, txtboxMiddleName.Text, txtboxLastName.Text, txtboxDob.Text, dropdownlistGender.Text, txtboxContact.Text, txtboxSecContact.Text, txtboxHouseAdd.Text, txtboxDistrict.Text, txtboxCity.Text, country);

                String username = txtboxUsername.Text;

                luc.insertOn_Log_UsersWholeField_WithInsertOperation(username);
                lpc.insertOn_Log_PatientWholeField_WithInsertOperation(username);

                Session["username"] = txtboxUsername.Text;
                Response.Redirect("Home_Patient.aspx");
                //ltrMessageGreen.Text = "New Account registered!";

                //txtboxUsername.Text = "";
                //txtboxPassword.Text = "";
                //txtboxEmail.Text = "";
                //txtboxSecEmail.Text = "";

                //txtboxFirstName.Text = "";
                //txtboxMiddleName.Text = "";
                //txtboxLastName.Text = "";
                //txtboxDob.Text = "";
                //dropdownlistGender.Text = "";
                //txtboxContact.Text = "";
                //txtboxSecContact.Text = "";
                //txtboxHouseAdd.Text = "";
                //txtboxDistrict.Text = "";
                //txtboxCity.Text = "";
                //txtboxCountry.Text = "";

                //txtboxFirstName.Focus();
            }
        }
        catch (Exception ex)
        {
            ltrMessage.Text = ex.Message;
        }
    }