Esempio n. 1
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;
        }
    }
Esempio n. 2
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;
        }
Esempio n. 3
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;
        }
    }
Esempio n. 4
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 { }
    }
Esempio n. 5
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;
    }
Esempio n. 6
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 { }

    }
Esempio n. 7
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;
        }
    }