Ejemplo n.º 1
0
        private void load()
        {
            string sql = "SELECT [PKEY],[DEPARTMENT_ID],[TRADING_DATE],[BILL_NUMBER],[EXCHANGES_UNIT],[SUM_VALUE],[SUM_MONEY],";

            sql += "[MAKE_ORDER_STAFF],[STAFF_CHECK_ID],[ORDERR_REVIEW],[REVIEW_DATE],[IS_REVIEW],[STAFF_SAVE_ID],";
            sql += "[IS_RED_BILL],[IS_IN_LEDGER],[ORDERR_IN_LEDGER],[IN_LEDGER_DATE] ";
            sql += "FROM [dbo].[WAREHOUSE_MANAGEMENT_IN] ORDER BY PKEY";

            m_tableDataList.Clear();

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

                    record.pkey           = DbDataConvert.ToInt32(row["PKEY"]);
                    record.departmentID   = DbDataConvert.ToInt32(row["DEPARTMENT_ID"]);
                    record.departmentName = AuxiliaryMaterial.getInctance().getAuxiliaryMaterialNameFromPkey("BASE_DEPARTMENT_LIST", record.departmentID);
                    record.tradingDate    = DbDataConvert.ToDateTime(row["TRADING_DATE"]).ToString("yyyy-MM-dd");
                    record.billNumber     = DbDataConvert.ToString(row["BILL_NUMBER"]);
                    record.exchangesUnit  = DbDataConvert.ToString(row["EXCHANGES_UNIT"]);

                    record.sumValue = DbDataConvert.ToString(row["SUM_VALUE"]);
                    record.sumMoney = DbDataConvert.ToString(row["SUM_MONEY"]);

                    record.staffSaveId   = DbDataConvert.ToInt32(row["STAFF_SAVE_ID"]);
                    record.staffSaveName = Staff.getInctance().getStaffNameFromPkey(record.staffSaveId);

                    record.orderReviewStaffId   = DbDataConvert.ToInt32(row["STAFF_CHECK_ID"]);
                    record.orderReviewStaffName = Staff.getInctance().getStaffNameFromPkey(record.orderReviewStaffId);

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

                    record.isReview = DbDataConvert.ToString(row["IS_REVIEW"]);
                    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.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);
                }
            }
        }
Ejemplo n.º 2
0
        public MaterielInOrderTable getMaterielInOrderInfoFromBillNumber(string billNumber)
        {
            MaterielInOrderTable record = new MaterielInOrderTable();

            foreach (KeyValuePair <int, MaterielInOrderTable> index in m_tableDataList)
            {
                if (index.Value.billNumber == billNumber)
                {
                    record = index.Value;
                    break;
                }
            }

            return(record);
        }
Ejemplo n.º 3
0
        public bool checkBillIsExist(string billNumber)
        {
            bool isRet = false;

            foreach (KeyValuePair <int, MaterielInOrderTable> index in m_tableDataList)
            {
                MaterielInOrderTable record = new MaterielInOrderTable();

                if (index.Value.billNumber == billNumber)
                {
                    isRet = true;
                    break;
                }
            }

            return(isRet);
        }
Ejemplo n.º 4
0
        public SortedDictionary <int, MaterielInOrderTable> getAllNotReviewMaterielInOrderInfo()
        {
            SortedDictionary <int, MaterielInOrderTable> list = new SortedDictionary <int, MaterielInOrderTable>();

            foreach (KeyValuePair <int, MaterielInOrderTable> index in m_tableDataList)
            {
                MaterielInOrderTable record = new MaterielInOrderTable();
                record = index.Value;

                if (index.Value.isReview != "1")
                {
                    list.Add(list.Count, index.Value);
                }
            }

            return(list);
        }
Ejemplo n.º 5
0
        public void insert(MaterielInOrderTable record, bool isDisplayMessageBox = true)
        {
            bool isExistReview             = false;
            MaterielInOrderTable oldRecord = new MaterielInOrderTable();

            string insert = "INSERT INTO [dbo].[WAREHOUSE_MANAGEMENT_IN]([DEPARTMENT_ID],[TRADING_DATE],[BILL_NUMBER],";

            insert += "[EXCHANGES_UNIT],[SUM_VALUE],[SUM_MONEY],[MAKE_ORDER_STAFF],[STAFF_SAVE_ID],[STAFF_CHECK_ID],";
            insert += "[IS_RED_BILL],[IS_IN_LEDGER]";

            // 根据单据编号,判断库中是否已经存在该单据 如果存在单据首先删除单据,然后再执行插入操作
            if (checkBillIsExist(record.billNumber))
            {
                if (checkBillIsReview(record.billNumber))
                {
                    isExistReview = true;
                    insert       += ",[ORDERR_REVIEW], [REVIEW_DATE], [IS_REVIEW] ";
                    oldRecord     = getMaterielInOrderInfoFromBillNumber(record.billNumber);
                }

                delete(record.billNumber);
            }

            insert += ") VALUES(";

            insert += record.departmentID + ",";
            insert += "'" + record.tradingDate + "',";
            insert += "'" + record.billNumber + "',";
            insert += "'" + record.exchangesUnit + "',";
            insert += "'" + record.sumValue + "',";
            insert += "'" + record.sumMoney + "',";
            insert += record.makeOrderStaff + ",";
            insert += record.staffSaveId + ",";
            insert += record.orderReviewStaffId + ",";

            // 红字蓝字标示
            insert += record.isRedBill + ",0";

            // 如果单据已经审核过,把之前的审核信息写到该记录中
            if (isExistReview)
            {
                insert += ",";
                insert += oldRecord.orderrReview + ",";
                insert += "'" + oldRecord.reviewDate + "', 1";
            }

            insert += ")";

            try
            {
                DatabaseAccessFactoryInstance.Instance.ExecuteCommand(FormMain.DB_NAME, insert);

                if (isDisplayMessageBox)
                {
                    MessageBoxExtend.messageOK("数据保存成功");
                }

                load();
            }
            catch (Exception error)
            {
                MessageBoxExtend.messageWarning(error.Message);
                return;
            }

            writeOperatorLog(301, OperatorLogType.Add, record.billNumber);
        }