Example #1
0
        public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport()
        {
            rptSavingsMain_Cheque rpt = new rptSavingsMain_Cheque();

            rpt.Site = this.Site;
            return(rpt);
        }
Example #2
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            if (cmbMode.Text == "")
            {
                Alert.show("Please Select Withdrawal Mode!", Alert.AlertType.error);
                return;
            }

            if (cmbMode.Text == "ALL Mode" && cmbStatus.Text == "ALL Status")
            {
                if (cmbSearchBy.Text == "All Withdrawal")
                {
                    searchBy = "*";
                }
            }
            else
            {
                if (cmbSearchBy.Text == "")
                {
                    Alert.show("Please Select Type of Search you want!", Alert.AlertType.error);
                    return;
                }
            }

            if (cmbStatus.Text == "")
            {
                Alert.show("Please Select Status of Withdrawal", Alert.AlertType.error);
                return;
            }

            if (cmbSearchBy.Text != "All Withdrawal" && cmbSearchBy.Text != "")
            {
                if (txtKeyWord.Text == "")
                {
                    Alert.show("Please Put Valid Keyword To Search!", Alert.AlertType.error);
                    return;
                }
            }

            if (Convert.ToDateTime(dtFrom.Text) > Convert.ToDateTime(dtTo.Text))
            {
                Alert.show("Please Put Valid Dates To Search", Alert.AlertType.error);
                return;
            }



            //====================================================================================
            //              GENERATE REPORT
            //====================================================================================

            //ATM REPORT
            CrystalDecisions.Shared.TableLogOnInfo li;

            //Print Purposes
            using (SqlConnection con = new SqlConnection(global.connectString()))
            {
                con.Open();


                //=====================================================================================
                //                  STRING QUERY BUILDER
                //=====================================================================================
                string str = "";
                if (searchBy == "*")
                {
                    str = "SELECT * FROM vw_SavingsWithdrawal WHERE Withdrawal_Mode in " + wdMode + " and Status in " + status + " and wdDate Between '" + dtFrom.Text + "' and '" + dtTo.Text + "' ORDER BY Withdrawal_Slip_No ASC";
                }
                else
                {
                    str = "SELECT * FROM vw_SavingsWithdrawal WHERE Withdrawal_Mode in " + wdMode + " and " + searchBy + " like '%" + txtKeyWord.Text + "%' and Status in " + status + " and wdDate Between '" + dtFrom.Text + "' and '" + dtTo.Text + "' ORDER BY Withdrawal_Slip_No ASC";
                }


                SqlDataAdapter adapter = new SqlDataAdapter(str, con);
                DataTable      checkDT = new DataTable();
                adapter.Fill(checkDT);

                if (checkDT.Rows.Count == 0)
                {
                    Alert.show("No Record(s) Found!", Alert.AlertType.error);
                    return;
                }

                DataTable dt = new DataTable();
                DataSet   ds = new DataSet();

                //Generate Report according to MODE
                if (cmbMode.Text == "ALL Mode") //ALL MODE
                {
                    ReportsForms.rptSavingsMainAllMode cr = new ReportsForms.rptSavingsMainAllMode();

                    li = new TableLogOnInfo();

                    li.ConnectionInfo.IntegratedSecurity = false;

                    adapter.Fill(ds, "vw_SavingsWithdrawal");
                    dt = ds.Tables["vw_SavingsWithdrawal"];
                    cr.SetDataSource(ds.Tables["vw_SavingsWithdrawal"]);

                    //cr.SetDatabaseLogon("sa", "SYSADMIN", "192.168.255.176", "PECCI-NEW");
                    cr.SetDatabaseLogon(global.username, global.pass, global.datasource, global.initialCatalog);


                    cr.SetParameterValue("paramDateFrom", dtFrom.Text);
                    cr.SetParameterValue("paramDateTo", dtTo.Text);


                    cr.SetParameterValue("paramGenerateBy", Classes.clsUser.Username);


                    crystalReportViewer1.ReportSource = cr;
                }
                else if (cmbMode.Text == "ATM - AT")//GENERATE ATM ONLY
                {
                    ReportsForms.rptSavingsMain cr = new ReportsForms.rptSavingsMain();

                    li = new TableLogOnInfo();

                    li.ConnectionInfo.IntegratedSecurity = false;

                    adapter.Fill(ds, "vw_SavingsWithdrawal");
                    dt = ds.Tables["vw_SavingsWithdrawal"];
                    cr.SetDataSource(ds.Tables["vw_SavingsWithdrawal"]);

                    //cr.SetDatabaseLogon("sa", "SYSADMIN", "192.168.255.176", "PECCI-NEW");
                    cr.SetDatabaseLogon(global.username, global.pass, global.datasource, global.initialCatalog);


                    cr.SetParameterValue("paramDateFrom", dtFrom.Text);
                    cr.SetParameterValue("paramDateTo", dtTo.Text);

                    cr.SetParameterValue("paramGenerateBy", Classes.clsUser.Username);


                    crystalReportViewer1.ReportSource = cr;
                }
                else if (cmbMode.Text == "CASH - CA")//GENERATE CASH ONLY
                {
                    ReportsForms.rptSavingsMainCash cr = new ReportsForms.rptSavingsMainCash();

                    li = new TableLogOnInfo();

                    li.ConnectionInfo.IntegratedSecurity = false;

                    adapter.Fill(ds, "vw_SavingsWithdrawal");
                    dt = ds.Tables["vw_SavingsWithdrawal"];
                    cr.SetDataSource(ds.Tables["vw_SavingsWithdrawal"]);

                    //cr.SetDatabaseLogon("sa", "SYSADMIN", "192.168.255.176", "PECCI-NEW");
                    cr.SetDatabaseLogon(global.username, global.pass, global.datasource, global.initialCatalog);


                    cr.SetParameterValue("paramDateFrom", dtFrom.Text);
                    cr.SetParameterValue("paramDateTo", dtTo.Text);

                    cr.SetParameterValue("paramGenerateBy", Classes.clsUser.Username);


                    crystalReportViewer1.ReportSource = cr;
                }
                else if (cmbMode.Text == "CHEQUE - CH")
                {
                    ReportsForms.rptSavingsMain_Cheque cr = new ReportsForms.rptSavingsMain_Cheque();

                    li = new TableLogOnInfo();

                    li.ConnectionInfo.IntegratedSecurity = false;

                    adapter.Fill(ds, "vw_SavingsWithdrawal");
                    dt = ds.Tables["vw_SavingsWithdrawal"];
                    cr.SetDataSource(ds.Tables["vw_SavingsWithdrawal"]);

                    //cr.SetDatabaseLogon("sa", "SYSADMIN", "192.168.255.176", "PECCI-NEW");
                    cr.SetDatabaseLogon(global.username, global.pass, global.datasource, global.initialCatalog);


                    cr.SetParameterValue("paramDateFrom", dtFrom.Text);
                    cr.SetParameterValue("paramDateTo", dtTo.Text);


                    cr.SetParameterValue("paramGenerateBy", Classes.clsUser.Username);


                    crystalReportViewer1.ReportSource = cr;
                }
            }
        }