コード例 #1
0
ファイル: CAA32.cs プロジェクト: ChiangHanLung/PIC_VDS
        /// <summary>
        /// CAA32 頁籤=一二代立沖帳(回復)
        /// </summary>
        /// <param name="ParameterList"></param>
        /// <returns></returns>
        public DataTable CAA32_1(ArrayList ParameterList)
        {
            #region 宣告變數

            BCO.CAACommon CAAComm = new BCO.CAACommon();
            ArrayList arl_ReportService = new ArrayList();
            DataTable dt_Return = new DataTable();

            #endregion

            #region 傳入參數

            arl_ReportService.Clear();
            arl_ReportService.Add(CAAComm.GetValueSetParameter(ParameterList[0].ToString(), "string", false));//[單號](0)
            arl_ReportService.Add(CAAComm.GetValueSetParameter(ParameterList[1].ToString(), "date", false));//[沖帳日期]起(1)
            arl_ReportService.Add(CAAComm.GetValueSetParameter(ParameterList[2].ToString(), "date", false));//[沖帳日期]迄(2)
            arl_ReportService.Add(CAAComm.GetValueSetParameter(ParameterList[3].ToString(), "string", false));//[來源別](3)
            arl_ReportService.Add(CAAComm.GetValueSetParameter(ParameterList[4].ToString(), "string", false));//[店號](4)
            arl_ReportService.Add(CAAComm.GetValueSetParameter(ParameterList[5].ToString(), "string", false));//[結帳統編](5)
            arl_ReportService.Add(CAAComm.GetValueSetParameter(ParameterList[6].ToString(), "string", false));//[統一編號](6)
            arl_ReportService.Add(CAAComm.GetValueSetParameter(ParameterList[7].ToString(), "string", false));//[利潤中心]起(7)
            arl_ReportService.Add(CAAComm.GetValueSetParameter(ParameterList[8].ToString(), "string", false));//[利潤中心]迄(8)
            arl_ReportService.Add(CAAComm.GetValueSetParameter(ParameterList[9].ToString(), "string", false));//[營業所]起(9)
            arl_ReportService.Add(CAAComm.GetValueSetParameter(ParameterList[10].ToString(), "string", false));//[營業所]迄(10)
            arl_ReportService.Add(CAAComm.GetValueSetParameter(ParameterList[11].ToString(), "string", false));//[營業人員](11)
            arl_ReportService.Add(CAAComm.GetValueSetParameter(ParameterList[12].ToString(), "string", false));//[帳務人員](12)
            arl_ReportService.Add(CAAComm.GetValueSetParameter(ParameterList[13].ToString(), "string", false));//[建立人員](13)

            #endregion

            #region 連結資料庫

            BCO.CAA32_BCO bco = new BCO.CAA32_BCO(ConntionDB);
            dt_Return = bco.QueryPreviousRPT(arl_ReportService);

            #endregion

            #region 檢查回傳資料

            if (dt_Return.Rows.Count == 0)
            { throw new Exception("查無資料"); }

            #endregion

            return dt_Return;
        }
コード例 #2
0
ファイル: CAA321.aspx.cs プロジェクト: ChiangHanLung/PIC_VDS
    bool bStop = false; //鎖定檢查沒過 就要中止程式執行
    protected void btnUndo_Click(object sender, EventArgs e)
    {


        CAAModel.CAA32_BCO bco = new CAAModel.CAA32_BCO(ConntionDB);

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

        string WASHMONTH = ((Label)grdRow.FindControl("lblWASHMONTH")).Text;
        string SECOND_NO = ((Label)grdRow.FindControl("lblSECOND_NO")).Text;

        //檢查CAA11是否已被鎖定,CAA11沖帳時不可執行回復動作
        byte[] btGuid = Guid.NewGuid().ToByteArray();//同一個時間點 同一台電腦 仍然可能會出現同一個GUID
        Random rnd = new Random();
        long lGuid = BitConverter.ToInt64(btGuid, 0) + rnd.Next(1000);


        ViewState["LockID"] = lGuid.ToString();
        ViewState["LockTime"] = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
        ScriptManager.RegisterStartupScript(this, this.GetType(), "RegLockID", "CAA11LockID = '" + lGuid.ToString() + "';", true);
        CheckLock();

        if (bStop == false)
        {       
            try
            {
                ParameterList.Clear();
                ParameterList.Add(WASHMONTH);
                ParameterList.Add(SECOND_NO);
                ParameterList.Add(Session["UID"].ToString());

                ArrayList arl_Return = bco.UndoPreData(ParameterList, ConntionDB);

                if (arl_Return[0].ToString() == "FALSE")
                {
                    ErrorMsgLabel.Text = arl_Return[1].ToString();
                }
                else
                {
                    ErrorMsgLabel.Text = "回復成功!";
                    DataBind();
                }

            }
            catch (Exception ex)
            {
                ErrorMsgLabel.Text = ex.Message;
            }
            finally 
            {
                DeleteControlChk(ViewState["LockID"].ToString(), Session["UID"].ToString(), ViewState["LockTime"].ToString());                
            }
        }

    }
コード例 #3
0
ファイル: CAA321.aspx.cs プロジェクト: ChiangHanLung/PIC_VDS
    protected void DataBind()
    {
        CAAModel.CAACommon CAAComm = new CAAModel.CAACommon();


        #region 傳入參數

        ParameterList.Clear();
        ParameterList.Add(CAAComm.GetValueSetParameter(this.txt_3_Second_No.Text, "string", false));//[單號]起
        ParameterList.Add(CAAComm.GetValueSetParameter(this.SLP_3_WASHDATE_RANGE.StartDate, "date", false));//[沖帳日期]起
        ParameterList.Add(CAAComm.GetValueSetParameter(this.SLP_3_WASHDATE_RANGE.EndDate, "date", false));//[沖帳日期]迄
        ParameterList.Add(CAAComm.GetValueSetParameter(this.slp_SOURCE_TYPE.Text, "string", false));//[來源別]
        ParameterList.Add(CAAComm.GetValueSetParameter(this.slp_3_STORE_ID.Text, "string", false));//[店號]
        ParameterList.Add(CAAComm.GetValueSetParameter(this.txt_3_RFNO.Text, "string", false));//[結帳統編]
        ParameterList.Add(CAAComm.GetValueSetParameter(this.txt_3_VOUCH_RFNO.Text, "string", false));//[統一編號]
        ParameterList.Add(CAAComm.GetValueSetParameter(this.slp_PROFIT_NO_B.Text, "string", false));//[利潤中心]起
        ParameterList.Add(CAAComm.GetValueSetParameter(this.slp_PROFIT_NO_E.Text, "string", false));//[利潤中心]迄
        ParameterList.Add(CAAComm.GetValueSetParameter(this.slp_Z_O_B.Text, "string", false));//[營業所]起
        ParameterList.Add(CAAComm.GetValueSetParameter(this.slp_Z_O_E.Text, "string", false));//[營業所]迄
        ParameterList.Add(CAAComm.GetValueSetParameter(this.slp_3_SAL_ID.Text, "string", false));//[營業人員]
        ParameterList.Add(CAAComm.GetValueSetParameter(this.SLP_3_AC_ID.Text, "string", false));//[帳務人員]
        ParameterList.Add(CAAComm.GetValueSetParameter(this.SLP_3_CREATEUID.Text, "string", false));//[建立人員]
        ParameterList.Add(CAAComm.GetValueSetParameter((this.txt_RowCountLimit.Text == string.Empty) ? "100" : (int.Parse(this.txt_RowCountLimit.Text) < 0) ? "100" : this.txt_RowCountLimit.Text, "int", false));//[筆數]

        #endregion

        #region 連結資料庫

        DataTable dt_Return = new DataTable();
        CAAModel.CAA32_BCO bco = new CAAModel.CAA32_BCO(ConntionDB);
        dt_Return = bco.QueryPreviousData(ParameterList);

        #endregion

        #region 資料與GridView繫結

        //抓取本頁初次登記的時間
        string SessionIDName = "CAA321_" + PageTimeStamp.Value;

        Session["SessionID"] = SessionIDName;
        Session[SessionIDName] = dt_Return;

        this.gv_QueryResult.DataSource = dt_Return;
        this.gv_QueryResult.PageSize = (this.txt_Pagesize.Text == string.Empty) ? 20 : (int.Parse(this.txt_Pagesize.Text) < 0) ? 20 : int.Parse(this.txt_Pagesize.Text);
        this.gv_QueryResult.PageIndex = 0;
        this.gv_QueryResult.DataBind();

        #endregion

        #region 將Key值存到Session中

        //ArrayList arl_Key = new ArrayList();
        //foreach (DataRow drRow in dt_Return.Rows)
        //{ arl_Key.Add(drRow["INV_NO"].ToString()); }

        //Session["CAA322_SortKey" + this.PageTimeStamp.Value] = arl_Key;

        #endregion

        #region 檢查回傳資料

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

        #endregion
    
    }
コード例 #4
0
ファイル: CAA321.aspx.cs プロジェクト: ChiangHanLung/PIC_VDS
    private void Export_Excel(ArrayList ParameterList)
    {
        try
        {

            CAAModel.CAA32_BCO BCO = new CAAModel.CAA32_BCO(ConntionDB);
            // 讀取 Excel 資料    

            DataTable dt = BCO.QueryExportFile(ParameterList);
            if (dt.Rows.Count == 0)
            {
                lblError.Text = "查無資料";
                return;
            }
            ExcelXmlWorkbook book = new ExcelXmlWorkbook();

            Worksheet sheet0 = book[0];

            AddSheetData(ref sheet0, "前期餘額匯出", dt);

            //設定輸出檔名
            string s_FileName =
            s_FileName = HttpUtility.UrlEncode("CAA321_" + ParameterList[0].ToString() + ParameterList[1].ToString() + ".XLS", System.Text.Encoding.UTF8);

            //File download
            Response.Charset = "big5";
            Response.ContentType = "application/x-excel;charset='utf-8'";
            Response.AddHeader("content-disposition", "attachment; filename=" + s_FileName);//excel檔名
            System.IO.MemoryStream stream = new System.IO.MemoryStream();
            book.Export(stream);
            string producedExcel = GetStringFromMemoryStream(stream);
            stream.Close();
            Response.Write(producedExcel);
            Response.Flush();
            Response.End();
        }
        catch (Exception ex)
        {
            this.lblError.Text = ex.ToString();
        }
        finally { }
    }
コード例 #5
0
ファイル: CAA321.aspx.cs プロジェクト: ChiangHanLung/PIC_VDS
    private void TempDataToDataBase()
    {
        #region
        ErrorMsgLabel.Text = "";
        try
        {
            ArrayList arl_Return = null;

            CAAModel.CAA32_BCO BCO = new CAAModel.CAA32_BCO(ConntionDB);

            arl_Return = BCO.TmpToDB(Session["UID"].ToString(), ConntionDB);

            if (arl_Return[0].ToString() == "TRUE")
            {
                #region 設定 UploadStatusPanel 的值
                //上傳結果
                //this.UploadStatusPanel1.UploadSum = 0;
                //this.UploadStatusPanel1.UploadOK = 0;
                //this.UploadStatusPanel1.UploadNG = 0;
                //匯入結果
                this.UploadStatusPanel1.ImportSum = int.Parse(arl_Return[1].ToString());
                this.UploadStatusPanel1.ImportOK = int.Parse(arl_Return[2].ToString());
                this.UploadStatusPanel1.ImportNG = int.Parse(arl_Return[3].ToString());
                #endregion
                btn_Unusual_Report.Enabled = false;
                if ((int)arl_Return[1] == (int)arl_Return[2])
                {
                    ErrorMsgLabel.Text = "[確定匯入]成功,資料已匯入完成。";

                }
                else if ((int)arl_Return[1] != (int)arl_Return[2])
                {
                    ErrorMsgLabel.Text = "[確定匯入]失敗,請檢視異常!";
                    btn_Unusual_Report.Enabled = true;
                }
            }
            else
            {
                ErrorMsgLabel.Text = "[確定匯入]發生錯誤!" + arl_Return[1].ToString();
                btn_Unusual_Report.Enabled = false;
            }
        }
        catch (Exception ex)
        {
            this.ErrorMsgLabel.Text = ex.Message;
            btn_Unusual_Report.Enabled = false;
        }
        finally
        {
            this.btn_File_To_Temp.Enabled = true;
            this.btn_Temp_To_DB.Enabled = false;

            //解除CAA11鎖定
            DeleteControlChk(ViewState["LockID"].ToString(), Session["UID"].ToString(), ViewState["LockTime"].ToString());                
        }
        #endregion
    }
コード例 #6
0
ファイル: CAA321.aspx.cs プロジェクト: ChiangHanLung/PIC_VDS
    private void ClientFileToServerTemp()
    {
        string s_AP_FileName;
        ErrorMsgLabel.Text = "";
        if (FileUpload1.FileName != "")
        {
            try
            {
                //設定頁面狀態
                this.ErrorMsgLabel.Text = "";

                System.Threading.Thread.Sleep(2000);
                string s_UploadPath = string.Empty;
                string s_BackPath = string.Empty;

                ArrayList arl_FileUpload_Return = null;
                ArrayList arl_FileToTmp_Return = null;
                System.Text.StringBuilder sb = new System.Text.StringBuilder();
                CAAModel.CAA32_BCO BCO = new CAAModel.CAA32_BCO(ConntionDB);

                //上傳檔案到AP端
                //取得要上傳的路徑
                s_UploadPath = Server.MapPath("..\\") + System.Configuration.ConfigurationManager.AppSettings["UploadPath"] + "\\CAA\\";

                string strOrg_FileName = FileUpload1.FileName;//原始的檔名

                arl_FileUpload_Return = BCO.FileUpload(s_UploadPath, this.FileUpload1, Session["UID"].ToString());


                if (arl_FileUpload_Return[0].ToString() == "FALSE")//檔案上傳至AP端錯誤
                {
                    sb.Append("檔案上傳至AP端錯誤<br/>");

                    this.ErrorMsgLabel.Text = sb.ToString();

                    //清空 UploadStatusPanel 的值

                    //上傳結果
                    this.UploadStatusPanel1.UploadSum = 0;
                    this.UploadStatusPanel1.UploadOK = 0;
                    this.UploadStatusPanel1.UploadNG = 0;

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

                    return;
                }
                else if (arl_FileUpload_Return[0].ToString() == "TRUE")//檔案上傳至AP端正常
                {
                    // 讀取 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;HDR=Yes;IMEX=1;'";
                        oleConnection = new OleDbConnection(connString);
                        oleConnection.Open();
                        OleDbCommand oleCommand = new OleDbCommand("SELECT * FROM [Sheet1$] where 序號 is not null", oleConnection);
                        OleDbDataAdapter oleAdapter = new OleDbDataAdapter(oleCommand);
                        oleAdapter.Fill(ds_Excel);

                        //請注意如果EXCEL檔欄位有值,但到DB卻沒有資料
                        //請修改,機碼 HKEY_LOCAL_MACHINE\Software\Microsoft\Jet\4.0\Engines\Excel\TypeGuessRows 值
                        //預設是 8, 表示會先讀取前 8 列來決定每一個欄位的型態, 所以如果前 8 列的資料都是數字, 到了第 9 列以後出現的文字資料都會變成 null
                        //如果要解決這個問題, 只要把 TypeGuessRows 機碼值改成 0

                    }
                    catch (Exception ex)
                    {
                        this.ErrorMsgLabel.Text = ex.Message;
                    }
                    finally
                    {
                        if (oleConnection != null)
                        {
                            oleConnection.Close();
                            oleConnection.Dispose();
                        }
                    }

                    //將檔案匯入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, Session["UID"].ToString(), ConntionDB, strOrg_FileName);


                    if (arl_FileToTmp_Return[0].ToString() == "FALSE")
                    {
                        ErrorMsgLabel.Text = arl_FileToTmp_Return[1].ToString();
                        this.btn_Temp_To_DB.Enabled = false;
                    }
                    else if (arl_FileToTmp_Return[0].ToString() == "TRUE")
                    {
                        // 將資料從 UploadPath 移至 BackPath
                        s_BackPath = Server.MapPath("..\\") + System.Configuration.ConfigurationManager.AppSettings["BackPath"] + "\\CAA\\";

                        // 檢查檔案路徑是否存在,如不存在新增相關路徑
                        if (Directory.Exists(s_BackPath) == false)
                        {
                            try
                            {
                                Directory.CreateDirectory(s_BackPath);
                            }
                            catch (Exception except)
                            {
                                throw new System.Exception(String.Format("不能建立文件目錄{0},錯誤訊息為{1}", s_BackPath, except.Message));
                            }
                        }

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

                        this.btn_Temp_To_DB.Enabled = false;
                        this.btn_Unusual_Report.Enabled = false;

                        // 將結果顯示在 UploadStatusPanel 中
                        //上傳結果
                        this.UploadStatusPanel1.UploadSum = ((int)arl_FileToTmp_Return[1]);
                        this.UploadStatusPanel1.UploadOK = ((int)arl_FileToTmp_Return[2]);
                        this.UploadStatusPanel1.UploadNG = ((int)arl_FileToTmp_Return[3]);
                        if ((int)arl_FileToTmp_Return[1] == 0)
                        {
                            ErrorMsgLabel.Text = "[匯入]失敗,請檢查匯入檔案是否為空檔!";
                            this.btn_Temp_To_DB.Enabled = false;
                            this.btn_Unusual_Report.Enabled = false;
                        }
                        else if ((int)arl_FileToTmp_Return[1] == (int)arl_FileToTmp_Return[2])
                        {
                            ErrorMsgLabel.Text = "[匯入]成功,請繼續[執行匯入]的功能。";
                            this.btn_Temp_To_DB.Enabled = true;
                            this.btn_Unusual_Report.Enabled = false;
                        }
                        else if ((int)arl_FileToTmp_Return[1] != (int)arl_FileToTmp_Return[2])
                        {
                            ErrorMsgLabel.Text = "[匯入]失敗,請檢視異常!";
                            this.btn_Temp_To_DB.Enabled = false;
                            this.btn_Unusual_Report.Enabled = true;
                        }
                    }

                }

            }
            catch (Exception ex)
            {
                this.ErrorMsgLabel.Text = ex.Message;
            }
        }
    }
コード例 #7
0
    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());
                ParameterList.Add("");
                ParameterList.Add("2");

                #endregion

                #region 連結資料庫

                CAAModel.CAA32_BCO BCO = new CAAModel.CAA32_BCO(ConntionDB);
                DataTable dt_Return = BCO.QueryTmp(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 { }
    }