Esempio n. 1
0
        public void fileImport(string filePath)
        {
            int rowIndex = 0;

            try
            {
                // 正式导入数据前,首先情况INIT_STORAGE_STOCK表数据
                DataTable dataTable = DatabaseAccessFactoryInstance.Instance.QueryDataTable(FormMain.DB_NAME, "DELETE FROM [dbo].[INIT_ACCOUNT_PAYABLE]");

                string sheetName = "应付账款初始数据";

                if (ExcelDocProc.getInstance().openFile(filePath))
                {
                    string supplierID, value, date;
                    for (rowIndex = 0; ; rowIndex++)
                    {
                        supplierID = ExcelDocProc.getInstance().getGridValue(sheetName, rowIndex, 0);
                        value      = ExcelDocProc.getInstance().getGridValue(sheetName, rowIndex, 1);
                        date       = ExcelDocProc.getInstance().getGridValue(sheetName, rowIndex, 2);

                        if (supplierID.Length == 0)
                        {
                            break;
                        }
                        else
                        {
                            InitAccountReceivableTable record = new InitAccountReceivableTable();
                            record.customerOrSupplierID = Convert.ToInt32(supplierID);
                            record.balance     = Convert.ToDouble(value);
                            record.tradingDate = date;

                            insert(record, false);
                        }
                    }

                    MessageBoxExtend.messageOK("应付账款初始数据导入成功");
                }
            }
            catch (Exception)
            {
                MessageBoxExtend.messageWarning("文件导入失败,[" + Convert.ToString(rowIndex) + "]行数据有误,请仔细核对");
                return;
            }
        }
Esempio n. 2
0
        public void fileImport(string filePath)
        {
            int rowIndex = 0;

            try
            {
                // 正式导入数据前,首先情况INIT_STORAGE_STOCK表数据
                DataTable dataTable = DatabaseAccessFactoryInstance.Instance.QueryDataTable(FormMain.DB_NAME, "DELETE FROM [dbo].[INIT_STORAGE_STOCK]");

                string sheetName = "存货初始数据";

                if (ExcelDocProc.getInstance().openFile(filePath))
                {
                    string materielID, value, price;
                    for (rowIndex = 0;; rowIndex++)
                    {
                        materielID = ExcelDocProc.getInstance().getGridValue(sheetName, rowIndex, 0);
                        price      = ExcelDocProc.getInstance().getGridValue(sheetName, rowIndex, 1);
                        value      = ExcelDocProc.getInstance().getGridValue(sheetName, rowIndex, 2);

                        if (materielID.Length == 0)
                        {
                            break;
                        }
                        else
                        {
                            InitMaterielTable record = new InitMaterielTable();
                            record.materielID = Convert.ToInt32(materielID.ToString());
                            record.value      = Convert.ToInt32(value.ToString());
                            record.price      = Convert.ToDouble(price.ToString());

                            insert(record, false);
                        }
                    }

                    MessageBoxExtend.messageOK("存货初始数据导入成功");
                }
            }
            catch (Exception)
            {
                MessageBoxExtend.messageWarning("文件导入失败,[" + Convert.ToString(rowIndex) + "]行数据有误,请仔细核对");
                return;
            }
        }