Пример #1
0
    protected bool ValidateandSave()
    {
        if (grPayroll.Rows.Count == 0)
        {
            lblMsg.Text = "No record found.";
            return(false);
        }

        string strFrom = "";
        string strTo   = "";

        strFrom = "01/" + ddlMonth.SelectedValue.Trim() + "/" + ddlYear.SelectedValue.Trim();
        strTo   = Common.GetMonthDay(Convert.ToInt16(ddlMonth.SelectedValue.Trim()), ddlYear.SelectedValue.Trim()).ToString() + "/" + ddlMonth.SelectedValue.Trim() + "/" + ddlYear.SelectedValue.Trim();
        foreach (GridViewRow gRow in grPayroll.Rows)
        {
            // validate with From date
            if (objVarMgr.IsDuplicateData(ddlSalHead.SelectedValue.ToString().Trim(), Common.ReturnDate(strFrom), gRow.Cells[0].Text.Trim()) == true)
            {
                lblMsg.Text = "Record cannot save. Duplicate record exist.";
                return(false);
            }
            // validate with To date
            if (objVarMgr.IsDuplicateData(ddlSalHead.SelectedValue.ToString().Trim(), Common.ReturnDate(strTo), gRow.Cells[0].Text.Trim()) == true)
            {
                lblMsg.Text = "Record cannot save. Duplicate record exist.";
                return(false);
            }
        }
        return(true);
    }