Ejemplo n.º 1
0
    /// <summary>
    /// BUTTON [匯出]鈕

    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void but_GetOnHandResult_Click(object sender, EventArgs e)
    {
        DataTable dtReturn = new DataTable();
        System.Text.StringBuilder sb = new System.Text.StringBuilder();
        ArrayList ParameterList = new ArrayList();
        try
        {
            #region 檢查必填欄位
            BCO.CRMCommon CRMComm = new BCO.CRMCommon();
            sb.Append(CRMComm.Check_MustFillIN_Column(this.slp_ST_ACCEPT_DATE.Text, "[門市進貨日]為必填欄位", "0"));
            if (sb.ToString().Length > 0)
            {
                throw new Exception(sb.ToString().Trim());
            }
            #endregion

            #region 從資料庫取得資料

            ParameterList.Add(slp_ST_ACCEPT_DATE.Text);
            ParameterList.Add(Session["UID"].ToString());
            PIC.VDS2G.BSM.ALO.MaintainStAccept alo_bco = new PIC.VDS2G.BSM.ALO.MaintainStAccept(ConntionDB);
            //ALOBCO.MaintainStAccept alo_bco = new ALOBCO.MaintainStAccept();

            dtReturn = alo_bco.QueryOnHandResult(ParameterList);
            if (dtReturn == null || dtReturn.Rows.Count < 1)
            {
                throw new Exception("查無資料,門市進貨日[" + slp_ST_ACCEPT_DATE.Text + "]無手開單轉單");
            }

            #endregion

            #region 匯出資料
            string[] NameArr = { "類別", "店數", "品項數", "總冊數" };
            for (int i = 0; i < NameArr.Length; i++)
            {
                dtReturn.Columns[i].ColumnName = NameArr[i];
            }
            string FileCode = "CRM17_手開單轉單品項_" + slp_ST_ACCEPT_DATE.Text.Replace("/", "") + ".xls";
            //ExcelExportHelper.RenderDataTableToExcel(dt_Return, FileCode);
            WriteToXls2(dtReturn, FileCode);

            #endregion

        }
        catch (Exception ex)
        {
            WaringLogProcess(ex.Message);
            this.ErrorMsgLabel.Text = ex.Message;
        }
        finally { }
    }
Ejemplo n.º 2
0
    private string CheckPage(object sender)
    {
        BCO.CRMCommon CRMComm = new BCO.CRMCommon();
        System.Text.StringBuilder sb = new System.Text.StringBuilder();
        Button but_Click = (Button)sender;

        #region 檢查必填欄位

        sb.Append(CRMComm.Check_MustFillIN_Column(this.slp_ST_ACCEPT_DATE.Text, "[門市進貨日]為必填欄位", "0"));
        if (but_Click.Text == "匯出")
        { sb.Append(CRMComm.Check_MustFillIN_Column(this.txt_Out_FileName.Text, "[匯出檔名]為必填欄位", "0")); }

        #endregion

        #region 結束欄位一定要大於或等於開始欄位

        sb.Append(CRMComm.Check_End_GreaterThan_Begin(this.slp_CHAN_NO_B.Text, this.slp_CHAN_NO_E.Text, "[通路]結束欄位一定要大於或等於開始欄位", "0"));
        sb.Append(CRMComm.Check_End_GreaterThan_Begin(this.slp_STORE_B.Text, this.slp_STORE_E.Text, "[門市]結束欄位一定要大於或等於開始欄位", "0"));

        #endregion

        #region 檢查長度 2009-06-17 cyhsu
        if (GetStringLen(txt_Out_FileName.Text) > txt_Out_FileName.MaxLength)
        { sb.Append("[匯出檔案]欄位輸入資料長度過長\\r\\n"); }
        #endregion

        return sb.ToString();
    }