public string GiftItemName(string Code,
                               string ITEM,
                               string PERIOD
                               )
    {
        string Name = "";
        string ConnectionDBStr = ((DatabaseSettings)ConfigurationManager.GetSection("dataConfiguration")).DefaultDatabase;
        MaintainGift bcoGift = new MaintainGift(ConnectionDBStr);

        if (Code != "")
        {
            ArrayList ParameterList = new ArrayList();

            ParameterList.Clear();
            ParameterList.Add(Code);
            ParameterList.Add(ITEM);
            ParameterList.Add(PERIOD);

            DataTable dt = bcoGift.QueryUnionItemForSLP(ParameterList);
            
            Name = ((dt.Rows.Count > 0) ? dt.Rows[0]["VIRTUAL_NAME"].ToString() : "查無資料");
        }

        return Name;
    }
Example #2
0
 //檢查配本了沒
 private int CheckDis(string strITEM, string strPERIOD, string strVIRTUAL_CODE)
 {
     ParameterList.Clear();
     ParameterList.Add(strITEM);
     ParameterList.Add(strVIRTUAL_CODE);
     ParameterList.Add(strPERIOD);
     BCO.MaintainGift bcoGift = new BCO.MaintainGift(ConnectionDB);
     return bcoGift.ChkDis(ParameterList);
 }
Example #3
0
    protected void Btn_PurchaseCard_Click(object sender, EventArgs e)
    {
        string strRootNo = string.Empty;
        string strUrl = string.Empty;
        string strItem = this.SLP_SKU1.Text;
        string strPeriod = this.SLP_ItemPeriod1.Text;

        #region 取得Root No決定連結 採購卡or圖書採購卡

        BCO.MaintainGift bcoGift = new BCO.MaintainGift(ConnectionDB);

        DataTable dt = new DataTable();

        dt = bcoGift.GetItemDataByItem(this.getParameterList());

        //品號資料check
        if (dt == null || (dt != null && dt.Rows.Count <= 0))
        {
            ErrorMsgLabel.Text = "品號資料錯誤";
            return;
        }

        strRootNo = dt.Rows[0]["ROOT_NO"].ToString();

        #endregion

        #region 連結 採購卡or圖書採購卡

        if (strRootNo == "1") //雜誌
        {
            ParameterList.Clear();
            SQLHelper.SQLWhere(ref ParameterList, DbType.VarNumeric, "M.ENABLE", 1, "=", "and");
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "ROWNUM", "2", "<=", "and");
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "I.ITEM", SLP_SKU1.Text, "=", "and");
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "M.PERIOD", SLP_ItemPeriod1.Text, "=", "and");
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "I.MANUFACTURE", "", "=", "and");
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "I.PUBLISH_TYPE", "", "=", "and");
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "M.CREATEUID", "", "=", "and");
            SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "M.PLAN_ACCEPT_DATE", "", ">=", "and");
            SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "M.PLAN_ACCEPT_DATE", "", "<=", "and");
            SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "M.PLAN_PUBLISH_DATE", "", ">=", "and");
            SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "M.PLAN_PUBLISH_DATE", "", "<=", "and");
            MaintainPurchaseCard bco = new MaintainPurchaseCard(ConnectionDB);
            DataTable Dt = bco.QueryPurchaseCardByFind_1(ParameterList);
            string ID = "";
            if (Dt.Rows.Count > 0)
            {
                DataRow[] dr = Dt.Select("1=1", "createdate desc");
                ID = dr[0]["ID"].ToString();
                strUrl = Application["AppSite_RootDir"] + "MKT/MKT052.aspx?Code=MKT05&ID=" + ID;
                //開啟[採購卡維護], 預設進入新增模式,並帶入品號&期別作為預設條件
                ScriptManager.RegisterStartupScript(this.upButton, typeof(UpdatePanel), "MKT052", "AddIFrameTab('採購卡維護','" + strUrl + "')", true);
            }
            else
                ScriptManager.RegisterClientScriptBlock(this.upButton, typeof(UpdatePanel), "", "if (confirm('該品項尚未開立採購卡,是否進入採購卡新增畫面?')){this.disabled=true;__doPostBack('','GoInsert05');}", true);
        }
        else if (strRootNo == "2")//圖書
        {
            ParameterList.Clear();
            SQLHelper.SQLWhere(ref ParameterList, DbType.VarNumeric, "M.ENABLE", 1, "=", "and");
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "ROWNUM", "2", "<=", "and");
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "I.ITEM", SLP_SKU1.Text, "=", "and");
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "I.MANUFACTURE", "", "=", "and");
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "I.PATTERN_NO", "", "=", "and");
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "M.COMMODITY_LEVEL", "", "=", "and");
            SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "M.PLAN_ACCEPT_DATE", "", ">=", "and");
            SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "M.PLAN_ACCEPT_DATE", "", "<=", "and");
            SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "M.PLAN_PUBLISH_DATE", "", ">=", "and");
            SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "M.PLAN_PUBLISH_DATE", "", "<=", "and");
            MaintainBooksPurchaseCardMain bco = new MaintainBooksPurchaseCardMain(ConnectionDB);
            DataTable Dt = bco.QueryBooksPurchaseCardMainByFind_1(ParameterList);
            string ID = "";
            if (Dt.Rows.Count > 0)
            {
                DataRow[] dr = Dt.Select("1=1", "createdate desc");
                ID = dr[0]["ID"].ToString();
                strUrl = Application["AppSite_RootDir"] + "MKT/MKT062.aspx?Code=MKT06&ID=" + ID;

                //開啟[圖書採購卡維護],預設進入新增模式,並帶入品號作為預設條件
                ScriptManager.RegisterStartupScript(this.upButton, typeof(UpdatePanel), "MKT062", "AddIFrameTab('圖書採購卡維護','" + strUrl + "')", true);
            }
            else
                ScriptManager.RegisterClientScriptBlock(this.upButton, typeof(UpdatePanel), "", "if (confirm('該品項尚未開立圖書採購卡,是否進入圖書採購卡新增畫面?')){this.disabled=true;__doPostBack('','GoInsert06');}", true);
        }

        #endregion
    }
Example #4
0
    private bool CheckApprove()
    {
        int intCnt = 0;
        BCO.MaintainGift bco = new MaintainGift(ConnectionDB);

        ParameterList.Clear();

        ParameterList.Add(SLP_SKU1.Text);
        ParameterList.Add(SLP_ItemPeriod1.Text);

        intCnt = bco.CheckApprove(ParameterList);

        if (intCnt > 0)
        {
            ScriptManager.RegisterStartupScript(Page, this.GetType(), "MKT151.aspx", "alert(' 此品項已有配本記錄,不得編輯! ');", true);
            return false;
        }

        return true;
    }
Example #5
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        try
        {
            RecordGridView();

            DataTable Dt = (DataTable)Session["MKT151_Data" + PageTimeStamp.Value];

            BCO.MaintainGift bco = new BCO.MaintainGift(ConnectionDB);

            bco.UpdateGiftDetail(Dt, null, Session["UID"].ToString());

            //儲存完畢,畫面狀態設為 VIEW
            Session["MKT151_PageMode"] = "VIEW";

            #region 重新BIND GridView

            //Dt.AcceptChanges();

            Dt = bco.QueryGift(this.getParameterList());

            #region 將ID為0的資料刪除,並存入Session

            DataTable Dt_forSession = Dt.Copy();
            DataRow dr = Dt_forSession.Select("ID='0'")[0];
            Dt_forSession.Rows.Remove(dr);
            Session["MKT151_Data" + PageTimeStamp.Value] = Dt_forSession;

            #endregion

            this.GridView1.DataSource = Dt;
            GridView1.PageSize = (TextBoxPagesize.Text == "" || TextBoxPagesize.Text == "0") ? 10 : int.Parse(TextBoxPagesize.Text);
            this.GridView1.PageIndex = 0;
            this.GridView1.DataBind();

            #endregion

            btnEdit.Enabled = true;
            btnSave.Enabled = false;
            btnCancel.Enabled = false;

            Btn_Query.Enabled = true;


        }
        catch (Exception ex)
        {
            if (ex.Message.IndexOf("品號") != -1)
            {
                int i = ex.Message.IndexOf("品號");
                int j = ex.Message.IndexOf("刪除") + 2;
                ErrorMsgLabel.Text = ex.Message.Substring(i, j - i);//"品號:100978、期別:001108、虛擬品號:100978-002之贈品已被其它功能設定,不可刪除";
            }
            else
                ErrorMsgLabel.Text = ex.Message;
        }
    }
Example #6
0
    /// <summary>
    /// 繫結資料 MST
    /// </summary>
    private void databind_Mst()
    {
        #region
        try
        {
            ErrorMsgLabel.Text = "";
            BCO.MaintainGift bco = new BCO.MaintainGift(ConnectionDB);

            ParameterList.Clear();

            ParameterList.Add(this.hiddenID.Value);

            DataTable Dt = bco.QueryGiftByID(ParameterList);

            #region 使用XML放置到前端資料
            MasterOLDData.InnerHtml = Dt.DataSet.GetXml();
            #endregion


        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }

        #endregion
    }//databind_Mst
Example #7
0
        //加入符合此品號/期別的贈品資料
        public DataTable Add_Gift(DataTable dtDetail)
        {
            ArrayList ParameterList = new ArrayList();
            DataTable dtGift = Gift_Schema();
            for (int x = 0; x < dtDetail.Rows.Count; x++)
            {
                string strItem = dtDetail.Rows[x]["ITEM"].ToString();
                string strPeriod = dtDetail.Rows[x]["PERIOD"].ToString();
                MaintainGift Gbco = new MaintainGift(strConn);
                ParameterList.Clear();
                ParameterList.Add(strItem);
                ParameterList.Add(strPeriod);
                ParameterList.Add(-1);
                DataTable dtTmp = Gbco.QueryGift(ParameterList);

                int iAddRow = 0;
                if (dtTmp != null && dtTmp.Rows.Count > 0)
                {
                    for (int i = 0; i < dtTmp.Rows.Count; i++)
                    {
                        if (dtTmp.Rows[i]["ID"].ToString() != "0")
                        {
                            DataRow dr = dtGift.NewRow();
                            dr["ID"] = 1 + i;
                            dr["ITEM"] = strItem;
                            dr["PERIOD"] = strPeriod;
                            dr["VIRTUAL_CODE"] = dtTmp.Rows[i]["VIRTUAL_CODE"].ToString();
                            dr["VIRTUAL_NAME"] = dtTmp.Rows[i]["VIRTUAL_NAME"].ToString();
                            dr["PURCHASE_QTY"] = dtTmp.Rows[i]["PLAN_QTY"].ToString();

                            DataRow[] FindRows = dtDetail.Select("ITEM='" + strItem + "' And PERIOD='" + strPeriod + "'");
                            dr["PLAN_ACCEPT_DATE"] = FindRows[0]["PLAN_ACCEPT_DATE"].ToString();

                            dr["COST"] = 0;
                            dr["MDC_QTY"] = 0;

                            ParameterList.Clear();
                            ParameterList.Add(dtTmp.Rows[i]["VIRTUAL_CODE"].ToString());
                            ParameterList.Add(strPeriod);
                            ParameterList.Add(FindRows[0]["PLAN_ACCEPT_DATE"].ToString());
                            dr["ACCEPT_ACCQTY"] = GetItem_ACCEPT_QTY(ParameterList);
                            dr["MSG"] = "";
                            dtGift.Rows.Add(dr);
                            iAddRow++;
                        }
                    }
                }
            }
            return dtGift;
        }
Example #8
0
    private string GetVIRTUAL_NAME(string strVIRTUAL_CODE)
    {
        ParameterList.Clear();
        ParameterList.Add(strVIRTUAL_CODE);
        ParameterList.Add("");
        ParameterList.Add("");

        PIC.VDS2G.BSM.MKT.MaintainGift bcoGift = new PIC.VDS2G.BSM.MKT.MaintainGift(ConntionDB);

        DataTable dt = bcoGift.QueryUnionItemForSLP(ParameterList);

        string strName = ((dt.Rows.Count > 0) ? dt.Rows[0]["VIRTUAL_NAME"].ToString() : "查無資料");

        return strName;
    }
Example #9
0
    //加入符合此品號/期別的贈品資料
    public static string Add_Gift(string sItem, string sPeriod, string sPageTimeStamp)
    {
        String rtnValue = "";

        if (sItem != "" && sPeriod != "")
        {
            PUR_PUR022 PUR022 = new PUR_PUR022();
            DataTable dtGift = (DataTable)PUR022.Session["PUR02_Gift_" + sPageTimeStamp];
            DataTable dtDetail = (DataTable)PUR022.Session["PUR02_DTL_" + sPageTimeStamp];

            if (dtGift == null)
            {
                MaintainPurchaseOrder bco = new MaintainPurchaseOrder(ConntionDB);
                dtGift = bco.QueryGiftSchema();
            }

            MaintainGift Gbco = new MaintainGift(ConntionDB);
            ParameterList.Clear();
            ParameterList.Add(sItem);
            ParameterList.Add(sPeriod);
            ParameterList.Add(-1);
            DataTable dtTmp = Gbco.QueryGift(ParameterList);
            int iAddRow = 0;
            if (dtTmp != null && dtTmp.Rows.Count > 0)
            {
                for (int i = 0; i < dtTmp.Rows.Count; i++)
                {
                    if (dtTmp.Rows[i]["ID"].ToString() != "0")
                    {
                        DataRow dr = dtGift.NewRow();
                        dr["ID"] = 1 + i;
                        dr["ITEM"] = sItem;
                        dr["PERIOD"] = sPeriod;
                        dr["VIRTUAL_CODE"] = dtTmp.Rows[i]["VIRTUAL_CODE"].ToString();
                        dr["VIRTUAL_NAME"] = dtTmp.Rows[i]["VIRTUAL_NAME"].ToString();
                        dr["PURCHASE_QTY"] = dtTmp.Rows[i]["PLAN_QTY"].ToString();
                        string strDate = string.Empty;
                        if (dtDetail != null)
                        {
                            DataRow[] FindRows = dtDetail.Select("ITEM='" + sItem + "' And PERIOD='" + sPeriod + "'");
                            if (FindRows.Length > 0)
                            {
                                strDate = FindRows[0]["PLAN_ACCEPT_DATE"].ToString();
                            }
                        }
                        dr["PLAN_ACCEPT_DATE"] = strDate;
                        dr["COST"] = 0;
                        dr["MDC_QTY"] = 0;
                        dr["ACCEPT_ACCQTY"] = 0;
                        dr["MSG"] = "";
                        dtGift.Rows.Add(dr);
                        iAddRow++;
                    }
                }
                if (iAddRow > 0)
                    PUR022.Session["PUR02_Gift_" + sPageTimeStamp] = dtGift;
            }
        }
        return rtnValue;
    }
Example #10
0
    protected void Btn_Export_Click(object sender, EventArgs e)
    {
        try
        {
            #region 匯出條件變數

            string strItem = this.SLP_SKU1.Text;
            string strPeriod = this.SLP_ItemPeriod1.Text;
            string strSLP_StoreChain_S = SLP_StoreChain_S.Text;
            string strSLP_StoreChain_E = SLP_StoreChain_E.Text;
            string strSLP_CodeFile97_S = SLP_CodeFile97_S.Text;
            string strSLP_CodeFile97_E = SLP_CodeFile97_E.Text;
            string strSLP_CodeFile91_S = SLP_CodeFile91_S.Text;
            string strSLP_CodeFile91_E = SLP_CodeFile91_E.Text;
            string strSLP_CodeFile18_S = SLP_CodeFile18_S.Text;
            string strSLP_CodeFile18_E = SLP_CodeFile18_E.Text;
            string strSLP_CodeFile3_S = SLP_CodeFile3_S.Text;
            string strSLP_CodeFile3_E = SLP_CodeFile3_E.Text;

            #endregion

            #region check是否存在OnPack贈品主檔資料

            DataTable dtGift = new DataTable();

            ParameterList.Clear();
            ParameterList.Add(GetValueSetParameter(strItem, "string"));
            ParameterList.Add(GetValueSetParameter(strPeriod, "string"));
            ParameterList.Add(GetValueSetParameter("-1", "int"));

            BCO.MaintainGift bco = new MaintainGift(ConnectionDB);

            dtGift = bco.QueryGift(ParameterList);

            if (dtGift == null || (dtGift != null && dtGift.Rows.Count <= 0))
            {
                ErrorMsgLabel.Text = "無贈品主檔資料";
                return;
            }

            #endregion

            #region check是否存在通路門市贈品資料

            DataTable dtStoreGift = new DataTable();

            ParameterList.Clear();
            ParameterList.Add(GetValueSetParameter(strItem, "string"));
            ParameterList.Add(GetValueSetParameter(strPeriod, "string"));
            ParameterList.Add(GetValueSetParameter(strSLP_StoreChain_S, "string"));
            ParameterList.Add(GetValueSetParameter(strSLP_StoreChain_E, "string"));
            ParameterList.Add(GetValueSetParameter(strSLP_CodeFile97_S, "string"));
            ParameterList.Add(GetValueSetParameter(strSLP_CodeFile97_E, "string"));
            ParameterList.Add(GetValueSetParameter(strSLP_CodeFile91_S, "string"));
            ParameterList.Add(GetValueSetParameter(strSLP_CodeFile91_E, "string"));
            ParameterList.Add(GetValueSetParameter(strSLP_CodeFile18_S, "string"));
            ParameterList.Add(GetValueSetParameter(strSLP_CodeFile18_E, "string"));
            ParameterList.Add(GetValueSetParameter(strSLP_CodeFile3_S, "string"));
            ParameterList.Add(GetValueSetParameter(strSLP_CodeFile3_E, "string"));
            ParameterList.Add(SLP_SHELVE_CM3.Text); //專屬架

            BCO.MaintainStoreGift bcoStoreGift = new MaintainStoreGift(ConnectionDB);

            dtStoreGift = bcoStoreGift.ExportStoreGift(ParameterList);

            if (dtStoreGift == null || (dtStoreGift != null && dtStoreGift.Rows.Count <= 0))
            {
                ErrorMsgLabel.Text = "無通路門市贈品資料";
                return;
            }

            #endregion

            #region 匯出通路門市贈品資料

            ExcelXmlWorkbook book = new ExcelXmlWorkbook();

            Worksheet sheet = book[0];
            Worksheet sheet1 = book[1];

            //設定Worksheet各column 寬度
            sheet.Columns(3).Width = 70;
            sheet.Columns(5).Width = 110;
            sheet.Columns(6).Width = 45;
            sheet.Columns(7).Width = 60;
            sheet.Columns(8).Width = 120;
            sheet1.Columns(0).Width = 30;
            sheet1.Columns(2).Width = 110;
            sheet1.Columns(3).Width = 45;
            sheet1.Columns(4).Width = 60;
            sheet1.Columns(5).Width = 120;
            //sheet1.Columns(6).Hidden = true; //品號品名怕被修改到,所以產生兩個隱藏欄位
            //sheet1.Columns(7).Hidden = true;


            int iRow = 0;
            //贈品主檔
            sheet1.Name = "贈品主檔";
            sheet1.PrintOptions.Orientation = PageOrientation.Landscape;
            sheet1.PrintOptions.SetMargins(0.5, 0.4, 0.5, 0.4);
            iRow = 0;
            sheet1[0, iRow].Value = "序號";
            sheet1[1, iRow].Value = "商品品號";
            sheet1[2, iRow].Value = "商品名稱";
            sheet1[3, iRow].Value = "期別";
            sheet1[4, iRow].Value = "贈品名稱";
            sheet1[5, iRow].Value = "虛擬品號";
            //sheet1[6, iRow].Value = "贈品名稱";
            //sheet1[7, iRow].Value = "虛擬品號";
            iRow++;

            DataRow[] drs = dtGift.Select("1=1", "VIRTUAL_NAME");
            foreach (DataRow dr in drs)
            {
                if (dr["id"].ToString() != "0")
                {
                    sheet1[0, iRow].Value = iRow.ToString();
                    sheet1[1, iRow].Value = dr["ITEM"].ToString();
                    sheet1[2, iRow].Value = dr["ITEM_NAME"].ToString();
                    sheet1[3, iRow].Value = dr["PERIOD"].ToString();
                    sheet1[4, iRow].Value = dr["VIRTUAL_NAME"].ToString();
                    sheet1[5, iRow].Value = dr["VIRTUAL_CODE"].ToString();
                    //sheet1[6, iRow].Value = dr["VIRTUAL_NAME"].ToString();
                    //sheet1[7, iRow].Value = dr["VIRTUAL_CODE"].ToString();
                    iRow++;
                }
            }

            //多通路門市贈品設定
            iRow = 0;
            sheet.Name = "多通路門市贈品設定";
            sheet.PrintOptions.Orientation = PageOrientation.Landscape;
            sheet.PrintOptions.SetMargins(0.5, 0.4, 0.5, 0.4);

            sheet[0, iRow].Value = "通路代號";
            sheet[1, iRow].Value = "通路名稱";
            sheet[2, iRow].Value = "門市代號";
            sheet[3, iRow].Value = "門市名稱";
            sheet[4, iRow].Value = "商品品號";
            sheet[5, iRow].Value = "商品名稱";
            sheet[6, iRow].Value = "期別";
            sheet[7, iRow].Value = "虛擬品號";
            sheet[8, iRow].Value = "贈品名稱";

            iRow++;
            foreach (DataRow dr in dtStoreGift.Rows)
            {
                sheet[0, iRow].Value = dr["CHAN_NO"].ToString();
                sheet[1, iRow].Value = dr["CHAN_NAME"].ToString();
                sheet[2, iRow].Value = dr["STORE"].ToString();
                sheet[3, iRow].Value = dr["STORE_NAME"].ToString();
                sheet[4, iRow].Value = dr["ITEM"].ToString();
                sheet[5, iRow].Value = dr["ITEM_NAME"].ToString();
                sheet[6, iRow].Value = dr["PERIOD"].ToString();
                Formula f = new Formula().Add("VLOOKUP").StartGroup();
                f.Add(new Range(sheet[8, iRow])).Operator(',');
                //f.Add(new Range(sheet1[5, 1], sheet1[5, dtGift.Rows.Count])).Operator(',');
                //f.Add(new Range(sheet1[4, 1], sheet1[4, dtGift.Rows.Count])).EndGroup();
                f.Add(new Range(sheet1[5, 1], sheet1[4, dtGift.Rows.Count])).Operator(',');
                f.Add("2").Operator(',');
                f.Add("false").EndGroup();
                sheet[7, iRow].Value = f;
                //sheet[7, x].Value = dr["VIRTUAL_CODE"].ToString();
                sheet[8, iRow].Value = dr["VIRTUAL_NAME"].ToString();
                iRow++;
            }

            //設定輸出檔名
            string s_FileName = "";
            s_FileName = HttpUtility.UrlEncode(string.Format("MKT14_通路贈品門市設定_{0}_{1}.xls", strItem, strPeriod), System.Text.Encoding.UTF8);

            //File download
            Response.Charset = "big5";
            Response.ContentType = "application/x-excel;charset='utf-8'";//"application/vnd.ms-excel";
            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();

            #endregion
        }
        catch (Exception ex)
        { this.ErrorMsgLabel.Text = ex.ToString(); }
        finally { }

    }
Example #11
0
    private void LoadData(int intID, string strItem, string strPeriod)
    {
        try
        {
            #region Bind gvGift

            MaintainGift bcoGift = new MaintainGift(ConntionDB);

            ParameterList.Clear();

            ParameterList.Add(strItem);
            ParameterList.Add(strPeriod);
            ParameterList.Add(999);

            DataTable Dt_Gift = bcoGift.QueryGift(ParameterList);
            Session["MKT05_POP_Gift" + PageTimeStamp.Value] = Dt_Gift;

            if (Dt_Gift != null && Dt_Gift.Rows.Count != 0)
            {
                gvGift.PageSize = 20;
                gvGift.PageIndex = 0;

                gvGift.DataSource = Dt_Gift;
                gvGift.DataBind();

                NoData_1.Visible = false;
            }
            else
            {
                NoData_1.Visible = true;
            }

            #endregion

            #region Bind gvGiftChan

            MaintainPurchaseCard bco = new MaintainPurchaseCard(ConntionDB);

            ParameterList.Clear();

            ParameterList.Add(intID);
            ParameterList.Add(strItem);
            ParameterList.Add(strPeriod);

            DataTable Dt_GiftChan = bco.MTK05_POP_GiftChan(ParameterList);
            Session["MKT05_POP_GiftChan" + PageTimeStamp.Value] = Dt_GiftChan;

            if (Dt_GiftChan != null && Dt_GiftChan.Rows.Count != 0)
            {
                gvGiftChan.PageSize = 20;
                gvGiftChan.PageIndex = 0;

                gvGiftChan.DataSource = Dt_GiftChan;
                gvGiftChan.DataBind();

                NoData_2.Visible = false;
            }
            else
            {
                NoData_2.Visible = true;
            }

            #endregion

            #region Bind 通路門市贈品

            MaintainStoreGift BCO = new MaintainStoreGift(ConntionDB);

            ParameterList.Clear();

            ParameterList.Add(strItem);
            ParameterList.Add(strPeriod);
            ParameterList.Add("99999999");

            DataTable Dt_GiftStore = BCO.QueryStoreGift(ParameterList);
            Session["MKT05_POP_GiftStore" + PageTimeStamp.Value] = Dt_GiftStore;

            if (Dt_GiftStore != null && Dt_GiftStore.Rows.Count != 0)
            {
                GridView1.PageSize = 20;
                GridView1.PageIndex = 0;

                GridView1.DataSource = Dt_GiftStore;
                GridView1.DataBind();

                NoData_3.Visible = false;
            }
            else
            {
                NoData_3.Visible = true;
            }

            #endregion
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
    }
Example #12
0
    public static string GetNextVirtualCode(string strItem, string strPeriod)
    {
        #region 取得下一個虛擬品號流水號

        String rtnValue = "";
        if (strItem != "")
        {

            BCO.MaintainGift bco = new BCO.MaintainGift(ConnectionDB);

            ParameterList.Clear();
            ParameterList.Add(strItem);
            ParameterList.Add(strPeriod);

            //取得下一個虛擬品號流水號
            DataTable dt = bco.GetNextVirtualCode(ParameterList);
            if (dt.Rows.Count > 0)
            {
                rtnValue = dt.Rows[0][0].ToString();
            }
            else
            {
                rtnValue = "";
            }

        }

        return rtnValue;

        #endregion
    }
Example #13
0
    protected void Btn_Delete_Click(object sender, EventArgs e)
    {
        ErrorMsgLabel.Text = "";
        if (this.hid_PageStatus.Value == "VIEW")
        {
            ErrorMsgLabel.Text = "";

            #region 取得更新前舊值


            #region 使用XML轉回DataSet

            DataSet DsMaster = new DataSet();
            System.IO.StringReader srM = new System.IO.StringReader(MasterOLDData.InnerHtml);
            DsMaster.ReadXml(srM);
            DataTable dtMasterOLD = DsMaster.Tables[0];

            #endregion

            #endregion

            #region 已於通路贈品設定中使用此贈品,不可刪除

            BCO.MaintainChainGiftDtl bcoChainGiftDtl = new BCO.MaintainChainGiftDtl(ConnectionDB);

            DataTable dt = new DataTable();

            dt = bcoChainGiftDtl.QueryByGiftData(this.getParameterList());

            //已於通路贈品設定中使用此贈品,不可刪除
            if (dt.Rows.Count > 0)
            {
                ErrorMsgLabel.Text = "已於通路贈品設定中使用此贈品,不可刪除";
                return;
            }

            #endregion

            #region 已於門市贈品設定中使用此贈品,不可刪除

            BCO.MaintainStoreGift bcoStoreGift = new BCO.MaintainStoreGift(ConnectionDB);

            dt = bcoStoreGift.QueryByGiftData(this.getParameterList());

            //已於門市贈品設定中使用此贈品,不可刪除
            if (dt.Rows.Count > 0)
            {
                ErrorMsgLabel.Text = "已於門市贈品設定中使用此贈品,不可刪除";
                return;
            }

            #endregion

            #region  處理刪除作業
            #region 組合刪除條件至ArrayList

            ArrayList returnList = new ArrayList();

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

            #endregion

            try
            {
                BCO.MaintainGift bco = new BCO.MaintainGift(ConnectionDB);

                bco.DeleteGift(returnList, dtMasterOLD.Rows[0], null);

                ScriptManager.RegisterStartupScript(Page, this.GetType(), "ClientScript", "alert('刪除完成');location.replace('MKT151.aspx?Code=MKT15');", true);

            }
            catch (Exception ex)
            {
                this.Btn_Save.Visible = false;//存檔

                ErrorMsgLabel.Text = ex.Message;
            }
            #endregion
        }
    }
Example #14
0
    protected void Btn_Save_Click(object sender, EventArgs e)
    {
        try
        {

            #region 資料儲存

            BCO.MaintainGift bco = new BCO.MaintainGift(ConnectionDB);

            {
                switch (this.hid_PageStatus.Value)
                {
                    case "INSERT":
                        {
                            // 做資料儲存的動作
                            int vPID = bco.CreateGift(this.getParameterList(), null);

                            this.hiddenID.Value = Convert.ToString(vPID);
                        }
                        break;
                    case "EDIT":
                        {

                            #region 使用XML轉回DataSet

                            DataTable MasterOldDt = null;
                            if (MasterOLDData.InnerHtml != "" && MasterOLDData.InnerHtml != "<NewDataSet />")
                            {
                                DataSet Ds = new DataSet();
                                System.IO.StringReader sr = new System.IO.StringReader(MasterOLDData.InnerHtml);
                                Ds.ReadXml(sr);
                                MasterOldDt = Ds.Tables[0];

                            }

                            #endregion


                            // 做資料儲存的動作
                            bco.UpdateGift(this.getParameterList(),
                                                      MasterOldDt.Rows[0],
                                                      null);

                            break;
                        }
                        break;
                }

            #endregion

                #region 存檔後資料重新讀取
                databind_Mst();

                #endregion

                #region 存檔後狀態設定

                this.hid_PageStatus.Value = "VIEW";
                this.txt_PageStatus.Text = "VIEW";

                #endregion

            }

        }
        catch (Exception ex)
        { this.ErrorMsgLabel.Text = ex.Message; }
        finally
        {
            if (this.ErrorMsgLabel.Text == "")
            {
                SetPageStatus();
                SetDefaultValue();
            }
        }
    }
Example #15
0
    protected void Btn_Export_Click(object sender, EventArgs e)
    {
        try
        {
            string strItem = this.SLP_SKU1.Text;
            string strPeriod = this.SLP_ItemPeriod1.Text;

            #region check是否存在OnPack贈品主檔資料

            DataTable Dt = new DataTable();

            ParameterList.Clear();
            ParameterList.Add(GetValueSetParameter(strItem, "string"));
            ParameterList.Add(GetValueSetParameter(strPeriod, "string"));
            ParameterList.Add(GetValueSetParameter("-1", "int"));
            BCO.MaintainGift bco = new MaintainGift(ConnectionDB);
            Dt = bco.QueryGift(ParameterList);

            if (Dt == null || (Dt != null && Dt.Rows.Count <= 0))
            {
                ErrorMsgLabel.Text = "無贈品主檔資料";
                return;
            }

            #endregion

            string strUrl = string.Empty;

            strUrl = "MKT143.aspx?Code=MKT14&Item=" + strItem + "&Period=" + strPeriod;
            Response.Redirect(strUrl, false);
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
    }
Example #16
0
    public static string SetBtn_PurchaseCardStatus(string s_ItemValue)
    {
        #region by功能權限 決定連結採購卡Button disable or enable

        MKT_MKT141 MKT141 = new MKT_MKT141();
        string strRootNo = "";
        string strRetuenValue = "disable";

        if (s_ItemValue.Trim() != "")
        {
            #region 取得Root No決定連結 採購卡or圖書採購卡

            ParameterList.Clear();
            ParameterList.Add(s_ItemValue.Trim());
            BCO.MaintainGift bcoGift = new BCO.MaintainGift(ConnectionDB);
            DataTable dt = new DataTable();
            dt = bcoGift.GetItemDataByItem(ParameterList);

            //取得Root No
            if (dt == null || (dt.Rows.Count == 0))
            {
                strRootNo = "";
            }
            else
            {
                strRootNo = dt.Rows[0]["ROOT_NO"].ToString();
            }

            if (strRootNo == "1") //雜誌
            {
                MKT141.SetAuthority("MKT05");//判斷功能MKT05權限

                if (MKT141.AuthCreate == true)
                {
                    strRetuenValue = "enable";
                }
                else
                {
                    strRetuenValue = "disable";
                }
            }
            else if (strRootNo == "2")//圖書
            {
                MKT141.SetAuthority("MKT06");//判斷功能MKT06權限

                if (MKT141.AuthCreate == true)
                {
                    strRetuenValue = "enable";
                }
                else
                {
                    strRetuenValue = "disable";
                }
            }
            else
            {
                strRetuenValue = "disable";
            }

            #endregion
        }
        else
        {
            strRetuenValue = "disable";
        }

        return strRetuenValue;

        #endregion
    }
Example #17
0
 protected void btnDelStoreGift_Click(object sender, EventArgs e)
 {
     ErrorMsgLabel.Text = "";
     GridViewRow grdRow = (GridViewRow)((Button)sender).Parent.Parent;
     string strITEM = ((HiddenField)grdRow.FindControl("HiddenField2")).Value;
     string strPERIOD = ((HiddenField)grdRow.FindControl("HiddenField3")).Value;
     string strVIRTUAL_CODE = ((HiddenField)grdRow.FindControl("HiddenField5")).Value;
     ParameterList.Clear();
     ParameterList.Add(strITEM);
     ParameterList.Add(strPERIOD);
     ParameterList.Add(strVIRTUAL_CODE);
     ParameterList.Add(DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"));
     ParameterList.Add(Session["UID"].ToString());
     BCO.MaintainGift bco = new BCO.MaintainGift(ConnectionDB);
     bco.DeleteStoreGift(ParameterList);
     ErrorMsgLabel.Text = "虛擬品號[" + strVIRTUAL_CODE + "]門市贈品資料已刪除";
 }
Example #18
0
    protected void btn_Del_Click(object sender, EventArgs e)
    {
        try
        {
            DataTable dt = (DataTable)Session["MKT151_Data" + PageTimeStamp.Value];

            Button btn = sender as Button;
            rowid_mst = Convert.ToInt16(btn.Attributes["rowid_mst"].ToString());

            string strItem = ((HiddenField)GridView1.Rows[rowid_mst].FindControl("HiddenField2")).Value.ToString();
            string strPeriod = ((HiddenField)GridView1.Rows[rowid_mst].FindControl("HiddenField3")).Value.ToString();
            string strVirtualCode = GridView1.Rows[rowid_mst].Cells[3].Text.ToString();

            ParameterList.Clear();
            ParameterList.Add(strItem);
            ParameterList.Add(strPeriod);
            ParameterList.Add(strVirtualCode);
            BCO.MaintainGift bco = new BCO.MaintainGift(ConnectionDB);
            if (bco.ChkExist(ParameterList) != "0")
            {
                ErrorMsgLabel.Text = "虛擬品號:「" + strVirtualCode + "」該贈品已被其它功能設定,不可刪除";
                return;
            }

            DataRow dr = dt.Select("ITEM = '" + strItem + "' and PERIOD = '" + strPeriod + "' and VIRTUAL_CODE = '" + strVirtualCode + "'")[0];
            dr.Delete();

            Session["MKT151_Data" + PageTimeStamp.Value] = dt;

            GridView1.DataSource = dt;
            GridView1.PageSize = (TextBoxPagesize.Text == "" || TextBoxPagesize.Text == "0") ? 10 : int.Parse(TextBoxPagesize.Text);
            this.GridView1.PageIndex = 0;
            GridView1.DataBind();
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
    }
Example #19
0
    protected void Btn_Query_Click(object sender, EventArgs e)
    {
        try
        {
            DataTable Dt = new DataTable();

            #region 清空靜態變數
            dt_Detail = null;
            #endregion

            #region 處理查詢

            BCO.MaintainGift bco = new MaintainGift(ConnectionDB);
            Dt = bco.QueryGift(this.getParameterList());
            dt_Detail = Dt.Copy();
            #endregion

            #region 將ID為0的資料刪除,並存入Session

            DataTable Dt_forSession = Dt.Copy();
            DataRow dr = Dt_forSession.Select("ID='0'")[0];
            Dt_forSession.Rows.Remove(dr);
            Session["MKT151_Data" + PageTimeStamp.Value] = Dt_forSession;

            #endregion

            if (Dt == null || (Dt != null && Dt.Rows.Count <= 1))
            {
                ErrorMsgLabel.Text = "查無資料";

                //SetButtonStatus(false);
                btnEdit.Enabled = false;
                btnSave.Enabled = false;
                btnCancel.Enabled = false;

                Btn_Query.Enabled = true;

                GridView1.Visible = false;
            }
            else
            {
                #region 將Key值存到Session中

                ArrayList arl_Key = new ArrayList();

                foreach (DataRow drRow in Dt.Rows)
                { arl_Key.Add(drRow["ID"].ToString()); }

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

                #endregion

                //查詢後,預設頁面狀態為 VIEW
                Session["MKT151_PageMode"] = "VIEW";

                //SetButtonStatus(true);
                btnEdit.Enabled = true;
                btnSave.Enabled = false;
                btnCancel.Enabled = false;

                Btn_Query.Enabled = true;

                GridView1.Visible = true;


            }

            #region 設定查詢結果

            this.GridView1.DataSource = Dt;
            GridView1.PageSize = (TextBoxPagesize.Text == "" || TextBoxPagesize.Text == "0") ? 10 : int.Parse(TextBoxPagesize.Text);
            this.GridView1.PageIndex = 0;
            this.GridView1.DataBind();
            Btn_PurchaseCard.Enabled = true;

            #endregion

            PanelGiftDetail.Visible = false;
        }
        catch (Exception ex)
        { this.ErrorMsgLabel.Text = ex.ToString(); }
        finally { }
    }
Example #20
0
        /// <summary>
        ///1.目的:將上傳檔案內容,存入暫存檔

        ///2.傳入參數:@處理檔名、@使用者
        ///  回傳參數:@處理筆數、@正確筆數、@錯誤筆數、@錯誤訊息

        ///3.處理表格:VDS_MKT_STOREGIFT_TMP(T)

        ///4.處理邏輯:

        ///  4.1) 先清除前一次,同一使用者執行的匯入暫存資訊與錯誤資訊。
        ///       相關Table:VDS_MKT_STOREGIFT_TMP
        ///  4.2) 讀取匯入檔案到暫存資料集。
        ///  4.3) 檢查匯入檔案格式內容是否正確,如有任何錯誤,則停止上傳流程,並回傳錯誤訊息。
        ///       『XX檔案,檔案內容錯誤:@錯誤說明』 (格式請參考資料庫Table Shcema)
        ///         * 日期:檢查日期格式。
        ///         * 數字:檢查內容是否為數字。
        ///         * 文字:檢查長度是否溢位。
        ///         * 檔案欄位數是否不足。
        ///         * 檢查必填欄位是否有值
        ///         * 工作表匯入內容有任一筆錯,皆視為錯誤,整批放棄。
        ///         * 匯入表格細節說明請參考:Excel文件
        ///  4.4) 格式檢查正確無誤後
        ///       a) 暫存檔中的[狀態]欄位調整為1:FILE TO TMP
        ///       b) 呼叫 [CheckData] ,檢查資料內容邏輯正確性 
        ///  4.5) 無論CheckData()檢查結果是否為True,
        ///       皆將上傳檔案內容新增到資料庫Tmp Table:,
        ///       並記錄錯誤原因、匯入者、匯入日期、處理檔案名稱=上傳檔名。

        ///5. 回傳處理結果(@處理筆數、@正確筆數、@錯誤筆數、@錯誤訊息(無錯誤時=null) )   
        /// </summary>
        public ArrayList FileToTmp(DataSet ds_Excel, DateTime d_CreateDate, string s_LoginUser, string s_AP_FileName,bool bCheckDis)
        {
            #region

            int iErrCounts = 0;
            int i_newTable_Count = 0;
            ArrayList arl_Return = new ArrayList();
            int i_FileToTemp_Total_count = 0;
            int i_FileToTemp_Right_count = 0;
            int i_FileToTemp_Wrong_count = 0;
            bool b_Check_Logic = true;
            ArrayList paramTemp = new ArrayList();
            Hashtable htTemp = new Hashtable();

            DataTable dtTemp = new DataTable();
            string strErrMsg = "";
            string strErrMsgDataFormat = "";

            Int32 iErrCount = 0;
            try
            {
                ParameterList.Clear();
                MaintainStoreGiftTmp BCO = new MaintainStoreGiftTmp(ConnectionDB);
                MaintainGift BCO_ChkDis = new MaintainGift(ConnectionDB);
                DataTable dt_MKT_IMPORT_TMP = BCO.GetStoreGift_TmpSchema();

                //刪除VDS_MKT_STOREGIFT_TMP資料 BY CREATEUID
                ParameterList.Clear();
                ParameterList.Add(s_LoginUser);
                BCO.DeleteStoreGiftTmp(ParameterList, null);

                foreach (System.Data.DataRow dRow in ds_Excel.Tables[0].Rows)
                {
                    iErrCount = 0;
                    strErrMsg = "";
                    if (!CheckRequiredField(dRow, iAryRequiredColumnsCheck, out strErrMsgDataFormat))//檢查必填欄位
                    {
                        #region 檢查資料格式正確性
                        arl_Return.Add("FALSE");
                        arl_Return.Add(strErrMsgDataFormat);
                        return arl_Return;
                    }
                    else
                    {
                        string strCHAN_NO = dRow[0].ToString().Trim();
                        string strSTORE = dRow[2].ToString().Trim();
                        string strITEM = dRow[4].ToString().Trim();
                        string strPERIOD = dRow[6].ToString().Trim();
                        string strVIRTUAL_CODE = dRow[7].ToString().Trim();

                        #region 檢查資料邏輯正確性

                        #region 將資料寫入 TEMP TABLE

                        DataRow dRow_Temp = dt_MKT_IMPORT_TMP.NewRow();

                        dRow_Temp["CREATEDATE"] = d_CreateDate;
                        dRow_Temp["CREATEUID"] = s_LoginUser;
                        dRow_Temp["CHAN_NO"] = strCHAN_NO;
                        dRow_Temp["CHAIN_NAME"] = dRow[1].ToString().Trim();
                        dRow_Temp["STORE"] = strSTORE;
                        dRow_Temp["STORE_NAME"] = dRow[3].ToString().Trim();
                        dRow_Temp["ITEM"] = strITEM;
                        dRow_Temp["ITEM_NAME"] = dRow[5].ToString().Trim();
                        dRow_Temp["PERIOD"] = strPERIOD;
                        dRow_Temp["VIRTUAL_CODE"] = strVIRTUAL_CODE;
                        dRow_Temp["VIRTUAL_NAME"] = dRow[8].ToString().Trim();
                        dRow_Temp["STATUS"] = 1; //1:FILE TO TMP  2:TMP TO DB
                        dRow_Temp["DATASOURCE"] = s_AP_FileName;

                        #endregion                    

                        #region 判斷是否可新增
                        ParameterList.Clear();
                        ParameterList.Add(strCHAN_NO);
                        ParameterList.Add(strSTORE);
                        ParameterList.Add(strITEM);
                        ParameterList.Add(strPERIOD);
                        ParameterList.Add(strVIRTUAL_CODE);

                        DataTable dtImportCheck = BCO.CheckImportStoreGiftTmp(ParameterList);

                        #region

                        ArrayList arrList = new ArrayList();
                        STMModel.MaintainStoreUnique STM_BCO = new STMModel.MaintainStoreUnique(ConnectionDB);
                        arrList.Clear();
                        arrList.Add(strSTORE);
                        arrList.Add(strCHAN_NO);
                        DataTable dt = STM_BCO.QueryForSLP(arrList);
                        if(dt.Rows.Count==0)
                        {
                            strErrMsg += "此門市不屬於此通路,";
                            iErrCounts++;
                        }
                        if (dtImportCheck != null && dtImportCheck.Rows.Count > 0)
                        {
                            //是否存在於通路主檔
                            if (dtImportCheck.Rows[0][0].ToString().Trim() == "0")
                            {
                                strErrMsg += "通路不存在,";
                                iErrCounts++;
                            }
                            //是否存在於門市主檔
                            if (dtImportCheck.Rows[0][1].ToString().Trim() == "0")
                            {
                                strErrMsg += "門市不存在,";
                                iErrCounts++;
                            }
                            //是否存在於品號主檔
                            if (dtImportCheck.Rows[0][2].ToString().Trim() == "0")
                            {
                                strErrMsg += "品號不存在,";
                                iErrCounts++;
                            }
                            else if (dtImportCheck.Rows[0][3].ToString().Trim() == "0") //是否存在於期別主檔
                            {
                                strErrMsg += "期別不存在,";
                                iErrCounts++;
                            }
                            else if (dtImportCheck.Rows[0][4].ToString().Trim() == "0") //是否存在於贈品主檔
                            {
                                strErrMsg += "虛擬品號不存在,";
                                iErrCounts++;
                            }
                            else
                            {
                                if (bCheckDis == false) //是否檢查配本已確認
                                {
                                    ParameterList.Clear();
                                    ParameterList.Add(strITEM);
                                    ParameterList.Add(strVIRTUAL_CODE);
                                    ParameterList.Add(strPERIOD);
                                    if (BCO_ChkDis.ChkDis(ParameterList) == 1)
                                    {
                                        strErrMsg += "配本以確認,";
                                        iErrCounts++;
                                    }
                                }
                            }
                            //是否存在於通路門市贈品檔
                            //取消此項檢核,若資料已存在通路門市贈品檔,則改成Update寫入 2009/11/4
                            //if (strErrMsg == "" && dtImportCheck.Rows[0][5].ToString().Trim() == "1")
                            //{
                            //    strErrMsg += "資料已存在通路門市贈品檔,";
                            //    iErrCounts++;
                            //}
                        }
                        #endregion

                        #endregion

                        #region 針對ERROR_MEMO是否為空字串做檢查

                        if (strErrMsg.Trim() == string.Empty)
                        {
                            dRow_Temp["ERROR_MEMO"] = System.DBNull.Value;
                        }
                        else
                        {
                            if (strErrMsg.Trim().Length > 0)
                            {
                                if (strErrMsg.Trim().Substring(strErrMsg.Trim().Length - 1) == ",")
                                {
                                    strErrMsg = strErrMsg.Trim().Substring(0, strErrMsg.Trim().Length - 1);
                                }
                            }
                            dRow_Temp["ERROR_MEMO"] = strErrMsg;
                            iErrCount++;
                        }

                        if (iErrCount != 0)
                        {
                            i_FileToTemp_Wrong_count += 1;
                            dRow_Temp["DATATYPE"] = 2;
                            b_Check_Logic = false;
                        }
                        else
                        {
                            i_FileToTemp_Right_count += 1;
                            dRow_Temp["DATATYPE"] = 1;
                        }

                        #endregion

                        dt_MKT_IMPORT_TMP.Rows.Add(dRow_Temp);
                        i_newTable_Count += 1;

                        #endregion
                    }

                    i_FileToTemp_Total_count += 1;
                        #endregion
                }

                #region 先清除前一次,同一使用者執行的匯入暫存資訊與錯誤資訊,並將 Excel 資料匯入 TEMP TABLE

                ParameterList.Clear();
                ParameterList.Add(s_LoginUser);
                INSERT_TEMP_TABLE(ParameterList, null, dt_MKT_IMPORT_TMP);

                #endregion

                arl_Return.Add("TRUE");
                arl_Return.Add(b_Check_Logic);
                arl_Return.Add(i_FileToTemp_Total_count);
                arl_Return.Add(i_FileToTemp_Right_count);
                arl_Return.Add(i_FileToTemp_Wrong_count);
            }
            catch (Exception ex)
            {
                arl_Return.Add("FALSE");
                arl_Return.Add(ex.Message);
            }
            return arl_Return;
            #endregion
        }
Example #21
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        try
        {
            DataTable Dt = (DataTable)Session["MKT154_Data" + PageTimeStamp.Value];
            string strItem = SLP_ITEM.Text;
            string strPeriod = SLP_PEROID.Text;
            string strUID = Session["UID"].ToString();

            #region 檢查虛擬品號是否為空白 及 如果預定進貨量為空白時,存入0

            foreach (DataRow dr in Dt.Rows)
            {
                if (dr["VIRTUAL_NAME"].ToString().Trim() == "")
                {
                    throw new Exception(" 虛擬贈品名稱不能空白 ");
                    //ScriptManager.RegisterStartupScript(Page, this.GetType(), "MKT154.aspx", "alert(' 虛擬贈品名稱不能空白 ');", true);
                    //return;
                }

                if (dr["PLAN_QTY"].ToString().Trim() == "")
                {
                    dr["PLAN_QTY"] = "0";
                }
            }

            #endregion
            
            Dt.AcceptChanges();

            #region 檢查是否有明細資料

            if (Dt.Rows.Count == 0)
            {
                throw new Exception(" 無明細資料 ");
            }

            #endregion
            
            BCO.MaintainGift bco = new BCO.MaintainGift(ConnectionDB);

            bco.InsertGift(strItem, strPeriod, strUID, Dt, null);

            ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "SaveOK", "setTimeout(function(){alert(' 新增 " + Dt.Rows.Count + " 筆贈品成功 ');location.href='MKT151.aspx?Code=MKT15&ITEM=" + SLP_ITEM.Text + "&PERIOD=" + SLP_PEROID.Text + "';},1);", true);

        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
    }