예제 #1
0
    protected bool ValidateandSave()
    {
        if (TabContainer1.ActiveTabIndex == 0)
        {
            if (grPayroll.Rows.Count == 0)
            {
                lblMsg.Text = "No record found.";
                return(false);
            }

            foreach (GridViewRow gRow in grPayroll.Rows)
            {
                // validate with From date
                if (objVarMgr.IsDuplicateIncDate(gRow.Cells[1].Text.Trim(), Common.ReturnDate(gRow.Cells[8].Text.Trim())) == true)
                {
                    lblMsg.Text    = "Record cannot save because of duplicate record exist. Please remove duplicate record.";
                    gRow.BackColor = System.Drawing.Color.Yellow;
                    return(false);
                }
            }
            return(true);
        }
        else
        {
            if (grIncrementList.Rows.Count == 0)
            {
                lblMsg.Text = "No record found.";
                return(false);
            }

            foreach (GridViewRow gRow in grIncrementList.Rows)
            {
                CheckBox chkB = (CheckBox)gRow.Cells[0].FindControl("chkBox");
                if (chkB.Checked == true)
                {
                    // validate with From date
                    if (objVarMgr.IsDuplicateIncDate(gRow.Cells[1].Text.Trim(), Common.ReturnDate(txtActionDate.Text.Trim())) == true)
                    {
                        lblMsg.Text    = "Record cannot save because of duplicate record exist. Please remove duplicate record.";
                        gRow.BackColor = System.Drawing.Color.Yellow;
                        return(false);
                    }
                }
            }
            return(true);
        }
    }