Exemplo n.º 1
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("2");

                #endregion

                #region 連結資料庫

                VAMModel.ProcessVAMMonthClose BCO = new VAMModel.ProcessVAMMonthClose(ConntionDB);
                DataTable dt_Return = BCO.QueryItemTmp(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 { }
    }
Exemplo n.º 2
0
    private void TempDataToDataBase()
    {
        #region
        ErrorMsgLabel.Text = "";
        try
        {
            ArrayList arl_Return = null;

            VAMModel.ProcessVAMMonthClose BCO = new VAMModel.ProcessVAMMonthClose(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;
                btnExportUnusual.Enabled = false;
                if (int.Parse(arl_Return[1].ToString()) == int.Parse(arl_Return[2].ToString()))
                {
                    ErrorMsgLabel.Text = "[確定匯入]成功,資料已匯入完成。";

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

        }
        #endregion
    }
Exemplo n.º 3
0
    private void ExportUnusual_Excel()
    {
        try
        {
            ParameterList.Clear();
            ParameterList.Add(Session["UID"].ToString());
            ParameterList.Add("2");
                                                                        
            BCO.ProcessVAMMonthClose bco = new BCO.ProcessVAMMonthClose(ConntionDB);
            DataTable dt_Return = bco.QueryTmp(ParameterList);
            if (dt_Return.Rows.Count == 0)
            {
                this.ErrorMsgLabel.Text = "查無資料";
                return;
            }
            ExcelXmlWorkbook book = new ExcelXmlWorkbook();

            Worksheet sheet0 = book[0];

            AddSheetData(ref sheet0, "Sheet1", dt_Return);

            //設定輸出檔名
            string s_FileName =
            s_FileName = HttpUtility.UrlEncode("VAM03_供應商合約補收異常報表.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)
        {
            ErrorMsgLabel.Text = ex.ToString();
        }
        finally { }
    }
Exemplo n.º 4
0
    protected void SetUnMonthClose()
    {
        try
        {
            BCO.ProcessVAMMonthClose bco = new BCO.ProcessVAMMonthClose(ConntionDB);
            if (this.rdoCntType1.Checked)
                bco.UnCheckMonthAgm(this.SLP_YearMonth1.Text.Trim());
            else
                bco.UnCheckMonthSKU(this.SLP_YearMonth1.Text.Trim());

            ErrorMsgLabel.Text = "月結解除完成";

        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
        finally
        {
            this.btnSet.Enabled = true;
            this.btnUnSet.Enabled = true;
            this.btnQVander.Enabled = true;
            this.btnQVanderCont.Enabled = true;
        }
    }
Exemplo n.º 5
0
    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();
                VAMModel.ProcessVAMMonthClose BCO = new VAMModel.ProcessVAMMonthClose(ConntionDB);

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

                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"] + "\\VAM\\";

                        // 檢查檔案路徑是否存在,如不存在新增相關路徑
                        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;
                        this.btnExportUnusual.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;
                            this.btnExportUnusual.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;
                            this.btnExportUnusual.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;
                            this.btnExportUnusual.Enabled = true;
                        }
                    }

                }

            }
            catch (Exception ex)
            {
                this.ErrorMsgLabel.Text = ex.Message;
            }
        }
    }
Exemplo n.º 6
0
    protected void SetMonthClose()
    {
        try
        {
            this.btnSet.Enabled = false;
            this.btnUnSet.Enabled = false;
            this.btnQVander.Enabled = false;
            this.btnQVanderCont.Enabled = false;
            BCO.ProcessVAMMonthClose bco = new BCO.ProcessVAMMonthClose(ConntionDB);
            string V_MSG, V_STATUS_CREATEUID;
            DateTime D_STATUS_CREATEDATE;
            if (this.rdoCntType1.Checked)
            {
                bco.CloseMonthAgm(this.SLP_YearMonth1.Text.Trim(), Session["UID"].ToString(), out V_MSG, out V_STATUS_CREATEUID, out D_STATUS_CREATEDATE);                
            }
            else
            {
                bco.CloseMonthSKU(this.SLP_YearMonth1.Text.Trim(), Session["UID"].ToString(), out V_MSG, out V_STATUS_CREATEUID, out D_STATUS_CREATEDATE);
            }

            if (V_MSG != "")
                ErrorMsgLabel.Text = V_MSG + ",結帳人員:" + V_STATUS_CREATEUID + ",結帳時間:" + D_STATUS_CREATEDATE.ToString() + "。";
            else
                ErrorMsgLabel.Text = "交易結轉完成";

        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
        finally
        {
            this.btnSet.Enabled = true;
            this.btnUnSet.Enabled = true;
            this.btnQVander.Enabled = true;
            this.btnQVanderCont.Enabled = true;
        }
    }
Exemplo n.º 7
0
    protected void SetUnCloseItemTrace()
    {
        try
        {
            BCO.ProcessVAMMonthClose bco = new BCO.ProcessVAMMonthClose(ConntionDB);

            ArrayList ParameterList = new ArrayList();
            ParameterList.Clear();
            ParameterList.Add(Session["UID"].ToString());
            ParameterList.Add(this.SLP_Item.Text.Trim());        //品號
            ParameterList.Add(this.SLP_ItemPeriod.Text.Trim());  //期別
            ParameterList.Add(this.slp_YearMonth_B.Text.Trim()); //解除結帳年月_起
            ParameterList.Add(this.slp_YearMonth_E.Text.Trim()); //解除結帳年月_迄

            string resault = bco.UnCloseItemTrace(ParameterList);

            ErrorMsgLabel.Text = resault;

        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
        finally
        {
            btnUnSetItemTrace.Enabled = true;
        }
    }
Exemplo n.º 8
0
    protected void btnUnSetItemTrace_Click(object sender, EventArgs e)
    {
        try
        {
            this.ErrorMsgLabel.Text = "";
            if (this.SLP_Item.TextBox_Code.Text.Trim() == "" || this.SLP_ItemPeriod.TextBox_Code.Text.Trim() == "" || slp_YearMonth_B.Text.Trim() == "" ||slp_YearMonth_B.Text.Trim() == "")
            {
                this.ErrorMsgLabel.Text = "品號、期別、結帳年月起、結帳年月迄 皆為必須輸入 !!";
                return;
            }
            else
            {
                string sResult;
                VAMModel.ProcessVAMMonthClose BCO = new VAMModel.ProcessVAMMonthClose(ConntionDB);
                ArrayList ParameterList = new ArrayList();
                ParameterList.Clear();
                ParameterList.Add(Session["UID"].ToString());
                ParameterList.Add(this.SLP_Item.Text.Trim());        //品號
                ParameterList.Add(this.SLP_ItemPeriod.Text.Trim());  //期別
                ParameterList.Add(this.slp_YearMonth_B.Text.Trim()); //解除結帳年月_起
                ParameterList.Add(this.slp_YearMonth_E.Text.Trim()); //解除結帳年月_迄

                string resault = BCO.ItemCloseYN(ParameterList);

                if (resault == "0")
                {
                    ErrorMsgLabel.Text = "指定品項沒有補收資料,請重新輸入!";
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "if (confirm('是否確定執行商品合約補收月結解除?')){this.disabled=true;"
                   + "document.getElementById('" + this.btnSet.ClientID + "').disabled=true;"
                   + "document.getElementById('" + this.btnUnSet.ClientID + "').disabled=true;"
                   + "document.getElementById('" + this.btnQVander.ClientID + "').disabled=true;"
                   + "document.getElementById('" + this.btnQVanderCont.ClientID + "').disabled=true;"
                   + "__doPostBack('UnCloseItemTrace','');}", true);
                }
            }

        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
        finally
        {
            this.btnSet.Enabled = true;
            this.btnUnSet.Enabled = true;
            this.btnQVander.Enabled = true;
            this.btnQVanderCont.Enabled = true;
        }


    }
Exemplo n.º 9
0
    private void TransToDB()
    {
        #region
        ErrorMsgLabel.Text = "";
        try
        {
            ArrayList arl_Return = null;

            VAMModel.ProcessVAMMonthClose BCO = new VAMModel.ProcessVAMMonthClose(ConntionDB);

            arl_Return = BCO.CloseMonthSKU_TRACE(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.UploadStatusPanel2.ImportSum = int.Parse(arl_Return[1].ToString());
                this.UploadStatusPanel2.ImportOK = int.Parse(arl_Return[2].ToString());
                this.UploadStatusPanel2.ImportNG = int.Parse(arl_Return[3].ToString());
                #endregion
                btnErrReport.Enabled = false;
                btnExpErrReport.Enabled = false;
                if (int.Parse(arl_Return[1].ToString()) == int.Parse(arl_Return[2].ToString()))
                {
                    ErrorMsgLabel.Text = "[確定匯入]成功,單品月結已執行完畢。";

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

        }
        #endregion
    }
Exemplo n.º 10
0
    protected void SetUnMonthCloseTrace()
    {
        try
        {
            BCO.ProcessVAMMonthClose bco = new BCO.ProcessVAMMonthClose(ConntionDB);
            
            ArrayList ParameterList = new ArrayList();
            ParameterList.Clear();
            ParameterList.Add(Session["UID"].ToString());
            ParameterList.Add(this.SLP_YearMonth2.Text.Trim()); //解除結帳年月
            ParameterList.Add(this.SLP_VendorBase1.Text.Trim()); //供應商編號

            string resault =bco.UnCheckMonthTrace(ParameterList);

            ErrorMsgLabel.Text = resault;

        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
        finally
        {
            btnUnSetTrace.Enabled = true;
        }
    }