protected bool ComplainValidation() { bool flag = false; foreach (GridViewRow gvr in gvPurchase.Rows) { if (((CheckBox)gvr.FindControl("chk")).Checked) { flag = true; } } foreach (GridViewRow gvr in gvPurchase.Rows) { if (((CheckBox)gvr.FindControl("chk")).Checked) { CustomerPurchaseId = int.Parse(gvPurchase.DataKeys[gvr.RowIndex].Values[0].ToString()); Business.Service.ServiceBook objServiceBook = new Business.Service.ServiceBook(); /* Checking whether any one docket exists or not*/ if (bool.Parse(((objServiceBook.Service_CheckIfAnyOpenDocket(CustomerPurchaseId).Rows[0]["Flag"].ToString()) == "1") ? "True" : "False")) { Message.IsSuccess = false; Message.Text = "Already a Docket is in queue. You can not docket more than one."; Message.Show = true; return(false); } /* Checking whether machine is in contract or not*/ Business.Service.Contract objContract = new Business.Service.Contract(); if (!objContract.Service_MachineIsInContractCheck(CustomerPurchaseId)) { Message.IsSuccess = false; Message.Text = "Out of Contract! Please call Customer Help Desk."; Message.Show = true; return(false); } } } if (txtProblem.Text.Trim() != string.Empty)// && txtCurrentMeterReading.Text.Trim() != string.Empty) { flag = true; } else { flag = false; } if (flag == false) { Message.IsSuccess = false; Message.Text = "Please enter/select all mendatory fields..."; Message.Show = true; } return(flag); }