Exemplo n.º 1
0
    public DataTable searchData()
    {
        #region 清空靜態變數
        Session["IVM381_" + PageTimeStamp.Value] = null;
        #endregion

        #region 處理查詢

        ParameterList.Clear();
        ParameterList.Add(GetValueSetParameter(this.slp_ITEM_B.Text.Trim(), "string"));
        ParameterList.Add(GetValueSetParameter(this.slp_ITEM_E.Text.Trim(), "string"));
        ParameterList.Add(GetValueSetParameter(this.txt_PERIOD_B.Text.Trim(), "string"));
        ParameterList.Add(GetValueSetParameter(this.txt_PERIOD_E.Text.Trim(), "string"));
        ParameterList.Add(GetValueSetParameter(this.slp_Vendor_B.Text.Trim(), "string"));
        ParameterList.Add(GetValueSetParameter(this.slp_Vendor_E.Text.Trim(), "string"));

        ParameterList.Add(GetValueSetParameter(TextBoxRowCountLimit.Text, "int"));

        BCO.VDS_IVM38_BCO bco = new BCO.VDS_IVM38_BCO(ConntionDB);
        DataTable Dt = bco.QueryByFind(ParameterList, int.Parse(TextBoxRowCountLimit.Text));


        #endregion
        return Dt;

    }
Exemplo n.º 2
0
    //異常查詢
    protected void ButtonQuery_Click(object sender, EventArgs e)
    {
        #region
        try
        {
            ErrorMsgLabel1.Text = "";
            DataTable dt = new DataTable();

            BCO.VDS_IVM38_BCO bco = new BCO.VDS_IVM38_BCO(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;
            dt = bco.QueryErrorByFind(GetValueSetParameter(this.txt_User.Text.Trim(), "string", this.CheckBoxLikeSearch.Checked).ToString(), dateB, dateE);

            #region 資料與GridView繫結

            //抓取本頁初次登記的時間
            if (dt.Rows.Count == 0)
            {
                this.gv_ErrorData.Visible = false;
                ErrorMsgLabel1.Text = "查無資料!";
            }
            else
            {
                string SessionIDName = "IVM381_ERR" + PageTimeStamp.Value;
                this.gv_ErrorData.Visible = true;
                Session["SessionID"] = SessionIDName;
                Session[SessionIDName] = dt;
                this.gv_ErrorData.DataSource = dt;
                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
    }
Exemplo n.º 3
0
    private void ClientFileToServerTemp()
    {
        #region

        try
        {
            //設定頁面狀態
            this.ErrorMsgLabel1.Text = "";
            gv_ErrorData.Visible = false;

            LockPage();
            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.VDS_IVM38_BCO bco = new BCO.VDS_IVM38_BCO(ConntionDB);

            #region 上傳檔案到AP端


            //取得要上傳的路徑
            s_UploadPath = Server.MapPath("..\\") + System.Configuration.ConfigurationManager.AppSettings["UploadPath"] + "\\IVM\\";
            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 ErrorMsg = "";
                DataTable dt = ds_Excel.Tables[0];
                int N_UPLOAD = dt.Rows.Count;
                arl_FileToTmp_Return = bco.FileToTmp(dt, null, arl_FileUpload_Return[3].ToString(), Session["UID"].ToString());

                #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();
        }
        catch (Exception ex)
        {
            this.ErrorMsgLabel1.Text = ex.Message.Split(Environment.NewLine.Replace(Environment.NewLine, "~").ToCharArray())[0];  //直接取第一個
            unLockPage();
        }

        #endregion
    }
Exemplo n.º 4
0
    //檢視異常報表
    protected void but_Unusual_Report_Click(object sender, EventArgs e)
    {
        #region
        try
        {
            ErrorMsgLabel1.Text = "";
            DataTable dt = new DataTable();
            this.gv_ErrorData.Visible = false;

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

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

            #region 資料與GridView繫結

            //抓取本頁初次登記的時間
            if (dt.Rows.Count == 0)
            {
                ErrorMsgLabel1.Text = "查無資料!";
            }
            else
            {
                string SessionIDName = "IVM381_ERR" + PageTimeStamp.Value;
                this.gv_ErrorData.Visible = true;
                Session["SessionID"] = SessionIDName;
                Session[SessionIDName] = dt;
                this.gv_ErrorData.DataSource = dt;
                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
    }
Exemplo n.º 5
0
    protected void btnDelete_Click(object sender, EventArgs e)
    {


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

        GridViewRow grdRow = (GridViewRow)((LinkButton)sender).Parent.Parent;

        string ITEM = ((Label)grdRow.FindControl("lblITEM")).Text;
        string PERIOD = ((Label)grdRow.FindControl("lblPERIOD")).Text;

            try
            {
                ParameterList.Clear();
                ParameterList.Add(ITEM);
                ParameterList.Add(PERIOD);
                ParameterList.Add(Session["UID"].ToString());

                bco.doDelete(ParameterList);

                ErrorMsgLabel.Text = "刪除成功!";

                DataTable Dt = new DataTable();

                Dt = this.searchData();

                if (Dt == null || (Dt != null && Dt.Rows.Count <= 0))
                {
                    ErrorMsgLabel.Text = "查無資料";
                }
                else
                {

                    #region 將查詢結果放至SESSION
                    Session["IVM381_" + PageTimeStamp.Value] = Dt;
                    #endregion

                }


                #region 設定查詢結果

                this.setGV(0, Dt, false);

                #endregion

            }
            catch (Exception ex)
            {
                ErrorMsgLabel.Text = ex.Message;
            }
    }