Example #1
0
        private void load()
        {
            string sql = "SELECT [PKEY],[SUPPLIER_ID],[TRADING_DATE],[BILL_NUMBER],[CONTRACT_NUM],[PURCHASE_TYPE],[PAYMENT_DATE],";

            sql += "[EXCHANGES_UNIT],[BUSINESS_PEOPLE_ID],[SUM_VALUE],[SUM_MONEY],[SUM_TRANSPORTATION_COST],[SUM_OTHER_COST],";
            sql += "[TOTAL_MONEY], [MAKE_ORDER_STAFF],[ORDERR_REVIEW],[REVIEW_DATE],[IS_REVIEW],";
            sql += "[SOURCE_BILL_TYPE], [SOURCE_BILL_NUMBER],[STAFF_SAVE_ID],[STAFF_CHECK_ID],[PAYMENT_OK],[PAYMENT_NO_OK],";
            sql += "[IS_RED_BILL],[IS_IN_LEDGER],[ORDERR_IN_LEDGER],[IN_LEDGER_DATE] ";
            sql += "FROM [dbo].[PURCHASE_IN_ORDER] ORDER BY PKEY DESC";

            m_tableDataList.Clear();

            using (DataTable dataTable = DatabaseAccessFactoryInstance.Instance.QueryDataTable(FormMain.DB_NAME, sql))
            {
                foreach (DataRow row in dataTable.Rows)
                {
                    PurchaseInOrderTable record = new PurchaseInOrderTable();

                    record.pkey          = DbDataConvert.ToInt32(row["PKEY"]);
                    record.supplierId    = DbDataConvert.ToInt32(row["SUPPLIER_ID"]);
                    record.supplierName  = Supplier.getInctance().getSupplierNameFromPkey(record.supplierId);
                    record.tradingDate   = DbDataConvert.ToDateTime(row["TRADING_DATE"]).ToString("yyyy-MM-dd");
                    record.billNumber    = DbDataConvert.ToString(row["BILL_NUMBER"]);
                    record.contractNum   = DbDataConvert.ToString(row["CONTRACT_NUM"]);
                    record.purchaseType  = DbDataConvert.ToString(row["PURCHASE_TYPE"]);
                    record.paymentDate   = DbDataConvert.ToDateTime(row["PAYMENT_DATE"]).ToString("yyyy-MM-dd");
                    record.exchangesUnit = DbDataConvert.ToString(row["EXCHANGES_UNIT"]);

                    record.businessPeopleId   = DbDataConvert.ToInt32(row["BUSINESS_PEOPLE_ID"]);
                    record.businessPeopleName = Staff.getInctance().getStaffNameFromPkey(record.businessPeopleId);
                    record.makeOrderStaff     = DbDataConvert.ToInt32(row["MAKE_ORDER_STAFF"]);
                    record.makeOrderStaffName = Staff.getInctance().getStaffNameFromPkey(record.makeOrderStaff);

                    if (DbDataConvert.ToString(row["ORDERR_REVIEW"]).Length > 0)
                    {
                        record.orderrReview     = DbDataConvert.ToInt32(row["ORDERR_REVIEW"]);
                        record.orderrReviewName = Staff.getInctance().getStaffNameFromPkey(record.orderrReview);
                        record.reviewDate       = DbDataConvert.ToDateTime(row["REVIEW_DATE"]).ToString("yyyy-MM-dd");
                    }

                    record.isReview = DbDataConvert.ToString(row["IS_REVIEW"]);

                    record.sumValue = DbDataConvert.ToString(row["SUM_VALUE"]);
                    record.sumMoney = DbDataConvert.ToString(row["SUM_MONEY"]);
                    record.sumTransportationCost = DbDataConvert.ToString(row["SUM_TRANSPORTATION_COST"]);
                    record.sumOtherCost          = DbDataConvert.ToString(row["SUM_OTHER_COST"]);
                    record.totalMoney            = DbDataConvert.ToString(row["TOTAL_MONEY"]);

                    // 采购入库单比采购订单中多出的字段
                    record.sourceBillType   = DbDataConvert.ToString(row["SOURCE_BILL_TYPE"]);
                    record.sourceBillNumber = DbDataConvert.ToString(row["SOURCE_BILL_NUMBER"]);
                    record.staffSaveId      = DbDataConvert.ToInt32(row["STAFF_SAVE_ID"]);
                    record.staffSaveName    = Staff.getInctance().getStaffNameFromPkey(record.staffSaveId);
                    record.staffCheckId     = DbDataConvert.ToInt32(row["STAFF_CHECK_ID"]);
                    record.staffCheckName   = Staff.getInctance().getStaffNameFromPkey(record.staffCheckId);

                    // 已还款金额和未还款金额
                    record.paymentOk   = DbDataConvert.ToString(row["PAYMENT_OK"]);
                    record.paymentNoOk = DbDataConvert.ToString(row["PAYMENT_NO_OK"]);

                    // 红字蓝字标示和是否入账标记
                    record.isRedBill = DbDataConvert.ToInt32(row["IS_RED_BILL"]);

                    // 记账相关信息
                    if (DbDataConvert.ToString(row["ORDERR_IN_LEDGER"]).Length > 0)
                    {
                        record.orderInLedger     = DbDataConvert.ToInt32(row["ORDERR_IN_LEDGER"]);
                        record.orderInLedgerName = Staff.getInctance().getStaffNameFromPkey(record.orderInLedger);
                        record.inLedgerDate      = DbDataConvert.ToDateTime(row["IN_LEDGER_DATE"]).ToString("yyyy-MM-dd");
                    }
                    record.isInLedger = DbDataConvert.ToInt32(row["IS_IN_LEDGER"]);

                    m_tableDataList.Add(m_tableDataList.Count, record);
                }
            }
        }