protected void drpForms_SelectedIndexChanged(object sender, EventArgs e)
 {
     StiWebViewer1.Visible       = false;
     dvPayanShowType.Visible     = drpForms.SelectedItem.Value == "3";
     ddl_PayanType.SelectedIndex = 0;
     //ddl_PayanType.Visible = drpForms.SelectedItem.Value == "3";
     chkRizNomre.Visible = drpForms.SelectedValue == "6";
     dvEstelam.Visible   = drpForms.SelectedValue == "6" || drpForms.SelectedValue == "5";
     if (drpForms.SelectedValue == "6" || drpForms.SelectedValue == "5")
     {
         setDrpInquirySource();
     }
     if (drpForms.SelectedValue == "7")
     {
         DataTable             checkDebit = new DataTable();
         CheckOutRefahBusiness refah      = new CheckOutRefahBusiness();
         checkDebit = refah.GetAllDebitByStcode(ViewState["stCode"].ToString());
         if (checkDebit.Rows.Count != 0)
         {
             divLoanInfo.Visible = true;
         }
         else
         {
             divLoanInfo.Visible = false;
         }
     }
     else
     {
         divLoanInfo.Visible = false;
     }
 }
        protected void btnOk_Click(object sender, EventArgs e)
        {
            if (Session["printDocument_Type"] != null)
            {
                Session.Remove("printDocument_Stcode");
                Session.Remove("printDocument_Type");
            }
            StiReport rpt = new StiReport();

            switch (Convert.ToInt32(drpForms.SelectedValue))
            {
            case 1:
                StiWebViewer1.Visible = true;
                StiWebViewer1.ResetReport();

                stCode     = (string)ViewState["stCode"];
                GFD.stCode = stCode;

                dr = GFB.getStatusReportInfo(GFD);
                rpt.Load(Server.MapPath("../Reports/GraduateStatus.mrt"));
                rpt.Dictionary.Databases.Clear();
                rpt.Dictionary.Databases.Add(new StiSqlDatabase("Connection1", CB.SupplementaryReportConnection.ToString()));
                rpt.Compile();
                rpt.CompiledReport.DataSources["[Graduate].[SP_getFormVaziatInfo]"].Parameters["@stcode"].ParameterValue = stCode;
                rpt.RegData(dr);
                StiWebViewer1.Report = rpt;
                break;

            case 2:
                StiWebViewer1.Visible = true;
                StiWebViewer1.ResetReport();

                stCode     = (string)ViewState["stCode"];
                GFD.stCode = stCode;

                dr = GFB.getDrafReportInfo(GFD);
                rpt.Load(Server.MapPath("../Reports/GraduateDraft.mrt"));
                rpt.Dictionary.Databases.Clear();
                rpt.Dictionary.Databases.Add(new StiSqlDatabase("Connection1", CB.SupplementaryReportConnection.ToString()));
                rpt.Compile();
                rpt.CompiledReport.DataSources["[Graduate].[SP_getFormDraftInfo]"].Parameters["@stcode"].ParameterValue   = stCode;
                rpt.CompiledReport.DataSources["[request].[SP_Get_StudentLoanInfo]"].Parameters["@stcode"].ParameterValue = stCode;
                rpt.RegData(dr);
                StiWebViewer1.Report = rpt;
                break;

            case 3:    //ریزنمره
                var SFD = GFB.getStudentFeraghatDocument(ViewState["stCode"].ToString());
                if (SFD.dateRiznomreErsal != null && SFD.dateRiznomreErsal.Trim() != "" && SFD.dateRiznomreErsal.Trim() != "-")
                {
                    showMessage("برای این دانشجو در تاریخ " + SFD.dateRiznomreErsal + " ریز نمره ارسال شده است.");
                }

                StiWebViewer1.Visible = true;
                StiWebViewer1.ResetReport();

                stCode     = (string)ViewState["stCode"];
                GFD.stCode = stCode;


                rpt.Load(Server.MapPath("../Reports/FinalWorkbook.mrt"));
                rpt.Dictionary.Databases.Clear();
                rpt.Dictionary.Databases.Add(new StiSqlDatabase("Connection1", CB.SupplementaryReportConnection.ToString()));
                rpt.Compile();
                rpt.CompiledReport.DataSources["[Graduate].[SP_getFormMarkListInfo]"].Parameters["@stcode"].ParameterValue          = stCode;
                rpt.CompiledReport.DataSources["[Graduate].[SP_getPayanFormMarkListInfo]"].Parameters["@stcode"].ParameterValue     = stCode;
                rpt.CompiledReport.DataSources["[Graduate].[SP_getPayanFormMarkListInfo]"].Parameters["@multiPayan"].ParameterValue = (ddl_PayanType.SelectedItem.Value == "1" ? 1 : 0);
                rpt.CompiledReport.DataSources["[dbo].[SP_GetStudentPic]"].Parameters["@stcode"].ParameterValue = stCode;

                StiWebViewer1.Report = rpt;
                setLog(Convert.ToInt32(stCode));
                break;

            case 4:

                StiWebViewer1.Visible = true;
                StiWebViewer1.ResetReport();

                stCode     = (string)ViewState["stCode"];
                GFD.stCode = stCode;

                dr = GFB.getCourseReportInfo(GFD);
                rpt.Load(Server.MapPath("../Reports/CorsePassesByType.mrt"));
                rpt.Dictionary.Databases.Clear();
                rpt.Dictionary.Databases.Add(new StiSqlDatabase("Connection1", CB.SupplementaryReportConnection.ToString()));
                rpt.Compile();
                rpt.CompiledReport.DataSources["[Graduate].[SP_getCoursePassedInfo]"].Parameters["@stcode"].ParameterValue = stCode;
                rpt.CompiledReport.DataSources["[dbo].[SP_GetStudentPic]"].Parameters["@stcode"].ParameterValue            = stCode;
                rpt.RegData(dr);
                StiWebViewer1.Report = rpt;
                break;

            case 5:    //استعلام گواهی موقت
            case 6:    //استعلام دانشنامه

                type = Convert.ToInt32(drpForms.SelectedValue);
                if (chkRizNomre.Checked && type == 6)
                {
                    type = 61;
                }
                StiWebViewer1.Visible = true;
                StiWebViewer1.ResetReport();

                stCode     = (string)ViewState["stCode"];
                GFD.stCode = stCode;

                dr = GFB.getCourseReportInfo(GFD);
                rpt.Load(Server.MapPath("../Reports/TaeedTahsili.mrt"));
                rpt.Dictionary.Databases.Clear();
                rpt.Dictionary.Databases.Add(new StiSqlDatabase("Connection1", CB.SupplementaryReportConnection.ToString()));
                rpt.Compile();
                rpt.CompiledReport.DataSources["Graduate.SP_getFormTaeedieTahsili"].Parameters["@stcode"].ParameterValue    = stCode;
                rpt.CompiledReport.DataSources["Graduate.SP_getFormTaeedieTahsili"].Parameters["@Type"].ParameterValue      = type;
                rpt.CompiledReport.DataSources["Graduate.SP_getFormTaeedieTahsili"].Parameters["@InquiryID"].ParameterValue = drpInquiry.SelectedItem.Value;
                rpt.CompiledReport.DataSources["[dbo].[SP_GetStudentPic]"].Parameters["@stcode"].ParameterValue             = stCode;

                //vam dar
                rpt.RegData(dr);
                StiWebViewer1.Report = rpt;
                break;

            case 7:    //گواهینامه موقت
                var SFD_G = GFB.getStudentFeraghatDocument(ViewState["stCode"].ToString());
                if (SFD_G.dateGovahiSodur != null && SFD_G.dateGovahiSodur.Trim() != "" && SFD_G.dateGovahiSodur.Trim() != "-")
                {
                    showMessage("برای این دانشجو در تاریخ " + SFD_G.dateGovahiSodur + " گواهینامه موقت ارسال شده است.");
                }
                DataTable             dt;
                CheckOutRefahBusiness refah = new CheckOutRefahBusiness();
                dt = refah.GetAllDebitByStcode(ViewState["stCode"].ToString());
                if (dt.Rows.Count != 0)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        if (dt.Rows[0]["DebitTypeID"].ToString() == "1")
                        {
                            divLoanInfo.Visible = true;
                            break;
                        }
                    }

                    DateTime date;
                    Boolean  flag = DateTime.TryParse(txtPayDate.Text,
                                                      new System.Globalization.CultureInfo("fa-IR"),
                                                      System.Globalization.DateTimeStyles.None,
                                                      out date);
                    if (!flag)
                    {
                        revPayDate.IsValid = false;
                    }
                }
                else
                {
                    divLoanInfo.Visible = false;
                    clearTextBox();
                }
                StiWebViewer1.Visible = true;
                StiWebViewer1.ResetReport();

                stCode     = (string)ViewState["stCode"];
                GFD.stCode = stCode;

                dr = GFB.getCourseReportInfo(GFD);
                rpt.Load(Server.MapPath("../Reports/GovahiMovaghatPayanTahsil.mrt"));
                rpt.Dictionary.Databases.Clear();
                rpt.Dictionary.Databases.Add(new StiSqlDatabase("Connection1", CB.SupplementaryReportConnection.ToString()));
                rpt.Compile();

                rpt.CompiledReport.DataSources["[Graduate].[SP_getFormGovahiMovaghatPayanTahsilat]"].Parameters["@stcode"].ParameterValue       = ViewState["stCode"].ToString();
                rpt.CompiledReport.DataSources["[Graduate].[SP_getFormGovahiMovaghatPayanTahsilat]"].Parameters["@date"].ParameterValue         = txtPayDate.Text;
                rpt.CompiledReport.DataSources["[Graduate].[SP_getFormGovahiMovaghatPayanTahsilat]"].Parameters["@monthPay"].ParameterValue     = txtAmount.Text;
                rpt.CompiledReport.DataSources["[Graduate].[SP_getFormGovahiMovaghatPayanTahsilat]"].Parameters["@acountNumber"].ParameterValue = txtAcountNumber.Text;
                rpt.CompiledReport.DataSources["[Graduate].[SP_getFormGovahiMovaghatPayanTahsilat]"].Parameters["@bankName"].ParameterValue     = txtBankName.Text;
                rpt.CompiledReport.DataSources["[Graduate].[SP_getFormGovahiMovaghatPayanTahsilat]"].Parameters["@branchName"].ParameterValue   = txtBranchName.Text;
                rpt.CompiledReport.DataSources["[Graduate].[SP_getFormGovahiMovaghatPayanTahsilat]"].Parameters["@address"].ParameterValue      = txtAddress.Text;


                rpt.RegData(dr);
                StiWebViewer1.Report = rpt;

                break;

            case 8:    //دانشنامه
                var SFD_Danesh = GFB.getStudentFeraghatDocument(ViewState["stCode"].ToString());
                if (SFD_Danesh.dateDaneshnameSodur != null && SFD_Danesh.dateDaneshnameSodur.Trim() != "" && SFD_Danesh.dateDaneshnameSodur.Trim() != "-")
                {
                    showMessage("برای این دانشجو در تاریخ " + SFD_Danesh.dateDaneshnameSodur + " دانشنامه صادر شده است.");
                }
                StiWebViewer1.ResetReport();
                if (GFB.IsEquivalentTwoYearsGraduated(ViewState["stCode"].ToString()))
                {
                    rpt.Load(Server.MapPath("../Reports/Daneshname_Kardani.mrt"));
                    rpt.Dictionary.Databases.Clear();
                    rpt.Dictionary.Databases.Add(new StiSqlDatabase("conn", CB.SupplementaryReportConnection.ToString()));
                    rpt.Compile();

                    rpt.CompiledReport.DataSources["Graduate.sp_getFormKardani"].Parameters["@stcode"].ParameterValue = ViewState["stCode"].ToString();
                }
                else
                {
                    rpt.Load(Server.MapPath("../Reports/daneshname.mrt"));
                    rpt.Dictionary.Databases.Clear();
                    rpt.Dictionary.Databases.Add(new StiSqlDatabase("conn", CB.SupplementaryReportConnection.ToString()));
                    rpt.Compile();

                    rpt.CompiledReport.DataSources["Graduate.sp_getFromDaneshname"].Parameters["@stcode"].ParameterValue = ViewState["stCode"].ToString();
                }
                StiWebViewer1.Report  = rpt;
                StiWebViewer1.Visible = true;
                break;
            }


            revPayDate.IsValid = true;
        }