예제 #1
0
        void GetPayRef()
        {
            //string values = string.Empty;
            int intval = 0;

            lblSelect.Text = string.Empty;

            int j = 0;



            for (int i = 0; i < selection.SelectedCount; i++)
            {
                values += String.Format("'{0}'", (selection.GetSelectedRow(i) as DataRowView)["PaymentRefNumber"]);
                if (j + 1 < selection.SelectedCount)
                {
                    values += ",";
                }
                ++j;


                temTable.Rows.Add(new object[] { String.Format("{0}", (selection.GetSelectedRow(i) as DataRowView)["EReceipts"]), String.Format("{0}", (selection.GetSelectedRow(i) as DataRowView)["PaymentRefNumber"]), Program.UserID });
            }

            using (SqlConnection connect = new SqlConnection(Logic.ConnectionString))
            {
                connect.Open();
                _command = new SqlCommand("InserttblReceipt", connect)
                {
                    CommandType = CommandType.StoredProcedure
                };
                _command.Parameters.Add(new SqlParameter("@tblCollectionReport_Temp", SqlDbType.Structured)).Value = temTable;
                _command.Parameters.Add(new SqlParameter("@type", SqlDbType.VarChar)).Value = "New";
                //_command.Parameters.Add(new SqlParameter("@intoption", SqlDbType.Int)).Value = intval;
                _command.Parameters.Add(new SqlParameter("@userid", SqlDbType.VarChar)).Value = Program.UserID;
                System.Data.DataSet response = new System.Data.DataSet();
                response.Clear();
                adp = new SqlDataAdapter(_command);
                adp.Fill(response);

                connect.Close();
                if (String.Compare(response.Tables[0].Rows[0]["returnCode"].ToString(), "00", false) == 0)
                {
                    //do something load the report page
                    using (SqlConnection db = new SqlConnection(Logic.ConnectionString))
                    {
                        SqlTransaction transaction;

                        db.Open();

                        transaction = db.BeginTransaction();

                        try
                        {
                            using (System.Data.DataSet dds = new System.Data.DataSet("DsCollectionReport"))
                            {
                                SqlDataAdapter ada;

                                using (WaitDialogForm form = new WaitDialogForm())
                                {
                                    string strFormat = null; string query = string.Empty;

                                    //if (Program.stateCode == "20")
                                    //{
                                    //    if (Convert.ToInt32(radioGroup1.EditValue) != 1)
                                    //    {
                                    //        query = string.Format("SELECT [ID] , [Provider] , [Channel] ,Collection.tblCollectionReport.PaymentRefNumber , [DepositSlipNumber] , CONVERT(VARCHAR,CONVERT(DATE,[PaymentDate])) AS PaymentDate,[PayerID] , UPPER([PayerName]) AS [PayerName], [Amount] ,[PaymentMethod] ,[ChequeNumber] ,[ChequeValueDate] ,[ChequeStatus] ,[DateChequeReturned] ,[TelephoneNumber] ,[ReceiptNo] ,[ReceiptDate] ,UPPER([PayerAddress]) as [PayerAddress] ,[User] ,[RevenueCode] ,[Description] , [ChequeBankCode] ,[ChequeBankName] ,[AgencyName] ,[AgencyCode] ,[BankCode] ,[BankName] ,[BranchCode] ,[BranchName] ,[ZoneCode] ,[ZoneName] ,[Username] ,[AmountWords] ,Collection.tblCollectionReport.[EReceipts] ,Collection.tblCollectionReport.[EReceiptsDate],[GeneratedBy] ,  Collection.tblCollectionReport.[StationCode] ,(SELECT TOP 1 StationName FROM Receipt.tblStation  WHERE tblStation.StationCode = Collection.tblCollectionReport.[StationCode]) AS StationName,ControlNumber , ControlNumberBy , ControlNumberDate ,IsPrintedDate , PrintedBY from Collection.tblCollectionReport  INNER JOIN Receipt.tblCollectionReceipt ON Receipt.tblCollectionReceipt.PaymentRefNumber = Collection.tblCollectionReport.PaymentRefNumber INNER JOIN Receipt.tblReceiptoption ON Receipt.tblReceiptoption.PaymentRefNumber = Receipt.tblCollectionReceipt.PaymentRefNumber WHERE Collection.tblCollectionReport.PaymentRefNumber  IN ({0})         AND Receipt.tblReceiptoption.IsPrinted = 1  ORDER BY Collection.tblCollectionReport.AgencyName ,Collection.tblCollectionReport.Description,Collection.tblCollectionReport.EReceipts", values);
                                    //    }
                                    //    else
                                    //    {
                                    //        query = string.Format("SELECT [ID] , [Provider] , [Channel] ,[PaymentRefNumber] , [DepositSlipNumber] , CONVERT(VARCHAR,CONVERT(DATE,[PaymentDate])) AS PaymentDate,[PayerID] , UPPER([PayerName]) AS [PayerName], [Amount] ,[PaymentMethod] ,[ChequeNumber] ,[ChequeValueDate] ,[ChequeStatus] ,[DateChequeReturned] ,[TelephoneNumber] ,[ReceiptNo] ,[ReceiptDate] ,UPPER([PayerAddress]) as [PayerAddress] ,[User] ,[RevenueCode] ,[Description] , [ChequeBankCode] ,[ChequeBankName] ,[AgencyName] ,[AgencyCode] ,[BankCode] ,[BankName] ,[BranchCode] ,[BranchName] ,[ZoneCode] ,[ZoneName] ,[Username] ,[AmountWords] ,[EReceipts] ,[EReceiptsDate] ,[GeneratedBy] ,[StationCode] ,(SELECT TOP 1 StationName FROM Receipt.tblStation  WHERE tblStation.StationCode = Collection.tblCollectionReport.[StationCode]) AS StationName from Collection.tblCollectionReport WHERE PaymentRefNumber IN ({0})  ORDER BY Collection.tblCollectionReport.AgencyName ,Collection.tblCollectionReport.Description,Collection.tblCollectionReport.EReceipts", values);
                                    //    }
                                    //}
                                    //else
                                    //{

                                    //}

                                    switch (Program.intCode)
                                    {
                                    case 20:    //detla state
                                        query = string.Format("SELECT [ID] , [Provider] , [Channel] ,[PaymentRefNumber] , [DepositSlipNumber] , CONVERT(VARCHAR,CONVERT(DATE,[PaymentDate])) AS PaymentDate,[PayerID] , UPPER([PayerName]) AS [PayerName], [Amount] ,[PaymentMethod] ,[ChequeNumber] ,[ChequeValueDate] ,[ChequeStatus] ,[DateChequeReturned] ,[TelephoneNumber] ,[ReceiptNo] ,[ReceiptDate] ,UPPER([PayerAddress]) as [PayerAddress] ,[User] ,[RevenueCode] ,tblCollectionReport.Description , [ChequeBankCode] ,[ChequeBankName] ,[AgencyName] ,[AgencyCode] ,[BankCode] ,[BankName] ,[BranchCode] ,[BranchName] ,[ZoneCode] ,[ZoneName] ,[Username] ,[AmountWords] ,[EReceipts] ,[EReceiptsDate] ,[GeneratedBy] ,[StationCode] ,(SELECT TOP 1 StationName FROM Receipt.tblStation  WHERE tblStation.StationCode = Collection.tblCollectionReport.[StationCode]) AS StationName,ControlNumber, Symbol , Surfix , tblCurrency.Description AS prefix from Collection.tblCollectionReport INNER JOIN Reconciliation.tblCurrency ON tblCurrency.CurrencyCode = tblCollectionReport.CurrencyCode WHERE PaymentRefNumber IN ({0})   ORDER BY Collection.tblCollectionReport.AgencyName ,Collection.tblCollectionReport.Description,Collection.tblCollectionReport.EReceipts", values);
                                        break;

                                    default:
                                        query = string.Format("SELECT [ID] , [Provider] , [Channel] ,[PaymentRefNumber] , [DepositSlipNumber] , CONVERT(VARCHAR,CONVERT(DATE,[PaymentDate])) AS PaymentDate,[PayerID] , UPPER([PayerName]) AS [PayerName], [Amount] ,[PaymentMethod] ,[ChequeNumber] ,[ChequeValueDate] ,[ChequeStatus] ,[DateChequeReturned] ,[TelephoneNumber] ,[ReceiptNo] ,[ReceiptDate] ,UPPER([PayerAddress]) as [PayerAddress] ,[User] ,[RevenueCode] ,tblCollectionReport.Description , [ChequeBankCode] ,[ChequeBankName] ,[AgencyName] ,[AgencyCode] ,[BankCode] ,[BankName] ,[BranchCode] ,[BranchName] ,[ZoneCode] ,[ZoneName] ,[Username] ,[AmountWords] ,[EReceipts] ,[EReceiptsDate] ,[GeneratedBy] ,[StationCode] ,(SELECT TOP 1 StationName FROM Receipt.tblStation  WHERE tblStation.StationCode = Collection.tblCollectionReport.[StationCode]) AS StationName, Symbol , Surfix , tblCurrency.Description AS prefix from Collection.tblCollectionReport INNER JOIN Reconciliation.tblCurrency ON tblCurrency.CurrencyCode = tblCollectionReport.CurrencyCode WHERE PaymentRefNumber IN ({0})   ORDER BY Collection.tblCollectionReport.AgencyName ,Collection.tblCollectionReport.Description,Collection.tblCollectionReport.EReceipts", values);
                                        break;
                                    }


                                    DataTable Dt = dds.Tables.Add("CollectionReportTable");
                                    ada = new SqlDataAdapter(query, Logic.ConnectionString);
                                    ada.Fill(dds, "CollectionReportTable");
                                    //Logic.ProcessDataTable(Dt);;
                                    Logic.ProcessDataTable(Dt);
                                    //strCollectionReportID = strFormat;
                                }

                                //XRepReceipt recportRec = new XRepReceipt { DataSource = dds.Tables[0] /*recportRec.DataAdapter = ada;*/, DataMember = "CollectionReportTable" };

                                //recportRec.ShowPreviewDialog();

                                ////selection.ClearSelection();
                                //dds.Clear();

                                switch (Program.intCode)
                                {
                                case 13:    //Akwa Ibom state
                                    XtraRepReceiptAkwa akwa = new XtraRepReceiptAkwa {
                                        DataSource = dds.Tables[0] /*recportRec.DataAdapter = ada;*/, DataMember = "CollectionReportTable"
                                    };
                                    akwa.ShowPreviewDialog();
                                    break;

                                case 20:    //detla state
                                    XtraRepReceiptDelta delta = new XtraRepReceiptDelta {
                                        DataSource = dds.Tables[0] /*recportRec.DataAdapter = ada;*/, DataMember = "CollectionReportTable"
                                    };
                                    //delta.PrintingSystem.StartPrint += PrintingSystem_StartPrint;
                                    //if (Program.stateCode == "20")
                                    //{
                                    //    if (Convert.ToInt32(radioGroup1.EditValue) != 1)
                                    //    {
                                    //        delta.xrLabel19.Visible = true;
                                    //        //delta.xrLabel13.Visible = true;
                                    //    }

                                    //}
                                    //delta.Watermark.Text = "DUPLICATE";
                                    ////delta.Watermark.TextDirection = DirectionMode.Clockwise;
                                    //delta.Watermark.Font = new Font(delta.Watermark.Font.FontFamily, 40);
                                    //delta.Watermark.ForeColor = Color.DodgerBlue;
                                    //delta.Watermark.TextTransparency = 150;
                                    //delta.Watermark.ShowBehind = false;

                                    delta.logoPath = Logic.singaturepth;
                                    delta.ShowPreviewDialog();
                                    //delta.Print();
                                    break;

                                case 37:    //ogun state
                                    XRepReceipt recportRec = new XRepReceipt {
                                        DataSource = dds.Tables[0] /*recportRec.DataAdapter = ada;*/, DataMember = "CollectionReportTable"
                                    };
                                    recportRec.logoPath = Logic.singaturepth;
                                    recportRec.ShowPreviewDialog();
                                    break;

                                case 40:    //oyo state
                                    XRepReceiptoyo recportRecs = new XRepReceiptoyo {
                                        DataSource = dds.Tables[0] /*recportRec.DataAdapter = ada;*/, DataMember = "CollectionReportTable"
                                    };
                                    recportRecs.ShowPreviewDialog();
                                    break;

                                //case 32://kogi state

                                //    XRepReceiptkogi recportRecko = new XRepReceiptkogi { DataSource = dds.Tables[0] /*recportRec.DataAdapter = ada;*/, DataMember = "CollectionReportTable" };
                                //    recportRecko.ShowPreviewDialog();

                                //    break;

                                default:

                                    break;
                                }
                            }

                            //dds.Clear();
                            DialogResult result = MessageBox.Show(" Is Receipt Printing Successful ?", Program.ApplicationName, MessageBoxButtons.YesNo);

                            if (result == DialogResult.Yes)
                            {
                                try
                                {
                                    SplashScreenManager.ShowForm(this, typeof(WaitForm1), true, true, false);

                                    //update the collection table by seting the isprinted to true
                                    using (SqlConnection dbs = new SqlConnection(Logic.ConnectionString))
                                    {
                                        SqlTransaction transactions;

                                        dbs.Open();

                                        //transaction = db.BeginTransaction();

                                        transactions = dbs.BeginTransaction();

                                        try
                                        {
                                            //string query1 = String.Format("UPDATE tblCollectionReport SET isPrinted=1,IsPrintedDate= '{0:MM/dd/yyyy HH:mm:ss tt}',PrintedBY='{1}' ,StationCode='{2}' WHERE PaymentRefNumber IN ({3})", DateTime.Now, Program.UserID, Program.stationCode, values);

                                            string query1 = String.Format("UPDATE Receipt.tblCollectionReceipt SET isPrinted=1,IsPrintedDate= '{0:MM/dd/yyyy HH:mm:ss tt}',PrintedBY='{1}',StationCode='{2}' WHERE PaymentRefNumber IN (SELECT PaymentRefNumber FROM Receipt.tblReceipt WHERE SentBy='{1}')", DateTime.Now, Program.UserID, Program.stationCode);

                                            using (SqlCommand sqlCommand = new SqlCommand(query1, db, transaction))
                                            {
                                                sqlCommand.ExecuteNonQuery();
                                            }
                                        }
                                        catch (Exception ex)
                                        {
                                            transaction.Rollback();
                                            Tripous.Sys.ErrorBox(ex);
                                            return;
                                        }
                                        transaction.Commit();

                                        db.Close();
                                    }
                                    bttnMain.Visible = true; label1.Visible = true;
                                    bttnMain.Enabled = true;
                                }
                                finally
                                {
                                    SplashScreenManager.CloseForm(false);
                                }
                                //using (FrmMainFest frmMainFest = new FrmMainFest(strCollectionReportID, values, criteria2, false) { IDList = strCollectionReportID })
                                //{
                                //    frmMainFest.ShowDialog();
                                //}
                            }
                            else
                            {
                                return;
                            }
                        }
                        catch (SqlException sqlError)
                        {
                            //transaction.Rollback();

                            Tripous.Sys.ErrorBox(sqlError);
                        }
                        catch (Exception ex)
                        {
                            Tripous.Sys.ErrorBox(ex);
                        }
                        db.Close();
                    }
                }
                else
                {
                    if (String.Compare(response.Tables[0].Rows[0]["returnCode"].ToString(), "-1", false) == 0)
                    {
                        Tripous.Sys.ErrorBox(response.Tables[0].Rows[0]["returnMessage"].ToString());
                        return;
                    }
                    else
                    {
                        using (Frmcontrol frmcontrol = new Frmcontrol())
                        {
                            frmcontrol.gridControl1.DataSource = response.Tables[1];
                            frmcontrol.gridView1.BestFitColumns();
                            frmcontrol.label1.Text = "Payment Ref. Number Receipt printing in Process";
                            frmcontrol.Text        = "Payment Ref. Number Receipt printing in Process";
                            frmcontrol.ShowDialog();
                        }

                        DialogResult result = MessageBox.Show("Do you wish to continue to Print the Receipts?", Program.ApplicationName, MessageBoxButtons.YesNo);

                        if (result == DialogResult.Yes)
                        {
                            using (SqlConnection db = new SqlConnection(Logic.ConnectionString))
                            {
                                SqlTransaction transaction;

                                db.Open();

                                transaction = db.BeginTransaction();

                                try
                                {
                                    using (System.Data.DataSet dds = new System.Data.DataSet("DsCollectionReport"))
                                    {
                                        SqlDataAdapter ada;

                                        using (WaitDialogForm form = new WaitDialogForm())
                                        {
                                            string strFormat = null; string query = string.Empty;


                                            switch (Program.intCode)
                                            {
                                            case 20:    //detla state
                                                query = string.Format("SELECT [ID] , [Provider] , [Channel] ,[PaymentRefNumber] , [DepositSlipNumber] , CONVERT(VARCHAR,CONVERT(DATE,[PaymentDate])) AS PaymentDate,[PayerID] , UPPER([PayerName]) AS [PayerName], [Amount] ,[PaymentMethod] ,[ChequeNumber] ,[ChequeValueDate] ,[ChequeStatus] ,[DateChequeReturned] ,[TelephoneNumber] ,[ReceiptNo] AS [EReceipts] ,[ReceiptDate] ,UPPER([PayerAddress]) as [PayerAddress] ,[User] ,[RevenueCode] ,tblCollectionReport.Description , [ChequeBankCode] ,[ChequeBankName] ,[AgencyName] ,[AgencyCode] ,[BankCode] ,[BankName] ,[BranchCode] ,[BranchName] ,[ZoneCode] ,[ZoneName] ,[Username] ,[AmountWords] ,[EReceiptsDate] ,[GeneratedBy] ,[StationCode] ,(SELECT TOP 1 StationName FROM Receipt.tblStation  WHERE tblStation.StationCode = Collection.tblCollectionReport.[StationCode]) AS StationName, Symbol , Surfix , tblCurrency.Description AS prefix from Collection.tblCollectionReport INNER JOIN Reconciliation.tblCurrency ON tblCurrency.CurrencyCode = tblCollectionReport.CurrencyCode WHERE PaymentRefNumber IN ({0})  ORDER BY Collection.tblCollectionReport.AgencyName ,Collection.tblCollectionReport.Description,Collection.tblCollectionReport.ReceiptNo", values);
                                                break;

                                            default:
                                                query = string.Format("SELECT [ID] , [Provider] , [Channel] ,[PaymentRefNumber] , [DepositSlipNumber] , CONVERT(VARCHAR,CONVERT(DATE,[PaymentDate])) AS PaymentDate,[PayerID] , UPPER([PayerName]) AS [PayerName], [Amount] ,[PaymentMethod] ,[ChequeNumber] ,[ChequeValueDate] ,[ChequeStatus] ,[DateChequeReturned] ,[TelephoneNumber] ,[ReceiptNo] ,[ReceiptDate] ,UPPER([PayerAddress]) as [PayerAddress] ,[User] ,[RevenueCode] ,tblCollectionReport.Description , [ChequeBankCode] ,[ChequeBankName] ,[AgencyName] ,[AgencyCode] ,[BankCode] ,[BankName] ,[BranchCode] ,[BranchName] ,[ZoneCode] ,[ZoneName] ,[Username] ,[AmountWords] ,[EReceipts] ,[EReceiptsDate] ,[GeneratedBy] ,[StationCode] ,(SELECT TOP 1 StationName FROM Receipt.tblStation  WHERE tblStation.StationCode = Collection.tblCollectionReport.[StationCode]) AS StationName, Symbol , Surfix , tblCurrency.Description AS prefix from Collection.tblCollectionReport INNER JOIN Reconciliation.tblCurrency ON tblCurrency.CurrencyCode = tblCollectionReport.CurrencyCode WHERE PaymentRefNumber IN ({0})  ORDER BY Collection.tblCollectionReport.AgencyName ,Collection.tblCollectionReport.Description,Collection.tblCollectionReport.EReceipts", values);
                                                break;
                                            }

                                            DataTable Dt = dds.Tables.Add("CollectionReportTable");
                                            ada = new SqlDataAdapter(query, Logic.ConnectionString);
                                            ada.Fill(dds, "CollectionReportTable");
                                            //Logic.ProcessDataTable(Dt);;
                                            Logic.ProcessDataTable(Dt);;
                                            //strCollectionReportID = strFormat;
                                        }


                                        //XRepReceipt recportRec = new XRepReceipt { DataSource = dds.Tables[0] /*recportRec.DataAdapter = ada;*/, DataMember = "CollectionReportTable" };

                                        //recportRec.ShowPreviewDialog();

                                        switch (Program.intCode)
                                        {
                                        case 13:    //Akwa Ibom state
                                            XtraRepReceiptAkwa akwa = new XtraRepReceiptAkwa {
                                                DataSource = dds.Tables[0] /*recportRec.DataAdapter = ada;*/, DataMember = "CollectionReportTable"
                                            };
                                            akwa.ShowPreviewDialog();
                                            break;

                                        case 20:    //detla state
                                            XtraRepReceiptDelta delta = new XtraRepReceiptDelta {
                                                DataSource = dds.Tables[0] /*recportRec.DataAdapter = ada;*/, DataMember = "CollectionReportTable"
                                            };
                                            //delta.PrintingSystem.StartPrint += PrintingSystem_StartPrint;
                                            delta.logoPath = Logic.singaturepth;
                                            delta.ShowPreviewDialog();
                                            //delta.Print();
                                            break;

                                        case 37:    //ogun state
                                            XRepReceipt recportRec = new XRepReceipt {
                                                DataSource = dds.Tables[0] /*recportRec.DataAdapter = ada;*/, DataMember = "CollectionReportTable"
                                            };
                                            recportRec.logoPath = Logic.singaturepth;
                                            recportRec.ShowPreviewDialog();
                                            break;

                                        case 40:    //oyo state
                                            XRepReceiptoyo recportRecs = new XRepReceiptoyo {
                                                DataSource = dds.Tables[0] /*recportRec.DataAdapter = ada;*/, DataMember = "CollectionReportTable"
                                            };
                                            recportRecs.ShowPreviewDialog();
                                            break;

                                        //case 32://kogi state

                                        //    XRepReceiptkogi recportRecko = new XRepReceiptkogi { DataSource = dds.Tables[0] /*recportRec.DataAdapter = ada;*/, DataMember = "CollectionReportTable" };
                                        //    recportRecko.ShowPreviewDialog();

                                        //    break;

                                        default:
                                            break;
                                        }
                                        //selection.ClearSelection();
                                        dds.Clear();
                                    }

                                    DialogResult results = MessageBox.Show(" Is Receipt Printing Successful ?", Program.ApplicationName, MessageBoxButtons.YesNo);

                                    if (results == DialogResult.Yes)
                                    {
                                        try
                                        {
                                            SplashScreenManager.ShowForm(this, typeof(WaitForm1), true, true, false);

                                            //update the collection table by seting the isprinted to true
                                            using (SqlConnection dbs = new SqlConnection(Logic.ConnectionString))
                                            {
                                                SqlTransaction transactions;

                                                dbs.Open();

                                                //transaction = db.BeginTransaction();

                                                transactions = dbs.BeginTransaction();

                                                try
                                                {
                                                    string query1 = String.Format("UPDATE Receipt.tblCollectionReceipt SET isPrinted=1,IsPrintedDate= '{0:MM/dd/yyyy HH:mm:ss tt}',PrintedBY='{1}' ,StationCode='{2}' WHERE PaymentRefNumber IN ({3})", DateTime.Now, Program.UserID, Program.stationCode, values);

                                                    //string query1 = String.Format("UPDATE Receipt.tblCollectionReceipt SET isPrinted=1,IsPrintedDate= '{0:MM/dd/yyyy HH:mm:ss tt}',PrintedBY='{1}',StationCode='{2}' WHERE PaymentRefNumber IN (SELECT PaymentRefNumber FROM Receipt.tblReceipt WHERE SentBy='{1}')", DateTime.Now, Program.UserID, Program.stationCode);

                                                    using (SqlCommand sqlCommand = new SqlCommand(query1, db, transaction))
                                                    {
                                                        sqlCommand.ExecuteNonQuery();
                                                    }
                                                }
                                                catch (Exception ex)
                                                {
                                                    transaction.Rollback();
                                                    Tripous.Sys.ErrorBox(ex);
                                                    return;
                                                }
                                                transaction.Commit();

                                                db.Close();
                                            }
                                            bttnMain.Visible = true; label1.Visible = true;
                                            bttnMain.Enabled = true;
                                        }
                                        finally
                                        {
                                            SplashScreenManager.CloseForm(false);
                                        }

                                        //using (FrmMainFest frmMainFest = new FrmMainFest(strCollectionReportID, values, criteria2, false) { IDList = strCollectionReportID })
                                        //{
                                        //    this.Close();
                                        //    frmMainFest.ShowDialog();
                                        //}
                                    }
                                    else
                                    {
                                        return;
                                    }
                                }
                                catch (SqlException sqlError)
                                {
                                    //transaction.Rollback();

                                    Tripous.Sys.ErrorBox(sqlError);
                                }
                                catch (Exception ex)
                                {
                                    Tripous.Sys.ErrorBox(ex);
                                }
                                db.Close();
                            }
                        }
                        else
                        {
                            return;
                        }
                    }

                    //else
                    //{
                    //    Common.setMessageBox(response.Tables[0].Rows[0]["returnMessage"].ToString(), "", 2);
                    //    return;
                    //}
                }
            }
            //load the recport
            //using (SqlConnection db = new SqlConnection(Logic.ConnectionString))
            //{
            //    SqlTransaction transaction;

            //    db.Open();

            //    transaction = db.BeginTransaction();

            //    try
            //    {
            //        using (System.Data.DataSet dds = new System.Data.DataSet("DsCollectionReport"))
            //        {
            //            SqlDataAdapter ada;

            //            //using (WaitDialogForm form = new WaitDialogForm())
            //            //{
            //            string strFormat = null;

            //            string query = String.Format("SELECT [ID] , [Provider] , [Channel] ,[PaymentRefNumber] , [DepositSlipNumber] , CONVERT(VARCHAR,CONVERT(DATETime,[PaymentDate])) AS PaymentDate,[PayerID] , UPPER([PayerName]) AS [PayerName], [Amount] ,[PaymentMethod] ,[ChequeNumber] ,[ChequeValueDate] ,[ChequeStatus] ,[DateChequeReturned] ,[TelephoneNumber] ,[ReceiptNo] ,[ReceiptDate] ,UPPER([PayerAddress]) as [PayerAddress] ,[User] ,[RevenueCode] , Description , [ChequeBankCode] ,[ChequeBankName] , [AgencyName] ,[AgencyCode] ,[BankCode] ,[BankName] ,[BranchCode] ,[BranchName] ,[ZoneCode] ,[ZoneName] ,[Username] ,[AmountWords] ,[EReceipts] ,[EReceiptsDate] ,[GeneratedBy] ,[StationCode] ,(SELECT TOP 1 StationName from Receipt.tblStation WHERE tblStation.StationCode = Collection.tblCollectionReport.[StationCode]) AS StationName from Collection.tblCollectionReport WHERE PaymentRefNumber IN ({0}) ORDER BY Collection.tblCollectionReport.StationCode , Collection.tblCollectionReport.AgencyCode ,Collection.tblCollectionReport.RevenueCode,Collection.tblCollectionReport.EReceipts  ", values);


            //            DataTable Dt = dds.Tables.Add("CollectionReportTable");
            //            ada = new SqlDataAdapter(query, Logic.ConnectionString);
            //            ada.Fill(dds, "CollectionReportTable");
            //            Logic.ProcessDataTable(Dt);;
            //            strCollectionReportID = values;
            //            //}


            //            XRepReceipt recportRec = new XRepReceipt { DataSource = dds.Tables[0] /*recportRec.DataAdapter = ada;*/, DataMember = "CollectionReportTable" };

            //            recportRec.ShowPreviewDialog();

            //            //selection.ClearSelection();
            //            //dds.Clear();
            //        }
            //        db.Close();
            //    }
            //    catch (SqlException sqlError)
            //    {
            //        Tripous.Sys.ErrorBox(sqlError);
            //    }

            //}
        }
예제 #2
0
        void GetPayRef()
        {
            string values = string.Empty;

            lblSelect.Text = string.Empty;

            int j = 0;

            temTable.Clear();

            for (int i = 0; i < selection.SelectedCount; i++)
            {
                temTable.Rows.Add(new object[] { String.Format("{0}", (selection.GetSelectedRow(i) as DataRowView)["EReceipts"]), String.Format("{0}", (selection.GetSelectedRow(i) as DataRowView)["PaymentRefNumber"]), Program.UserID });

                values += String.Format("'{0}'", (selection.GetSelectedRow(i) as DataRowView)["PaymentRefNumber"]);

                if (j + 1 < selection.SelectedCount)
                {
                    values += ",";
                }
                ++j;
            }

            Program.IsReprint = false;
            try
            {
                SplashScreenManager.ShowForm(this, typeof(WaitForm1), true, true, false);

                if (!isReprint)
                {
                    //using (WaitDialogForm form = new WaitDialogForm("Application Working...,Please Wait...", "Processing Your Request"))
                    //{

                    using (SqlConnection connect = new SqlConnection(Logic.ConnectionString))
                    {
                        connect.Open();
                        _command = new SqlCommand("InserttblReceipt", connect)
                        {
                            CommandType = CommandType.StoredProcedure
                        };
                        _command.Parameters.Add(new SqlParameter("@tblCollectionReport_Temp", SqlDbType.Structured)).Value = temTable;
                        _command.Parameters.Add(new SqlParameter("@type", SqlDbType.VarChar)).Value   = "Edit";
                        _command.Parameters.Add(new SqlParameter("@userid", SqlDbType.VarChar)).Value = Program.UserID;
                        System.Data.DataSet response = new System.Data.DataSet();
                        response.Clear();
                        adp = new SqlDataAdapter(_command);
                        adp.Fill(response);

                        connect.Close();
                        if (String.Compare(response.Tables[0].Rows[0]["returnCode"].ToString(), "00", false) == 0)
                        {
                            //do something load the report page
                            using (SqlConnection db = new SqlConnection(Logic.ConnectionString))
                            {
                                SqlTransaction transaction;

                                db.Open();

                                transaction = db.BeginTransaction();

                                try
                                {
                                    using (System.Data.DataSet dds = new System.Data.DataSet("DsCollectionReport"))
                                    {
                                        SqlDataAdapter ada;

                                        string strFormat = null;

                                        query = string.Format("SELECT  [ID] , [Provider] , [Channel] , tblCollectionReport.PaymentRefNumber , [DepositSlipNumber] ,CONVERT(VARCHAR, CONVERT(DATE, [PaymentDate])) AS PaymentDate , [PayerID] , UPPER([PayerName]) AS [PayerName] , [Amount] , [PaymentMethod] ,[ChequeNumber] , [ChequeValueDate] , [ChequeStatus] ,[DateChequeReturned] ,[TelephoneNumber] ,  [ReceiptNo] , [ReceiptDate] , UPPER([PayerAddress]) AS [PayerAddress] ,[User] ,   [RevenueCode] , tblCollectionReport.Description , [ChequeBankCode] ,[ChequeBankName] ,   [AgencyName] , [AgencyCode] , [BankCode] , [BankName] , [BranchCode] ,[BranchName] , [ZoneCode] , [ZoneName] ,  [Username] ,[AmountWords] , [EReceipts] , [EReceiptsDate] ,[GeneratedBy] ,[StationCode] ,ControlNumber ,ControlNumberDate , ( SELECT TOP 1 StationName  FROM  Receipt.tblStation  WHERE     tblStation.StationCode = Collection.tblCollectionReport.[StationCode]) AS StationName, Symbol , Surfix , tblCurrency.Description AS prefix FROM    Collection.tblCollectionReport LEFT JOIN Receipt.tblReprintedReceipts ON tblCollectionReport.PaymentRefNumber = tblReprintedReceipts.PaymentRefNumber inner JOIN Reconciliation.tblCurrency ON tblCurrency.CurrencyCode = tblCollectionReport.CurrencyCode WHERE  tblCollectionReport.PaymentRefNumber IN ({0})  ORDER BY Collection.tblCollectionReport.StationCode , Collection.tblCollectionReport.AgencyCode ,Collection.tblCollectionReport.RevenueCode,Collection.tblCollectionReport.EReceipts", values);

                                        DataTable Dt = dds.Tables.Add("CollectionReportTable");
                                        ada = new SqlDataAdapter(query, Logic.ConnectionString);
                                        ada.Fill(dds, "CollectionReportTable");
                                        Logic.ProcessDataTable(Dt);;
                                        //strCollectionReportID = strFormat;



                                        //XRepReceipt recportRec = new XRepReceipt { DataSource = dds.Tables[0] /*recportRec.DataAdapter = ada;*/, DataMember = "CollectionReportTable" };

                                        //recportRec.ShowPreviewDialog();

                                        switch (Program.intCode)
                                        {
                                        case 13:    //Akwa Ibom state
                                            XtraRepReceiptAkwa akwa = new XtraRepReceiptAkwa {
                                                DataSource = dds.Tables[0] /*recportRec.DataAdapter = ada;*/, DataMember = "CollectionReportTable"
                                            };
                                            akwa.ShowPreviewDialog();
                                            break;

                                        case 20:    //detla state
                                            XtraRepReceiptDelta delta = new XtraRepReceiptDelta {
                                                DataSource = dds.Tables[0] /*recportRec.DataAdapter = ada;*/, DataMember = "CollectionReportTable"
                                            };
                                            //delta.PrintingSystem.StartPrint += PrintingSystem_StartPrint;
                                            //if (Program.stateCode == "20")
                                            //{
                                            //    if (Convert.ToInt32(radioGroup1.EditValue) != 1)
                                            //    {
                                            //        delta.xrLabel19.Visible = true;
                                            //        //delta.xrLabel13.Visible = true;
                                            //    }

                                            //}
                                            //delta.Watermark.Text = "DUPLICATE";
                                            ////delta.Watermark.TextDirection = DirectionMode.Clockwise;
                                            //delta.Watermark.Font = new Font(delta.Watermark.Font.FontFamily, 40);
                                            //delta.Watermark.ForeColor = Color.DodgerBlue;
                                            //delta.Watermark.TextTransparency = 150;
                                            //delta.Watermark.ShowBehind = false;

                                            delta.logoPath  = Logic.singaturepth;
                                            delta.Imagepath = Logic.logopth;
                                            //report.Watermark.Text = "DUPLICATE";
                                            delta.xrLabel3.Visible = true;
                                            //delta.Imagepath = Logic.;
                                            delta.Watermark.Text = "DUPLICATE";
                                            delta.ShowPreviewDialog();
                                            //delta.Print();
                                            break;

                                        case 37:    //ogun state
                                            XRepReceipt recportRec = new XRepReceipt {
                                                DataSource = dds.Tables[0] /*recportRec.DataAdapter = ada;*/, DataMember = "CollectionReportTable"
                                            };
                                            //recportRec.logoPath = Logic.singaturepth;
                                            recportRec.logoPath = Logic.singaturepth;
                                            recportRec.ShowPreviewDialog();
                                            break;

                                        case 40:    //oyo state
                                            XRepReceiptoyo recportRecs = new XRepReceiptoyo {
                                                DataSource = dds.Tables[0] /*recportRec.DataAdapter = ada;*/, DataMember = "CollectionReportTable"
                                            };
                                            recportRecs.ShowPreviewDialog();
                                            break;

                                        //case 32://kogi state

                                        //    XRepReceiptkogi recportRecko = new XRepReceiptkogi { DataSource = dds.Tables[0] /*recportRec.DataAdapter = ada;*/, DataMember = "CollectionReportTable" };
                                        //    recportRecko.ShowPreviewDialog();

                                        //    break;

                                        default:
                                            break;
                                        }

                                        //selection.ClearSelection(); dds.Clear();
                                    }
                                }
                                catch (SqlException sqlError)
                                {
                                    //transaction.Rollback();

                                    Tripous.Sys.ErrorBox(sqlError);
                                }
                                catch (Exception ex)
                                {
                                    Tripous.Sys.ErrorBox(ex);
                                }
                                db.Close();
                            }
                        }
                        else
                        {
                            if (String.Compare(response.Tables[0].Rows[0]["returnCode"].ToString(), "-1", false) == 0)
                            {
                                using (Frmcontrol frmcontrol = new Frmcontrol())
                                {
                                    frmcontrol.gridControl1.DataSource = response.Tables[1];
                                    frmcontrol.gridView1.BestFitColumns();
                                    frmcontrol.label1.Text = "Payment Ref. Number Already been used";
                                    frmcontrol.Text        = "Payment Ref. Number Already been used";
                                    frmcontrol.ShowDialog();
                                }
                            }
                            else
                            {
                                Common.setMessageBox(response.Tables[0].Rows[0]["returnMessage"].ToString(), "", 2);
                                return;
                            }
                        }
                    }
                }
                else
                {
                    using (SqlConnection db = new SqlConnection(Logic.ConnectionString))
                    {
                        SqlTransaction transaction;

                        db.Open();

                        transaction = db.BeginTransaction();

                        using (System.Data.DataSet dds = new System.Data.DataSet("DsCollectionReport"))
                        {
                            SqlDataAdapter ada;

                            using (WaitDialogForm form = new WaitDialogForm())
                            {
                                string strFormat = null;

                                query = string.Format("SELECT  [ID] , [Provider] , [Channel] , tblCollectionReport.PaymentRefNumber , [DepositSlipNumber] ,CONVERT(VARCHAR, CONVERT(DATE, [PaymentDate])) AS PaymentDate , [PayerID] , UPPER([PayerName]) AS [PayerName] , [Amount] , [PaymentMethod] ,[ChequeNumber] , [ChequeValueDate] , [ChequeStatus] ,[DateChequeReturned] ,[TelephoneNumber] ,  [ReceiptNo] , [ReceiptDate] , UPPER([PayerAddress]) AS [PayerAddress] ,[User] ,   [RevenueCode] , tblCollectionReport.Description , [ChequeBankCode] ,[ChequeBankName] ,   [AgencyName] , [AgencyCode] , [BankCode] , [BankName] , [BranchCode] ,[BranchName] , [ZoneCode] , [ZoneName] ,  [Username] ,[AmountWords] , [EReceipts] , [EReceiptsDate] ,[GeneratedBy] ,[StationCode] ,ControlNumber ,ControlNumberDate , ( SELECT TOP 1 StationName  FROM  Receipt.tblStation  WHERE     tblStation.StationCode = Collection.tblCollectionReport.[StationCode]) AS StationName, Symbol , Surfix , tblCurrency.Description AS prefix FROM    Collection.tblCollectionReport INNER JOIN Reconciliation.tblCurrency ON tblCurrency.CurrencyCode = tblCollectionReport.CurrencyCode LEFT JOIN Receipt.tblReprintedReceipts ON tblCollectionReport.PaymentRefNumber = tblReprintedReceipts.PaymentRefNumber WHERE  tblCollectionReport.PaymentRefNumber IN ({0}) ORDER BY Collection.tblCollectionReport.EReceipts", values);

                                DataTable Dt = dds.Tables.Add("CollectionReportTable");
                                ada = new SqlDataAdapter(query, Logic.ConnectionString);
                                ada.Fill(dds, "CollectionReportTable");
                                Logic.ProcessDataTable(Dt);;
                                //strCollectionReportID = strFormat;
                            }


                            //XRepReceipt recportRec = new XRepReceipt { DataSource = dds.Tables[0] /*recportRec.DataAdapter = ada;*/, DataMember = "CollectionReportTable" };

                            //recportRec.ShowPreviewDialog();

                            //selection.ClearSelection(); dds.Clear();
                            switch (Program.intCode)
                            {
                            case 13:    //Akwa Ibom state
                                XtraRepReceiptAkwa akwa = new XtraRepReceiptAkwa {
                                    DataSource = dds.Tables[0] /*recportRec.DataAdapter = ada;*/, DataMember = "CollectionReportTable"
                                };
                                akwa.ShowPreviewDialog();
                                break;

                            case 37:    //ogun state
                                XRepReceipt recportRec = new XRepReceipt {
                                    DataSource = dds.Tables[0] /*recportRec.DataAdapter = ada;*/, DataMember = "CollectionReportTable"
                                };
                                recportRec.logoPath = Logic.singaturepth;
                                recportRec.ShowPreviewDialog();
                                break;

                            case 20:    //detla state
                                XtraRepReceiptDelta delta = new XtraRepReceiptDelta {
                                    DataSource = dds.Tables[0] /*recportRec.DataAdapter = ada;*/, DataMember = "CollectionReportTable"
                                };
                                //delta.PrintingSystem.StartPrint += PrintingSystem_StartPrint;
                                //if (Program.stateCode == "20")
                                //{
                                //    if (Convert.ToInt32(radioGroup1.EditValue) != 1)
                                //    {
                                //        delta.xrLabel19.Visible = true;
                                //        //delta.xrLabel13.Visible = true;
                                //    }

                                //}
                                //delta.Watermark.Text = "DUPLICATE";
                                ////delta.Watermark.TextDirection = DirectionMode.Clockwise;
                                //delta.Watermark.Font = new Font(delta.Watermark.Font.FontFamily, 40);
                                //delta.Watermark.ForeColor = Color.DodgerBlue;
                                //delta.Watermark.TextTransparency = 150;
                                //delta.Watermark.ShowBehind = false;

                                delta.logoPath  = Logic.singaturepth;
                                delta.Imagepath = Logic.logopth;
                                //report.Watermark.Text = "DUPLICATE";
                                delta.xrLabel3.Visible = true; delta.logoPath = Logic.singaturepth;
                                delta.Watermark.Text   = "DUPLICATE";
                                delta.ShowPreviewDialog();
                                //delta.Print();
                                break;

                            case 40:    //oyo state
                                XRepReceiptoyo recportRecs = new XRepReceiptoyo {
                                    DataSource = dds.Tables[0] /*recportRec.DataAdapter = ada;*/, DataMember = "CollectionReportTable"
                                };
                                recportRecs.ShowPreviewDialog();
                                break;

                            //case 32://kogi state

                            //    XRepReceiptkogi recportRecko = new XRepReceiptkogi { DataSource = dds.Tables[0] /*recportRec.DataAdapter = ada;*/, DataMember = "CollectionReportTable" };
                            //    recportRecko.ShowPreviewDialog();

                            //    break;

                            default:
                                break;
                            }
                        }
                    }
                }
            }
            finally
            {
                SplashScreenManager.CloseForm(false);
            }

            //return values;
        }
예제 #3
0
        void btnPrint_Click(object sender, EventArgs e)
        {
            values = string.Empty;

            lblSelect.Text = string.Empty;

            int j = 0;

            if (selection.SelectedCount == 0)
            {
                Common.setMessageBox("No Selection Made for Printing of Receipts", Program.ApplicationName, 3);
                return;
            }
            else
            {
                temTable.Clear();

                for (int i = 0; i < selection.SelectedCount; i++)
                {
                    temTable.Rows.Add(new object[] { String.Format("{0}", (selection.GetSelectedRow(i) as DataRowView)["EReceipts"]), String.Format("{0}", (selection.GetSelectedRow(i) as DataRowView)["PaymentRefNumber"]), Program.UserID });

                    values += String.Format("'{0}'", (selection.GetSelectedRow(i) as DataRowView)["PaymentRefNumber"]);

                    if (j + 1 < selection.SelectedCount)
                    {
                        values += ",";
                    }
                    ++j;
                }

                using (SqlConnection connect = new SqlConnection(Logic.ConnectionString))
                {
                    connect.Open();
                    _command = new SqlCommand("InserttblReceipt", connect)
                    {
                        CommandType = CommandType.StoredProcedure
                    };
                    _command.Parameters.Add(new SqlParameter("@tblCollectionReport_Temp", SqlDbType.Structured)).Value = temTable;
                    _command.Parameters.Add(new SqlParameter("@type", SqlDbType.VarChar)).Value   = "New";
                    _command.Parameters.Add(new SqlParameter("@userid", SqlDbType.VarChar)).Value = Program.UserID;
                    System.Data.DataSet response = new System.Data.DataSet();
                    response.Clear();
                    adp = new SqlDataAdapter(_command);
                    adp.Fill(response);

                    connect.Close();
                    if (String.Compare(response.Tables[0].Rows[0]["returnCode"].ToString(), "00", false) == 0)
                    {
                        //do something load the report page
                        using (SqlConnection db = new SqlConnection(Logic.ConnectionString))
                        {
                            SqlTransaction transaction;

                            db.Open();

                            transaction = db.BeginTransaction();

                            try
                            {
                                using (System.Data.DataSet dds = new System.Data.DataSet("DsCollectionReport"))
                                {
                                    SqlDataAdapter ada;

                                    using (WaitDialogForm form = new WaitDialogForm())
                                    {
                                        string strFormat = null;

                                        query = string.Format("SELECT [ID] , [Provider] , [Channel] ,[PaymentRefNumber] , [DepositSlipNumber] , CONVERT(VARCHAR,CONVERT(DATETime,[PaymentDate])) AS PaymentDate,[PayerID] , UPPER([PayerName]) AS [PayerName], [Amount] ,[PaymentMethod] ,[ChequeNumber] ,[ChequeValueDate] ,[ChequeStatus] ,[DateChequeReturned] ,[TelephoneNumber] ,[ReceiptNo] ,[ReceiptDate] ,UPPER([PayerAddress]) as [PayerAddress] ,[User] ,[RevenueCode] , tblCollectionReport.Description , [ChequeBankCode] ,[ChequeBankName] ,[AgencyName] ,[AgencyCode] ,[BankCode] ,[BankName] ,[BranchCode] ,[BranchName] ,[ZoneCode] ,[ZoneName] ,[Username] ,[AmountWords] ,[EReceipts] ,[EReceiptsDate] ,[GeneratedBy] ,[StationCode] ,(SELECT StationName FROM Receipt.tblStation  WHERE tblStation.StationCode = Collection.tblCollectionReport.[StationCode]) AS StationName, Symbol , Surfix , tblCurrency.Description AS prefix from Collection.tblCollectionReport  JOIN Reconciliation.tblCurrency ON tblCurrency.CurrencyCode = tblCollectionReport.CurrencyCode WHERE PaymentRefNumber IN ({0})  ORDER BY Collection.tblCollectionReport.StationCode , Collection.tblCollectionReport.AgencyCode ,Collection.tblCollectionReport.RevenueCode,Collection.tblCollectionReport.EReceipts", values);

                                        DataTable Dt = dds.Tables.Add("CollectionReportTable");
                                        ada = new SqlDataAdapter(query, Logic.ConnectionString);
                                        ada.Fill(dds, "CollectionReportTable");
                                        Logic.ProcessDataTable(Dt);;
                                        //strCollectionReportID = strFormat;
                                    }


                                    //XRepReceipt recportRec = new XRepReceipt { DataSource = dds.Tables[0] /*recportRec.DataAdapter = ada;*/, DataMember = "CollectionReportTable" };

                                    //recportRec.ShowPreviewDialog();

                                    //selection.ClearSelection(); dds.Clear();

                                    switch (Program.intCode)
                                    {
                                    case 13:    //Akwa Ibom state
                                        XtraRepReceiptAkwa akwa = new XtraRepReceiptAkwa {
                                            DataSource = dds.Tables[0] /*recportRec.DataAdapter = ada;*/, DataMember = "CollectionReportTable"
                                        };

                                        akwa.ShowPreviewDialog();

                                        break;

                                    case 20:    //detla state

                                        XtraRepReceiptDelta delta = new XtraRepReceiptDelta {
                                            DataSource = dds.Tables[0] /*recportRec.DataAdapter = ada;*/, DataMember = "CollectionReportTable"
                                        };
                                        //XRepReceipto/*yo delta = new XRepReceiptoyo { DataSource = dds.Tables[0] /*recportRec.DataAdapter = ada;*/, DataMember = "CollectionReportTable" };*/
                                        ////delta.PrintingSystem.StartPrint += PrintingSystem_StartPrint;
                                        delta.logoPath = Logic.singaturepth;
                                        delta.ShowPreviewDialog();
                                        break;

                                    case 37:    //ogun state
                                        XRepReceipt recportRec = new XRepReceipt {
                                            DataSource = dds.Tables[0] /*recportRec.DataAdapter = ada;*/, DataMember = "CollectionReportTable"
                                        }; recportRec.logoPath = Logic.singaturepth;
                                        recportRec.ShowPreviewDialog();
                                        break;

                                    case 40:    //oyo state
                                        XRepReceiptoyo recportRecs = new XRepReceiptoyo {
                                            DataSource = dds.Tables[0] /*recportRec.DataAdapter = ada;*/, DataMember = "CollectionReportTable"
                                        };
                                        recportRecs.ShowPreviewDialog();
                                        break;

                                    //case 32://kogi state

                                    //    XRepReceiptkogi recportRecko = new XRepReceiptkogi { DataSource = dds.Tables[0] /*recportRec.DataAdapter = ada;*/, DataMember = "CollectionReportTable" };
                                    //    recportRecko.ShowPreviewDialog();

                                    //    break;

                                    default:
                                        break;
                                    }
                                }
                            }
                            catch (SqlException sqlError)
                            {
                                //transaction.Rollback();

                                Tripous.Sys.ErrorBox(sqlError);
                            }
                            catch (Exception ex)
                            {
                                Tripous.Sys.ErrorBox(ex);
                            }
                            db.Close();
                        }
                        //    //ask if the print was sucessfull
                        DialogResult result = MessageBox.Show(" Is Receipt Printing Successful ?", Program.ApplicationName, MessageBoxButtons.YesNo);
                        if (result == DialogResult.Yes)
                        {
                            try
                            {
                                SplashScreenManager.ShowForm(this, typeof(WaitForm1), true, true, false);

                                //update the collection table by seting the isprinted to true
                                using (SqlConnection db = new SqlConnection(Logic.ConnectionString))
                                {
                                    SqlTransaction transaction;

                                    db.Open();

                                    transaction = db.BeginTransaction();
                                    try
                                    {
                                        string query1 = String.Format("UPDATE Receipt.tblCollectionReceipt SET isPrinted=1,IsPrintedDate= '{0:MM/dd/yyyy HH:mm:ss tt}',PrintedBY='{1}',StationCode='{2}' WHERE PaymentRefNumber IN ({3})", DateTime.Now, Program.UserID, Program.stationCode, values);

                                        using (SqlCommand sqlCommand = new SqlCommand(query1, db, transaction))
                                        {
                                            sqlCommand.ExecuteNonQuery();
                                        }
                                    }
                                    catch (Exception ex)
                                    {
                                        transaction.Rollback();
                                        Tripous.Sys.ErrorBox(ex);
                                        return;
                                    }
                                    transaction.Commit();

                                    db.Close();
                                }
                            }
                            finally
                            {
                                SplashScreenManager.CloseForm(false);
                            }
                        }
                        else
                        {
                            try
                            {
                                SplashScreenManager.ShowForm(this, typeof(WaitForm1), true, true, false);

                                using (SqlConnection db = new SqlConnection(Logic.ConnectionString))
                                {
                                    SqlTransaction transaction;

                                    db.Open();

                                    transaction = db.BeginTransaction();
                                    try
                                    {
                                        string query1 = String.Format("DELETE FROM Receipt.tblCollectionReceipt WHERE PaymentRefNumber IN (SELECT PaymentRefNumber FROM Receipt.tblReceipt WHERE PaymentRefNumber in ({0})", values);

                                        using (SqlCommand sqlCommand = new SqlCommand(query1, db, transaction))
                                        {
                                            sqlCommand.ExecuteNonQuery();
                                        }

                                        string query = String.Format("DELETE  FROM Receipt.tblReceipt where PaymentRefNumber in ({0})", values);

                                        using (SqlCommand sqlCommand1 = new SqlCommand(query, db, transaction))
                                        {
                                            sqlCommand1.ExecuteNonQuery();
                                        }

                                        transaction.Commit();
                                    }
                                    catch (Exception ex)
                                    {
                                        transaction.Rollback();
                                        Tripous.Sys.ErrorBox(ex);
                                        return;
                                    }


                                    db.Close();
                                }
                            }
                            finally
                            {
                                SplashScreenManager.CloseForm(false);
                            }
                            return;
                        }
                    }
                    else
                    {
                        if (String.Compare(response.Tables[0].Rows[0]["returnCode"].ToString(), "-1", false) == 0)
                        {
                            Common.setMessageBox(response.Tables[0].Rows[0]["returnMessage"].ToString(), "", 2);
                            //return;

                            if (response.Tables[0].Rows[0]["returnMessage"].ToString() != "Payment Ref. Number Already Exist")
                            {
                                //using (Frmcontrol frmcontrol = new Frmcontrol())
                                //{
                                //    frmcontrol.gridControl1.DataSource = response.Tables[1];
                                //    frmcontrol.gridView1.BestFitColumns();
                                //    frmcontrol.label1.Text = "Payment Ref. Number Already been used";
                                //    frmcontrol.Text = "Payment Ref. Number Already been used";
                                //    frmcontrol.ShowDialog();
                                //}
                                return;
                            }
                            else
                            {
                                using (Frmcontrol frmcontrol = new Frmcontrol())
                                {
                                    frmcontrol.gridControl1.DataSource = response.Tables[1];
                                    frmcontrol.gridView1.BestFitColumns();
                                    frmcontrol.label1.Text = "Payment Ref. Number Already been used";
                                    frmcontrol.Text        = "Payment Ref. Number Already been used";
                                    frmcontrol.ShowDialog();
                                }
                            }
                        }
                        else
                        {
                            Common.setMessageBox(response.Tables[0].Rows[0]["returnMessage"].ToString(), "", 2);
                            return;
                        }
                    }
                }
            }
        }