Example #1
0
        public W56090(string programID, string programName) : base(programID, programName)
        {
            InitializeComponent();
            dao56090  = new D56090();
            dtReadTxt = new DataTable();
            //設定資料欄位
            dtReadTxt.Columns.Add("FEETDCC_YM", typeof(string));
            dtReadTxt.Columns.Add("FEETDCC_FCM_NO", typeof(string));
            dtReadTxt.Columns.Add("FEETDCC_ACC_NO", typeof(string));
            dtReadTxt.Columns.Add("FEETDCC_KIND_ID", typeof(string));
            dtReadTxt.Columns.Add("FEETDCC_DISC_QNTY", typeof(int));
            dtReadTxt.Columns.Add("FEETDCC_DISC_RATE", typeof(string));
            dtReadTxt.Columns.Add("FEETDCC_ORG_AR", typeof(int));
            dtReadTxt.Columns.Add("FEETDCC_DISC_AMT", typeof(int));
            dtReadTxt.Columns.Add("FEETDCC_W_USER_ID", typeof(string));
            dtReadTxt.Columns.Add("FEETDCC_W_TIME", typeof(DateTime));
            dtReadTxt.Columns.Add("FEETDCC_SESSION", typeof(string));

            ImportShow.Hide();

            this.Text = _ProgramID + "─" + _ProgramName;

            gcMain.Hide();
            txtYM.Text = GlobalInfo.OCF_DATE.ToString("yyyy/MM");
        }
Example #2
0
        protected override ResultStatus Import()
        {
            base.Import(gcMain);

            //1.讀檔並寫入DataTable
            try {
                Stream openFile = PbFunc.wf_getfileopenname("56090.txt", "*.txt (*.txt)|*.txt");

                //選擇取消時, 不做處理
                if (openFile == null)
                {
                    return(ResultStatus.FailButNext);
                }

                ImportShow.Text = "開始轉檔...";
                ImportShow.Show();

                using (TextReader tr = new StreamReader(openFile)) {
                    string line;
                    while ((line = tr.ReadLine()) != null)
                    {
                        DataRow d         = dtReadTxt.NewRow();
                        float   DISC_RATE = float.Parse(line.SubStr(32, 9)) == 0 ? 0 :
                                            float.Parse(line.SubStr(32, 9)) / 100000000;
                        d[0]  = line.SubStr(0, 6);
                        d[1]  = line.SubStr(6, 7);
                        d[2]  = line.SubStr(13, 7);
                        d[3]  = line.SubStr(20, 4);
                        d[4]  = line.SubStr(24, 8);
                        d[5]  = DISC_RATE == 0 ? "0" : DISC_RATE.ToString("##.##");
                        d[6]  = line.SubStr(41, 10);
                        d[7]  = line.SubStr(51, 10);
                        d[8]  = GlobalInfo.USER_ID;
                        d[9]  = DateTime.Now;
                        d[10] = line.SubStr(61, 2);

                        dtReadTxt.Rows.Add(d);
                    }
                }

                //2.確認資料日期&畫面日期(讀取資料)
                string datadate = dtReadTxt.Rows[0][0].ToString();
                if (datadate != txtYM.Text.Replace("/", ""))
                {
                    DialogResult result = MessageBox.Show("資料年月(" + datadate + ")與畫面年月不同,是否將畫面改為資料年月?", "注意", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (result == DialogResult.No)
                    {
                        return(ResultStatus.Fail);
                    }
                    else
                    {
                        txtYM.Text = datadate.SubStr(0, 4) + "/" + datadate.SubStr(4, 2);
                    }
                }
                //3.刪除舊有資料
                if (dao56090.DeleteByYM(datadate) < 0)
                {
                    MessageDisplay.Error("刪除失敗");
                    return(ResultStatus.Fail);
                }
                //4.轉入資料即PB的wf_importfile()→wf_importfile_extra()
                if (Save(new PokeBall()) == ResultStatus.Success)
                {
                    ImportShow.Text = "轉檔完成!";
                    Retrieve();
                }
                else
                {
                    throw new Exception("轉檔失敗");
                }
            } catch (Exception ex) {
                throw ex;
            }
            return(ResultStatus.Success);
        }