Ejemplo n.º 1
0
        protected override ResultStatus Export()
        {
            if (txtStartDate.DateTimeValue > txtEndDate.DateTimeValue)
            {
                MessageDisplay.Error("起始日期不得大於結束日期!");
                return(ResultStatus.Fail);
            }

            ExportShow.Text = "轉檔中...";
            ExportShow.Show();

            try
            {
                base.Export();

                string excelDestinationPath = PbFunc.wf_copy_file(_ProgramID, _ProgramID); //CopyExcelTemplateFile(_ProgramID, FileType.XLS);

                return(ManipulateExcel(excelDestinationPath));
            }
            catch (Exception ex)
            {
                ExportShow.Text = "轉檔失敗";
                WriteLog(ex);
                return(ResultStatus.Fail);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// TextEdit驗證DateTime格式
        /// </summary>
        /// <param name="textEdit"></param>
        /// <param name="inputText"></param>
        /// <param name="errorText"></param>
        /// <returns></returns>
        public static bool IsDate(this DevExpress.XtraEditors.TextEdit textEdit, string inputText, string errorText)
        {
            DateTime dateTime;

            string[] YMD            = inputText.Split('/');
            string   formatInputTxt = inputText;

            switch (YMD.Length)
            {
            case 1:
                formatInputTxt = $"{YMD[0].PadLeft(4, '0')}/01/01";
                //textEdit.Text = year;
                break;

            case 2:
                formatInputTxt = $"{YMD[0].PadLeft(4, '0')}/{YMD[1].PadLeft(2, '0')}/01";
                //textEdit.Text = $"{year}/{month}";
                break;

            case 3:
                formatInputTxt = $"{YMD[0].PadLeft(4, '0')}/{YMD[1].PadLeft(2, '0')}/{YMD[2].PadLeft(2, '0')}";
                //textEdit.Text = $"{year}/{month}/{date}";
                break;
            }

            if (!DateTime.TryParse(formatInputTxt, out dateTime))
            {
                MessageDisplay.Error(errorText, GlobalInfo.ErrorText);
                textEdit.Focus();
                return(false);
            }
            return(true);
        }
Ejemplo n.º 3
0
        protected override ResultStatus Retrieve()
        {
            try {
                dao41010 = new D41010();
                string prodType, kindId;
                prodType = rdgProdType.EditValue.AsString();
                kindId   = txtProd.Text.Trim();
                if (kindId.IndexOf("%") == -1)
                {
                    kindId = kindId + "%";
                }
                if (kindId == "")
                {
                    kindId = "%";
                }

                //讀取資料
                DataTable dt41010 = dao41010.d_41010(prodType, txtSDate.DateTimeValue, txtEDate.DateTimeValue, kindId);
                gcMain.DataSource = dt41010;
                DataTable dt41010e = dao41010.d_41010e(prodType, txtSDate.DateTimeValue, txtEDate.DateTimeValue, kindId);
                gcMainE.DataSource = dt41010e;
                //自動調整欄寬
                gvMain.BestFitColumns();
                gvMainE.BestFitColumns();
            }
            catch (Exception ex) {
                MessageDisplay.Error("讀取錯誤");
                throw ex;
            }
            return(ResultStatus.Success);
        }
Ejemplo n.º 4
0
        protected override ResultStatus Save(PokeBall pokeBall)
        {
            try
            {
                ResultStatus myCheckResult = CheckShield();
                if (myCheckResult != ResultStatus.Success)
                {
                    return(myCheckResult);
                }
                if (myCheckResult == ResultStatus.Success)
                {
                    base.Save(gcMain);

                    DataTable dt = (DataTable)gcMain.DataSource;
                    dtForAdd = dt.GetChanges(DataRowState.Added);
                    DataTable dtForModified = dt.GetChanges(DataRowState.Modified);
                    DataTable dtForDeleted  = dt.GetChanges(DataRowState.Deleted);


                    ResultData myResultData = daoUPF.Update(dt);

                    DataTable dtTemp = new DataTable();
                    //若刪除user ,一併刪除相關權限
                    if (dtForDeleted != null)
                    {
                        dtTemp = dtForDeleted.Clone();

                        int rowIndex = 0;
                        foreach (DataRow dr in dtForDeleted.Rows)
                        {
                            DataRow drNewDelete = dtTemp.NewRow();
                            for (int colIndex = 0; colIndex < dtForDeleted.Columns.Count; colIndex++)
                            {
                                drNewDelete[colIndex] = dr[colIndex, DataRowVersion.Original];
                            }
                            dtTemp.Rows.Add(drNewDelete);
                            rowIndex++;
                        }

                        foreach (DataRow row in dtTemp.Rows)
                        {
                            string userId = row["UPF_USER_ID"].AsString();
                            bool   result = daoUTP.DeleteUTPByUserId(userId);
                        }
                    }

                    //列印
                    PrintOrExport(gcMain, dtForAdd, dtTemp, dtForModified);

                    _IsPreventFlowPrint  = true;
                    _IsPreventFlowExport = true;
                }
            }
            catch (Exception ex)
            {
                MessageDisplay.Error(ex.Message);
                throw;
            }
            return(ResultStatus.Success);
        }
Ejemplo n.º 5
0
        private bool StartExport()
        {
            if (!emStartMth.IsDate(emStartMth.Text + "/01", CheckDate.Start))
            {
                //is_chk = "Y";
                return(false);
            }
            if (!emEndMth.IsDate(emEndMth.Text + "/01", CheckDate.End))
            {
                //is_chk = "Y";
                return(false);
            }
            if (emStartMth.Text.SubStr(0, 4) != emEndMth.Text.SubStr(0, 4))
            {
                MessageDisplay.Error("不可跨年度查詢!");
                emStartMth.Focus();
                return(false);
            }

            /*******************
            *  Messagebox
            *******************/
            stMsgtxt.Visible = true;
            stMsgtxt.Text    = "開始轉檔...";
            this.Cursor      = Cursors.WaitCursor;
            this.Refresh();
            Thread.Sleep(5);
            return(true);
        }
Ejemplo n.º 6
0
        protected bool IsDataModify(Object grid)
        {
            DataTable dt = null;

            if (grid is GridControl)
            {
                GridControl gridControl = ((GridControl)grid);
                gridControl.MainView.CloseEditor();
                gridControl.MainView.UpdateCurrentRow();
                dt = (DataTable)gridControl.DataSource;
            }
            else if (grid is VGridControl)
            {
                VGridControl gridControl = ((VGridControl)grid);
                gridControl.CloseEditor();
                gridControl.UpdateFocusedRecord();
                dt = (DataTable)gridControl.DataSource;
            }

            if (dt == null || dt.GetChanges() == null || dt.GetChanges().Rows.Count == 0)
            {
                MessageDisplay.Error(MessageDisplay.MSG_NO_DATA_FOR_MODIFY);
                return(false);
            }

            return(true);
        }
Ejemplo n.º 7
0
        private void recentFilesCountTextBox_Validating(object sender, System.ComponentModel.CancelEventArgs e)
        {
            if (recentFilesCountTextBox.Text.Length == 0)
            {
                recentFilesCountTextBox.Text = Settings.Gui.RecentProjects.MaxFiles.ToString();
                recentFilesCountTextBox.SelectAll();
                e.Cancel = true;
            }
            else
            {
                string errmsg = null;

                try
                {
                    int count = int.Parse(recentFilesCountTextBox.Text);

                    if (count < 0 || count > 24)
                    {
                        errmsg = string.Format("Number of files must be from 0 to 24");
                    }
                }
                catch
                {
                    errmsg = "Number of files must be numeric";
                }

                if (errmsg != null)
                {
                    recentFilesCountTextBox.SelectAll();
                    MessageDisplay.Error(errmsg);
                    e.Cancel = true;
                }
            }
        }
Ejemplo n.º 8
0
        protected virtual ResultData ExecuteForm(PokeBall args)
        {
            ResultData resultData    = new ResultData();
            var        dllIndividual = Assembly.LoadFile(Application.ExecutablePath);
            string     typeFormat    = "{0}.FormUI.Prefix{1}.W{2}";
            string     txnId         = args.TXF_TID.Substring(2, 5);
            Type       myType        = dllIndividual.GetType(string.Format(typeFormat, Path.GetFileNameWithoutExtension(Application.ExecutablePath), txnId.Substring(0, 1), txnId));

            if (myType == null)
            {
                MessageDisplay.Error("無此程式");
            }

            object myObj = Activator.CreateInstance(myType, txnId, args.TXF_TID_NAME);

            FormParent formInstance = (FormParent)myObj;


            if (formInstance.BeforeOpen() == ResultStatus.Success)
            {
                formInstance.MdiParent     = this.MdiParent;
                formInstance.StartPosition = FormStartPosition.Manual;
                formInstance.WindowState   = FormWindowState.Maximized;
                formInstance.Show();
            }
            formInstance.IsPreventFlowExportAfter = true;
            ExecuteFormBefore(formInstance, args);
            resultData.Status = formInstance.ProcessExport();
            formInstance.Close();

            return(resultData);
        }
Ejemplo n.º 9
0
        private string wf_set_valid_date(int ai_row)
        {
            string osw_grp = gvMain.GetRowCellValue(ai_row, "OSW_GRP").AsString();

            if (gvMain.GetRowCellValue(ai_row, "SP2_ADJ_CODE").AsString() == "Y")
            {
                if (osw_grp == "1")
                {
                    if (txtDate1.Text == "1901/01/01")
                    {
                        MessageDisplay.Error("請先輸入" + labG1.Text, GlobalInfo.ErrorText);
                        return("N");
                    }
                    gvMain.SetRowCellValue(ai_row, "ISSUE_BEGIN_YMD", txtDate1.DateTimeValue.ToString("yyyyMMdd"));
                }
                if (osw_grp == "5")
                {
                    if (txtDate2.Text == "1901/01/01")
                    {
                        MessageDisplay.Error("請先輸入" + labG2.Text, GlobalInfo.ErrorText);
                        return("N");
                    }
                    gvMain.SetRowCellValue(ai_row, "ISSUE_BEGIN_YMD", txtDate2.DateTimeValue.ToString("yyyyMMdd"));
                }
            }
            else
            {
                if (gvMain.GetRowCellValue(ai_row, "ISSUE_BEGIN_YMD").AsString() != null)
                {
                    gvMain.SetRowCellValue(ai_row, "ISSUE_BEGIN_YMD", nullYmd);
                }
            }
            return("");
        }
Ejemplo n.º 10
0
 /// <summary>
 /// Lukas, 將CSV文件的數據讀取到DataTable中
 /// </summary>
 /// <param name="filePath">CSV文件路徑</param>
 /// <param name="dt">指定欄位的DataTable</param>
 /// <param name="encoding">CSV編碼格式</param>
 /// <returns></returns>
 private DataTable OpenCSV(string filePath, DataTable dt, Encoding encoding)
 {
     try {
         var csv = File.ReadAllText(filePath, encoding);
         foreach (var line in CsvReader.ParseLines(csv))
         {
             string newLine = line;
             if (line.SubStr(line.Length - 1, 1) == ",")
             {
                 newLine = line.Remove(line.Length - 1, 1);
             }
             string[] strArray    = CsvReader.ParseFields(newLine).ToArray();
             int      columnCount = strArray.Length;
             DataRow  dr          = dt.NewRow();
             for (int j = 0; j < columnCount; j++)
             {
                 dr[j] = strArray[j].Replace("\"", "");
             }
             dt.Rows.Add(dr);
         }
         return(dt);
     } catch (Exception ex) {
         WriteLog(ex, "", false);
         MessageDisplay.Error("請先關閉欲匯入之csv檔再執行匯入動作!", GlobalInfo.ErrorText);
         return(null);
     }
 }
Ejemplo n.º 11
0
        /// <summary>
        /// 比對條件,刪除不符合的資料行(linq平行處理)
        /// </summary>
        /// <param name="FilterDt"></param>
        /// <param name="CompareDt"></param>
        /// <returns></returns>
        public DataTable FilterDataByParallel(DataTable FilterDt, DataTable CompareDt)
        {
            int       useCpuCount = Environment.ProcessorCount > 3 ? 2 : 1;//限制cpu使用數目
            bool      found = false;
            DataTable dt = FilterDt;
            string    brkNo2 = "", prodID2 = "";

            for (int k = 0; k < dt.Rows.Count; k++)
            {
                DataRow dr = dt.Rows[k];
                if (brkNo2 != dr["AMM0_BRK_NO"].AsString() || prodID2 != dr["AMM0_PROD_ID"].AsString())
                {
                    brkNo2  = dr["AMM0_BRK_NO"].AsString();
                    prodID2 = dr["AMM0_PROD_ID"].AsString();
                    try {
                        //found = ids.Select($@"AMM0_BRK_NO='{dr["AMM0_BRK_NO"]}' and AMM0_PROD_ID='{dr["AMM0_PROD_ID"]}'").Any();
                        found = CompareDt.AsEnumerable().AsParallel().WithDegreeOfParallelism(useCpuCount).Where(r => r.Field <object>("AMM0_BRK_NO").AsString() == brkNo2 && r.Field <object>("AMM0_PROD_ID").AsString() == prodID2).Any();
                    }
                    catch (Exception ex) {
#if DEBUG
                        MessageDisplay.Error($"第{k}筆資料:{ex.Message}", "FilterDataByParallel");
#endif
                    }
                }
                if (!found)
                {
                    FilterDt.Rows.RemoveAt(k);
                    k = k - 1;
                }
                Thread.Sleep(0);
            }//for (int k = 0; k < dt.Rows.Count; k++)

            return(FilterDt.AddSeriNumToDataTable());
        }
Ejemplo n.º 12
0
        public ResultStatus ExecuteFile(string param, string fileName)
        {
            try
            {
                //取得網路磁碟機路徑、帳密
                DataTable dtInfo     = daoTXFP.GetPathAccPwd("file", param);
                string    userId     = dtInfo.Rows[0]["ls_user"].AsString();
                string    pwd        = dtInfo.Rows[0]["ls_pwd"].AsString();
                string    targetPath = dtInfo.Rows[0]["is_path"].AsString();
                pwd = PbFunc.f_decode(pwd);

                string txtPath = Path.Combine(GlobalInfo.DEFAULT_REPORT_DIRECTORY_PATH, fileName.Replace("\\", ""));

                //執行f_netdragon
                int li_rtn = Go("N", userId, pwd, txtPath, targetPath + "\\" + fileName, "Y");
                if (li_rtn != 1)
                {
                    MessageDisplay.Error($"執行 {_ProgramID} 傳送檔案{fileName}失敗!", GlobalInfo.ErrorText);
                    return(ResultStatus.Fail);
                }
            }
            catch (Exception ex)
            {
                WriteLog(ex);
                return(ResultStatus.Fail);
            }

            return(ResultStatus.Success);
        }
Ejemplo n.º 13
0
        /// <summary>
        /// 搜尋指定的副檔名並設定儲存路徑
        /// </summary>
        /// <param name="is_txn_id"></param>
        /// <param name="as_filename"></param>
        /// <returns></returns>
        public static string wf_copyfile(string is_txn_id, string as_filename)
        {
            string ls_excel_name, ls_excel_ext, ls_excel_path, ls_sub_path, ls_rename;

            ls_excel_path = gs_excel_path;
            ls_excel_name = as_filename;
            ls_excel_ext  = ".xls";
            //讀取ci.RPTX設定檔
            DataTable dtRPTX = new RPTX().ListByTxn(is_txn_id, as_filename);

            ls_sub_path  = dtRPTX.Rows[0]["RPTX_SUBPATH"].AsString();
            ls_excel_ext = dtRPTX.Rows[0]["RPTX_FILENAME_EXT"].AsString();
            ls_rename    = dtRPTX.Rows[0]["RPTX_RENAME"].AsString();
            if (ls_sub_path != ".")
            {
                ls_excel_path = ls_excel_path + ls_sub_path;
            }
            if (!File.Exists(Path.Combine(ls_excel_path, ls_excel_name + ls_excel_ext)))
            {
                MessageDisplay.Error("無此檔案「" + Path.Combine(ls_excel_path, ls_excel_name + ls_excel_ext) + "」!");
            }

            string originalFilePath = Path.Combine(gs_excel_path, as_filename + ls_excel_ext);

            string destinationFilePath = Path.Combine(gs_savereport_path, as_filename + "_" + DateTime.Now.ToString("yyyy.MM.dd") + "-" + DateTime.Now.ToString("hh.mm.ss") + ls_excel_ext);

            File.Copy(originalFilePath, destinationFilePath, true);
            if (!File.Exists(destinationFilePath))
            {
                MessageDisplay.Error("複製「" + ls_excel_path + ls_excel_name + ls_excel_ext + "」到「" + destinationFilePath + "」檔案錯誤!");
            }
            return(destinationFilePath);
        }
Ejemplo n.º 14
0
        protected override ResultStatus Export()
        {
            try {
                this.Cursor = Cursors.WaitCursor;
                this.Refresh();
                Thread.Sleep(5);
                lblProcessing.Visible = true;
                ShowMsg("開始轉檔...");
                dao30100 = new D30100();

                string   rptId, file, rptName;
                DateTime sYmd = txtSDate.DateTimeValue;
                DateTime eYmd = txtEDate.DateTimeValue;
                int      rowNum;
                rptId   = "30100";
                rptName = "Kill Switch使用紀錄查詢";
                ShowMsg(rptId + "-" + rptName + " 轉檔中...");

                //讀取資料
                DataTable dt30100 = dao30100.d_30100(sYmd, eYmd,
                                                     dwFcmKs.EditValue.AsString() + "%", dwFcmIn.EditValue.AsString() + "%",
                                                     rdgMarketCode.EditValue.AsString());
                if (dt30100.Rows.Count == 0)
                {
                    MessageDisplay.Info(txtSDate.Text + "~" + txtEDate.Text + "," + rptId + '-' + rptName + ",無任何資料!");
                    lblProcessing.Visible = false;
                    return(ResultStatus.Fail);
                }

                //複製檔案
                file = PbFunc.wf_copy_file(rptId, rptId);
                if (file == "")
                {
                    return(ResultStatus.Fail);
                }

                //開啟檔案
                Workbook workbook = new Workbook();
                workbook.LoadDocument(file);

                //切換Sheet
                Worksheet ws30100 = workbook.Worksheets[0];
                //身份碼總列數隱藏於A2
                rowNum = 1;
                ws30100.Import(dt30100, false, rowNum, 0);

                //存檔
                ws30100.ScrollToRow(0);
                workbook.SaveDocument(file);
                lblProcessing.Text = "轉檔成功";
            } catch (Exception ex) {
                MessageDisplay.Error("輸出錯誤");
                throw ex;
            } finally {
                this.Cursor = Cursors.Arrow;
                this.Refresh();
                Thread.Sleep(5);
            }
            return(ResultStatus.Success);
        }
Ejemplo n.º 15
0
        public ResultData CheckLogin(string id, string password)
        {
            ResultData result = new ResultData();
            UPF        daoUPF = new UPF();
            DataTable  dtUPF  = daoUPF.ListDataByUserId(id);

            result.ReturnData = dtUPF;

            if (dtUPF.Rows.Count != 0)
            {
                if (password == dtUPF.Rows[0]["UPF_PASSWORD"].ToString().Trim())
                {
                    result.Status = ResultStatus.Success;
                }
                else
                {
                    MessageDisplay.Error("密碼錯誤");
                    result.Status = ResultStatus.Fail;
                }
            }
            else
            {
                MessageDisplay.Error("無此帳號");
                result.Status = ResultStatus.Fail;
            }
            return(result);
        }
Ejemplo n.º 16
0
        private void SearchControl1_KeyDown(object sender, KeyEventArgs e)
        {
            string txnID = "";

            if (e.KeyCode == Keys.Enter)
            {
                txnID = ((SearchControl)sender).EditValue.ToString();

                if (string.IsNullOrEmpty(txnID))
                {
                    MessageDisplay.Error("請輸入文字 !");
                    return;
                }

                var itemList = accordionMenu.Elements.Where(x => x.Tag.ToString().ToUpper() == txnID.Substring(0, 1).ToUpper()).FirstOrDefault();

                if (itemList == null)
                {
                    MessageDisplay.Error("無此程式");
                    return;
                }
                var item = itemList;
                item = null; //預設為空
                             //分兩個階層找尋
                foreach (var ele in itemList.Elements)
                {
                    if (((ItemData)ele.Elements.Element.Tag).TXN_ID.ToUpper() == txnID.ToUpper())
                    {
                        item = ele;
                    }
                    else
                    {
                        foreach (var subEle in ele.Elements)
                        {
                            if (((ItemData)subEle.Elements.Element.Tag).TXN_ID.ToUpper() == txnID.ToUpper())
                            {
                                item = subEle;
                            }
                        }
                    }
                }
                //var item = itemList.Elements.Where(x => ((ItemData)x.Tag).TXN_ID.ToUpper() == txnID.ToUpper()).FirstOrDefault();

                if (item == null)
                {
                    MessageDisplay.Error("無此程式");
                    return;
                }
                else
                {
                    accordionMenu.SelectedElement = item;
                    accordionMenu.KeyNavHelperEx.SelectedElement = item;
                    accordionMenu.ExpandElement(item);
                    accordionMenu.MakeElementVisible(accordionMenu.SelectedElement);

                    ItemData itemData = ((ItemData)item.Tag);
                    OpenForm(itemData.TXN_ID, itemData.TXN_NAME);
                }
            }
        }
Ejemplo n.º 17
0
        protected override ResultStatus Save(PokeBall pokeBall)
        {
            try
            {
                ResultStatus myCheckResult = CheckShield();
                if (myCheckResult != ResultStatus.Success)
                {
                    return(myCheckResult);
                }
                if (myCheckResult == ResultStatus.Success)
                {
                    base.Save(gcMain);
                    DataTable dt = (DataTable)gcMain.DataSource;

                    ResultData result = new RPTF().UpdateData(dt.GetChanges());

                    _IsPreventFlowPrint  = true;
                    _IsPreventFlowExport = true;
                }
            }
            catch (Exception ex)
            {
                MessageDisplay.Error(ex.Message);
                throw;
            }
            return(ResultStatus.Success);
        }
Ejemplo n.º 18
0
        /// <summary>
        /// 發生錯誤時,寫log to db (logType=Error) 順便截圖和顯示錯誤訊息
        /// </summary>
        /// <param name="ex">最後儲存的長度為100字元</param>
        /// <param name="extraMsg">額外的資訊,顯示在最前面</param>
        /// <param name="showMsg">true=顯示錯誤訊息,false=不顯示</param>
        public void WriteLog(Exception ex, string extraMsg = "", bool showMsg = true)
        {
            //1.一旦發生非預期的Error(有產生Exception),截取目前畫面並儲存在local端的log/yyyyMM
            SaveErrorScreenshot();

            //2.write log to db
            string logType = "Error";

            WriteLog(extraMsg + Environment.NewLine + ex.ToString(), logType, "Z", false);//ken,如果要發送訊息,在本身的函數內處理,比較詳盡

            //3.show message to UI
            if (showMsg)
            {
                string     tmp  = "";
                MethodBase site = ex.TargetSite;
                tmp  = "發生錯誤";
                tmp += (extraMsg == "" ? "" : "(" + extraMsg + ")");
                tmp += (site == null ? "" : Environment.NewLine + "Error Function=" + site.Name);
                if (FlagAdmin)
                {
                    tmp += Environment.NewLine + ex.ToString().SubStr(0, 1000);//Msg太多字數不好,要看詳細直接去檔案看
                }
                MessageDisplay.Error(tmp);
            }//if (showMsg) {
        }
Ejemplo n.º 19
0
        protected override ResultStatus Save(PokeBall pokeBall)
        {
            try {
                base.Save(gcMain);

                DataTable dt       = (DataTable)gcMain.DataSource;
                DataTable dtChange = dt.GetChanges();

                if (dtChange == null)
                {
                    MessageBox.Show("沒有變更資料,不需要存檔!", "注意", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return(ResultStatus.Fail);
                }
                if (dtChange.Rows.Count == 0)
                {
                    MessageBox.Show("沒有變更資料,不需要存檔!", "注意", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return(ResultStatus.Fail);
                }
                //更新主要Table
                else
                {
                    ResultData myResultData = daoAA1.updateAA1(dt);
                }
                //不要自動列印
                _IsPreventFlowPrint = true;
            }
            catch (Exception ex) {
                MessageDisplay.Error("儲存錯誤");
                throw ex;
            }
            return(ResultStatus.Success);
        }
Ejemplo n.º 20
0
        protected override ResultStatus Save(PokeBall pokeBall)
        {
            try {
                DataTable dt       = (DataTable)gcMain.DataSource;
                DataTable dtChange = dt.GetChanges();

                if (dtChange == null)
                {
                    MessageBox.Show("沒有變更資料,不需要存檔!", "注意", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return(ResultStatus.Fail);
                }
                if (dtChange.Rows.Count == 0)
                {
                    MessageBox.Show("沒有變更資料,不需要存檔!", "注意", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return(ResultStatus.Fail);
                }

                DataTable dtForAdd = dt.GetChanges(DataRowState.Added);
                if (dtForAdd != null)
                {
                    //檢查重複key值
                    if (!checkDuplicate(dt.GetChanges(DataRowState.Added)))
                    {
                        return(ResultStatus.FailButNext);
                    }
                }

                //更新主要Table
                foreach (DataRow dr in dtChange.Rows)
                {
                    if (dr.RowState == DataRowState.Added || dr.RowState == DataRowState.Modified)
                    {
                        if (string.IsNullOrEmpty(dr["PLT1_QNTY_MIN"].AsString()) || string.IsNullOrEmpty(dr["PLT1_QNTY_MAX"].AsString()) ||
                            string.IsNullOrEmpty(dr["PLT1_MULTIPLE"].AsString()))
                        {
                            MessageDisplay.Info("資料尚未填寫完成!");
                            return(ResultStatus.FailButNext);
                        }
                        else
                        {
                            ResultData myResultData = dao20220.updatePLT1(dt);
                            if (myResultData.Status == ResultStatus.Fail)
                            {
                                return(ResultStatus.Fail);
                            }
                            else
                            {
                                _IsPreventFlowPrint = false; //若有update成功才會跳列印PDF視窗
                            }
                        }
                    }
                }
            } catch (Exception ex) {
                MessageDisplay.Error("存檔失敗");
                WriteLog(ex);
                return(ResultStatus.FailButNext);
            }
            return(ResultStatus.Success);
        }
Ejemplo n.º 21
0
        protected override ResultStatus Retrieve()
        {
            try {
                #region 輸入&日期檢核
                if (string.Compare(txtStartDate.Text, txtEndDate.Text) > 0)
                {
                    MessageDisplay.Error(CheckDate.Datedif, GlobalInfo.ErrorText);
                    return(ResultStatus.Fail);
                }
                #endregion

                DataTable dt = new MG8().ListData(StartDate, EndDate);
                if (dt.Rows.Count <= 0)
                {
                    MessageDisplay.Info(MessageDisplay.MSG_NO_DATA, GlobalInfo.ResultText);
                }
                else
                {
                    retDt = dt.Clone();
                    foreach (DataRow r in dt.Rows)
                    {
                        retDt.ImportRow(r);
                    }

                    //設定grid裡的 date format
                    RepositoryItemTextEdit effectYmd = new RepositoryItemTextEdit();
                    effectYmd.Mask.MaskType = DevExpress.XtraEditors.Mask.MaskType.RegEx;
                    effectYmd.Mask.EditMask = "[0-9]{4}/(((0[13578]|(10|12))/(0[1-9]|[1-2][0-9]|3[0-1]))|(02/(0[1-9]|[1-2][0-9]))|((0[469]|11)/(0[1-9]|[1-2][0-9]|30)))";
                    effectYmd.Mask.UseMaskAsDisplayFormat = true;

                    gcMain.RepositoryItems.Add(effectYmd);
                    gvMain.Columns["MG8_EFFECT_YMD"].ColumnEdit = effectYmd;

                    RepositoryItemTextEdit issueYmd = new RepositoryItemTextEdit();
                    issueYmd.Mask.MaskType = DevExpress.XtraEditors.Mask.MaskType.RegEx;
                    issueYmd.Mask.EditMask = "[0-9]{4}/(((0[13578]|(10|12))/(0[1-9]|[1-2][0-9]|3[0-1]))|(02/(0[1-9]|[1-2][0-9]))|((0[469]|11)/(0[1-9]|[1-2][0-9]|30)))";
                    issueYmd.Mask.UseMaskAsDisplayFormat = true;

                    gcMain.RepositoryItems.Add(issueYmd);
                    gvMain.Columns["MG8_ISSUE_YMD"].ColumnEdit = issueYmd;
                }

                //設定gvMain
                gcMain.Visible = true;
                //gvMain.Columns.Clear();
                gcMain.DataSource = dt;

                //gvMain.BestFitColumns();
                GridHelper.SetCommonGrid(gvMain);
                gcMain.Focus();

                return(ResultStatus.Success);
            } catch (Exception ex) {
                WriteLog(ex);
            }
            return(ResultStatus.Fail);
        }
Ejemplo n.º 22
0
        protected override ResultStatus Export()
        {
            try {
                #region 日期檢核
                if (string.Compare(txtStartMonth.Text, txtEndMonth.Text) > 0)
                {
                    MessageDisplay.Error("月份起始年月不可小於迄止年月!", GlobalInfo.ErrorText);
                    return(ResultStatus.Fail);
                }
                #endregion

                //0. ready
                panFilter.Enabled = false;
                labMsg.Visible    = true;
                labMsg.Text       = "開始轉檔...";
                this.Cursor       = Cursors.WaitCursor;
                this.Refresh();
                Thread.Sleep(5);

                //1. copy template xls to target path
                string   excelDestinationPath = PbFunc.wf_copy_file(_ProgramID, _ProgramID);
                Workbook workbook             = new Workbook();
                workbook.LoadDocument(excelDestinationPath);
                Worksheet worksheet = workbook.Worksheets[0];
                Range     range     = worksheet.Range["A7:Q7"];
                range.Alignment.WrapText = true;

                //2.填資料
                bool result = false;
                result = wf_Export(workbook, worksheet, txtStartMonth.Text.Replace("/", ""), txtEndMonth.Text.Replace("/", ""));

                if (!result)
                {
                    try {
                        workbook = null;
                        System.IO.File.Delete(excelDestinationPath);
                    } catch (Exception) {
                        //
                    }
                    return(ResultStatus.Fail);
                }

                //存檔
                workbook.SaveDocument(excelDestinationPath);
                labMsg.Visible = false;
                return(ResultStatus.Success);
            } catch (Exception ex) {
                WriteLog(ex);
            } finally {
                panFilter.Enabled = true;
                labMsg.Text       = "";
                labMsg.Visible    = false;
                this.Cursor       = Cursors.Arrow;
            }

            return(ResultStatus.Fail);
        }
Ejemplo n.º 23
0
        /// <summary>
        /// 調整後部位限制級距(PLS1_CP_LEVEL)、上季部位限制級距(PLS1_CUR_LEVEL)
        /// 欄位異動時觸發的事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void gvMain_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
        {
            try {
                GridView gv = sender as GridView;
                int      data;
                switch (e.Column.FieldName)
                {
                case "PLS1_CP_LEVEL":
                    data = gv.GetRowCellValue(e.RowHandle, "PLS1_CP_LEVEL").AsInt();
                    DataTable dtPLST1 = dao30222.SetPLST1LevelData(data);
                    if (dtPLST1.Rows.Count == 0)
                    {
                        MessageDisplay.Error("PLST1無任何資料!");
                        return;
                    }
                    gv.SetRowCellValue(e.RowHandle, "PLS1_CP_NATURE", dtPLST1.Rows[0]["PLST1_NATURE"]);
                    gv.SetRowCellValue(e.RowHandle, "PLS1_CP_LEGAL", dtPLST1.Rows[0]["PLST1_LEGAL"]);
                    gv.SetRowCellValue(e.RowHandle, "PLS1_CP_999", dtPLST1.Rows[0]["PLST1_999"]);
                    if (gv.GetRowCellValue(e.RowHandle, "PLS1_CUR_LEVEL").AsInt() > data)
                    {
                        gv.SetRowCellValue(e.RowHandle, "PLS1_LEVEL_ADJ", "+");
                    }
                    else if (gv.GetRowCellValue(e.RowHandle, "PLS1_CUR_LEVEL").AsInt() < data)
                    {
                        gv.SetRowCellValue(e.RowHandle, "PLS1_LEVEL_ADJ", "-");
                    }
                    else
                    {
                        gv.SetRowCellValue(e.RowHandle, "PLS1_LEVEL_ADJ", " ");
                    }
                    break;

                case "PLS1_CUR_LEVEL":
                    data = gv.GetRowCellValue(e.RowHandle, "PLS1_CUR_LEVEL").AsInt();
                    if (data.AsString() == "")
                    {
                        gv.SetRowCellValue(e.RowHandle, "PLS1_LEVEL_ADJ", "*");
                    }
                    else if (data > gv.GetRowCellValue(e.RowHandle, "PLS1_CP_LEVEL").AsInt())
                    {
                        gv.SetRowCellValue(e.RowHandle, "PLS1_LEVEL_ADJ", "+");
                    }
                    else if (data < gv.GetRowCellValue(e.RowHandle, "PLS1_CP_LEVEL").AsInt())
                    {
                        gv.SetRowCellValue(e.RowHandle, "PLS1_LEVEL_ADJ", "-");
                    }
                    else
                    {
                        gv.SetRowCellValue(e.RowHandle, "PLS1_LEVEL_ADJ", " ");
                    }
                    break;
                }
            }
            catch (Exception ex) {
                WriteLog(ex, "", false);
            }
        }
Ejemplo n.º 24
0
        protected override ResultStatus Save(PokeBall poke)
        {
            gvMain.CloseEditor();
            gvMain.UpdateCurrentRow();
            ResultStatus resultStatus = ResultStatus.Fail;

            try {
                DataTable dt = (DataTable)gcMain.DataSource;

                if (!checkComplete(dt))
                {
                    return(ResultStatus.Fail);
                }

                DataTable dtChange      = dt.GetChanges();
                DataTable dtForAdd      = dt.GetChanges(DataRowState.Added);
                DataTable dtForModified = dt.GetChanges(DataRowState.Modified);

                ResultData resultData = new ResultData();
                resultData.ChangedDataViewForAdded    = dtForAdd == null ? new DataView() : dtForAdd.DefaultView;
                resultData.ChangedDataViewForModified = dtForModified == null ? new DataView() : dtForModified.DefaultView;

                if (dtChange == null)
                {
                    MessageDisplay.Info("沒有變更資料, 不需要存檔!");
                    return(ResultStatus.FailButNext);
                }
                string result = dao51060.ExecuteStoredProcedure(txtYM.DateTimeValue.ToString("yyyyMMdd"));
                if (result == "0")
                {
                    foreach (DataRow r in dt.Rows)
                    {
                        if (r.RowState != DataRowState.Deleted)
                        {
                            r["MMIQ_W_TIME"]    = DateTime.Now;
                            r["MMIQ_W_USER_ID"] = GlobalInfo.USER_ID;
                        }
                        if (Equals(0, r["MMIQ_INVALID_QNTY"]))
                        {
                            r.Delete();
                        }
                    }
                    resultStatus = dao51060.updateData(dt).Status;
                    if (resultStatus == ResultStatus.Fail)
                    {
                        MessageDisplay.Error("儲存失敗");
                        return(ResultStatus.Fail);
                    }
                }

                //列印新增 刪除 修改的資料
                PrintOrExportChangedByKen(gcMain, dtForAdd, null, dtForModified);
            } catch (Exception ex) {
                throw ex;
            }
            return(resultStatus);
        }
Ejemplo n.º 25
0
 protected override ResultStatus DeleteRow()
 {
     try {
         base.DeleteRow(gvMain);
     } catch (Exception ex) {
         MessageDisplay.Error("刪除資料列失敗");
         throw ex;
     }
     return(ResultStatus.Success);
 }
Ejemplo n.º 26
0
 public WP0040(string programID, string programName) : base(programID, programName)
 {
     try {
         InitializeComponent();
         GridHelper.SetCommonGrid(gvMain);
         this.Text = _ProgramID + "─" + _ProgramName;
     } catch (Exception ex) {
         MessageDisplay.Error(ex.ToString());
     }
 }
Ejemplo n.º 27
0
        protected override ResultStatus Save(PokeBall pokeBall)
        {
            //base.Save(gcMain);

            DataTable dt       = (DataTable)gcMain.DataSource;
            DataTable dtChange = dt.GetChanges();

            if (dtChange == null)
            {
                MessageBox.Show("沒有變更資料,不需要存檔!", "注意", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(ResultStatus.Fail);
            }
            if (dtChange.Rows.Count == 0)
            {
                MessageBox.Show("沒有變更資料,不需要存檔!", "注意", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(ResultStatus.Fail);
            }

            //取得idfg_table_id
            //string idfgTableId = "";
            //if () {
            //   idfgTableId = dt.Rows[0]["IDFG_TABLE_ID"].AsString();
            //}
            //賦值
            foreach (DataRow dr in dt.Rows)
            {
                if (dr.RowState == DataRowState.Added)
                {
                    dr["IDFG_W_TIME"]    = DateTime.Now;
                    dr["IDFG_W_USER_ID"] = GlobalInfo.USER_ID;
                    dr["IDFG_TABLE_ID"]  = dt.Rows[0]["IDFG_TABLE_ID"].AsString();
                }
            }

            //寫入DB
            try {
                ResultData myResultData = dao20420.UpdateIDFG(dt);
                if (myResultData.Status == ResultStatus.Fail)
                {
                    MessageDisplay.Error("更新資料庫IDFG錯誤! ");
                    return(ResultStatus.Fail);
                }
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message);
                return(ResultStatus.Fail);
            }

            //重新Retrieve
            gcMain.RefreshDataSource();

            //不要自動列印
            _IsPreventFlowPrint = true;
            return(ResultStatus.Success);
        }
Ejemplo n.º 28
0
        protected override ResultStatus Export()
        {
            try {
                #region 輸入&日期檢核
                if (string.Compare(txtStartDate.Text, txtEndDate.Text) > 0)
                {
                    MessageDisplay.Error(CheckDate.Datedif, GlobalInfo.ErrorText);
                    return(ResultStatus.Fail);
                }
                #endregion

                //1.開始轉出資料
                panFilter.Enabled = false;
                labMsg.Visible    = true;
                labMsg.Text       = "開始轉檔...";
                this.Refresh();
                ResultStatus res = ResultStatus.Fail;

                if (ReportType == "Summary")
                {
                    //統計,會輸出一個csv檔案
                    if (Source == "Old")
                    {
                        res = wf_30681_s();
                    }
                    else
                    {
                        res = wf_30681_s_new();
                    }
                }
                else
                {
                    //明細,會輸出兩個csv檔案
                    if (Source == "Old")
                    {
                        res = wf_30681_d();
                        res = wf_30681_d_mtf();
                    }
                    else
                    {
                        res = wf_30681_d_new();
                        res = wf_30681_d_mtf_new();
                    }
                }

                return(res);
            } catch (Exception ex) {
                WriteLog(ex);
            } finally {
                panFilter.Enabled = true;
                labMsg.Text       = "";
                labMsg.Visible    = false;
            }
            return(ResultStatus.Fail);
        }
Ejemplo n.º 29
0
        public FormParent OpenForm(string txn_id, string txn_name)
        {
            //Austin 20190813 平行測試期間正式環境不開放維護功能
            if (GlobalDaoSetting.GetConnectionInfo.ConnectionName == "CI")
            {
                if (maintainItem.Contains(txn_id))
                {
                    MessageDisplay.Normal("維護功能暫不使用!");
                    accordionMenu.Focus();
                    accordionMenu.KeyNavHelperEx.SelectedElement = accordionMenu.SelectedElement;
                    return(null);
                }
            }
            if (txn_id == "Z2010")
            {
                OpenForm();
                return(new FormParent());
            }
            var    dllIndividual = Assembly.LoadFile(Application.ExecutablePath);
            string typeFormat    = "{0}.FormUI.Prefix{1}.W{2}";
            Type   myType        = dllIndividual.GetType(string.Format(typeFormat, Path.GetFileNameWithoutExtension(Application.ExecutablePath), txn_id.Substring(0, 1), txn_id));

            if (myType == null)
            {
                MessageDisplay.Error("無此程式");
                accordionMenu.Focus();
                accordionMenu.KeyNavHelperEx.SelectedElement = accordionMenu.SelectedElement;
                return(null);
            }

            object myObj = Activator.CreateInstance(myType, txn_id, txn_name);

            FormParent formInstance = (FormParent)myObj;

            //int width = SystemInformation.PrimaryMonitorSize.Width;
            //if (width <= 1600) {
            //    formInstance.WindowState = FormWindowState.Maximized;
            //}

            if (formInstance.BeforeOpen() == ResultStatus.Success)
            {
                formInstance.MdiParent          = this;
                formInstance.RibbonAlwaysAtBack = false;
                formInstance.FormClosed        += new FormClosedEventHandler(Child_FormClosed);
                formInstance.Icon          = (Icon)Icon.Clone();
                formInstance.StartPosition = FormStartPosition.Manual;
                //formInstance.WindowState = FormWindowState.Maximized;
                formInstance.Dock          = DockStyle.Fill;
                formInstance.AutoScaleMode = AutoScaleMode.None;
                formInstance.Show();
            }

            return(formInstance);
        }
Ejemplo n.º 30
0
        protected override ResultStatus Export()
        {
            if (gvMain.RowCount == 0)
            {
                MessageDisplay.Error("畫面中無資料可轉出!");
                return(ResultStatus.Fail);
            }

            /*******************
            *  點選儲存檔案之目錄
            *******************/
            string rpt;

            rpt = dw_txn_id.EditValue.AsString();
            SaveFileDialog save = new SaveFileDialog();

            save.Filter           = "*.csv (*.csv)|*.csv";
            save.Title            = "請點選儲存檔案之目錄";
            save.InitialDirectory = GlobalInfo.DEFAULT_REPORT_DIRECTORY_PATH;
            save.FileName         = _ProgramID + "_" + rpt + "_" + DateTime.Now.ToString("yyyy.MM.dd-HH.mm.ss") + ".csv";
            DialogResult saveResult = save.ShowDialog();

            if (saveResult == DialogResult.Cancel)
            {
                return(ResultStatus.Fail);
            }
            this.Cursor = Cursors.WaitCursor;
            //開一張空的table來轉成CSV
            DataTable  dtCSV  = new DataTable();
            DataColumn dcType = new DataColumn("ACC_GRP", typeof(string));
            DataColumn dcCode = new DataColumn("ACC_CODE", typeof(string));

            dtCSV.Columns.Add(dcType);
            dtCSV.Columns.Add(dcCode);
            dtCSV.Rows.Add("身份碼歸屬", "身份碼");
            for (int i = 0; i < gvMain.RowCount; i++)
            {
                dtCSV.Rows.Add();
                dtCSV.Rows[i + 1]["ACC_GRP"]  = IDFG_TYPE.ColumnEdit.GetDisplayText(gvMain.GetRowCellValue(i, gvMain.Columns["IDFG_TYPE"])).AsString();
                dtCSV.Rows[i + 1]["ACC_CODE"] = gvMain.GetRowCellValue(i, gvMain.Columns["IDFG_ACC_CODE"]).AsString();
            }
            //存CSV (ps:輸出csv 都用ascii)
            ExportOptions csvref = new ExportOptions();

            csvref.HasHeader = false;
            csvref.Encoding  = Encoding.GetEncoding(950);//ASCII
            Common.Helper.ExportHelper.ToCsv(dtCSV, save.FileName, csvref);
#if DEBUG
            //存完直接開檔檢視
            //System.Diagnostics.Process.Start(save.FileName);
#endif
            this.Cursor = Cursors.Arrow;
            return(ResultStatus.Success);
        }