コード例 #1
0
    private Boolean FieldValidation()
    {
        IIQCareSystem IQCareSecurity = (IIQCareSystem)ObjectFactory.CreateInstance("BusinessProcess.Security.BIQCareSystem, BusinessProcess.Security");
        DateTime      theCurrentDate = (DateTime)IQCareSecurity.SystemDate();
        IQCareUtils   theUtils       = new IQCareUtils();

        if (DDFinalResult.SelectedItem.Value == "9")
        {
            spDeath.Visible = true;
        }

        if (TxtFirstName.Text.Trim() == "")
        {
            MsgBuilder theBuilder = new MsgBuilder();
            theBuilder.DataElements["Control"] = "First Name";
            IQCareMsgBox.Show("BlankTextBox", theBuilder, this);
            TxtFirstName.Focus();
            return(false);
        }
        if (TxtLastName.Text.Trim() == "")
        {
            MsgBuilder theBuilder = new MsgBuilder();
            theBuilder.DataElements["Control"] = "Last Name";
            IQCareMsgBox.Show("BlankTextBox", theBuilder, this);
            TxtLastName.Focus();
            return(false);
        }

        if (TxtInfantId.Text.Trim() == "")
        {
            MsgBuilder theBuilder = new MsgBuilder();
            theBuilder.DataElements["Control"] = "Infant ID";
            IQCareMsgBox.Show("BlankTextBox", theBuilder, this);
            TxtInfantId.Focus();
            return(false);
        }

        try
        {
            int i = Convert.ToInt32(TxtInfantId.Text);
        }
        catch
        {
            MsgBuilder theBuilder = new MsgBuilder();
            theBuilder.DataElements["Control"] = "Infant ID";
            IQCareMsgBox.Show("BlankTextBox", theBuilder, this);
            TxtDateOfBirth.Focus();
            return(false);
        }

        if (TxtDateOfBirth.Value.Trim() == "")
        {
            MsgBuilder theBuilder = new MsgBuilder();
            theBuilder.DataElements["Control"] = "DOB";
            IQCareMsgBox.Show("BlankTextBox", theBuilder, this);
            TxtDateOfBirth.Focus();
            return(false);
        }
        DateTime theDOBDate = Convert.ToDateTime(theUtils.MakeDate(TxtDateOfBirth.Value));

        if (theDOBDate > theCurrentDate)
        {
            IQCareMsgBox.Show("DOBDate", this);
            TxtDateOfBirth.Focus();
            return(false);
        }

        if (TxtDeathDate.Text != "")
        {
            spDeath.Visible = true;

            DateTime theDeathDate = Convert.ToDateTime(theUtils.MakeDate(TxtDeathDate.Text));
            if (theDeathDate > theCurrentDate)
            {
                IQCareMsgBox.Show("DeathDateCheck", this);
                TxtDeathDate.Focus();
                return(false);
            }
            if (theDeathDate < theDOBDate)
            {
                IQCareMsgBox.Show("DeathDOBDate", this);
                TxtDeathDate.Focus();
                return(false);
            }
        }



        //if (DDInfantFeedingPractice.SelectedItem.Value.Trim() == "0")
        //{
        //    IQCareMsgBox.Show("InfantFeed", this);
        //    DDInfantFeedingPractice.Focus();
        //    return false;
        //}
        //if (DDHIVTestType.SelectedItem.Value.Trim() == "0")
        //{
        //    IQCareMsgBox.Show("InfantHivTestType", this);
        //    DDHIVTestType.Focus();
        //    return false;
        //}
        //if (DDResult.SelectedItem.Value.Trim() == "0")
        //{
        //    IQCareMsgBox.Show("InfantResult", this);
        //    DDResult.Focus();
        //    return false;
        //}

        //if (DDFinalResult.SelectedItem.Value.Trim() == "0")
        //{
        //    IQCareMsgBox.Show("InfantFinalResult", this);
        //    DDFinalResult.Focus();
        //    return false;
        //}
        return(true);
    }
コード例 #2
0
    protected void btnAdd_Click1(object sender, EventArgs e)
    {
        if (ViewState["DT"] != null)
        {
            dtTemp = (DataTable)ViewState["DT"];
        }
        if (btnAdd.Text == "Add Infant")
        {
            IInfantEnrollment ptnMgrPMTCT = (IInfantEnrollment)ObjectFactory.CreateInstance(ObjFactoryParameter);
            DataSet           theDS       = ptnMgrPMTCT.CheckIdentity(TxtInfantId.Text);
            if (theDS.Tables[0].Rows.Count > 0)
            {
                IQCareMsgBox.Show("InfantDataDBExist", this);
                TxtInfantId.Focus();
                return;
            }
            if (grdChildInfo.Rows.Count > 0)
            {
                for (int i = 0; i < grdChildInfo.Rows.Count; i++)
                {
                    if (grdChildInfo.Rows[i].Cells[2].Text == TxtInfantId.Text)
                    {
                        IQCareMsgBox.Show("InfantDataDBExist", this);
                        TxtInfantId.Focus();
                        return;
                    }
                }
            }
        }
        else
        {
            if (dtTemp.Rows.Count > 0)
            {
                int    r     = Convert.ToInt32(Session["SelectedRow"]);
                string InfID = dtTemp.Rows[r][2].ToString();
                if (InfID != TxtInfantId.Text)
                {
                    IInfantEnrollment ptnMgrPMTCT = (IInfantEnrollment)ObjectFactory.CreateInstance(ObjFactoryParameter);
                    DataSet           theDS       = ptnMgrPMTCT.CheckIdentity(TxtInfantId.Text);
                    if (theDS.Tables[0].Rows.Count > 0)
                    {
                        IQCareMsgBox.Show("InfantDataDBExist", this);
                        TxtInfantId.Focus();
                        return;
                    }
                }

                if (grdChildInfo.Rows.Count > 0)
                {
                    for (int i = 0; i < grdChildInfo.Rows.Count; i++)
                    {
                        if (grdChildInfo.Rows[i].Cells[2].Text == TxtInfantId.Text && i != r)
                        {
                            IQCareMsgBox.Show("InfantDataDBExist", this);
                            TxtInfantId.Focus();
                            return;
                        }
                    }
                }
            }
        }
        if (Authentiaction.HasFunctionRight(ApplicationAccess.ChildEnrollment, FunctionAccess.Add, (DataTable)Session["UserRight"]) == false)
        {
            btnsave.Enabled = false;
            btnAdd.Enabled  = false;
        }
        else
        {
            btnsave.Enabled = true;
            btnAdd.Enabled  = true;
        }

        if (FieldValidation() == false)
        {
            return;
        }

        if (btnAdd.Text == "Add Infant")
        {
            icount = dtTemp.Rows.Count;
            DataRow row;
            row                    = dtTemp.NewRow();
            row["Id"]              = "0";
            row["FirstName"]       = ViewState["FirstName"].ToString();
            row["LastName"]        = ViewState["LastName"].ToString();
            row["ExposedInfantId"] = TxtInfantId.Text;
            string   strDob = TxtDateOfBirth.Value;
            DateTime dtDob  = Convert.ToDateTime(strDob);
            strDob     = dtDob.ToString("dd MMM yyyy");
            row["DOB"] = strDob;
            if (DDInfantFeedingPractice.SelectedItem.Text == "Select")
            {
                row["FeedingPractice3mos"] = string.Empty;
            }
            else
            {
                row["FeedingPractice3mos"] = string.IsNullOrEmpty(DDInfantFeedingPractice.SelectedValue) ?
                                             string.Empty : DDInfantFeedingPractice.SelectedItem.Text;
            }
            row["CTX2mos"] = ChkCPTStarted.Checked ? "Yes" : "No";

            if (DDHIVTestType.SelectedItem.Text == "Select")
            {
                row["HIVTestType"] = string.Empty;
            }
            else
            {
                row["HIVTestType"] = string.IsNullOrEmpty(DDHIVTestType.SelectedValue) ?
                                     string.Empty : DDHIVTestType.SelectedItem.Text;
            }
            if (DDResult.SelectedItem.Text == "Select")
            {
                row["HIVResult"] = string.Empty;
            }
            else
            {
                row["HIVResult"] = string.IsNullOrEmpty(DDResult.SelectedValue) ?
                                   string.Empty : DDResult.SelectedItem.Text;
            }
            if (DDFinalResult.SelectedItem.Text == "Select")
            {
                row["FinalStatus"] = string.Empty;
            }
            else
            {
                row["FinalStatus"] = string.IsNullOrEmpty(DDFinalResult.SelectedValue) ?
                                     string.Empty : DDFinalResult.SelectedItem.Text;
            }
            if (!TxtDeathDate.Text.Equals(string.Empty))
            {
                string   strDeath = TxtDeathDate.Text;
                DateTime dtDeath  = Convert.ToDateTime(strDeath);
                strDeath         = dtDeath.ToString("dd MMM yyyy");
                row["DeathDate"] = strDeath;
            }
            if (TxtDeathDate.Text == "")
            {
            }
            // New
            row["HivResultId"] = string.IsNullOrEmpty(DDResult.SelectedItem.Value) ?
                                 string.Empty : DDResult.SelectedItem.Value;
            row["FeedID"] = string.IsNullOrEmpty(DDInfantFeedingPractice.SelectedItem.Value) ?
                            string.Empty : DDInfantFeedingPractice.SelectedItem.Value;
            row["FinalStatusID"] = string.IsNullOrEmpty(DDFinalResult.SelectedItem.Value) ?
                                   string.Empty : DDFinalResult.SelectedItem.Value;
            row["HIVTestTypeID"] = string.IsNullOrEmpty(DDHIVTestType.SelectedItem.Value) ?
                                   string.Empty : DDHIVTestType.SelectedItem.Value;

            dtTemp.Rows.InsertAt(row, icount);
            ViewState["DT"]    = dtTemp;
            ViewState["Count"] = dtTemp.Rows.Count + 1;
            BindGrid(dtTemp);
            ClearControl();
        }
        else if (btnAdd.Text == "Update Infant")
        {
            int r = Convert.ToInt32(Session["SelectedRow"]);
            dtTemp.Rows[r]["FirstName"]       = TxtFirstName.Text;
            dtTemp.Rows[r]["LastName"]        = TxtLastName.Text;
            dtTemp.Rows[r]["ExposedInfantId"] = TxtInfantId.Text;
            string   strDob = TxtDateOfBirth.Value;
            DateTime dtDob  = Convert.ToDateTime(strDob);
            strDob = dtDob.ToString("dd MMM yyyy");
            dtTemp.Rows[r]["DOB"] = strDob;

            if (DDInfantFeedingPractice.SelectedItem.Text == "Select")
            {
                dtTemp.Rows[r]["FeedingPractice3mos"] = string.Empty;
            }
            else
            {
                dtTemp.Rows[r]["FeedingPractice3mos"] = string.IsNullOrEmpty(DDInfantFeedingPractice.SelectedValue) ?
                                                        string.Empty : DDInfantFeedingPractice.SelectedItem.Text;
            }


            dtTemp.Rows[r]["CTX2mos"] = ChkCPTStarted.Checked ? "Yes" : "No";

            if (DDHIVTestType.SelectedItem.Text == "Select")
            {
                dtTemp.Rows[r]["HIVTestType"] = string.Empty;
            }
            else
            {
                dtTemp.Rows[r]["HIVTestType"] = string.IsNullOrEmpty(DDHIVTestType.SelectedValue) ?
                                                string.Empty : DDHIVTestType.SelectedItem.Text;
            }

            if (DDResult.SelectedItem.Text == "Select")
            {
                dtTemp.Rows[r]["HIVResult"] = string.Empty;
            }
            else
            {
                dtTemp.Rows[r]["HIVResult"] = string.IsNullOrEmpty(DDResult.SelectedValue) ?
                                              string.Empty : DDResult.SelectedItem.Text;
            }
            if (DDFinalResult.SelectedItem.Text == "Select")
            {
                dtTemp.Rows[r]["FinalStatus"] = string.Empty;
            }
            else
            {
                dtTemp.Rows[r]["FinalStatus"] = string.IsNullOrEmpty(DDFinalResult.SelectedValue) ?
                                                string.Empty : DDFinalResult.SelectedItem.Text;
            }

            if (!TxtDeathDate.Text.Equals(string.Empty))
            {
                string   strDeath = TxtDeathDate.Text;
                DateTime dtDeath  = Convert.ToDateTime(strDeath);
                strDeath = dtDeath.ToString("dd MMM yyyy");
                dtTemp.Rows[r]["DeathDate"] = strDeath;
            }
            if (TxtDeathDate.Text == "")
            {
                dtTemp.Rows[r]["DeathDate"] = System.DBNull.Value;
            }
            dtTemp.Rows[r]["HivResultId"] = string.IsNullOrEmpty(DDResult.SelectedItem.Value) ?
                                            string.Empty : DDResult.SelectedItem.Value;
            dtTemp.Rows[r]["FeedID"] = string.IsNullOrEmpty(DDInfantFeedingPractice.SelectedItem.Value) ?
                                       string.Empty : DDInfantFeedingPractice.SelectedItem.Value;
            dtTemp.Rows[r]["FinalStatusID"] = string.IsNullOrEmpty(DDFinalResult.SelectedItem.Value) ?
                                              string.Empty : DDFinalResult.SelectedItem.Value;
            dtTemp.Rows[r]["HIVTestTypeID"] = string.IsNullOrEmpty(DDHIVTestType.SelectedItem.Value) ?
                                              string.Empty : DDHIVTestType.SelectedItem.Value;
            ViewState["DT"] = dtTemp;
            BindGrid(dtTemp);
            btnAdd.Text = "Add Infant";
            ClearControl();
        }
    }
コード例 #3
0
    private Boolean FieldValidation()
    {
        IIQCareSystem IQCareSecurity = (IIQCareSystem)ObjectFactory.CreateInstance("BusinessProcess.Security.BIQCareSystem, BusinessProcess.Security");
        DateTime      theCurrentDate = (DateTime)IQCareSecurity.SystemDate();
        IQCareUtils   theUtils       = new IQCareUtils();

        if (DDFinalResult.SelectedItem.Value == "9")
        {
            spDeath.Visible = true;
        }

        if (TxtFirstName.Text.Trim() == "")
        {
            MsgBuilder theBuilder = new MsgBuilder();
            theBuilder.DataElements["Control"] = "First Name";
            IQCareMsgBox.Show("BlankTextBox", theBuilder, this);
            TxtFirstName.Focus();
            return(false);
        }
        if (TxtLastName.Text.Trim() == "")
        {
            MsgBuilder theBuilder = new MsgBuilder();
            theBuilder.DataElements["Control"] = "Last Name";
            IQCareMsgBox.Show("BlankTextBox", theBuilder, this);
            TxtLastName.Focus();
            return(false);
        }

        if (TxtInfantId.Text.Trim() == "")
        {
            MsgBuilder theBuilder = new MsgBuilder();
            theBuilder.DataElements["Control"] = "Infant ID";
            IQCareMsgBox.Show("BlankTextBox", theBuilder, this);
            TxtInfantId.Focus();
            return(false);
        }

        try
        {
            Int64 i = Convert.ToInt64(TxtInfantId.Text);
        }
        catch
        {
            MsgBuilder theBuilder = new MsgBuilder();
            theBuilder.DataElements["Control"] = "Infant ID";
            IQCareMsgBox.Show("BlankTextBox", theBuilder, this);
            TxtDateOfBirth.Focus();
            return(false);
        }

        if (TxtDateOfBirth.Value.Trim() == "")
        {
            MsgBuilder theBuilder = new MsgBuilder();
            theBuilder.DataElements["Control"] = "DOB";
            IQCareMsgBox.Show("BlankTextBox", theBuilder, this);
            TxtDateOfBirth.Focus();
            return(false);
        }
        DateTime theDOBDate = Convert.ToDateTime(theUtils.MakeDate(TxtDateOfBirth.Value));

        if (theDOBDate > theCurrentDate)
        {
            IQCareMsgBox.Show("DOBDate", this);
            TxtDateOfBirth.Focus();
            return(false);
        }

        int Age = GetAge(theDOBDate);

        if (TxtDateOfBirth.Value != "")
        {
            Decimal AgeinYear = Math.Round(Convert.ToDecimal(Session["PatientAge"]), 0);
            if (Convert.ToDecimal(Age) >= AgeinYear)
            {
                //ScriptManager.RegisterStartupScript(this, GetType(), "PatientAge", "alert('Infant Age cannot be more than Parent Age');", true);
                MsgBuilder theMsg = new MsgBuilder();
                theMsg.DataElements["Control"] = "Infant Age cannot be more than Parent Age";
                IQCareMsgBox.Show("PatientAge", theMsg, this);
                TxtDateOfBirth.Focus();
                return(false);
            }
        }

        if (TxtDeathDate.Value != "")
        {
            spDeath.Visible = true;

            DateTime theDeathDate = Convert.ToDateTime(theUtils.MakeDate(TxtDeathDate.Value));
            if (theDeathDate > theCurrentDate)
            {
                IQCareMsgBox.Show("DeathDateCheck", this);
                TxtDeathDate.Focus();
                return(false);
            }
            if (theDeathDate < theDOBDate)
            {
                IQCareMsgBox.Show("DeathDOBDate", this);
                TxtDeathDate.Focus();
                return(false);
            }
        }



        //if (DDInfantFeedingPractice.SelectedItem.Value.Trim() == "0")
        //{
        //    IQCareMsgBox.Show("InfantFeed", this);
        //    DDInfantFeedingPractice.Focus();
        //    return false;
        //}
        //if (DDHIVTestType.SelectedItem.Value.Trim() == "0")
        //{
        //    IQCareMsgBox.Show("InfantHivTestType", this);
        //    DDHIVTestType.Focus();
        //    return false;
        //}
        //if (DDResult.SelectedItem.Value.Trim() == "0")
        //{
        //    IQCareMsgBox.Show("InfantResult", this);
        //    DDResult.Focus();
        //    return false;
        //}

        //if (DDFinalResult.SelectedItem.Value.Trim() == "0")
        //{
        //    IQCareMsgBox.Show("InfantFinalResult", this);
        //    DDFinalResult.Focus();
        //    return false;
        //}
        return(true);
    }