示例#1
0
        private int DownloadIssueReceipt()
        {
            try
            {
                using (SqlConnection connect = new SqlConnection(Logic.ConnectionString))
                {
                    connect.Open();

                    command = new SqlCommand("doGetStationInfo", connect)
                    {
                        CommandType = CommandType.StoredProcedure
                    };

                    command.CommandTimeout = 0;

                    using (System.Data.DataSet ds = new System.Data.DataSet())
                    {
                        adp = new SqlDataAdapter(command);

                        adp.SelectCommand.CommandTimeout = 0;

                        adp.Fill(ds);

                        Dts = ds.Tables[0];

                        connect.Close();

                        if (ds.Tables.Count < 1 && ds.Tables[0].Rows.Count < 1)
                        {
                            return(0);
                        }
                        else
                        {
                            System.Data.DataSet dataSet = new System.Data.DataSet();

                            switch (Program.intCode)
                            {
                            case 13:    //Akwa Ibom state
                                using (var receiptAka = new AkwaIbomReceiptServices.ReceiptService())
                                {
                                    dataSet = receiptAka.DownloadDataIssueReceipt(ds, Program.stateCode);
                                }
                                break;

                            case 20:
                                using (var receiptDelta = new DeltaBir.ReceiptService())
                                {
                                    dataSet = receiptDelta.DownloadDataIssueReceipt(ds, Program.stateCode);
                                }
                                break;

                            case 32:    //kogi state
                                break;

                            case 37:    //ogun state

                                using (var receiptsserv = new ReceiptService())
                                {
                                    dataSet = receiptsserv.DownloadDataIssueReceipt(ds, Program.stateCode);
                                }

                                break;

                            case 40:    //oyo state

                                using (var receiptsServices = new OyoReceiptServices.ReceiptService())
                                {
                                    dataSet = receiptsServices.DownloadDataIssueReceipt(ds, Program.stateCode);
                                }


                                break;

                            default:
                                break;
                            }

                            if (dataSet.Tables.Count < 1 && dataSet.Tables[0].Rows.Count < 1)
                            {
                                return(0);
                            }
                            else
                            {
                                System.Data.DataSet dataSet2 = new System.Data.DataSet();

                                dataSet2 = InsertDataIssueReceipt(dataSet);

                                switch (Program.intCode)
                                {
                                case 13:    //Akwa Ibom state
                                    using (var receiptAka = new AkwaIbomReceiptServices.ReceiptService())
                                    {
                                        dataSet2 = receiptAka.DownloadDataUpdateIssueReceipts(dataSet2, Program.stateCode);
                                    }
                                    break;

                                case 20:
                                    using (var receiptDelta = new DeltaBir.ReceiptService())
                                    {
                                        dataSet = receiptDelta.DownloadDataUpdateIssueReceipts(dataSet2, Program.stateCode);
                                    }
                                    break;

                                case 32:    //kogi state
                                    break;

                                case 37:    //ogun state

                                    using (var receiptsserv = new ReceiptService())
                                    {
                                        dataSet2 = receiptsserv.DownloadDataUpdateIssueReceipts(dataSet2, Program.stateCode);
                                    }

                                    break;

                                case 40:    //oyo state

                                    using (var receiptsServices = new OyoReceiptServices.ReceiptService())
                                    {
                                        dataSet2 = receiptsServices.DownloadDataUpdateIssueReceipts(dataSet2, Program.stateCode);
                                    }


                                    break;

                                default:
                                    break;
                                }

                                return(1);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                timer1.Stop();

                Common.setMessageBox(String.Format("{0}....{1}..Download Issues Reeipts to Station", ex.Message, ex.StackTrace), Program.ApplicationName, 3);

                timer2.Stop();
                timer2.Enabled   = false;
                btnStart.Visible = true; btnStart.Enabled = true;
                //btnStop.Visible = false;
                //btnStartup.Visible = true;
                //m_oWorker.CancelAsync();
                //bResponse=false;
                return(0);
            }
            //return bResponse;
        }