Esempio n. 1
0
    //檢視異常報表
    protected void but_Unusual_Report_Click(object sender, EventArgs e)
    {
        #region
        try
        {
            string s_LoginUser = string.Empty;
            DataTable dt_Return = new DataTable();
            ArrayList ParameterList = new ArrayList();

            s_LoginUser = Session["UID"].ToString();//登入人員

            ParameterList.Clear();
            ParameterList.Add(Session["UID"].ToString());
            ParameterList.Add(string.Empty);
            ParameterList.Add(Session["UID"].ToString());
            ParameterList.Add(DateTime.Now);

            Int32 iTopRowNum;
            Int32.TryParse(TextBoxRowCountLimit.Text.Trim(), out iTopRowNum);
            ParameterList.Add(iTopRowNum);
            ParameterList.Add(PageTimeStamp.Value);


            ALOModel.ImportStoreOrderItem BCO = new ALOModel.ImportStoreOrderItem(ConnectionDB);
            dt_Return = BCO.QueryErrorByFind(ParameterList);

            if (dt_Return.Rows.Count > 0)
            {
                string SessionIDName = string.Format("{0}_{1}", PAGE_DT_01, PageTimeStamp.Value);
                Session["SessionID"] = SessionIDName;
                Session[SessionIDName] = dt_Return;
                this.gv_ErrorData.DataSource = dt_Return.DefaultView;

                this.gv_ErrorData.PageSize = (TextBoxPagesize.Text == "") ? 10 : (int.Parse(TextBoxPagesize.Text) <= 0) ? 10 : int.Parse(TextBoxPagesize.Text);
                this.gv_ErrorData.PageIndex = 0;
                this.gv_ErrorData.DataBind();

                btn_Export.Enabled = true;

            }
            else
            {
                btn_Export.Enabled = false;

                this.gv_ErrorData.DataSource = dt_Return.DefaultView;
                this.gv_ErrorData.DataBind();
                //System.Web.UI.ScriptManager.RegisterStartupScript(this.up_GridView, this.GetType(), "TO_ALO054.aspx", "alert('查無資料')", true);
                ResultMsgLabel.Text = "查無資料";

            }

        }
        catch (Exception ex)
        {
            this.ErrorMsgLabel.Text = ex.Message;
        }
        finally { }
        #endregion
    }
Esempio n. 2
0
    private bool ClientFileToServerTemp()
    {
        #region

        bool bResult = false;

        try
        {
            if (FileUpload1.FileName == "") return bResult = false;

            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;

            ALOModel.ImportStoreOrderItem BCO = new ALOModel.ImportStoreOrderItem(ConnectionDB);

            #region 上傳檔案到AP端


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

                #region 讀取 Excel 資料

                DataSet ds_Excel = BCO.ReadDataFromExcel(arl_FileUpload_Return[1].ToString());

                #endregion

                #region 將檔案匯入TmpTable

                DateTime d_CreateDate = Convert.ToDateTime(arl_FileUpload_Return[2]);
                s_AP_FileName = string.Empty;
                s_AP_FileName = arl_FileUpload_Return[3].ToString();

                arl_FileToTmp_Return = BCO.FileToTmp(ds_Excel, d_CreateDate, s_LoginUser, s_AP_FileName, PageTimeStamp.Value);

                #endregion

                if (arl_FileToTmp_Return[0].ToString() == "FALSE")
                {
                    this.but_Temp_To_DB.Enabled = false;
                    bResult = false;
                    ErrorMsgLabel.Text = arl_FileToTmp_Return[1].ToString();

                    //System.Web.UI.ScriptManager.RegisterStartupScript(this.but_File_To_Temp, this.GetType(), "TO_ALO064.aspx", "alert('" + arl_FileToTmp_Return[1].ToString() + "')", true);
                }
                else if (arl_FileToTmp_Return[0].ToString() == "TRUE")
                {
                    #region
                    if (((bool)arl_FileToTmp_Return[1]) == false)
                    { this.but_Temp_To_DB.Enabled = false; }//代表內容邏輯不正確

                    else
                    { this.but_Temp_To_DB.Enabled = true; }

                    #region 將資料從 UploadPath 移至 BackPath

                    s_BackPath = Server.MapPath(System.Configuration.ConfigurationManager.AppSettings["BackPath"]).Replace("ALO\\", "") + "\\ALO\\";

                    s_UploadPath += s_AP_FileName;
                    s_BackPath += s_AP_FileName;

                    System.IO.File.Copy(s_UploadPath, s_BackPath);
                    System.IO.File.Delete(s_UploadPath);

                    #endregion

                    #region 將結果顯示在 UploadStatusPanel 中


                    //上傳結果
                    this.UploadStatusPanel1.UploadSum = ((int)arl_FileToTmp_Return[2]);
                    this.UploadStatusPanel1.UploadOK = ((int)arl_FileToTmp_Return[3]);
                    this.UploadStatusPanel1.UploadNG = ((int)arl_FileToTmp_Return[4]);
                    //匯入結果
                    this.UploadStatusPanel1.ImportSum = 0;
                    this.UploadStatusPanel1.ImportOK = 0;
                    this.UploadStatusPanel1.ImportNG = 0;

                    iProcessingCounts = ((int)arl_FileToTmp_Return[2]);

                    #endregion

                    this.but_Unusual_Report.Enabled = true;
                    #endregion

                    if ((int)arl_FileToTmp_Return[4] == 0)
                    {
                        bResult = true;
                    }
                    else
                    {
                        bResult = false;
                    }
                }

                return bResult;

                #endregion
            }
        }
        catch (Exception ex)
        {
            this.ErrorMsgLabel.Text = ex.Message;
            return bResult = false;
        }

        return bResult;

        #endregion
    }
Esempio n. 3
0
    private void TempDataToDataBase()
    {
        #region
        try
        {
            ArrayList arl_Return = null;
            string s_LoginUser = string.Empty;
            string s_UploadPath_File = string.Empty;
            string s_BackPath_File = string.Empty;
            int err_cnt;

            s_LoginUser = Session["UID"].ToString();//登入人員

            ALOModel.ImportStoreOrderItem BCO = new ALOModel.ImportStoreOrderItem(ConnectionDB);

            if (s_AP_FileName != string.Empty)
            { arl_Return = BCO.TmpToDB(s_AP_FileName, s_LoginUser, PageTimeStamp.Value); }
            else
            { this.Response.Write("請重新匯入 EXCEL 檔"); }

            if (arl_Return[0].ToString() == "TEMPTODB 正確")
            {
                #region 設定 UploadStatusPanel 的值

                //匯入結果
                UploadStatusPanel1.ImportSum = iProcessingCounts;
                UploadStatusPanel1.ImportOK = iProcessingCounts;
                UploadStatusPanel1.ImportNG = 0;

                #endregion
            }
            else if (arl_Return[0].ToString() == "CHECKDATA 不正確")
            {
                #region 設定 UploadStatusPanel 的值

                //匯入結果
                UploadStatusPanel1.ImportSum = iProcessingCounts;

                int.TryParse(arl_Return[1].ToString(), out err_cnt);
                
                UploadStatusPanel1.ImportOK = iProcessingCounts - err_cnt;
                UploadStatusPanel1.ImportNG = err_cnt;

                #endregion
            }

        }
        catch (Exception ex)
        {
            this.ErrorMsgLabel.Text = ex.Message;
        }
        finally
        {
            this.but_Temp_To_DB.Enabled = false;
            this.but_File_To_Temp.Enabled = true;
            this.but_Unusual_Report.Enabled = true;
            this.ButtonQuery.Enabled = true;
            this.btn_Back.Enabled = true;
        }
        #endregion
    }
Esempio n. 4
0
    private void QueryData()
    {
        #region
        string s_LoginUser = string.Empty;
        DataTable dt_Return = new DataTable();
        ArrayList ParameterList = new ArrayList();

        s_LoginUser = Session["UID"].ToString();//登入人員

        ParameterList.Clear();
        ParameterList.Add(this.txt_User.Text.Trim());
        ParameterList.Add(this.txt_Date.Text.Trim());
        ParameterList.Add(Session["UID"].ToString());
        ParameterList.Add(DateTime.Now);

        Int32 iTopRowNum;
        Int32.TryParse(TextBoxRowCountLimit.Text.Trim(), out iTopRowNum);
        ParameterList.Add(iTopRowNum);
        if (this.txt_User.Text.Trim() != Session["UID"].ToString())
            ParameterList.Add(null);
        else
            ParameterList.Add(PageTimeStamp.Value);

        ALOModel.ImportStoreOrderItem BCO = new ALOModel.ImportStoreOrderItem(ConnectionDB);
        dt_Return = BCO.QueryErrorByFind(ParameterList);

        if (dt_Return.Rows.Count > 0)
        {
            string SessionIDName = string.Format("{0}_{1}", PAGE_DT_01, PageTimeStamp.Value);
            Session["SessionID"] = SessionIDName;
            Session[SessionIDName] = dt_Return;
            this.gv_ErrorData.DataSource = dt_Return.DefaultView;

            //頁面顯示初始狀態設定

            this.gv_ErrorData.PageSize = (TextBoxPagesize.Text == "") ? 10 : (int.Parse(TextBoxPagesize.Text) <= 0) ? 10 : int.Parse(TextBoxPagesize.Text);
            this.gv_ErrorData.PageIndex = 0;
            this.gv_ErrorData.DataBind();
            btn_Export.Enabled = true;

        }
        else
        {
            btn_Export.Enabled = false;

            this.gv_ErrorData.DataBind();
            //System.Web.UI.ScriptManager.RegisterStartupScript(this.up_GridView, this.GetType(), "TO_ALO054.aspx", "alert('查無資料')", true);
            ResultMsgLabel.Text = "查無資料";

        }
        #endregion
    }