Esempio n. 1
0
        public void LoadObject(DataTable MedicalTable, MedicalInfo mInfo)
        {
            if (MedicalTable.Rows.Count > 0)
            {
                Type type = mInfo.GetType();
                foreach (DataColumn dC in MedicalTable.Columns)
                {
                    PropertyInfo pi = type.GetProperty(dC.ColumnName);
                    switch (pi.PropertyType.ToString())
                    {
                    case "System.Int32":
                        if (MedicalTable.Rows[0][dC.ColumnName].GetType().ToString() == "System.DBNull")
                        {
                            pi.SetValue(mInfo, 0, null);
                        }
                        else
                        {
                            pi.SetValue(mInfo, Int32.Parse(MedicalTable.Rows[0][dC.ColumnName].ToString()), null);
                        }
                        break;

                    case "System.String":
                        pi.SetValue(mInfo, MedicalTable.Rows[0][dC.ColumnName].ToString(), null);
                        break;
                    }
                }
            }
        }
Esempio n. 2
0
        } // Done... Tested

        #endregion

        #region btnContinue_Click(object sender, System.EventArgs e)
        protected void btnContinue_Click(object sender, System.EventArgs e)
        {
            Page.Validate("PageSubmit");
            if (Page.IsValid)
            {
                MedicalInfo newMedical = new MedicalInfo();
                Type        type       = newMedical.GetType();

                foreach (Control ctl in Page.Form.Controls)
                {
                    string pName;

                    if (ctl.ID != null)
                    {
                        pName = ctl.ID.Substring(3, ctl.ID.Length - 3);
                    }
                    else
                    {
                        continue;
                    }
                    switch (ctl.GetType().ToString())
                    {
                    case "System.Web.UI.WebControls.TextBox":
                        if (((TextBox)ctl).Text.Length > 0 && type.GetProperty(pName) != null)
                        {
                            PropertyInfo pi    = type.GetProperty(pName);
                            string       input = HttpUtility.HtmlEncode(((TextBox)ctl).Text.Replace("'", "''"));
                            pi.SetValue(newMedical, input, null);
                        }
                        continue;

                    case "System.Web.UI.WebControls.DropDownList":
                        if (((DropDownList)ctl).SelectedIndex > -1 && type.GetProperty(pName) != null)
                        {
                            PropertyInfo pi    = type.GetProperty(pName);
                            string       input = HttpUtility.HtmlEncode(((DropDownList)ctl).SelectedValue);
                            pi.SetValue(newMedical, Int32.Parse(input), null);
                        }
                        continue;

                    case "System.Web.UI.WebControls.RadioButtonList":
                        if (((RadioButtonList)ctl).SelectedIndex > -1 && type.GetProperty(pName) != null)
                        {
                            PropertyInfo pi    = type.GetProperty(pName);
                            string       input = HttpUtility.HtmlEncode(((RadioButtonList)ctl).SelectedValue);
                            pi.SetValue(newMedical, input, null);
                        }
                        continue;
                    }
                }
                Session["newMedical"] = newMedical;
                Server.Transfer("save.Medical.aspx");
            }
            else
            {
                ValidationSummary1.ValidationGroup = "PageSubmit";
                setupGrid();
            }
        }
Esempio n. 3
0
        private void LoadMedicalControls(MedicalInfo pInfo, Control c)
        {
            if (pInfo != null)
            {
                Type type = pInfo.GetType();

                foreach (Control ctl in c.Controls)
                {
                    if (ctl.ID == null)
                    {
                        continue;
                    }

                    if (ctl.ID.Contains("span"))
                    {
                        string       pName = ctl.ID.Substring(7, ctl.ID.Length - 7);
                        PropertyInfo pi    = type.GetProperty(pName);
                        ((System.Web.UI.HtmlControls.HtmlGenericControl)ctl).InnerText = (string)pi.GetValue(pInfo, null).ToString();

                        if (ctl.ID.Contains("spancbo"))
                        {
                            string       cName  = ctl.ID.Substring(4, ctl.ID.Length - 4);
                            DropDownList ddlCtl = (DropDownList)c.FindControl(cName);
                            ddlCtl.SelectedValue = pi.GetValue(pInfo, null).ToString();
                            ((System.Web.UI.HtmlControls.HtmlGenericControl)ctl).InnerText = ddlCtl.SelectedItem.Text;
                        }

                        if (ctl.ID.Contains("spanchk"))
                        {
                            string   cName  = ctl.ID.Substring(4, ctl.ID.Length - 4);
                            CheckBox chkCtl = (CheckBox)c.FindControl(cName);
                            chkCtl.Checked = Convert.ToBoolean(pi.GetValue(pInfo, null));
                            ((System.Web.UI.HtmlControls.HtmlGenericControl)ctl).InnerText = chkCtl.Checked.ToString();
                        }
                    }

                    if (ctl.HasControls())
                    {
                        LoadMedicalControls(pInfo, ctl);
                        //LoadControlsIncomplete_BL(pInfo, ctl);
                    }
                }
            }
            else
            {
                Response.Redirect("CustError.aspx");
            }
        }
Esempio n. 4
0
        public int updateMedicalRecord(MedicalInfo mInfo)
        {
            clsUtility.Connection = getConnectionString();
            Type type = mInfo.GetType();

            InfiniEdge.SqlParameterCollection parameters = new InfiniEdge.SqlParameterCollection();

            foreach (PropertyInfo pi in type.GetProperties())
            {
                // Database was not saving these 2 date fields correctly if they were null.
                // Added this statement to insert DBNulls instead.
                if (pi.Name == "DepartDate" || pi.Name == "ArrivalDate")
                {
                    if (pi.GetValue(mInfo, null) == null)
                    {
                        parameters.Add(new SqlParameter("@" + pi.Name, DBNull.Value));
                    }
                    else
                    {
                        parameters.Add(new SqlParameter("@" + pi.Name, pi.GetValue(mInfo, null).ToString()));
                    }
                }
                else
                {
                    if (pi.GetValue(mInfo, null) == null)
                    {
                        parameters.Add(new SqlParameter("@" + pi.Name, ""));
                    }
                    else
                    {
                        parameters.Add(new SqlParameter("@" + pi.Name, pi.GetValue(mInfo, null).ToString()));
                    }
                }
            }

            parameters.Add(new SqlParameter("@PatientID", Int32.Parse(HttpContext.Current.Session["PatientID"].ToString())));
            // 'Gets the password for the user
            //Dim passwdOutput As New SqlParameter("@password", SqlDbType.VarChar, 35)
            //passwdOutput.Direction = ParameterDirection.Output
            //pParams.Add(passwdOutput)
            //oSQL.ExecuteSP("GetPasswordByUserName", pParams)
            //password = passwdOutput.Value.ToString()

            int pKey = clsUtility.ExecuteSP_RETURN_VALUE("InsertPatientMedical", parameters);

            return(pKey);
        }
Esempio n. 5
0
        public void doIncompletes_BL(MedicalInfo mInfo, Control c)
        {
            foreach (Control ctrl in c.Controls)
            {
                if (ctrl.GetType().ToString() == "System.Web.UI.WebControls.RadioButtonList" || ctrl.GetType().ToString() == "System.Web.UI.WebControls.TextBox" || ctrl.GetType().ToString() == "System.Web.UI.WebControls.DropDownList" || ctrl.GetType().ToString() == "System.Web.UI.HtmlControls.HtmlGenericControl")
                {
                    // get the id, don't retrieve the first three letters
                    string strID = ctrl.ID.Substring(3);

                    Type         type = mInfo.GetType();
                    PropertyInfo pi   = type.GetProperty(strID);
                    if (pi != null)
                    {
                        if (pi.GetValue(mInfo, null) != null)
                        {
                            string strValue = pi.GetValue(mInfo, null).ToString();

                            switch (ctrl.GetType().ToString())
                            {
                            case "System.Web.UI.WebControls.RadioButtonList":
                                RadioButtonList rdoList = (RadioButtonList)ctrl;
                                if (rdoList.Visible)
                                {
                                    if (strValue.Equals("0"))
                                    {
                                        rdoList.SelectedIndex = Convert.ToInt32(strValue.Trim());
                                    }
                                    else if (strValue.Equals("1"))
                                    {
                                        rdoList.SelectedIndex = Convert.ToInt32(strValue.Trim());
                                    }
                                }
                                else
                                {
                                    HtmlGenericControl spanTxt = (HtmlGenericControl)c.FindControl("span" + ctrl.ID);
                                    spanTxt.InnerHtml = strValue.Trim();
                                }
                                break;

                            case "System.Web.UI.WebControls.TextBox":
                                TextBox txtField = (TextBox)ctrl;
                                if (txtField.Visible)
                                {
                                    txtField.Text = strValue.Trim();
                                }
                                else
                                {
                                    HtmlGenericControl spanTxt = (HtmlGenericControl)c.FindControl("span" + ctrl.ID);
                                    spanTxt.InnerHtml = strValue.Trim();
                                }
                                break;

                            case "System.Web.UI.WebControls.DropDownList":
                                DropDownList cboField = (DropDownList)ctrl;
                                if (cboField.Visible)
                                {
                                    cboField.SelectedValue = strValue.Trim();
                                }
                                else
                                {
                                    HtmlGenericControl spanTxt = (HtmlGenericControl)c.FindControl("span" + ctrl.ID);
                                    cboField.SelectedValue = strValue.Trim();
                                    spanTxt.InnerHtml      = cboField.SelectedItem.Text;
                                }
                                break;

                            case "System.Web.UI.HtmlControls.HtmlGenericControl":
                                if (ctrl.Visible)
                                {
                                    HtmlGenericControl spanTxt = (HtmlGenericControl)c.FindControl(ctrl.ID);
                                    spanTxt.InnerHtml = strValue.Trim();
                                }
                                break;
                            }
                            strValue = null;
                        }
                    }
                }
                if (ctrl.HasControls())
                {
                    doIncompletes_BL(mInfo, ctrl);
                }
            }
        }