Exemplo n.º 1
0
    protected void btnOk_Address_Click(object sender, EventArgs e)
    {
        if (txtboxHouseAdd.Text != lblHouseAdd.Text ||
            txtboxDistrict.Text != lblDistrict.Text ||
            txtboxCity.Text != lblCity.Text)
        {
            try
            {
                int              hospitalId;
                HospitalClass    hc  = new HospitalClass();
                LogHospitalClass lhc = new LogHospitalClass();

                String hospitalIndivFieldLog_Operation = "Update";
                String hospitalIndivFieldLog_Field     = "hospitalAddress";
                String hospitalIndivFieldLog_DataLater = txtboxHouseAdd.Text
                                                         + "; " + txtboxDistrict.Text
                                                         + "; " + txtboxCity.Text;
                String hospitalIndivFieldLog_DataBefore = lblHouseAdd.Text
                                                          + "; " + lblDistrict.Text
                                                          + "; " + lblCity.Text;;

                /*Update Hospital's Address on Hospital table
                 * Insert values on Log_HospitalIndivField table*/
                /*Getting HospitalId from HospitalName table*/
                DataTable dt = hc.SelectAllHospitalFromHospitalFullName(Session["selectedRow_HospitalName"].ToString());
                if (dt.Rows.Count > 0)
                {
                    Session["hospitalId"] = dt.Rows[0]["hospitalId"].ToString();
                    hospitalId            = Convert.ToInt32(Session["hospitalId"]);

                    hc.update_hospitalAddressFrom_hospitalId(hospitalId, txtboxHouseAdd.Text,
                                                             txtboxDistrict.Text, txtboxCity.Text);
                    lhc.insertOn_Log_HospitalIndivField_WithUpdateOperation(hospitalIndivFieldLog_Operation,
                                                                            hospitalId, hospitalIndivFieldLog_Field, hospitalIndivFieldLog_DataBefore,
                                                                            hospitalIndivFieldLog_DataLater);
                }
            }
            catch (Exception ex)
            {
                ltrMessage.Text = ex.Message;
            }
            finally
            {
                Session["selectedRow_HospitalHouseAddress"] = txtboxHouseAdd.Text;
                Session["selectedRow_HospitalDistrict"]     = txtboxDistrict.Text;
                Session["selectedRow_HospitalCity"]         = txtboxCity.Text;
                lblHouseAdd.Text       = txtboxHouseAdd.Text;
                lblDistrict.Text       = txtboxDistrict.Text;
                lblCity.Text           = txtboxCity.Text;
                txtboxHouseAdd.Visible = false;
                txtboxDistrict.Visible = false;
                txtboxCity.Visible     = false;
                btnOk_Address.Visible  = false;
            }
        }
    }
Exemplo n.º 2
0
    protected void btnOk_Type_Click(object sender, EventArgs e)
    {
        if (dropdownlistType.SelectedValue != lblType.Text)
        {
            try
            {
                int              hospitalId;
                HospitalClass    hc  = new HospitalClass();
                LogHospitalClass lhc = new LogHospitalClass();

                String hospitalIndivFieldLog_Operation  = "Update";
                String hospitalIndivFieldLog_Field      = "hospitalType";
                String hospitalIndivFieldLog_DataLater  = dropdownlistType.SelectedValue;
                String hospitalIndivFieldLog_DataBefore = lblType.Text;

                /*Update Hospital's Type on Hospital table
                 * Insert values on Log_HospitalIndivField table*/
                /*Getting HospitalId from HospitalName table*/
                DataTable dt = hc.SelectAllHospitalFromHospitalFullName(Session["selectedRow_HospitalName"].ToString());
                if (dt.Rows.Count > 0)
                {
                    Session["hospitalId"] = dt.Rows[0]["hospitalId"].ToString();
                    hospitalId            = Convert.ToInt32(Session["hospitalId"]);

                    hc.update_hospitalTypeFrom_hospitalId(hospitalId, dropdownlistType.Text);
                    lhc.insertOn_Log_HospitalIndivField_WithUpdateOperation(hospitalIndivFieldLog_Operation,
                                                                            hospitalId, hospitalIndivFieldLog_Field, hospitalIndivFieldLog_DataBefore,
                                                                            hospitalIndivFieldLog_DataLater);
                }
            }
            catch (Exception ex)
            {
                ltrMessage.Text = ex.Message;
            }
            finally
            {
                Session["selectedRow_HospitalType"] = dropdownlistType.SelectedValue;
                lblType.Text             = dropdownlistType.SelectedValue;
                dropdownlistType.Visible = false;
                btnOk_Type.Visible       = false;
            }
        }
    }