Exemple #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;

            BCO.ProcessImportHoliday bco = new BCO.ProcessImportHoliday(ConntionDB);

            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)
            {
                ErrorMsgLabel1.Text = "查無資料!";
            }
            else
            {
                string SessionIDName = "STM321A_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.ErrorMsgLabel1.Text = ex.Message.Split(Environment.NewLine.Replace(Environment.NewLine, "~").ToCharArray())[0];  //直接取第一個
        }
        finally { }
        #endregion
    }
Exemple #2
0
    //查詢
    protected void ButtonQuery_Click(object sender, EventArgs e)
    {
        #region
        try
        {
            #region 檢查條件

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

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

            BCO.ProcessImportHoliday bco = new BCO.ProcessImportHoliday(ConntionDB);

            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;
                ErrorMsgLabel1.Text = "查無資料!";
            }
            else
            {
                string SessionIDName = "STM321A_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)
        {
            ErrorMsgLabel1.Text = ex.Message.Split(Environment.NewLine.Replace(Environment.NewLine, "~").ToCharArray())[0];  //直接取第一個
        }
        #endregion
    }
Exemple #3
0
    private void ClientFileToServerTemp()
    {
        #region

        try
        {
            //設定頁面狀態
            this.ErrorMsgLabel1.Text = "";
            gv_ErrorData.Visible = false;
            if (this.ddl_STORE_TYPE.SelectedValue.Trim() == "")
            {
                this.ErrorMsgLabel1.Text = "[類別]欄位不可空白<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;
            ArrayList arl_FileToTmp_Return = null;

            BCO.ProcessImportHoliday bco = new BCO.ProcessImportHoliday(ConntionDB);

            #region 上傳檔案到AP端


            //取得要上傳的路徑
            s_UploadPath = Server.MapPath("..\\") + System.Configuration.ConfigurationManager.AppSettings["UploadPath"] + "\\STM\\";
            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.ErrorMsgLabel1.Text = "檔案上傳至AP端錯誤";//檔案上傳至AP端錯誤,後面直接不做了
                #endregion
            }
            else if (arl_FileUpload_Return[0].ToString() == "TRUE")//檔案上傳至AP端正常
            {
                #region

                #region 讀取 Excel 資料

                OleDbConnection oleConnection = null;
                DataSet ds_Excel = new DataSet();

                try
                {
                    String connString = "Provider=Microsoft.JET.OLEDB.4.0;Data Source =" + arl_FileUpload_Return[1].ToString() + ";Extended Properties=Excel 8.0;";
                    oleConnection = new OleDbConnection(connString);
                    oleConnection.Open();
                    OleDbCommand oleCommand = new OleDbCommand("SELECT * FROM [Sheet1$]", oleConnection);
                    OleDbDataAdapter oleAdapter = new OleDbDataAdapter(oleCommand);
                    oleAdapter.Fill(ds_Excel);

                    #region 請注意如果EXCEL檔欄位有值,但到DB卻沒有資料

                    //請修改,機碼 HKEY_LOCAL_MACHINE\Software\Microsoft\Jet\4.0\Engines\Excel\TypeGuessRows 值

                    //預設是 8, 表示會先讀取前 8 列來決定每一個欄位的型態, 所以如果前 8 列的資料都是數字, 到了第 9 列以後出現的文字資料都會變成 null
                    //如果要解決這個問題, 只要把 TypeGuessRows 機碼值改成 0
                    #endregion
                }
                catch (Exception ex)
                {
                    this.Response.Write(ex.Message);
                }
                finally
                {
                    if (oleConnection != null)
                    {
                        oleConnection.Close();
                        oleConnection.Dispose();
                    }
                }

                #endregion

                #region 將檔案匯入TmpTable

                int N_TMP_CNT = 0;
                int N_TAB_CNT = 0;
                string V_STORE_TYPE = this.ddl_STORE_TYPE.SelectedValue.Trim();
                string ErrorMsg = "";
                DataTable dtA = ds_Excel.Tables[0];
                int N_UPLOAD = dtA.Rows.Count;
                arl_FileToTmp_Return = bco.FileToTmp(dtA, null, arl_FileUpload_Return[3].ToString(), Session["UID"].ToString(), V_STORE_TYPE);

                #endregion

                //上傳結果
                this.UploadStatusPanel1.UploadSum = Convert.ToInt32(arl_FileToTmp_Return[4].ToString());
                this.UploadStatusPanel1.UploadOK = Convert.ToInt32(arl_FileToTmp_Return[4].ToString())- Convert.ToInt32(arl_FileToTmp_Return[5].ToString());
                this.UploadStatusPanel1.UploadNG = Convert.ToInt32(arl_FileToTmp_Return[5].ToString()) ;
                //匯入結果
                this.UploadStatusPanel1.ImportSum = Convert.ToInt32(arl_FileToTmp_Return[1].ToString());
                this.UploadStatusPanel1.ImportOK = Convert.ToInt32(arl_FileToTmp_Return[2].ToString());
                this.UploadStatusPanel1.ImportNG = Convert.ToInt32(arl_FileToTmp_Return[3].ToString());


                #endregion
            }
            unLockPage();
            this.hid_FrmStatus.Value = "fmBroswe";
        }
        catch (Exception ex)
        {
            this.ErrorMsgLabel1.Text = ex.Message.Split(Environment.NewLine.Replace(Environment.NewLine, "~").ToCharArray())[0];  //直接取第一個
            unLockPage();
            //this.hid_FrmStatus.Value = "fmBroswe";
        }

        #endregion
    }