Example #1
0
    //檢視異常報表
    protected void but_Unusual_Report_Click(object sender, EventArgs e)
    {
        #region
        try
        {
            System.Threading.Thread.Sleep(2000);
           
            DataTable dtA = new DataTable();
            this.gv_ErrorData.Visible = false;

            OUT01ProcessImportItem bco = new OUT01ProcessImportItem(ConnectionDB);            
            
            dtA = bco.QueryErrorByFind(Session["UID"].ToString(), Convert.ToDateTime(System.DateTime.Now.ToShortDateString()), Convert.ToDateTime(System.DateTime.Now.ToShortDateString()));

            #region 資料與GridView繫結

            //抓取本頁初次登記的時間
            if (dtA.Rows.Count == 0)
            {
                ErrorMsgLabel.Text = "查無資料!";
            }
            else
            {
                string SessionIDName = "OUT013A_gv_ItemInfo" + PageTimeStamp.Value;
                this.gv_ErrorData.Visible = true;
                Session["SessionID"] = SessionIDName;
                Session[SessionIDName] = dtA;
                this.gv_ErrorData.DataSource = dtA;
                if (this.TextBoxPagesize.Text == "")
                    this.gv_ErrorData.PageSize = 10;
                else
                    this.gv_ErrorData.PageSize = Convert.ToInt32(this.TextBoxPagesize.Text);
                this.gv_ErrorData.PageIndex = 0;
                this.gv_ErrorData.DataBind();
            }

            #endregion            
        }
        catch (Exception ex)
        {
            this.ErrorMsgLabel.Text = ex.Message.Split(Environment.NewLine.Replace(Environment.NewLine, "~").ToCharArray())[0];  //直接取第一個
        }
        finally { }
        #endregion
    }
Example #2
0
    //查詢
    protected void ButtonQuery_Click(object sender, EventArgs e)
    {
        #region
        try
        {
            #region 檢查條件

            this.ErrorMsgLabel.Text = "";
            string s_CheckPage = CheckPage(sender);
            if (s_CheckPage != string.Empty)
            {
                this.ErrorMsgLabel.Text = s_CheckPage;
                return;
            }

            #endregion
            ErrorMsgLabel.Text = "";
            DataTable dtA = new DataTable();

            OUT01ProcessImportItem bco = new OUT01ProcessImportItem(ConnectionDB);
            
            DateTime dateB, dateE;

            DateTime.TryParse(this.SLP_SLPDateRange1.StartDate.ToString(), out dateB);

            if (DateTime.TryParse(this.SLP_SLPDateRange1.EndDate.ToString(), out dateE) == false)
                dateE = Convert.ToDateTime("3000/01/01");
            else
                DateTime.TryParse(this.SLP_SLPDateRange1.EndDate.ToString(), out dateE);

            this.gv_ErrorData.Visible = false;
            dtA = bco.QueryErrorByFind(GetValueSetParameter(this.txt_User.Text.Trim(),"string",this.CheckBoxLikeSearch.Checked).ToString(), dateB, dateE);

            #region 資料與GridView繫結

            //抓取本頁初次登記的時間
            if (dtA.Rows.Count == 0)
            {
                this.gv_ErrorData.Visible = false;
                ErrorMsgLabel.Text = "查無資料!";
            }
            else
            {
                string SessionIDName = "OUT013A_gv_ItemInfo" + PageTimeStamp.Value;
                this.gv_ErrorData.Visible = true;
                Session["SessionID"] = SessionIDName;
                Session[SessionIDName] = dtA;
                this.gv_ErrorData.DataSource = dtA;
                if (this.TextBoxPagesize.Text == "")
                    this.gv_ErrorData.PageSize = 10;
                else
                    this.gv_ErrorData.PageSize = Convert.ToInt32(this.TextBoxPagesize.Text);
                this.gv_ErrorData.PageIndex = 0;
                this.gv_ErrorData.DataBind();
            }
            #endregion
                       
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message.Split(Environment.NewLine.Replace(Environment.NewLine, "~").ToCharArray())[0];  //直接取第一個
        }
        #endregion
    }
Example #3
0
    private void ClientFileToServerTemp()
    {
        #region
        
        try
        {
            //設定頁面狀態
            this.ErrorMsgLabel.Text = "";
            gv_ErrorData.Visible = false;
            if (this.SLP_DCStartDate.Text.Trim() == "")
            {
                this.ErrorMsgLabel.Text = "[DC開始日]欄位不可空白<br/>";
                return;
            }
            this.hid_FrmStatus.Value = "fmProcess";
            //LockPage();
            System.Threading.Thread.Sleep(2000);
            string s_UploadPath = string.Empty;
            string s_BackPath = string.Empty;
            string s_LoginUser = string.Empty;
            ArrayList arl_FileUpload_Return = null;


            OUT01ProcessImportItem bco = new OUT01ProcessImportItem(ConnectionDB);

            #region 上傳檔案到AP端


            //取得要上傳的路徑
            s_UploadPath = Server.MapPath("..\\") + System.Configuration.ConfigurationManager.AppSettings["UploadPath"] + "\\OUT\\";
            s_LoginUser = Session["UID"].ToString();
            arl_FileUpload_Return = bco.FileUpload(s_UploadPath, this.FileUpload1, s_LoginUser);
           
            #endregion

            if (arl_FileUpload_Return[0].ToString() == "FALSE")//檔案上傳至AP端錯誤
            {
                #region
                this.ErrorMsgLabel.Text = "檔案上傳至AP端錯誤";//檔案上傳至AP端錯誤,後面直接不做了
                #endregion
            }
            else if (arl_FileUpload_Return[0].ToString() == "TRUE")//檔案上傳至AP端正常
            {
                #region
                
                #region 讀取 txt 資料

                
                DataTable dtA = new DataTable();
                dtA = this.MakeDT();
                int N_UPLOAD = 0;//上傳筆數
                try
                {                
                    FileStream fs = new FileStream(arl_FileUpload_Return[1].ToString(), FileMode.Open, FileAccess.Read);
                    StreamReader m_streamReader = new StreamReader(fs, System.Text.Encoding.GetEncoding(950));
                    //使用StreamReader來讀取資料
                    m_streamReader.BaseStream.Seek(0, SeekOrigin.Begin);

                    string strLine = m_streamReader.ReadLine();
                    while (strLine != null && strLine != "")
                    {                        
                        DataRow drA = dtA.NewRow();
                        drA[0] = strLine;                        
                        dtA.Rows.Add(drA);
                        strLine = m_streamReader.ReadLine();
                        N_UPLOAD++;
                    }
                }
                catch (Exception ex)
                {
                    this.Response.Write(ex.Message);
                }
                
                #endregion

                #region 將檔案匯入TmpTable

                int N_TMP_CNT = 0;
                int N_TAB_CNT = 0;
                string V_EFF_START = this.SLP_DCStartDate.Text.Trim();
                string ErrorMsg = "";
                bco.FileToTmp(dtA, null, arl_FileUpload_Return[4].ToString(), Session["UID"].ToString(), V_EFF_START,out ErrorMsg);
                bco.QueryItemTmpImportStat(DateTime.Parse(V_EFF_START),Session["UID"].ToString(), out N_TMP_CNT, out N_TAB_CNT);
                
                
                #endregion


                //上傳結果
                this.UploadStatusPanel1.UploadSum = N_UPLOAD;
                this.UploadStatusPanel1.UploadOK = N_TMP_CNT;
                this.UploadStatusPanel1.UploadNG = N_UPLOAD - N_TMP_CNT;
                //匯入結果
                this.UploadStatusPanel1.ImportSum = N_TMP_CNT;
                this.UploadStatusPanel1.ImportOK = N_TAB_CNT;
                this.UploadStatusPanel1.ImportNG = N_TMP_CNT - N_TAB_CNT;
                #endregion
            }
            unLockPage();
            this.hid_FrmStatus.Value = "fmBroswe";
        }
        catch (Exception ex)
        {
            this.ErrorMsgLabel.Text = ex.Message.Split(Environment.NewLine.Replace(Environment.NewLine, "~").ToCharArray())[0];  //直接取第一個
            unLockPage();
            this.hid_FrmStatus.Value = "fmBroswe";
        }

        #endregion
    }