Exemplo n.º 1
0
 protected void btnRemarks_Click(object sender, System.EventArgs e)
 {
     try
     {
         if (string.IsNullOrEmpty(txtRemarks.Text.Trim()))
         {
             this.ErrorMessage += "Remarks is Required <br />";
         }
         else
         {
             //Save Remarks
             string strSql = string.Format("Update doctorpatient set doctorremarks='{0}' where " +
                                           "doctorid = {1} and patientid = {2} ",
                                           BaseDA.Escape(txtRemarks.Text.Trim()),
                                           this.UserId, this.SelectedPId);
             BaseDA.ExecuteNonQuery(strSql);
             phRemarks.Visible = false;
             this.SelectedPId  = 0;
         }
     }
     catch (Exception ex)
     {
         this.ErrorMessage = ex.Message;
     }
 }
Exemplo n.º 2
0
        protected void btnAssociate_Click(object sender, System.EventArgs e)
        {
            try
            {
                if (this.ValidateData())
                {
                    string strSql = " insert into doctorpatient(doctorid, patientid) " +
                                    " values ({0}, {1}); " +
                                    " update login set isnewuser=false where id={2} ";
                    foreach (GridViewRow row in gvHist.Rows)
                    {
                        CheckBox chk = (CheckBox)(row.FindControl("chkSelect"));
                        if (chk.Checked)
                        {
                            int          PatId    = Convert.ToInt32(row.Cells[1].Text);
                            DropDownList ddlDoc   = (DropDownList)(row.FindControl("ddlDoctor"));
                            int          intDocId = Convert.ToInt32(ddlDoc.SelectedValue);
                            //check duplicate
                            string  userIdSql = string.Format("select * from doctorpatient where doctorid = " + intDocId + " and patientid = " + PatId);
                            DataSet ds        = BaseDA.ExecuteDataSet(userIdSql);

                            if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                            {
                                DataRow dr = ds.Tables[0].Rows[0];
                                if (dr != null)
                                {
                                    if (dr["doctorid"] != null)
                                    {
                                        ErrorMessage += "Patient " + row.Cells[2].Text + " already associated to the selected Doctor  <br/>";
                                    }
                                }
                            }
                            else
                            {
                                BaseDA.ExecuteNonQuery(string.Format(strSql, intDocId, PatId, PatId));
                            }
                        }
                    }
                    this.RefreshData();
                }
            }
            catch (Exception ex)
            {
                this.ErrorMessage = "Exception : " + ex.Message;
            }
        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            ErrorMessage = string.Empty;
            try
            {
                StrErros = string.Empty;
                if (string.IsNullOrEmpty(username))
                {
                    ErrorMessage += "You donot have access to this page";
                    Response.Redirect("Default.aspx");
                }
                if (string.IsNullOrEmpty(txtPassword.Text.Trim()))
                {
                    StrErros += "Password is required <br/>";
                }
                if (string.IsNullOrEmpty(txtRetypePassword.Text.Trim()))
                {
                    StrErros += "Retype Password is required <br/>";
                }
                if (!string.IsNullOrEmpty(txtPassword.Text.Trim()) &&
                    !string.IsNullOrEmpty(txtRetypePassword.Text.Trim()))
                {
                    if (txtPassword.Text.Trim() != txtRetypePassword.Text.Trim())
                    {
                        StrErros += "Password and Retyped Password must be the same <br/>";
                    }
                }

                if (string.IsNullOrEmpty(StrErros))
                {
                    //update new password
                    string strSql = string.Format("Update login set password='******' where " +
                                                  "username = '******'",
                                                  BaseDA.Escape(txtPassword.Text.Trim()),
                                                  username);
                    BaseDA.ExecuteNonQuery(strSql);
                    Response.Redirect("PasswordChanged.aspx");
                }
            }
            catch (Exception ex)
            {
                StrErros = "Exception " + ex;
            }
        }
Exemplo n.º 4
0
        protected void btnRegister_Click(object sender, EventArgs e)
        {
            ErrorMessage   = string.Empty;
            lblErrors.Text = string.Empty;
            try
            {
                //check for required field validation

                if (string.IsNullOrEmpty(txtUserId.Text.Trim()))
                {
                    ErrorMessage += "User name is required <br/>";
                }

                //check if the user name selected already exists in the database, if it exists its an invalid entry
                if (!string.IsNullOrEmpty(txtUserId.Text.Trim()))
                {
                    string  userIdSql = string.Format("SELECT * FROM LOGIN WHERE username = '******'", BaseDA.Escape(txtUserId.Text.Trim()));
                    DataSet ds        = BaseDA.ExecuteDataSet(userIdSql);

                    if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                    {
                        DataRow dr = ds.Tables[0].Rows[0];
                        if (dr != null)
                        {
                            if (dr["Id"] != null)
                            {
                                ErrorMessage += "User name already exists. Please choose a different user name <br/>";
                            }
                        }
                    }
                }

                if (string.IsNullOrEmpty(txtPassword.Text.Trim()))
                {
                    ErrorMessage += "Password is required <br/>";
                }
                if (string.IsNullOrEmpty(txtRetypePwd.Text.Trim()))
                {
                    ErrorMessage += "Retype Password is required <br/>";
                }

                // check that password = retyped password
                if (!string.IsNullOrEmpty(txtPassword.Text.Trim()) && !string.IsNullOrEmpty(txtRetypePwd.Text.Trim()))
                {
                    if (txtPassword.Text.Trim() != txtRetypePwd.Text.Trim())
                    {
                        ErrorMessage += "Password and Retyped Password must be the same <br/>";
                    }
                }

                if (string.IsNullOrEmpty(txtFirstName.Text.Trim()))
                {
                    ErrorMessage += "First name is required <br/>";
                }

                if (string.IsNullOrEmpty(txtLastName.Text.Trim()))
                {
                    ErrorMessage += "Last name is required <br/>";
                }

                /*  if (Int16.Parse(listSecQuestion.SelectedValue.Trim())== -1)
                 * {
                 *    ErrorMessage += "Security question is required <br/>";
                 * }*/

                if (string.IsNullOrEmpty(txtAnswer.Text.Trim()))
                {
                    ErrorMessage += "Answer is required <br/>";
                }
                if (string.IsNullOrEmpty(listMonth.SelectedValue.Trim()) || string.IsNullOrEmpty(txtDay.Text.Trim()) || string.IsNullOrEmpty(txtYear.Text.Trim()))
                {
                    ErrorMessage += "Birthdate is required <br/>";
                }

                DateTime birthDate = DateTime.MinValue;

                //Build birth date from the values entered and validate it
                if (!string.IsNullOrEmpty(listMonth.SelectedValue.Trim()) && !string.IsNullOrEmpty(txtDay.Text.Trim()) && !string.IsNullOrEmpty(txtYear.Text.Trim()))
                {
                    double Num;
                    bool   isValidDay, isValidYear;

                    isValidDay = double.TryParse(txtDay.Text, out Num);

                    if (!isValidDay)
                    {
                        ErrorMessage = "Enter a valid date<br/>";
                    }

                    isValidYear = double.TryParse(txtYear.Text, out Num);

                    if (!isValidYear)
                    {
                        ErrorMessage = "Enter a valid date<br/>";
                    }

                    if (!IsValidDate(listMonth.SelectedValue, txtDay.Text.Trim(), txtYear.Text.Trim()))
                    {
                        ErrorMessage = "Enter a valid date<br/>";
                    }
                }


                if (!string.IsNullOrEmpty(ErrorMessage))
                {
                    lblErrors.Text = ErrorMessage;
                }

                //If there is no error message , Valid entry

                if (string.IsNullOrEmpty(ErrorMessage))
                {
                    int month = Int16.Parse(listMonth.SelectedValue);
                    int day   = Int16.Parse(txtDay.Text.Trim());
                    int year  = Int16.Parse(txtYear.Text.Trim());

                    birthDate = new DateTime(year, month, day);

                    //No validation errors, insert the entry

                    string sql = string.Format("INSERT INTO LOGIN (username ,password,firstname,lastname,gender,dob,address,securityQuestion,answer,isnewuser) VALUES ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}')",
                                               BaseDA.Escape(txtUserId.Text), BaseDA.Escape(txtPassword.Text), BaseDA.Escape(txtFirstName.Text), BaseDA.Escape(txtLastName.Text), BaseDA.Escape(listGender.SelectedValue), birthDate, BaseDA.Escape(txtAddress.Text), BaseDA.Escape(listSecQuestion.SelectedValue), BaseDA.Escape(txtAnswer.Text), "TRUE");

                    BaseDA.ExecuteNonQuery(sql);
                    Response.Redirect("Default.aspx", true);
                }
            }

            catch (Exception ex)
            {
                ErrorMessage   = "Exception " + ex;
                lblErrors.Text = ErrorMessage;
            }
        }
Exemplo n.º 5
0
        protected void btnpatient_Click(object sender, EventArgs e)
        {
            try

            {
                /*StringBuilder sb = new StringBuilder();
                 * sb.Append("<script language=\"javascript\">" + "\n");
                 * sb.Append("function confirmthis() { if(confirm(”Do you want to do save this record?”)) { return true; } else { return false; } }");
                 * sb.Append("</script>");
                 * Page.ClientScript.RegisterStartupScript(
                 * this.Page.GetType(),
                 * "OpenPopup",
                 * sb.ToString());*/

                ErrorMessage = string.Empty;

                //clerk
                if (IsAdmin == true)
                {
                    //populate list box with patient names
                    String  sql1 = "SELECT id FROM public.Login where isadmin = false and isdoctor = false and firstname||' '||lastname = '" + listpid.SelectedValue + "'";
                    DataSet ds   = BaseDA.ExecuteDataSet(sql1);

                    if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                    {
                        DataRow dr = ds.Tables[0].Rows[0];
                        if (dr != null)
                        {
                            if (dr["Id"] != null)
                            {
                                lblpatid.Text = dr["id"].ToString();
                            }
                        }
                    }
                }

                //patient
                //store the patient id to be inserted later for new records

                if (IsAdmin == false)
                {
                    lblpatid.Text = this.UserId.ToString();
                }

                //Field Validations

                if (string.IsNullOrEmpty(listpid.Text.Trim()))
                {
                    this.ErrorMessage += "No Patient Selected <br />";
                }

                if ((string.IsNullOrEmpty(txttemp.Text.Trim())))
                {
                    ErrorMessage += "Temperature Is Required. <br />";
                }
                else
                {
                    if (!CheckIfNumbericTemp(txttemp.Text))
                    {
                        this.ErrorMessage += "Temperature should be a Numeric Value<br />";
                    }
                    else
                    {
                        if ((Convert.ToDouble(txttemp.Text) <= 80.00) || (Convert.ToDouble(txttemp.Text) >= 120.00))
                        {
                            this.ErrorMessage += "Temperature should be a positive number between 80 and 120, decimal numbers are accepted. <br />";
                        }
                    }
                }
                if (string.IsNullOrEmpty(txtbphigh.Text.Trim()))
                {
                    this.ErrorMessage += "Blood Pressure - HIGH Is Required. <br />";
                }
                else
                {
                    if (!CheckIfNumberic(txtbphigh.Text))
                    {
                        this.ErrorMessage += "Blood Pressure - HIGH should be Numeric Value<br />";
                    }
                    else
                    {
                        if ((txtbphigh.Text.Length) > 5)
                        {
                            this.ErrorMessage += "Invalid Blood Pressure - HIGH value.Digits Cannot be Greater than 5 <br />";
                        }
                        else
                        {
                            if (((Convert.ToInt32(txtbphigh.Text) <= 0)))
                            {
                                this.ErrorMessage += "Blood Pressure - HIGH value must be positive number, decimal numbers are not accepted. <br />";
                            }
                        }
                    }
                }
                if (string.IsNullOrEmpty(txtbplow.Text.Trim()))
                {
                    this.ErrorMessage += "Blood Pressure - LOW Is Required. <br />";
                }
                else
                {
                    if (!CheckIfNumberic(txtbplow.Text))
                    {
                        this.ErrorMessage += "Blood Pressure - LOW should be Numeric Value<br />";
                    }
                    else
                    {
                        if ((txtbplow.Text.Length) > 5)
                        {
                            this.ErrorMessage += "Invalid Blood Pressure - LOW value.Digits Cannot be Greater than 5 <br />";
                        }
                        else
                        {
                            if (((Convert.ToInt32(txtbplow.Text) <= 0)))
                            {
                                this.ErrorMessage += "Blood Pressure - LOW value must be positive number, decimal numbers are not accepted. <br />";
                            }
                        }
                    }
                    if ((Convert.ToInt32(txtbplow.Text)) > (Convert.ToInt32(txtbphigh.Text)))
                    {
                        this.ErrorMessage += "Blood Pressure - LOW value must be Less Than Blood Pressure - HIGH. <br/>";
                    }
                }
                if (string.IsNullOrEmpty(txtpulserate.Text.Trim()))
                {
                    this.ErrorMessage += "Pulse Rate Is Required. <br />";
                }
                else
                {
                    if (!CheckIfNumberic(txtpulserate.Text))
                    {
                        this.ErrorMessage += "Pulse Rate should be a Numeric Value<br />";
                    }
                    else
                    {
                        if (((Convert.ToInt32(txtpulserate.Text) <= 20)) || ((Convert.ToInt32(txtpulserate.Text) >= 200)))
                        {
                            this.ErrorMessage += "Pulse Rate must be a positive number between 20 and 200, decimal numbers are not accepted. <br />";
                        }
                    }
                }
                if (string.IsNullOrEmpty(txtglucose.Text.Trim()))
                {
                }
                else
                {
                    if (!CheckIfNumberic(txtglucose.Text))
                    {
                        this.ErrorMessage += "Glucose should be a Numeric Value <br />";
                    }
                    else
                    {
                        if ((Convert.ToInt32(txtglucose.Text) <= 20) || (Convert.ToInt32(txtglucose.Text) >= 300))
                        {
                            this.ErrorMessage += "Glucose level must be a positive number between 20 and 300. Decimal numbers are not accepted. <br />";
                        }
                    }
                }

                String sql;
                int    dbinsert = 0;

                bool   isConfirmNeeded = false;
                string confirmMessage  = string.Empty;

                // All server side execution goes here and, if user confirmation is needed,
                // set isConfirmNeeded to true and create the confirmMessage text.


                //Insert Records
                if (string.IsNullOrEmpty(ErrorMessage))
                {
                    //glucose is blank, pain and desc are not blank
                    if ((string.IsNullOrEmpty(txtglucose.Text.Trim())) && (listpainlevel.SelectedValue != "Select") && (!string.IsNullOrEmpty(txtdescription.Text.Trim())))
                    {
                        sql      = string.Format("INSERT into public.patient (pid,temperature,bphigh,bplow,glucose,painlevel,description,entrydate,pulserate) VALUES (" + lblpatid.Text + "," + txttemp.Text + "," + txtbphigh.Text + "," + txtbplow.Text + "," + "NULL" + "," + listpainlevel.Text + ",'" + txtdescription.Text + "',CURRENT_DATE," + txtpulserate.Text + ")");
                        dbinsert = BaseDA.ExecuteNonQuery(sql);
                    }

                    //pain and glucose is blank,desc is not blank
                    if ((string.IsNullOrEmpty(txtglucose.Text.Trim())) && (listpainlevel.SelectedValue.Trim().Contains("Select")) && (!string.IsNullOrEmpty(txtdescription.Text.Trim())))

                    {
                        sql      = string.Format("INSERT into public.patient (pid,temperature,bphigh,bplow,glucose,painlevel,description,entrydate,pulserate) VALUES (" + lblpatid.Text + "," + txttemp.Text + "," + txtbphigh.Text + "," + txtbplow.Text + "," + "NULL" + "," + "NULL" + ",'" + txtdescription.Text + "',CURRENT_DATE," + txtpulserate.Text + ")");
                        dbinsert = BaseDA.ExecuteNonQuery(sql);
                    }


                    //desc and glucose is blank,pain is not blank
                    if ((string.IsNullOrEmpty(txtglucose.Text.Trim())) && (listpainlevel.SelectedValue != "Select") && (string.IsNullOrEmpty(txtdescription.Text.Trim())))
                    {
                        sql      = string.Format("INSERT into public.patient (pid,temperature,bphigh,bplow,glucose,painlevel,description,entrydate,pulserate) VALUES (" + lblpatid.Text + "," + txttemp.Text + "," + txtbphigh.Text + "," + txtbplow.Text + "," + "NULL" + "," + listpainlevel.Text + "," + "NULL" + ",CURRENT_DATE," + txtpulserate.Text + ")");
                        dbinsert = BaseDA.ExecuteNonQuery(sql);
                    }

                    //pain and desc is blank, glucose is not blank
                    if ((!string.IsNullOrEmpty(txtglucose.Text.Trim())) && (listpainlevel.SelectedValue.Trim().Contains("Select")) && (string.IsNullOrEmpty(txtdescription.Text.Trim())))
                    {
                        sql      = string.Format("INSERT into public.patient (pid,temperature,bphigh,bplow,glucose,painlevel,description,entrydate,pulserate) VALUES (" + lblpatid.Text + "," + txttemp.Text + "," + txtbphigh.Text + "," + txtbplow.Text + "," + txtglucose.Text + "," + "NULL" + "," + "NULL" + ",CURRENT_DATE," + txtpulserate.Text + ")");
                        dbinsert = BaseDA.ExecuteNonQuery(sql);
                    }

                    //pain is blank, glucose and desc are not blank
                    if ((listpainlevel.SelectedValue.Trim().Contains("Select")) && (!string.IsNullOrEmpty(txtglucose.Text.Trim())) && (!string.IsNullOrEmpty(txtdescription.Text.Trim())))
                    {
                        sql      = string.Format("INSERT into public.patient (pid,temperature,bphigh,bplow,glucose,painlevel,description,entrydate,pulserate) VALUES (" + lblpatid.Text + "," + txttemp.Text + "," + txtbphigh.Text + "," + txtbplow.Text + "," + txtglucose.Text + "," + "NULL" + ",'" + txtdescription.Text + "',CURRENT_DATE," + txtpulserate.Text + ")");
                        dbinsert = BaseDA.ExecuteNonQuery(sql);
                    }

                    //desc is blank, glucose and pain is not blank
                    if ((string.IsNullOrEmpty(txtdescription.Text.Trim())) && (!string.IsNullOrEmpty(txtglucose.Text.Trim())) && (listpainlevel.SelectedValue != "Select"))
                    {
                        sql      = string.Format("INSERT into public.patient (pid,temperature,bphigh,bplow,glucose,painlevel,description,entrydate,pulserate) VALUES (" + lblpatid.Text + "," + txttemp.Text + "," + txtbphigh.Text + "," + txtbplow.Text + "," + txtglucose.Text + "," + listpainlevel.Text + "," + "NULL" + ",CURRENT_DATE," + txtpulserate.Text + ")");
                        dbinsert = BaseDA.ExecuteNonQuery(sql);
                    }

                    //all blank
                    if ((string.IsNullOrEmpty(txtdescription.Text.Trim())) && (string.IsNullOrEmpty(txtglucose.Text.Trim())) && (listpainlevel.SelectedValue.Trim().Contains("Select")))
                    {
                        sql      = string.Format("INSERT into public.patient (pid,temperature,bphigh,bplow,glucose,painlevel,description,entrydate,pulserate) VALUES (" + lblpatid.Text + "," + txttemp.Text + "," + txtbphigh.Text + "," + txtbplow.Text + "," + "NULL" + "," + "NULL" + "," + "NULL" + ",CURRENT_DATE," + txtpulserate.Text + ")");
                        dbinsert = BaseDA.ExecuteNonQuery(sql);
                    }

                    //all filled
                    if (!string.IsNullOrEmpty(txtdescription.Text.Trim()) && (!string.IsNullOrEmpty(txtglucose.Text.Trim())) && (listpainlevel.SelectedValue != "Select"))
                    {
                        sql      = string.Format("INSERT into public.patient (pid,temperature,bphigh,bplow,glucose,painlevel,description,entrydate,pulserate) VALUES (" + lblpatid.Text + "," + txttemp.Text + "," + txtbphigh.Text + "," + txtbplow.Text + "," + txtglucose.Text + "," + listpainlevel.Text + ",'" + txtdescription.Text + "',CURRENT_DATE," + txtpulserate.Text + ")");
                        dbinsert = BaseDA.ExecuteNonQuery(sql);
                    }



                    if (dbinsert != -1)
                    //	Record Inserted Successfuly
                    {
                        StringBuilder sb = new StringBuilder();
                        sb.Append("<script language=\"javascript\">" + "\n");
                        sb.Append("alert(\"Record Inserted Successfuly\")");
                        sb.Append("</script>");
                        Page.ClientScript.RegisterStartupScript(
                            this.Page.GetType(),
                            "OpenPopup",
                            sb.ToString());
                    }

                    else
                    //Failed to Insert the Record"

                    {
                        StringBuilder sb = new StringBuilder();
                        sb.Append("<script language=\"javascript\">" + "\n");
                        sb.Append("alert(\"Failed to Insert the Record\")");
                        sb.Append("</script>");
                        Page.ClientScript.RegisterStartupScript(
                            this.Page.GetType(),
                            "OpenPopup",
                            sb.ToString());
                    }
                }
            }


            catch (Exception ex)

            {
                lblErrors.Text = ErrorMessage;
            }
        }