Exemplo n.º 1
0
        private void ImportWJFL_SF()
        {
            if (!IsValidToImportWJFL(this.lblImportWJFLPathSF.Text))
            {
                return;
            }
            var      filePath = this.lblImportWJFLPathSF.Text;
            DateTime asOfDate;
            var      result = ExcelHelper.GetImportDateFromWJFLSF(filePath, out asOfDate);

            if (!string.IsNullOrEmpty(result))
            {
                ShowError(result);
                return;
            }
            var importer = new ImporterSF();

            this.Cursor = Cursors.WaitCursor;
            try {
                var startTime = DateTime.Now;
                result      = importer.UpdateWJFL(asOfDate, filePath);
                this.Cursor = Cursors.Default;
                if (string.IsNullOrEmpty(result))
                {
                    var seconds  = Math.Round((DateTime.Now - startTime).TotalSeconds);
                    var timeSpan = seconds > 3 ? string.Format("({0}秒)", seconds) : "";
                    ShowInfo(string.Format("神府支行{0}数据的七级分类已经更新完毕。{1}", asOfDate.ToString("yyyy年M月d日"), timeSpan));
                }
                else
                {
                    ShowError("神府支行: " + result);
                }
            }
            catch (IOException ex) {
                if (ex.Message.IndexOf("it is being used by another process") > 0)
                {
                    ShowError("五级分类文件已经被打开,请先从Excel里关闭该报表然后再导入。");
                }
                else
                {
                    ShowError("请关闭所有excel,然后再尝试导出报表。");
                }
                logger.Error(ex);
            }
            catch (System.Data.SqlClient.SqlException ex) {
                logger.Error("Error in ImportWJFL_SF:\r\n", ex);
                ShowError("数据库访问发生错误,请确保数据库可以访问。");
            }
            catch (Exception ex) {
                ShowError("导入发生错误");
                logger.Error(ex);
            }
            finally {
                this.Cursor = Cursors.Default;
            }
        }
Exemplo n.º 2
0
        private void btnImport_Click(object sender, EventArgs e)
        {
            DateTime asOfDate;

            if (IsValidToImport(out asOfDate))
            {
                if (MessageBox.Show(string.Format("确定您导入的数据是{0}的吗?", asOfDate.ToString("yyyy-M-d")), this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                {
                    return;
                }

                string[] sourceFiles =
                {
                    "dummy",                       // 1-based array is required
                    string.Join("|",               importLoanFiles),
                    this.lblImportPublic.Text,     this.lblImportPrivate.Text,
                    this.lblImportNonAccrual.Text, this.lblImportOverdue.Text,
                    string.Join("|",               importYWNeiFiles),
                    string.Join("|",               importYWWaiFiles),
                    this.lblImportLoanSF.Text
                };
                var importer = new ImporterSF();
                this.Cursor = Cursors.WaitCursor;
                try {
                    var startTime = DateTime.Now;
                    var result    = importer.CreateImport(asOfDate, sourceFiles);
                    this.Cursor = Cursors.Default;
                    if (string.IsNullOrEmpty(result))
                    {
                        var seconds  = Math.Round((DateTime.Now - startTime).TotalSeconds);
                        var timeSpan = seconds > 3 ? string.Format("({0}秒)", seconds) : "";
                        ShowInfo(string.Format("{0}的数据导入完毕。{1}", asOfDate.ToString("yyyy年M月d日"), timeSpan));
                        logger.DebugFormat("Import done. {0} seconds costed.", seconds);
                        InitImportPanel();
                    }
                    else
                    {
                        ShowError(result);
                    }
                }
                catch (System.Data.SqlClient.SqlException ex) {
                    logger.Error("Error in btnImport_Click:\r\n", ex);
                    ShowError("数据库访问发生错误,请确保数据库可以访问。");
                }
                catch (Exception ex) {
                    ShowError("导入发生错误");
                    logger.Error(ex);
                }
                finally {
                    this.Cursor = Cursors.Default;
                }
            }
        }
Exemplo n.º 3
0
 private void ImportWJFL_SF()
 {
     if (!IsValidToImportWJFL(this.lblImportWJFLPathSF.Text)) {
         return;
     }
     var filePath = this.lblImportWJFLPathSF.Text;
     DateTime asOfDate;
     var result = ExcelHelper.GetImportDateFromWJFLSF(filePath, out asOfDate);
     if (!string.IsNullOrEmpty(result)) {
         ShowError(result);
         return;
     }
     var importer = new ImporterSF();
     this.Cursor = Cursors.WaitCursor;
     try {
         var startTime = DateTime.Now;
         result = importer.UpdateWJFL(asOfDate, filePath);
         this.Cursor = Cursors.Default;
         if (string.IsNullOrEmpty(result)) {
             var seconds = Math.Round((DateTime.Now - startTime).TotalSeconds);
             var timeSpan = seconds > 3 ? string.Format("({0}秒)", seconds) : "";
             ShowInfo(string.Format("神府支行{0}数据的七级分类已经更新完毕。{1}", asOfDate.ToString("yyyy年M月d日"), timeSpan));
         }
         else {
             ShowError("神府支行: " + result);
         }
     }
     catch (IOException ex) {
         if (ex.Message.IndexOf("it is being used by another process") > 0) {
             ShowError("五级分类文件已经被打开,请先从Excel里关闭该报表然后再导入。");
         }
         else {
             ShowError("请关闭所有excel,然后再尝试导出报表。");
         }
         logger.Error(ex);
     }
     catch (System.Data.SqlClient.SqlException ex) {
         logger.Error("Error in ImportWJFL_SF:\r\n", ex);
         ShowError("数据库访问发生错误,请确保数据库可以访问。");
     }
     catch (Exception ex) {
         ShowError("导入发生错误");
         logger.Error(ex);
     }
     finally {
         this.Cursor = Cursors.Default;
     }
 }
Exemplo n.º 4
0
        private void btnImport_Click(object sender, EventArgs e)
        {
            DateTime asOfDate;
            if (IsValidToImport(out asOfDate)) {
                if (MessageBox.Show(string.Format("确定您导入的数据是{0}的吗?", asOfDate.ToString("yyyy-M-d")), this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) {
                    return;
                }

                string[] sourceFiles = {
                        "dummy", // 1-based array is required
                        this.lblImportLoan.Text,
                        this.lblImportPublic.Text, this.lblImportPrivate.Text,
                        this.lblImportNonAccrual.Text, this.lblImportOverdue.Text,
                        string.Join("|", importYWNeiFiles),
                        string.Join("|", importYWWaiFiles),
                        this.lblImportLoanSF.Text
                    };
                var importer = new ImporterSF();
                this.Cursor = Cursors.WaitCursor;
                try {
                    var startTime = DateTime.Now;
                    var result = importer.CreateImport(asOfDate, sourceFiles);
                    this.Cursor = Cursors.Default;
                    if (string.IsNullOrEmpty(result)) {
                        var seconds = Math.Round((DateTime.Now - startTime).TotalSeconds);
                        var timeSpan = seconds > 3 ? string.Format("({0}秒)", seconds) : "";
                        ShowInfo(string.Format("{0}的数据导入完毕。{1}", asOfDate.ToString("yyyy年M月d日"), timeSpan));
                        logger.DebugFormat("Import done. {0} seconds costed.", seconds);
                        InitImportPanel();
                    }
                    else {
                        ShowError(result);
                    }
                }
                catch (System.Data.SqlClient.SqlException ex) {
                    logger.Error("Error in btnImport_Click:\r\n", ex);
                    ShowError("数据库访问发生错误,请确保数据库可以访问。");
                }
                catch (Exception ex) {
                    ShowError("导入发生错误");
                    logger.Error(ex);
                }
                finally {
                    this.Cursor = Cursors.Default;
                }
            }
        }