Exemplo n.º 1
0
    /// <summary>
    /// 繫結資料到控制項
    /// </summary>
    /// <param name="vdb"></param>
    private void QueryData()
    {
        #region

        string SessionIDName = string.Format("{0}_{1}", PAGE_DT_01, PageTimeStamp.Value);
        MKTModel.VDS_MKT21_BCO BCO = new MKTModel.VDS_MKT21_BCO(ConnectionDB);

        DataTable dt = null;

        dt = BCO.QUERY_UN_TAG_STORE(GetQueryParams());

        Session[SessionIDName] = dt;
        Int32 iRowCount = 0;
        aryParamsPKey.Clear();


        GridView1.DataSource = dt;
        GridView1.PageSize = (TextBoxPagesize.Text == "") ? 10 : (int.Parse(TextBoxPagesize.Text) <= 0) ? 10 : int.Parse(TextBoxPagesize.Text);
        GridView1.PageIndex = 0;
        GridView1.DataBind();

        if (dt != null && dt.Rows.Count > 0)
        {
            iRowCount = dt.Rows.Count;

            foreach (DataRow dr in dt.Rows)
            {
                #region
                aryParamsPKey.Add(dr["ID"].ToString());
                #endregion
            }
        }
        else
        {
            ErrorMsgLabel.Text = "查無資料";
        }


        Session[string.Format("{0}_{1}", strPreFixed, PageTimeStamp.Value)] = aryParamsPKey;

        LabelQueryRecordCount.Text = string.Format(" {0} Rows ", iRowCount);

        #endregion
    }
Exemplo n.º 2
0
    protected void btn_StoreSelect_Click(object sender, EventArgs e)
    {
        #region
        try
        {

            dtMultiSaveMKT21 = dtMKT21_POP_SelectStore;
            //(加入之前尚未存檔的選擇項目)
            if (dtMKT21_POP_SelectStore_old != null && dtMKT21_POP_SelectStore == null)
            { dtMultiSaveMKT21 = dtMKT21_POP_SelectStore_old; }

            if (dtMultiSaveMKT21.Rows.Count > 0)
            {
                //STEP 1.扣除已存在前次新增之資料
                #region
                if (dtMKT21_POP_SelectStore_old != null && dtMKT21_POP_SelectStore_old.Rows.Count > 0)
                {
                    for (Int32 i = dtMultiSaveMKT21.Rows.Count - 1; i >= 0; i--)
                    {
                        for (Int32 k = 0; k <= dtMKT21_POP_SelectStore_old.Rows.Count - 1; k++)
                        {
                            if (dtMultiSaveMKT21.Rows[i]["code"].ToString().Trim() == dtMKT21_POP_SelectStore_old.Rows[k]["code"].ToString().Trim())
                            {
                                dtMultiSaveMKT21.Rows.RemoveAt(i);
                                break;
                            }
                        }
                    }
                }
                #endregion

                //STEP 2.與前次新增之DATATABLE合併
                #region
                if (dtMKT21_POP_SelectStore_old != null && dtMKT21_POP_SelectStore_old.Rows.Count > 0)
                {
                    dtMultiSaveMKT21.Merge(dtMKT21_POP_SelectStore_old);
                }
                #endregion

                //STEP 3.扣除已存在DB之資料
                #region
                MKTModel.VDS_MKT21_BCO BCO = new MKTModel.VDS_MKT21_BCO(ConnectionDB);
                ArrayList ParameterList = new ArrayList();
                ParameterList.Clear();
                ParameterList.Add(null);
                ParameterList.Add(null);
                ParameterList.Add(null);
                ParameterList.Add(null);
                ParameterList.Add(null);
                ParameterList.Add(null);
                ParameterList.Add(9999);

                DataTable Dt = BCO.QUERY_UN_TAG_STORE(ParameterList);

                if (Dt.Rows.Count > 0)
                {
                    for (Int32 i = dtMultiSaveMKT21.Rows.Count - 1; i >= 0; i--)
                    {
                        for (Int32 k = 0; k <= Dt.Rows.Count - 1; k++)
                        {
                            if (dtMultiSaveMKT21.Rows[i]["code"].ToString().Trim() == Dt.Rows[k]["code"].ToString().Trim())
                            {
                                dtMultiSaveMKT21.Rows.RemoveAt(i);
                                break;
                            }
                        }
                    }
                }
                #endregion
            }

            //將舊資料存到old
            dtMKT21_POP_SelectStore_old = dtMultiSaveMKT21;
            //Binding 到GridView
            GridView1.DataSource = dtMultiSaveMKT21;
            GridView1.DataBind();
            UpdatePanel1.Update();
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
        #endregion
    }