Ejemplo n.º 1
0
    private bool ValidateForm(bool isDraft)
    {
        lbError.Text = "";
        GeneralFunction.RemoveHighlightControls(this);


        // Validate scores only if not recused
        if (ddlRecuse.SelectedValue == "No")
        {
            lbError.Text += GeneralFunction.ValidateTextBox("Score for Strategic Challenge & Objectives", txtSC, true, "int");
            lbError.Text += GeneralFunction.ValidateTextBox("Score for Idea", txtID, true, "int");
            lbError.Text += GeneralFunction.ValidateTextBox("Score for Bringing Idea to Life", txtIL, true, "int");
            lbError.Text += GeneralFunction.ValidateTextBox("Score for Results", txtRE, true, "int");


            try
            {
                int sc = int.Parse(txtSC.Text);
                if (sc < 10 || sc > 100)
                {
                    throw(new Exception());                       //throw error for catching
                }
            }
            catch
            {
                lbError.Text += "SC Score must be a valid number between 10 to 100<br/>";
                GeneralFunction.HighlightControl(txtSC);
            }

            try
            {
                int id = int.Parse(txtID.Text);
                if (id < 10 || id > 100)
                {
                    throw (new Exception());                      //throw error for catching
                }
            }
            catch
            {
                lbError.Text += "ID Score must be a valid number between 10 to 100<br/>";
                GeneralFunction.HighlightControl(txtID);
            }

            try
            {
                int il = int.Parse(txtIL.Text);
                if (il < 10 || il > 100)
                {
                    throw (new Exception());                      //throw error for catching
                }
            }
            catch
            {
                lbError.Text += "IL Score must be a valid number between 10 to 100<br/>";
                GeneralFunction.HighlightControl(txtIL);
            }

            try
            {
                int re = int.Parse(txtRE.Text);
                if (re < 10 || re > 100)
                {
                    throw (new Exception());                      //throw error for catching
                }
            }
            catch
            {
                lbError.Text += "RE Score must be a valid number between 10 to 100<br/>";
                GeneralFunction.HighlightControl(txtRE);
            }

            //if (round == "1")
            {
                string v_advancement = GeneralFunction.ValidateDropDownList("Recommendation for advancement", ddlRecommendation, true, "");
                if (v_advancement != "")
                {
                    lbError.Text += v_advancement;
                    GeneralFunction.HighlightControl(ddlRecommendation);
                }
            }
        }
        else
        {
            txtSC.Text = "0";
            txtID.Text = "0";
            txtIL.Text = "0";
            txtRE.Text = "0";

            if (!isDraft)
            {
                lbError.Text += GeneralFunction.ValidateTextBox("Recuse reason", txtRecuseRemarks, true, "string");
            }
        }


        if (ddlFlag.SelectedValue != "" && !isDraft)
        {
            lbError.Text += GeneralFunction.ValidateTextBox("Flag reason", txtFlagOthers, true, "string");
        }

        if (txtFeedbackStrong.Text.Trim().Length > 1000)
        {
            lbError.Text += "Strongest element of the case cannot exceed 1000 characters.";
            GeneralFunction.HighlightControl(txtFeedbackStrong);
        }

        if (txtFeedbackWeak.Text.Trim().Length > 1000)
        {
            lbError.Text += "Weakest element of the case cannot exceed 1000 characters.";
            GeneralFunction.HighlightControl(txtFeedbackWeak);
        }

        if (txtAdditionalComments.Text.Trim().Length > 1000)
        {
            lbError.Text += "Advice and additional comments cannot exceed 1000 characters.";
            GeneralFunction.HighlightControl(txtAdditionalComments);
        }


        // Is this entry scored by this judege before?
        List <Score> scores = ScoreList.GetScoreList(entry.Id, jury.Id).ToList();

        //if (scores.Count != 0 && scores[0].IsSubmitted)
        if (scores.Count != 0 && scores[0].IsSubmitted && scores[0].Round == round)
        {
            lbError.Text += "Scored before. Score not saved.<br/>";
        }

        if (round == "2" && ddlRecommendation.SelectedValue == "Yes")
        {
            lbError.Text += GeneralFunction.ValidateDropDownList("Nomination", ddlNomination, true, "");
        }

        return(lbError.Text == "");
    }