Ejemplo n.º 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;
            this.gv_ErrorDataB.Visible = false;
            if (this.TextBoxRowCountLimit.Text.Trim() == "")
            {
                this.TextBoxRowCountLimit.Text = "500";
            }
            VDMModel.ProcessImportVCMSLevel bcoA = new VDMModel.ProcessImportVCMSLevel(ConnectionDB);
            VDMModel.ProcessImportVCMSFee bcoB = new VDMModel.ProcessImportVCMSFee(ConnectionDB);
            if (this.rdoType1.Checked == true)
            {
                dtA = bcoA.QueryErrorByFind(Session["UID"].ToString(), Convert.ToDateTime(System.DateTime.Now.ToShortDateString()), Convert.ToDateTime(System.DateTime.Now.ToShortDateString()), Convert.ToInt32(this.TextBoxRowCountLimit.Text.Trim()));

                #region 資料與GridView繫結

                //抓取本頁初次登記的時間
                if (dtA.Rows.Count == 0)
                {
                    
                    ErrorMsgLabel.Text = "查無資料!";

                }
                else
                {
                    string SessionIDName = "VDM051A_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
            }
            else
            {
                dtA = bcoB.QueryErrorByFind(Session["UID"].ToString(), Convert.ToDateTime(System.DateTime.Now.ToShortDateString()), Convert.ToDateTime(System.DateTime.Now.ToShortDateString()), Convert.ToInt32(this.TextBoxRowCountLimit.Text.Trim()));
                string SessionIDName = "VDM051B_gv_ItemInfo" + PageTimeStamp.Value;

                this.gv_ErrorDataB.Visible = true;
                Session["SessionID"] = SessionIDName;
                Session[SessionIDName] = dtA;
                this.gv_ErrorDataB.DataSource = dtA;
                if (this.TextBoxPagesize.Text == "")
                    this.gv_ErrorDataB.PageSize = 10;
                else
                    this.gv_ErrorDataB.PageSize = Convert.ToInt32(this.TextBoxPagesize.Text);
                this.gv_ErrorDataB.PageIndex = 0;
                this.gv_ErrorDataB.DataBind();
            }

            

        }
        catch (Exception ex)
        {
            this.ErrorMsgLabel.Text = ex.Message;
        }
        finally { }
        #endregion
    }
Ejemplo n.º 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();

            VDMModel.ProcessImportVCMSLevel bcoA = new VDMModel.ProcessImportVCMSLevel(ConnectionDB);
            VDMModel.ProcessImportVCMSFee bcoB = new VDMModel.ProcessImportVCMSFee(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;
            this.gv_ErrorDataB.Visible = false;

            if (this.TextBoxRowCountLimit.Text.Trim() == "")
            {
                this.TextBoxRowCountLimit.Text = "500";
            }

            if (this.rdoTypeQ1.Checked == true)
            {

                //因為把"關鍵字搜尋"拿掉,所以沒有CheckBoxLikeSearch
                //dtA = bcoA.QueryErrorByFind(GetValueSetParameter(this.txt_User.Text.Trim(), "string", this.CheckBoxLikeSearch.Checked).ToString(), dateB, dateE, Convert.ToInt32(this.TextBoxRowCountLimit.Text.Trim()));
                dtA = bcoA.QueryErrorByFind(GetValueSetParameter(this.txt_User.Text.Trim(), "string", false).ToString(), dateB, dateE,Convert.ToInt32(this.TextBoxRowCountLimit.Text.Trim()));

                #region 資料與GridView繫結

                //抓取本頁初次登記的時間
                if (dtA.Rows.Count == 0)
                {
                    this.gv_ErrorData.Visible = false;
                    ErrorMsgLabel.Text = "查無資料!";

                }
                else
                {
                    string SessionIDName = "VDM051A_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
            }
            else
            {

                //因為把"關鍵字搜尋"拿掉,所以沒有CheckBoxLikeSearch
                //dtA = bcoB.QueryErrorByFind(GetValueSetParameter(this.txt_User.Text.Trim(), "string", this.CheckBoxLikeSearch.Checked).ToString(), dateB, dateE, Convert.ToInt32(this.TextBoxRowCountLimit.Text.Trim()));
                dtA = bcoB.QueryErrorByFind(GetValueSetParameter(this.txt_User.Text.Trim(), "string", false).ToString(), dateB, dateE, Convert.ToInt32(this.TextBoxRowCountLimit.Text.Trim()));
                
                
                string SessionIDName = "VDM051B_gv_ItemInfo" + PageTimeStamp.Value;
                if (dtA.Rows.Count == 0)
                {
                    this.gv_ErrorData.Visible = false;
                    ErrorMsgLabel.Text = "查無資料!";

                }
                else
                {
                    this.gv_ErrorDataB.Visible = true;
                    Session["SessionID"] = SessionIDName;
                    Session[SessionIDName] = dtA;
                    this.gv_ErrorDataB.DataSource = dtA;
                    if (this.TextBoxPagesize.Text == "")
                        this.gv_ErrorDataB.PageSize = 10;
                    else
                        this.gv_ErrorDataB.PageSize = Convert.ToInt32(this.TextBoxPagesize.Text);
                    this.gv_ErrorDataB.PageIndex = 0;
                    this.gv_ErrorDataB.DataBind();
                }
            }

            
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
        #endregion
    }
Ejemplo n.º 3
0
    private void ClientFileToServerTemp()
    {
        #region
        
        try
        {
            this.ErrorMsgLabel.Text = "";
            //設定頁面狀態
            this.hid_FrmStatus.Value = "fmBroswe";
            //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;

            VDMModel.ProcessImportVCMSLevel bcoA = new VDMModel.ProcessImportVCMSLevel(ConnectionDB);

            VDMModel.ProcessImportVCMSFee bcoB = new VDMModel.ProcessImportVCMSFee(ConnectionDB);

            #region 上傳檔案到AP端


            //取得要上傳的路徑
            if (this.FileUpload1.FileName == "")
            {
                this.ErrorMsgLabel.Text = "請點選要匯入的檔案";
                return;
            }
            s_UploadPath = Server.MapPath("..\\") + System.Configuration.ConfigurationManager.AppSettings["UploadPath"] + "\\VDM\\";
            s_LoginUser = Session["UID"].ToString();
            if (this.rdoType1.Checked)
                arl_FileUpload_Return = bcoA.FileUpload(s_UploadPath, this.FileUpload1, s_LoginUser);
            else
                arl_FileUpload_Return = bcoB.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)
                    {                        
                        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_MSG = "";
                if (this.rdoType1.Checked == true)
                {
                    V_MSG=bcoA.FileToTmp(dtA, null, arl_FileUpload_Return[4].ToString(), Session["UID"].ToString());
                    if (V_MSG == "")
                    {
                        bcoA.QueryVcmsMainTmpImportStat(Session["UID"].ToString(), out N_TMP_CNT, out N_TAB_CNT);
                    }
                    else
                    {
                        this.ErrorMsgLabel.Text = V_MSG;
                    }
                }
                else
                {
                    V_MSG=bcoB.FileToTmp(dtA, null, arl_FileUpload_Return[4].ToString(), Session["UID"].ToString());
                    if (V_MSG == "")
                    {
                        bcoB.QueryVcmsItemTmpImportStat(Session["UID"].ToString(), out N_TMP_CNT, out N_TAB_CNT);
                    }
                    else
                    {
                        this.ErrorMsgLabel.Text = V_MSG;
                    }
                }

                #endregion

                //上傳結果
                this.UploadStatusPanel1.UploadSum = N_UPLOAD;
                this.UploadStatusPanel1.UploadOK = N_TMP_CNT;
                this.UploadStatusPanel1.UploadNG = N_UPLOAD-N_TMP_CNT;
                if (N_UPLOAD - N_TMP_CNT > 0)
                {
                    ((TextBox)UploadStatusPanel1.FindControl("txtUP13")).ForeColor = System.Drawing.Color.Red;
                }
                //匯入結果
                this.UploadStatusPanel1.ImportSum = N_TMP_CNT;
                this.UploadStatusPanel1.ImportOK = N_TAB_CNT;
                this.UploadStatusPanel1.ImportNG = N_TMP_CNT - N_TAB_CNT;
                if (N_TMP_CNT - N_TAB_CNT > 0)
                {
                    ((TextBox)UploadStatusPanel1.FindControl("txtUP23")).ForeColor = System.Drawing.Color.Red;
                }

                #endregion
            }
            unLockPage();
            this.hid_FrmStatus.Value = "";
        }
        catch (Exception ex)
        {
            this.ErrorMsgLabel.Text = ex.Message;
            unLockPage();
            this.hid_FrmStatus.Value = "";
        }

        #endregion
    }