示例#1
0
    protected void CHANDetail_InsertButton_Click(object sender, EventArgs e)
    {
        #region 檢查通路是否正確

        TextBox txt_Code = ((ASP.stm_slp_slp_storechain_ascx)this.FormView4.FindControl("txtCHAN_NO")).TextBox_Code;

        ParameterList.Clear();
        ParameterList.Add(txt_Code.Text);

        PIC.VDS2G.GFM.STM.MaintainStoreChain BCO_STM = new PIC.VDS2G.GFM.STM.MaintainStoreChain(ConntionDB);

        DataTable dt_Code = BCO_STM.QueryStoreChainByCode(ParameterList);

        if (dt_Code.Rows.Count != 1)
        {
            Alert("期別通路主檔頁籤 請輸入正確的配本通路");
            return;
        }

        #endregion
        DataTable dtChan = (DataTable)Session["VDS_ITM_PRE_PERIOD_CHAN_NEW_" + PageTimeStamp.Value];
        DataRow dr = dtChan.NewRow();
        dr["CHAN_NO"] = ((STM_SLP_StoreChain)FormView4.FindControl("txtCHAN_NO")).Text.Trim();
        dr["CHAN_NO_NAME"] = Request[((STM_SLP_StoreChain)FormView4.FindControl("txtCHAN_NO")).TextBox_Name.UniqueID];
        dr["ITEM_MAP"] = ((TextBox)FormView4.FindControl("txtITEM_MAP")).Text.Trim();
        dr["TRUN_OUT"] = ((DropDownList)FormView4.FindControl("ddlTRUN_OUT")).Text.Trim();
        if (((WUI.SLP.SLPDate)FormView4.FindControl("txtEFFECTIVE_DATE")).Text.Trim() != "") dr["EFFECTIVE_DATE"] = ((WUI.SLP.SLPDate)FormView4.FindControl("txtEFFECTIVE_DATE")).Text.Trim();
        if (((WUI.SLP.SLPDate)FormView4.FindControl("txtCHAN_END_DATE")).Text.Trim() != "") dr["CHAN_END_DATE"] = ((WUI.SLP.SLPDate)FormView4.FindControl("txtCHAN_END_DATE")).Text.Trim();
        dr["FREQUENCY_TYPE"] = ((TextBox)FormView4.FindControl("txtFREQUENCY_TYPE")).Text.Trim();

        int iRowID = 0;
        if (dtChan.Rows.Count > 0)
        {
            iRowID = int.Parse(dtChan.Compute("MAX(ROWID)", "").ToString());
            iRowID++;
        }
        dr["ROWID"] = iRowID;

        dtChan.Rows.Add(dr);

        Session["VDS_ITM_PRE_PERIOD_CHAN_NEW_" + PageTimeStamp.Value] = dtChan;

        datagetChan();
        TabContainer4.Visible = false;
        UpdatePanel3.Update();
    }
示例#2
0
    /// <summary>
    /// 檢核通路是否合法存在
    /// </summary>
    /// <param name="strChan"></param>
    /// <param name="strChanName"></param>
    /// <returns></returns>
    private bool CheckChanIsAvaliable(string strChan,out string strChanName)
    {
        #region
        bool bResult = false;
        strChanName = "";
        STMModel.MaintainStoreChain BCO = new STMModel.MaintainStoreChain(ConnectionDB);
        try
        {
            ArrayList ParameterList = new ArrayList();//20091106
            ParameterList.Clear();
            ParameterList.Add(strChan);

            DataTable dt = BCO.QueryStoreChainByCode(ParameterList);
            if (dt != null && dt.Rows.Count > 0)
            {
                strChanName = dt.Rows[0]["NAME"].ToString().Trim();
                bResult = true;
            }
            else 
            {
                strChanName = "查無資料";
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }

        return bResult;
        #endregion
    }
    public string StoreChainName(string Code)
    {
        string Name = "";
        string ConnectionDBStr = ((DatabaseSettings)ConfigurationManager.GetSection("dataConfiguration")).DefaultDatabase;
        MaintainStoreChain co_main = new MaintainStoreChain(ConnectionDBStr);

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

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

        return Name;
    }
示例#4
0
    protected void btn_Confirm_Click(object sender, EventArgs e)
    {
        #region
        try
        {
            if (GetStringLen(txt_Memo.Text.Trim()) > 200)
            {
                hiddenFocusCtrlID.Value = txt_Memo.ClientID;
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "ClientScript", "alert('備註限制100中文字');", true);
            }
            else
            {
                #region
                DateTime dtProcessing = DateTime.Now;
                string strUID = Session["UID"].ToString();

                string strChan = SLP_StoreChain3.Text.Trim();
                string strStore = SLP_Store3.Text.Trim();
                string strPattern = SLP_Pattern3.Text.Trim();
                string strChanName = "";
                string strStoreName = "";
                string strPatternName = "";

                ArrayList ParameterList = new ArrayList();//20091112

                int iRowIndex = 0;


                ALOModel.MaintainStoreRank BCO = new ALOModel.MaintainStoreRank(ConnectionDB);
                ParameterList.Clear();
                ParameterList.Add(strChan);
                ParameterList.Add(strStore);
                ParameterList.Add(strPattern);
                ParameterList.Add(dtProcessing);
                ParameterList.Add(strUID);
                ParameterList.Add(dtProcessing);
                ParameterList.Add(strUID);
                ParameterList.Add(null);
                ParameterList.Add(strRankCode2);
                ParameterList.Add(SLP_SLPNumber1.Text.Trim());
                ParameterList.Add(txt_RankLevel.Text.Trim());
                ParameterList.Add(txt_Memo.Text.Trim());
                ParameterList.Add(s_PROCNO);
                BCO.ADD_STORERANK_AFTERQUERY(ParameterList, null);

                //todo gridview binding


                #region
                //chan_name
                ParameterList.Clear();
                ParameterList.Add(strChan);
                STMModel.MaintainStoreChain BCO_STM1 = new STMModel.MaintainStoreChain(ConnectionDB);
                DataTable dt_stm1 = BCO_STM1.QueryStoreChainByCode(ParameterList);
                strChanName = ((dt_stm1 != null &&  dt_stm1.Rows.Count > 0) ? dt_stm1.Rows[0]["NAME"].ToString() : "查無資料");

                //store_name
                ParameterList.Clear();
                ParameterList.Add(strStore);
                ParameterList.Add(strChan);
                ParameterList.Add(null);

                STMModel.MaintainStoreUnique BCO_STM2 = new STMModel.MaintainStoreUnique(ConnectionDB);
                DataTable dt_stm2 = BCO_STM2.QueryForSLP2(ParameterList);
                strStoreName = ((dt_stm2 != null && dt_stm2.Rows.Count > 0) ? dt_stm2.Rows[0]["STORE_NAME"].ToString() : "查無資料");

                //pattern_name
                ParameterList.Clear();
                ParameterList.Add(strPattern);
                ParameterList.Add(null);
                ParameterList.Add(null);
                ParameterList.Add(null);
                ParameterList.Add(null);

                ITMModel.MaintainItemClassify BCO_ITM1 = new ITMModel.MaintainItemClassify(ConnectionDB);
                DataTable dt_itm1 = BCO_ITM1.QueryPatternForSLP(ParameterList);
                strPatternName = ((dt_itm1 != null && dt_itm1.Rows.Count > 0) ? dt_itm1.Rows[0]["PATTERN_NAME"].ToString() : "查無資料");

                #endregion

                #region Insert New Row
                string SessionIDName = string.Format("{0}_{1}", PAGE_DT_01, PageTimeStamp.Value);

                DataTable dt1 = (DataTable)Session[SessionIDName];
                DataView dv = dt1.DefaultView;

                if (ViewState["SortingCondition"] != null)
                {
                    dv.Sort = ViewState["SortingCondition"].ToString();
                }

                DataTable dt2 = dv.ToTable();

                //判斷是否已存在目前DataTable中
                if (CheckDataIsExistedInCurrentDataTable(strChan, strStore, strPattern, dt2, out iRowIndex))
                {
                    #region 如存在則刪除畫面上舊資料
                    dt2.Rows.RemoveAt(iRowIndex);
                    #endregion
                }

                #region 新增一筆
                DataRow dr = dt2.NewRow();
                dr["PATTERN_NO"] = strPattern;
                dr["PATTERN_NAME"] = strPatternName;
                dr["CHAN_NO"] = strChan;
                dr["CHAN_NAME"] = strChanName;
                dr["STORE"] = strStore;
                dr["STORE_NAME"] = strStoreName;
                dr["RANK_CODE"] = ((DropDownList)SLP_Rank2.FindControl("D1")).SelectedItem.Value;
                dr["RANK_NAME"] = ((DropDownList)SLP_Rank2.FindControl("D1")).SelectedItem.Text;
                dr["RANK_VALUE"] = SLP_SLPNumber1.Text.Trim();
                dr["RANK_LEVEL"] = txt_RankLevel.Text.Trim();
                dr["MEMO"] = txt_Memo.Text.Trim();

                //2010/09/20 added 
                //dr["c_start_date"] = SLP_SLPDate1.Text.Trim();//暫不顯示
                //dr["c_end_date"] = SLP_SLPDate2.Text.Trim();//暫不顯示
                dr["update_date"] = DateTime.Now.ToString("yyyy/MM/dd");
                dr["user_name"] = ((DataTable)Session["UserInfo"]).Rows[0]["Name"].ToString();


                
                dt2.Rows.InsertAt(dr, 0);
                #endregion

                Session[SessionIDName] = dt2;
                GridView1.DataSource = dt2;
                GridView1.DataBind();

                #endregion

                PanelG3.Visible = false;
                hiddenFocusCtrlID.Value = "";


                ResultMsgLabel.Text = "新增成功";
                #endregion
            }
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
        #endregion
    }