protected void btnSearch_Click(object sender, EventArgs e)
    {
        try
        {
            if ((txtFromDate.Text != "") && (txtToDate.Text != ""))
            {
                lblDateErr.Text = "";
                int dateMonthdiff = 0, DateYearDiff = 0;

                if (gvComm.PageIndex != -1)
                {
                    gvComm.PageIndex = 0;
                }

                if (ddlRegion.SelectedIndex != 0)
                {
                    sqlParamSrh[1].Value = int.Parse(ddlRegion.SelectedValue.ToString());
                }
                else
                {
                    sqlParamSrh[1].Value = 0;
                }
                if ((ddlBranch.SelectedIndex != 0) && (ddlBranch.SelectedIndex != -1))
                {
                    sqlParamSrh[2].Value = int.Parse(ddlBranch.SelectedValue.ToString());
                }
                else
                {
                    sqlParamSrh[2].Value = 0;
                }
                if (ddlProductDivison.SelectedIndex != 0)
                {
                    sqlParamSrh[3].Value = int.Parse(ddlProductDivison.SelectedValue.ToString());
                }
                else
                {
                    sqlParamSrh[3].Value = 0;
                }
                sqlParamSrh[4].Value = txtFromDate.Text.Trim();
                sqlParamSrh[5].Value = txtToDate.Text.Trim();
                sqlParamSrh[6].Value = txtReqNo.Text.Trim();

                if ((txtFromDate.Text != "") && (txtToDate.Text != ""))
                {
                    DateTime Fromdate = Convert.ToDateTime(txtFromDate.Text);
                    DateTime Todate   = Convert.ToDateTime(txtToDate.Text);
                    //FDate=Fromdate.Month;
                    //ToDate = Todate.Month;
                    dateMonthdiff = Todate.Month - Fromdate.Month;
                    DateYearDiff  = Todate.Year - Fromdate.Year;
                    if (DateYearDiff > 0)
                    {
                        dateMonthdiff = Todate.Month + 12 - Fromdate.Month;
                    }
                    //dateMonthdiff = ToDate - FDate;
                }
                if (ddlCallStage.SelectedIndex != 0)
                {
                    sqlParamSrh[7].Value = ddlCallStage.SelectedValue.ToString();
                }
                else
                {
                    sqlParamSrh[7].Value = "";
                }
                if ((ddlCallStatus.SelectedIndex != 0) && (ddlCallStatus.SelectedIndex != -1))
                {
                    sqlParamSrh[8].Value = int.Parse(ddlCallStatus.SelectedValue.ToString());
                }
                else
                {
                    sqlParamSrh[8].Value = "";
                }
                if ((ddlSerContractor.SelectedIndex != 0) && (ddlSerContractor.SelectedIndex != -1))
                {
                    sqlParamSrh[9].Value = int.Parse(ddlSerContractor.SelectedValue.ToString());
                }
                else
                {
                    sqlParamSrh[9].Value = "";
                }

                // For Defect Category
                if ((ddlDefectCategory.SelectedIndex != 0) && (ddlDefectCategory.SelectedIndex != -1))
                {
                    sqlParamSrh[10].Value = int.Parse(ddlDefectCategory.SelectedValue.ToString());
                }
                else
                {
                    sqlParamSrh[10].Value = "";
                }
                // End Defect Category

                // For Defect

                if ((ddlDefect.SelectedIndex != 0) && (ddlDefect.SelectedIndex != -1))
                {
                    sqlParamSrh[11].Value = ddlDefect.SelectedValue.ToString();
                }
                else
                {
                    sqlParamSrh[11].Value = "";
                }

                // End Defect

                //Code Added By Pravesh
                //For Product Serial No
                if (txtProductSerialNo.Text != "")
                {
                    sqlParamSrh[13].Value = txtProductSerialNo.Text.Trim();
                }
                else
                {
                    sqlParamSrh[13].Value = "";
                }
                //End Product Serial No

                //Code Added By Pravesh
                //For Product Line No
                if ((ddlProductLine.SelectedIndex > 0))
                {
                    sqlParamSrh[14].Value = int.Parse(ddlProductLine.SelectedValue.ToString());
                }
                else
                {
                    sqlParamSrh[14].Value = 0;
                }
                //End Product Line No

                //Code Added By Pravesh
                //For SRF
                if (ddlSRF.SelectedIndex != 0)
                {
                    sqlParamSrh[15].Value = ddlSRF.SelectedValue.ToString();
                }
                if (ddlWarrantyStatus.SelectedIndex != 0)
                {
                    sqlParamSrh[16].Value = ddlWarrantyStatus.SelectedValue.ToString();
                }

                // Added By Guarav Garg for MTO
                sqlParamSrh[17].Value = ddlBusinessLine.SelectedValue.ToString();

                if (ddlResolver.SelectedValue.ToString() != "0")
                {
                    sqlParamSrh[18].Value = int.Parse(ddlResolver.SelectedValue.ToString());
                }
                if ((ddlCGExec.SelectedIndex != 0) && (ddlCGExec.SelectedIndex != -1))
                {
                    sqlParamSrh[19].Value = int.Parse(ddlCGExec.SelectedValue.ToString());
                }
                if ((ddlCGContractEmp.SelectedIndex != 0) && (ddlCGContractEmp.SelectedIndex != -1))
                {
                    sqlParamSrh[20].Value = int.Parse(ddlCGContractEmp.SelectedValue.ToString());
                }



                if (dateMonthdiff > 3)
                {
                    lblMessage.Text = "Date Difference is not more than 3 month.";
                }
                else
                {
                    lblMessage.Text = "";
                    //objCommonClass.BindDataGrid(gvComm, "uspResolutionTimeAnalysis", true, sqlParamSrh, lblRowCount);
                    //objMisReport.BindDataGrid(gvComm, "uspResolutionTimeAnalysis", true, sqlParamSrh, lblRowCount, lblDefectCount); By Ashok Kumar 26 may 2014
                    objCommonClass.BindGridDetails(gvComm, sqlParamSrh, lblRowCount, lblDefectCount);

                    if (gvComm.Rows.Count > 0)
                    {
                        btnExport.Visible = true;
                    }
                    else
                    {
                        btnExport.Visible = false;
                    }
                }
            }
            else
            {
                lblDateErr.Text = "Date Required.";
            }
        }
        catch (Exception ex)
        {
            //Writing Error message to File using CommonClass WriteErrorErrFile method taking arguments as URL of page
            // trace, error message
            CommonClass.WriteErrorErrFile(Request.RawUrl.ToString(), ex.StackTrace.ToString() + "-->" + ex.Message.ToString());
        }
    }