All pastes #110616 Raw Edit

Mine

public text v1 · immutable
·published 2006-08-01 20:09 UTC
rendered paste body
 if( BatchID.Text != "" )
                {
               
                this.utvBatchLookup.Nodes.Add( "General Ledger Batch" );
                this.utvBatchLookup.Nodes.Add( "Invoice Batch" );
                this.utvBatchLookup.Nodes.Add( "General Ledger Batch Detail" );
                
                
                // Load the Tree
                DataSet ds = clsGL._GL_Batch( CompNo, BatchID.Text );
                this.utvBatchLookup.Nodes[ 0 ].Nodes.SetDataBinding( ds, ds.Tables[ 0 ].TableName );

                ds = clsGL._Gl_Batch_Invoices( CompNo, BatchID.Text );
                this.utvBatchLookup.Nodes[ 1 ].Nodes.SetDataBinding( ds, ds.Tables[ 0 ].TableName );
            
               
                //  this.utvBatchLookup.SetDataBinding( ds, ds.Tables[ 0 ].TableName );
                    //this.ultraTree1.SetDataBinding(ds, ds.Tables[0].TableName);
                    //
                //  this.ugvTenderPayment.DataSource = _Tender_Payments();
                //  this.ugvROA.DataSource = _ROA_Detail();
                //   this.ugvMiscAdjustments.DataSource = _MiscAdjustments_Detail();
                }


      #region  GL invoices

        public static DataSet _Gl_Batch_Invoices(int CompNo, string BatchNo)
            {
            DataSet objDs = new DataSet();
            DataTable dtMain = new DataTable();
            DataTable dtSub = new DataTable();
            DataRow drCat;
            int iTotal = 0;   
            /*    Sales
           CompanyID, OrderID, OrderTypeID, OrderTypeSubID, OrderStageID, OrderProgressID, OrderStatus, TransferNo, InvoiceNo, sContactID, bCustomerID, 
                      bCustomerName, Re, Terms, CustomerPoNo, WebOrderNo, InvoiceTypeID, PoNo, Reoccur, sMaintenance, TaxGroup, TotalCost, SubTotalSell, 
                      FreightTotal, GrandTotalSell, Paid, oPay, oPayAmount, TenderName, PaymentID, InvoiceDate, OrderedDate, PrintedDate, FaxedDate, EmailedDate, 
                      ShippingIn, SellLevel, ServiceTagNo, EnteredByID, SalesNo, SalesCompanyNo, LabourBilled, DailyBatchNo, DailyBatchNoDate, ConsolidatedBatchNo,
                       ConsolidatedBatchDate
           */
            dtMain.Columns.Add( "InvoiceDate", typeof( string ) );    // 0
            dtMain.Columns.Add( "bCustomerID", typeof( string ) );    // 1 
            dtMain.Columns.Add( "OrderID", typeof( string ) );    // 2 
            dtMain.Columns.Add( "TenderName", typeof( string ) );    // 3
            dtMain.Columns.Add( "Paid", typeof( string ) );    // 4
            dtMain.Columns.Add( "bCustomerName", typeof( string ) );    // 5            
            dtMain.Columns.Add( "InvoiceNo", typeof( string ) );    // 6     
            dtMain.Columns.Add( "GrandTotalSell", typeof( string ) );    // 7     
            dtMain.Columns.Add( "TenderID", typeof( string ) );    // 8
            dtMain.Columns.Add( "OrderStageID", typeof( string ) );    //9
            dtMain.Columns.Add( "TenderColor", typeof( string ) );    // 10 
            dtMain.Columns.Add( "OrderTypeID", typeof( string ) );    // 11 

            // Payment Detail
            //CompanyID, PaymentID, PaymentRecNo, OrderID, InvoiceNo, CustomerID, CompanyName, TransactionDate, TransactionTypeID, TransactionType, 
            //      TransactionNo, BatchNo, TenderType, TenderMethod, TenderAmount, DepositNo, DepositDate, ConsolidatedBatchNo, ConsolidatedBatchDate, UserID, StationID
            dtSub.Columns.Add( "PaymentID", typeof( string ) );    // 0
            dtSub.Columns.Add( "OrderID", typeof( string ) );    // 1
            dtSub.Columns.Add( "InvoiceNo", typeof( string ) );    // 2
            dtSub.Columns.Add( "TenderMethod", typeof( string ) );    // 3
            dtSub.Columns.Add( "TransactionNo", typeof( string ) );    // 4
            dtSub.Columns.Add( "AppliedDate", typeof( string ) );    // 5
            dtSub.Columns.Add( "TenderAmount", typeof( string ) );    // 6
            dtSub.Columns.Add( "TransactionDate", typeof( string ) );    // 7
            dtSub.Columns.Add( "UserID", typeof( string ) );    // 8
            dtSub.Columns.Add( "StationID", typeof( string ) );    // 9 
            dtSub.Columns.Add( "TenderColor", typeof( string ) );    // 10 

            try
                {
                SqlDataReader oRd, oRdP;
               // sales
                clsTLK.clsTableSelect( "Sales",
                                    "CompanyID = " + "'" + CompNo + "'" + " ) AND ( " +
                                    "ConsolidatedBatchNo = " + "'" + BatchNo + "'",
                                    "CompanyID, OrderStageID, InvoiceNo ",
                                     "CompanyID, OrderID, OrderTypeID, OrderStageID, InvoiceNo, bCustomerID, bCustomerName, GrandTotalSell, Paid, TenderName, TenderID, InvoiceDate " );
                //, OrderTypeSubID, OrderProgressID, OrderStatus, TransferNo , sContactID Re, Terms, CustomerPoNo, WebOrderNo, InvoiceTypeID, PoNo, Reoccur, sMaintenance, TaxGroup, TotalCost, SubTotalSell,FreightTotal, OrderedDate, PrintedDate, FaxedDate, EmailedDate,ShippingIn, SellLevel, ServiceTagNo, EnteredByID, SalesNo, SalesCompanyNo, LabourBilled, DailyBatchNo, DailyBatchNoDate, ConsolidatedBatchNo,ConsolidatedBatchDate, oPay, oPayAmount
                oRd = clsTLK.TLSql.ExecuteReader( CommandBehavior.CloseConnection );
                if( oRd.HasRows )
                    {
                    while( oRd.Read() )
                        {
                        iTotal++;
                        drCat = dtMain.NewRow();
                        drCat[ 0 ] = clsCon.MMMDDYYYY( oRd[ 11 ].ToString() );  // InvoiceDate
                        drCat[ 1 ] = oRd[ 5 ].ToString(); // bCustomerID
                        drCat[ 2 ] = oRd[ 1 ].ToString();  // OrderID
                        drCat[ 3 ] = oRd[ 9 ].ToString(); // TenderName
                        drCat[ 4 ] = oRd[ 8 ].ToString();  // Paid
                        drCat[ 5 ] = oRd[ 6 ].ToString();  // bCustomerName
                        drCat[ 6 ] = oRd[ 4 ].ToString();  // InvoiceNo
                        drCat[ 7 ] = oRd[ 7 ].ToString();  // GrandTotalSell
                        drCat[ 8 ] = oRd[ 10 ].ToString();  // TenderID
                        drCat[ 9 ] = oRd[ 3 ].ToString();  // OrderStageID
                        cls_Color.Color_Tender( CompNo, oRd[ 10 ].ToString() ); // TenderColor
                        drCat[ 10 ] = cls_Color.Back;
                        drCat[ 11 ] = oRd[ 2 ].ToString();  // OrderTypeID

                        dtMain.Rows.Add( drCat );

                        // Payment Detail
                        string sdf = oRd[ 1 ].ToString();
                        clsTLK.clsTableSelect( "PaymentDetail",
                              "CompanyID = " + "'" + CompNo + "'" + " ) AND ( " +
                              "OrderID = " + "'" + oRd[ 1 ].ToString() + "'",
                              "CompanyID, PaymentID",
                              "PaymentID, OrderID, InvoiceNo , TenderMethod,TransactionNo, AppliedDate ,TenderAmount, TransactionDate, UserID, StationID, TenderType"
                              );
                        oRdP = clsTLK.TLSql.ExecuteReader( CommandBehavior.CloseConnection );
                        if( oRdP.HasRows )
                            {
                            while( oRdP.Read() )
                                {
                                //   if( oRdP[ 6 ].ToString() != "" )
                                //      dcTotPay += clsCon.Rou_2D( oRdP[ 6 ].ToString() );
                                drCat = dtSub.NewRow();

                                drCat[ 0 ] = Convert.ToString( oRdP[ 0 ] );  //PaymentID
                                drCat[ 1 ] = Convert.ToString( oRdP[ 1 ] );  //OrderID
                                drCat[ 2 ] = Convert.ToString( oRdP[ 2 ] );  //InvoiceNo
                                drCat[ 3 ] = Convert.ToString( oRdP[ 3 ] );  //TenderMethod
                                drCat[ 4 ] = Convert.ToString( oRdP[ 4 ] ); // TransactionNo
                                //  AppliedDate 
                                if( oRdP[ 5 ].ToString() != "" )
                                    {
                                    drCat[ 5 ] = clsCon.ddd_MMMDDYY_PM( oRdP[ 5 ].ToString() );
                                    }
                                else
                                    drCat[ 5 ] = "";

                                drCat[ 6 ] = Convert.ToString( oRdP[ 6 ] ); // TenderAmount

                                //TransactionDate
                                if( oRdP[ 7 ].ToString() != "" )
                                    {
                                    //   fddgfd = oRdP[ 7 ].ToString();
                                    drCat[ 7 ] = clsCon.ddd_MMMDDYY_PM( oRdP[ 7 ].ToString() );
                                    }
                                else
                                    drCat[ 7 ] = "";
                                //   UserID
                                if( oRdP[ 8 ].ToString() != "" )
                                    {
                                    drCat[ 8 ] = clsTLK.clsTableGetOneFieldData( "SysName",
                                        "SysCompanyID = " + "'" + oRd[ 0 ].ToString() + "'" + " ) AND ( " + "SysNameID = " + "'" + oRdP[ 8 ].ToString() + "'",
                                         "SysCompanyID, SysNameID",
                                         "SysLoginName" );
                                    //  drCat[ 5 ] = clsTLK.GetOneFieldData;
                                    }
                                else
                                    drCat[ 8 ] = "";

                                drCat[ 9 ] = Convert.ToString( oRdP[ 9 ] ); // StationID

                                cls_Color.Color_Tender( CompNo, oRdP[ 10 ].ToString() ); // TenderColor
                                drCat[ 10 ] = cls_Color.Back;

                                dtSub.Rows.Add( drCat );
                                }
                            }
                        oRdP.Close();
                        }
                    }
                oRd.Close();

             //   InvoiceNoOfRec.Text = iTotal.ToString();
              //  InvoiceSelectedNo.Text = "0";

                }
            catch( SqlException ex )
                {
                MessageBox.Show( "Database error has occurred: " + ex.ToString() );
                //System.Diagnostics.Debug.WriteLine( ex.ToString() );
                }
            objDs.Tables.Add( dtMain );
            objDs.Tables.Add( dtSub );

            objDs.Relations.Add( "GL_SalesInv", objDs.Tables[ 0 ].Columns[ 2 ], objDs.Tables[ 1 ].Columns[ 1 ], false );

            return objDs;
            }
          #endregion   GL invoices