protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            #region 清空Message

            this.ErrorMsgLabel.Text = string.Empty;
            this.RightMsgLabel.Text = string.Empty;

            #endregion

            if (!IsPostBack)
            {
                #region Attributes

                this.but_Close.Attributes["onclick"] += "window.close();";

                #endregion

                #region 取得異常資料

                #region 傳入參數

                ParameterList.Clear();
                ParameterList.Add(Session["UID"].ToString());

                #endregion

                #region 連結資料庫

                BCO.ImportDeclarePO bco = new BCO.ImportDeclarePO(ConntionDB);
                DataTable dt_Return = bco.QUERYERRORBYFIND(ParameterList);

                #endregion

                #region 檢查回傳資料

                if (dt_Return.Rows.Count == 0)
                {
                    this.ErrorMsgLabel.Text = "查無資料";
                    return;
                }
                else
                {
                    this.gv_Result.DataSource = dt_Return;
                    this.gv_Result.DataBind();
                }

                #endregion

                #endregion
            }
        }
        catch (Exception ex)
        {
            WaringLogProcess(ex.Message);
            this.ErrorMsgLabel.Text = ex.Message;
        }
        finally { }
    }
Beispiel #2
0
    /// <summary>
    /// BUTTON [載入檔案]鈕
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void but_tab2_LoadFile_Click(object sender, EventArgs e)
    {
        try
        {
            #region 將Client端的檔案上傳至AP端

            #region 宣告變數

            string s_UploadPath = string.Empty;
            ArrayList arl_Return = new ArrayList();

            #endregion

            #region 將Client端的檔案上傳至AP端

            s_UploadPath = Server.MapPath("..\\") + System.Configuration.ConfigurationManager.AppSettings["UploadPath"] + "CAA\\";

            BCO.ImportDeclarePO bco = new BCO.ImportDeclarePO(ConntionDB);
            arl_Return = bco.FileUpload(s_UploadPath, this.fileupload_tab2_Path, Session["UID"].ToString());

            #endregion

            #region 檢查回傳結果

            if (arl_Return[0].ToString() == "FALSE")
            {
                #region 清空上傳匯入結果

                this.UploadStatusPanel1.UploadSum = 0;//上傳結果總筆數
                this.UploadStatusPanel1.UploadOK = 0;//上傳結果正常筆數
                this.UploadStatusPanel1.UploadNG = 0;//上傳結果錯誤筆數
                this.UploadStatusPanel1.ImportSum = 0;//匯入結果總筆數
                this.UploadStatusPanel1.ImportOK = 0;//匯入結果正常筆數
                this.UploadStatusPanel1.ImportNG = 0;//匯入結果錯誤筆數

                #endregion

                #region 設定控制項

                this.but_tab2_Import.Enabled = false;//確定匯入
                this.but_tab2_Error.Enabled = false;//檢視異常

                #endregion

                this.ErrorMsgLabel.Text = arl_Return[1].ToString();
                return;
            }

            #endregion

            #endregion

            #region 依據AP端檔案資料匯入TmpTable

            #region 取得 TempTable VDS_CAA_DECLARE_TEMP 的 SCHEMA

            BCO.CAACommon CAAComm = new BCO.CAACommon();
            DataTable dt_Temp = new DataTable();

            ParameterList.Clear();
            ParameterList.Add(CAAComm.GetValueSetParameter(Session["UID"].ToString(), "string", false));//V_LOG_UPDATEUID

            dt_Temp = bco.GET_DECLARE_TEMP_SCHEMA(ParameterList);

            #endregion

            #region 將資料寫入 TempTable

            DateTime d_Now = DateTime.Now;
            string s_FileLine = string.Empty;
            System.IO.StreamReader str = new System.IO.StreamReader(arl_Return[1].ToString());

            while ((s_FileLine = str.ReadLine()) != null)
            {
                #region 檢查條件

                ArrayList arl_ConditionReturn = Check_Condition_FileLine(s_FileLine, dt_Temp);

                #endregion

                #region 檢查正確

                if (arl_ConditionReturn[1].ToString() == string.Empty)
                {
                    DataRow dr_Temp = dt_Temp.NewRow();

                    //該筆資料為註記空白發票的資料
                    if (s_FileLine.Substring(61, 1) == "D" &&
                        s_FileLine.Substring(79, 1) == "A")
                    {
                        dr_Temp["ID"] = dt_Temp.Rows.Count + 1;//ID
                        dr_Temp["MEMO"] = "該筆資料為註記空白發票的資料;";//說明
                        dr_Temp["DATATYPE"] = CAAComm.GetValueSetParameter("1", "int", false);//資料類別(1:FILE TO TMP;2:TMP TO DB)
                        dr_Temp["DATASOURCE"] = CAAComm.GetValueSetParameter(arl_Return[3].ToString(), "string", false);//匯入檔案
                        dr_Temp["STATUS"] = CAAComm.GetValueSetParameter("1", "int", false);//處理狀態(1:正常資料;2:錯誤資料)
                        dr_Temp["CREATEUID"] = CAAComm.GetValueSetParameter(Session["UID"].ToString(), "string", false);
                        dr_Temp["CREATEDATE"] = CAAComm.GetValueSetParameter(d_Now.ToString(), "datetime", false);
                        dr_Temp["UPDATEUID"] = CAAComm.GetValueSetParameter(string.Empty, "string", false);
                        dr_Temp["UPDATEDATE"] = CAAComm.GetValueSetParameter(string.Empty, "string", false);
                    }
                    else
                    {
                        #region 取得稅別

                        //20090921秀玲更改規則,
                        //文字檔傳入的課稅別為,1:應稅,2:零稅率,3:免稅
                        //高見系統的課稅別為  ,0:應稅,2:零稅率,1:免稅
                        string s_TAX_TYPE = string.Empty;

                        if (s_FileLine.Substring(61, 1) == "1")
                        { s_TAX_TYPE = "0"; }
                        else if (s_FileLine.Substring(61, 1) == "2")
                        { s_TAX_TYPE = "2"; }
                        else if (s_FileLine.Substring(61, 1) == "3")
                        { s_TAX_TYPE = "1"; }
                        else
                        { s_TAX_TYPE = s_FileLine.Substring(61, 1); }

                        #endregion

                        dr_Temp["ID"] = dt_Temp.Rows.Count + 1;//ID
                        dr_Temp["INV_FORM"] = CAAComm.GetValueSetParameter(s_FileLine.Substring(0, 2), "string", false);//格式代號
                        dr_Temp["SEQ_NO"] = CAAComm.GetValueSetParameter(s_FileLine.Substring(11, 7), "int", false);//流水號
                        dr_Temp["INV_YM"] = CAAComm.GetValueSetParameter(Convert.ToString(int.Parse(s_FileLine.Substring(18, 5)) + 191100), "string", false);//年月
                        dr_Temp["RFNO"] = CAAComm.GetValueSetParameter(s_FileLine.Substring(23, 8), "string", false);//客戶統編
                        dr_Temp["INV_NO"] = CAAComm.GetValueSetParameter(s_FileLine.Substring(39, 10), "string", false);//銷項發票
                        dr_Temp["INV_UAMT"] = CAAComm.GetValueSetParameter(s_FileLine.Substring(49, 12), "int64", false);//銷售額
                        dr_Temp["TAX_TYPE"] = CAAComm.GetValueSetParameter(s_TAX_TYPE, "string", false);//課稅別
                        dr_Temp["INV_TAX"] = CAAComm.GetValueSetParameter(s_FileLine.Substring(62, 10), "int64", false);//稅額
                        dr_Temp["MEMO"] = CAAComm.GetValueSetParameter(string.Empty, "string", false);//說明
                        dr_Temp["DATATYPE"] = CAAComm.GetValueSetParameter("1", "int", false);//資料類別(1:FILE TO TMP;2:TMP TO DB)
                        dr_Temp["DATASOURCE"] = CAAComm.GetValueSetParameter(arl_Return[3].ToString(), "string", false);//匯入檔案
                        dr_Temp["STATUS"] = CAAComm.GetValueSetParameter("1", "int", false);//處理狀態(1:正常資料;2:錯誤資料)
                        dr_Temp["CREATEUID"] = CAAComm.GetValueSetParameter(Session["UID"].ToString(), "string", false);
                        dr_Temp["CREATEDATE"] = CAAComm.GetValueSetParameter(d_Now.ToString(), "datetime", false);
                        dr_Temp["UPDATEUID"] = CAAComm.GetValueSetParameter(string.Empty, "string", false);
                        dr_Temp["UPDATEDATE"] = CAAComm.GetValueSetParameter(string.Empty, "string", false);
                    }

                    dt_Temp.Rows.Add(dr_Temp);
                }

                #endregion

                #region 檢查不正確

                else
                {
                    DataRow dr_Temp = dt_Temp.NewRow();

                    string s_ErrorMsg = string.Empty;
                    s_ErrorMsg = arl_ConditionReturn[1].ToString().Replace("<br/>", string.Empty);

                    dr_Temp["ID"] = dt_Temp.Rows.Count + 1;//ID
                    dr_Temp["STATUS"] = CAAComm.GetValueSetParameter("2", "int", false);//處理狀態(1:正常資料;2:錯誤資料)
                    dr_Temp["DATASOURCE"] = CAAComm.GetValueSetParameter(arl_Return[3].ToString(), "string", false);//匯入檔案
                    dr_Temp["MEMO"] = s_ErrorMsg;//說明
                    dr_Temp["CREATEUID"] = CAAComm.GetValueSetParameter(Session["UID"].ToString(), "string", false);
                    dr_Temp["CREATEDATE"] = CAAComm.GetValueSetParameter(d_Now.ToString(), "datetime", false);
                    dr_Temp["UPDATEUID"] = CAAComm.GetValueSetParameter(string.Empty, "string", false);
                    dr_Temp["UPDATEDATE"] = CAAComm.GetValueSetParameter(string.Empty, "string", false);

                    dt_Temp.Rows.Add(dr_Temp);
                }

                #endregion
            }

            str.Close();
            str.Dispose();

            #endregion

            #region 連結資料庫

            if (dt_Temp.Rows.Count == 0)
            {
                this.ErrorMsgLabel.Text = "無匯入資料";
                return;
            }
            else
            {
                #region 將資料寫入TempTable

                DataTable dt_Return = bco.FileToTmp(null, Session["UID"].ToString(), dt_Temp);

                #endregion

                #region 計算[總筆數][正常筆數][錯誤筆數]

                int i_Total_Count = 0;//總筆數
                int i_Success_Count = 0;//正常筆數
                int i_Failure_Count = 0;//錯誤筆數

                string s_FilterExpression = string.Empty;

                s_FilterExpression = "STATUS ='1'";//1:正常資料;
                DataRow[] dr_Success = dt_Return.Select(s_FilterExpression);
                if (dr_Success.Length == 1)
                { i_Success_Count = int.Parse(dr_Success[0]["count"].ToString()); }

                s_FilterExpression = "STATUS ='2'";//2:錯誤資料;
                DataRow[] dr_Failure = dt_Return.Select(s_FilterExpression);
                if (dr_Failure.Length == 1)
                { i_Failure_Count = int.Parse(dr_Failure[0]["count"].ToString()); }

                i_Total_Count = i_Success_Count + i_Failure_Count;

                this.UploadStatusPanel1.UploadSum = i_Total_Count;//上傳結果總筆數
                this.UploadStatusPanel1.UploadOK = i_Success_Count;//上傳結果正常筆數
                this.UploadStatusPanel1.UploadNG = i_Failure_Count;//上傳結果錯誤筆數
                this.UploadStatusPanel1.ImportSum = 0;//匯入結果總筆數
                this.UploadStatusPanel1.ImportOK = 0;//匯入結果正常筆數
                this.UploadStatusPanel1.ImportNG = 0;//匯入結果錯誤筆數

                #endregion

                #region 設定控制項

                if ((i_Total_Count == i_Success_Count) &&
                   (i_Failure_Count == 0))
                {
                    this.but_tab2_Import.Enabled = true;//確定匯入
                    this.but_tab2_Error.Enabled = false;//檢視異常
                }

                if (i_Failure_Count > 0)
                {
                    this.but_tab2_Import.Enabled = false;//確定匯入
                    this.but_tab2_Error.Enabled = true;//檢視異常 
                }

                #endregion
            }

            #endregion

            #endregion
        }
        catch (Exception ex)
        {
            WaringLogProcess(ex.Message);
            this.ErrorMsgLabel.Text = ex.Message;
        }
        finally
        {
            #region 設定 TabContainer 的 ActiveTabIndex

            this.TabContainer1.ActiveTabIndex = 1;

            #endregion
        }
    }
Beispiel #3
0
    /// <summary>
    /// BUTTON [確定匯入]鈕
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void but_tab2_Import_Click(object sender, EventArgs e)
    {
        try
        {
            #region 檢查條件

            ArrayList arl_Check_Condition = Check_Condition("BUTTON [確定匯入]");

            #region 如果檢查有誤,則Return

            if (arl_Check_Condition[1].ToString() != string.Empty)
            {
                #region 錯誤訊息

                this.ErrorMsgLabel.Text = arl_Check_Condition[1].ToString();

                #endregion

                return;
            }

            #endregion

            #endregion

            #region 將TempTable的資料寫入正式Table

            #region 傳入參數

            string s_SourcePath = Server.MapPath("..\\") + System.Configuration.ConfigurationManager.AppSettings["UploadPath"] + "CAA\\";
            string s_DestinationPath = Server.MapPath("..\\") + System.Configuration.ConfigurationManager.AppSettings["BackPath"] + "CAA\\";

            ParameterList.Clear();
            ParameterList.Add(Session["UID"].ToString());
            ParameterList.Add(DateTime.Now);
            ParameterList.Add(s_SourcePath);//來源資料路徑
            ParameterList.Add(s_DestinationPath);//目的地資料路徑

            #endregion

            #region 連結資料庫

            BCO.ImportDeclarePO bco = new BCO.ImportDeclarePO(ConntionDB);
            DataTable dt_Return = bco.TmpToDB(null, ParameterList);

            #endregion

            #region 計算[總筆數][正常筆數][錯誤筆數]

            int i_Total_Count = 0;//總筆數
            int i_Success_Count = 0;//正常筆數
            int i_Failure_Count = 0;//錯誤筆數

            string s_FilterExpression = string.Empty;

            s_FilterExpression = "STATUS ='1'";//1:正常資料;
            DataRow[] dr_Success = dt_Return.Select(s_FilterExpression);
            if (dr_Success.Length == 1)
            { i_Success_Count = int.Parse(dr_Success[0]["count"].ToString()); }

            s_FilterExpression = "STATUS ='2'";//2:錯誤資料;
            DataRow[] dr_Failure = dt_Return.Select(s_FilterExpression);
            if (dr_Failure.Length == 1)
            { i_Failure_Count = int.Parse(dr_Failure[0]["count"].ToString()); }

            i_Total_Count = i_Success_Count + i_Failure_Count;

            this.UploadStatusPanel1.ImportSum = i_Total_Count;//匯入結果總筆數
            this.UploadStatusPanel1.ImportOK = i_Success_Count;//匯入結果正常筆數
            this.UploadStatusPanel1.ImportNG = i_Failure_Count;//匯入結果錯誤筆數

            #endregion

            #region 設定控制項

            if ((i_Total_Count == i_Success_Count) &&
               (i_Failure_Count == 0))
            {
                this.but_tab2_Import.Enabled = false;//確定匯入
                this.but_tab2_Error.Enabled = false;//檢視異常
            }

            if (i_Failure_Count > 0)
            {
                this.but_tab2_Import.Enabled = false;//確定匯入
                this.but_tab2_Error.Enabled = true;//檢視異常
            }

            #endregion

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