//UPDATE
 protected void update_Click(object sender, EventArgs e)
 {
     try
     {
         //check to see if a insert is needed for deceased
         person = person.Select(Convert.ToInt32(Update_gvClientSearchresult.SelectedValue));
         client = client.Select(person.person_id);
         if (Update_deceasedYes.Checked == true)
         {
             person  = person_update(Convert.ToInt32(Update_gvClientSearchresult.SelectedValue));
             missing = missing_update(person.person_id);
             //check if update of insert of deceased
             deceased = deceased.Select(client.client_id);
             if (deceased.deceased_id == 0)
             {
                 deceased = deceased_insert_For_Update();
             }
             else
             {
                 deceased = deceased_update(person.person_id);
             }
         }
         else
         {
             person  = person_update(Convert.ToInt32(Update_gvClientSearchresult.SelectedValue));
             missing = missing_update(person.person_id);
         }
         address   = address_update(person.address_id);
         client    = client_update(person.person_id);
         encounter = encounter_insert();
         Update_refreshclient();
     }
     catch { Update_lbl_Client_Error.Text = "There has been an error updating information for the missing client."; }
     finally { Update_lbl_Client_Error.Text = "The missing client's information has been successfully updated."; }
 }
 public deceased Insert_deceased_select(int ID)
 {
     deceased = deceased.Select(ID);
     Insert_date_of_autopsy_txt.Text   = Convert.ToString(deceased.date_of_autopsy);
     Insert_external_exam_txt.Text     = Convert.ToString(deceased.external_exam);
     Insert_identifying_marks_txt.Text = Convert.ToString(deceased.identifying_marks);
     Insert_internal_exam_txt.Text     = Convert.ToString(deceased.internal_exam);
     Insert_reason_of_death_txt.Text   = Convert.ToString(deceased.reason_of_death);
     Insert_time_of_death_txt.Text     = Convert.ToString(deceased.time_of_death);
     return(deceased);
 }
 //UPDATE
 public deceased deceased_update(int ID)
 {
     deceased = deceased.Select(ID);
     deceased.date_of_autopsy   = Convert.ToDateTime(Update_date_of_autopsy_txt.Text);
     deceased.external_exam     = Update_external_exam_txt.Text;
     deceased.identifying_marks = Update_identifying_marks_txt.Text;
     deceased.internal_exam     = Update_internal_exam_txt.Text;
     deceased.reason_of_death   = Update_reason_of_death_txt.Text;
     deceased.time_of_death     = Convert.ToDateTime(Update_time_of_death_txt.Text);
     deceased.Update(deceased);
     //GridView1.DataBind();
     return(deceased);
 }
 public deceased deceased_insert()
 {
     deceased.date_of_autopsy   = Convert.ToDateTime(Insert_date_of_autopsy_txt.Text);
     deceased.external_exam     = Insert_external_exam_txt.Text;
     deceased.identifying_marks = Insert_identifying_marks_txt.Text;
     deceased.internal_exam     = Insert_internal_exam_txt.Text;
     deceased.reason_of_death   = Insert_reason_of_death_txt.Text;
     deceased.time_of_death     = Convert.ToDateTime(Insert_time_of_death_txt.Text);
     deceased = deceased.Insert(deceased);
     Insert_deceased_GridView.DataBind();
     Update_deceased_GridView.DataBind();
     Delete_deceased_GridView.DataBind();
     return(deceased);
 }
        public deceased deceased_insert_For_Update()
        {
            deceased.deceased_id       = client.client_id;
            deceased.date_of_autopsy   = Convert.ToDateTime(Update_date_of_autopsy_txt.Text);
            deceased.external_exam     = Update_external_exam_txt.Text;
            deceased.identifying_marks = Update_identifying_marks_txt.Text;
            deceased.internal_exam     = Update_internal_exam_txt.Text;
            deceased.reason_of_death   = Update_reason_of_death_txt.Text;
            deceased.time_of_death     = Convert.ToDateTime(Update_time_of_death_txt.Text);

            deceased = deceased.Insert(deceased);
            //GridView1.DataBind();
            return(deceased);
        }
 public deceased deceased_insert()
 {
     deceased.date_of_autopsy = Convert.ToDateTime(Insert_date_of_autopsy_txt.Text);
     deceased.external_exam = Insert_external_exam_txt.Text;
     deceased.identifying_marks = Insert_identifying_marks_txt.Text;
     deceased.internal_exam = Insert_internal_exam_txt.Text;
     deceased.reason_of_death = Insert_reason_of_death_txt.Text;
     deceased.time_of_death = Convert.ToDateTime(Insert_time_of_death_txt.Text);
     deceased = deceased.Insert(deceased);
     Insert_deceased_GridView.DataBind();
     Update_deceased_GridView.DataBind();
     Delete_deceased_GridView.DataBind();
     return deceased;
 }
 public deceased deceased_update(int ID)
 {
     deceased = deceased.Select(ID);
     deceased.deceased_id = Convert.ToInt32(Update_deceased_id_txt.Text);
     deceased.date_of_autopsy = Convert.ToDateTime(Update_date_of_autopsy_txt.Text);
     deceased.external_exam = Update_external_exam_txt.Text;
     deceased.identifying_marks = Update_identifying_marks_txt.Text;
     deceased.internal_exam = Update_internal_exam_txt.Text;
     deceased.reason_of_death = Update_reason_of_death_txt.Text;
     deceased.time_of_death = Convert.ToDateTime(Update_time_of_death_txt.Text);
     deceased.Update(deceased);
     Insert_deceased_GridView.DataBind();
     Update_deceased_GridView.DataBind();
     Delete_deceased_GridView.DataBind();
     return deceased;
 }
        //INSERT
        protected void insert_Click(object sender, EventArgs e)
        {
            try
            {
                address = address_insert();
                person  = person_insert();
                client  = client_insert();
                missing = missing_insert();

                if (Insert_deceasedYes.Checked == true)
                {
                    deceased = deceased_insert();
                }
                case_intake = case_intake_insert();
                case_client = case_client_insert();
                encounter   = encounter_insert();
            }
            catch { Insert_lbl_Client_Error.Text = "There has been an error updating information for the missing client."; }
            finally { Insert_lbl_Client_Error.Text = "The missing client's information has been successfully updated."; }
        }
        //INSERT
        protected void insert_Click(object sender, EventArgs e)
        {
            try
            {
                address = address_insert();
                person = person_insert();
                client = client_insert();
                missing = missing_insert();

                if (Insert_deceasedYes.Checked == true)
                {
                    deceased = deceased_insert();
                }
                case_intake = case_intake_insert();
                case_client = case_client_insert();
                encounter = encounter_insert();
            }
            catch { Insert_lbl_Client_Error.Text = "There has been an error updating information for the missing client."; }
            finally { Insert_lbl_Client_Error.Text = "The missing client's information has been successfully updated."; }
        }
        //select a client and display data
        protected void Update_gvClientSearchresult_SelectedIndexChanged(object sender, EventArgs e)
        {
            person = person.Select(Convert.ToInt32(Update_gvClientSearchresult.SelectedDataKey.Value));
            GlobalVariables.PersonID = Convert.ToInt32(Update_gvClientSearchresult.SelectedDataKey.Value);

            address  = address.Select(person.address_id);
            missing  = missing.Select(person.person_id);
            deceased = deceased.Select(person.person_id);

            client = client.Select(person.person_id);
            GlobalVariables.ClientID = client.client_id;


            Update_LocationDiscription_txt.Text    = missing.last_known_location;
            Update_reason_of_death_txt.Text        = deceased.reason_of_death;
            Update_time_of_death_txt.Text          = Convert.ToString(deceased.time_of_death);
            Update_identifying_marks_txt.Text      = deceased.identifying_marks;
            Update_external_exam_txt.Text          = deceased.external_exam;
            Update_date_of_autopsy_txt.Text        = Convert.ToString(deceased.date_of_autopsy.ToShortDateString());
            Update_internal_exam_txt.Text          = deceased.external_exam;
            Update_client_other_info_txt.Text      = missing.client_other_info;
            Update_Client_latitude_txt.Text        = Convert.ToString(address.latitude);
            Update_Client_longitude_txt.Text       = Convert.ToString(address.longitude);
            Update_Client_zip_plus_four_txt.Text   = Convert.ToString(address.zip_plus_four);
            Update_Client_str_add2_txt.Text        = address.str_add;
            Update_Client_str_add_txt.Text         = address.str_add2;
            Update_Client_County_Township_txt.Text = address.County_Township;
            Update_Client_country_txt.Text         = address.country;
            Update_Client_state_txt.Text           = address.state;
            Update_Client_city_txt.Text            = address.city;
            Update_hair_color_ddl.SelectedValue    = client.hair_color;
            Update_skin_color_ddl.SelectedValue    = client.skin_color;
            Update_eye_color_ddl.SelectedValue     = client.eye_color;
            Update_ethnicity_txt.Text             = client.ethnicity;
            Update_weight_txt.Text                = Convert.ToString(client.weight);
            Update_height_ddl.SelectedValue       = Convert.ToString(client.height);
            Update_date_of_disappearance_txt.Text = Convert.ToString(missing.date_of_disappearance.ToShortDateString());
            Update_clothing_txt.Text              = missing.clothing;
            Update_phone_primary_txt.Text         = person.phone_primary;
            Update_ssn_txt.Text             = Convert.ToString(person.ssn);
            Update_gender_ddl.SelectedValue = person.gender;
            Update_l_name_txt.Text          = person.l_name;
            Update_m_initial_txt.Text       = person.m_initial;
            Update_f_name_txt.Text          = person.f_name;


            //change condishions
            Update_txtFirstName.Text = person.f_name.ToString();
            Update_txtLastName.Text  = person.l_name.ToString();



            if (client.client_status == "D")
            {
                Update_Deceased_Div.Style.Add("display", "block");
                Update_deceasedYes.Checked = true;
                Update_missingYes.Checked  = false;
            }
            else
            {
                Update_Deceased_Div.Style.Add("display", "none");
                Update_deceasedYes.Checked = false;
                Update_missingYes.Checked  = true;
            }


            Update_sClient_L.Text = "</br>" + person.f_name + " " + person.l_name + " is selected.";
        }
        public deceased deceased_insert_For_Update()
        {
            deceased.deceased_id = client.client_id;
            deceased.date_of_autopsy = Convert.ToDateTime(Update_date_of_autopsy_txt.Text);
            deceased.external_exam = Update_external_exam_txt.Text;
            deceased.identifying_marks = Update_identifying_marks_txt.Text;
            deceased.internal_exam = Update_internal_exam_txt.Text;
            deceased.reason_of_death = Update_reason_of_death_txt.Text;
            deceased.time_of_death = Convert.ToDateTime(Update_time_of_death_txt.Text);

            deceased = deceased.Insert(deceased);
            //GridView1.DataBind();
            return deceased;
        }
 protected void INSERT(object sender, EventArgs e)
 {
     deceased = deceased_insert();
 }
 protected void INSERT(object sender, EventArgs e)
 {
     deceased = deceased_insert();
 }
 protected void UPDATE(object sender, EventArgs e)
 {
     deceased = deceased_update(Convert.ToInt32(Update_deceased_GridView.SelectedValue));
 }
 protected void Insert_Select_Record(object sender, EventArgs e)
 {
     deceased = Insert_deceased_select(Convert.ToInt32(Insert_deceased_GridView.SelectedValue));
 }
 protected void Update_Select_Record(object sender, EventArgs e)
 {
     deceased = Update_deceased_select(Convert.ToInt32(Update_deceased_GridView.SelectedValue));
 }
 protected void Insert_Select_Record(object sender, EventArgs e)
 {
     deceased = Insert_deceased_select(Convert.ToInt32(Insert_deceased_GridView.SelectedValue));
 }
 //UPDATE
 protected void update_Click(object sender, EventArgs e)
 {
     try
     {
         //check to see if a insert is needed for deceased
         person = person.Select(Convert.ToInt32(Update_gvClientSearchresult.SelectedValue));
         client = client.Select(person.person_id);
         if (Update_deceasedYes.Checked == true)
         {
             person = person_update(Convert.ToInt32(Update_gvClientSearchresult.SelectedValue));
             missing = missing_update(person.person_id);
             //check if update of insert of deceased
             deceased = deceased.Select(client.client_id);
             if (deceased.deceased_id == 0) { deceased = deceased_insert_For_Update(); }
             else { deceased = deceased_update(person.person_id); }
         }
         else
         {
             person = person_update(Convert.ToInt32(Update_gvClientSearchresult.SelectedValue));
             missing = missing_update(person.person_id);
         }
         address = address_update(person.address_id);
         client = client_update(person.person_id);
         encounter = encounter_insert();
         Update_refreshclient();
     }
     catch { Update_lbl_Client_Error.Text = "There has been an error updating information for the missing client."; }
     finally { Update_lbl_Client_Error.Text = "The missing client's information has been successfully updated."; }
 }
 protected void UPDATE(object sender, EventArgs e)
 {
     deceased = deceased_update(Convert.ToInt32(Update_deceased_GridView.SelectedValue));
 }
 protected void Update_Select_Record(object sender, EventArgs e)
 {
     deceased = Update_deceased_select(Convert.ToInt32(Update_deceased_GridView.SelectedValue));
 }
        //select a client and display data
        protected void Update_gvClientSearchresult_SelectedIndexChanged(object sender, EventArgs e)
        {
            person = person.Select(Convert.ToInt32(Update_gvClientSearchresult.SelectedDataKey.Value));
            GlobalVariables.PersonID = Convert.ToInt32(Update_gvClientSearchresult.SelectedDataKey.Value);

            address = address.Select(person.address_id);
            missing = missing.Select(person.person_id);
            deceased = deceased.Select(person.person_id);

            client = client.Select(person.person_id);
            GlobalVariables.ClientID = client.client_id;

            Update_LocationDiscription_txt.Text = missing.last_known_location;
            Update_reason_of_death_txt.Text = deceased.reason_of_death;
            Update_time_of_death_txt.Text = Convert.ToString(deceased.time_of_death);
            Update_identifying_marks_txt.Text = deceased.identifying_marks;
            Update_external_exam_txt.Text = deceased.external_exam;
            Update_date_of_autopsy_txt.Text = Convert.ToString(deceased.date_of_autopsy.ToShortDateString());
            Update_internal_exam_txt.Text = deceased.external_exam;
            Update_client_other_info_txt.Text = missing.client_other_info;
            Update_Client_latitude_txt.Text = Convert.ToString(address.latitude);
            Update_Client_longitude_txt.Text = Convert.ToString(address.longitude);
            Update_Client_zip_plus_four_txt.Text = Convert.ToString(address.zip_plus_four);
            Update_Client_str_add2_txt.Text = address.str_add;
            Update_Client_str_add_txt.Text = address.str_add2;
            Update_Client_County_Township_txt.Text = address.County_Township;
            Update_Client_country_txt.Text = address.country;
            Update_Client_state_txt.Text = address.state;
            Update_Client_city_txt.Text = address.city;
            Update_hair_color_ddl.SelectedValue = client.hair_color;
            Update_skin_color_ddl.SelectedValue = client.skin_color;
            Update_eye_color_ddl.SelectedValue = client.eye_color;
            Update_ethnicity_txt.Text = client.ethnicity;
            Update_weight_txt.Text = Convert.ToString(client.weight);
            Update_height_ddl.SelectedValue = Convert.ToString(client.height);
            Update_date_of_disappearance_txt.Text = Convert.ToString(missing.date_of_disappearance.ToShortDateString());
            Update_clothing_txt.Text = missing.clothing;
            Update_phone_primary_txt.Text = person.phone_primary;
            Update_ssn_txt.Text = Convert.ToString(person.ssn);
            Update_gender_ddl.SelectedValue = person.gender;
            Update_l_name_txt.Text = person.l_name;
            Update_m_initial_txt.Text = person.m_initial;
            Update_f_name_txt.Text = person.f_name;

            //change condishions
            Update_txtFirstName.Text = person.f_name.ToString();
            Update_txtLastName.Text = person.l_name.ToString();

            if (client.client_status == "D")
            {
                Update_Deceased_Div.Style.Add("display", "block");
                Update_deceasedYes.Checked = true;
                Update_missingYes.Checked = false;
            }
            else
            {
                Update_Deceased_Div.Style.Add("display", "none");
                Update_deceasedYes.Checked = false;
                Update_missingYes.Checked = true;
            }

            Update_sClient_L.Text = "</br>" + person.f_name + " " + person.l_name + " is selected.";
        }
 public deceased Delete_deceased_select(int ID)
 {
     deceased = deceased.Select(ID);
     Delete_deceased_id_txt_lbl.Text = Convert.ToString(deceased.deceased_id);
     Delete_date_of_autopsy_txt_lbl.Text = Convert.ToString(deceased.date_of_autopsy);
     Delete_external_exam_txt_lbl.Text = Convert.ToString(deceased.external_exam);
     Delete_identifying_marks_txt_lbl.Text = Convert.ToString(deceased.identifying_marks);
     Delete_internal_exam_txt_lbl.Text = Convert.ToString(deceased.internal_exam);
     Delete_reason_of_death_txt_lbl.Text = Convert.ToString(deceased.reason_of_death);
     Delete_time_of_death_txt_lbl.Text = Convert.ToString(deceased.time_of_death);
     return deceased;
 }