Beispiel #1
0
    protected void btn_PatternSelect_Click(object sender, EventArgs e)
    {
        #region
        try
        {


            dtMultiSaveClassAndItem = dtClassAndItemSelected;// (DataTable)Session["dtClassAndItemSelected"];
            // 2009-05-10 cyhsu add (加入之前尚未存檔的選擇項目)
            if (dtClassAndItemSelected_old != null && dtClassAndItemSelected == null)
            { dtMultiSaveClassAndItem = dtClassAndItemSelected_old; }

            if (dtMultiSaveClassAndItem.Rows.Count > 0)
            {

                string strWhere = string.Format(" and m.dis_user='******'", SLP_User1.Text.Trim());

                ALOModel.MaintinDisPattern BCO = new ALOModel.MaintinDisPattern(ConnectionDB);

                ArrayList ParameterList = new ArrayList();//20091111
                ParameterList.Clear();
                ParameterList.Add(strWhere);

                DataTable Dt = BCO.QuerySwitch(ALOModel.MaintinDisPattern.QueryType.Custom, ParameterList);

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

            //2009-05-10 cyhsu add將舊資料存到old
            dtClassAndItemSelected_old = dtMultiSaveClassAndItem;
            //Binding 到GridView
            GridView1.DataSource = dtMultiSaveClassAndItem;
            GridView1.DataBind();
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
        #endregion
    }
Beispiel #2
0
    /// <summary>
    /// 繫結資料到控制項
    /// </summary>
    private void QueryData()
    {
        #region
        try
        {
            string SessionIDName = string.Format("{0}_{1}", PAGE_DT_01, PageTimeStamp.Value);
            ALOModel.MaintinDisPattern BCO = new ALOModel.MaintinDisPattern(ConnectionDB);

            string strWhere = "";
            strWhere = GetQuerySQLStatement();

            ParameterList.Clear();
            ParameterList.Add(strWhere);

            DataTable dt = BCO.QuerySwitch(ALOModel.MaintinDisPattern.QueryType.Custom, ParameterList);

            #region 使用XML放置到前端資料

            MasterOLDData.InnerHtml = dt.DataSet.GetXml();
            #endregion

            dtQueryViewState = dt;
            Session[SessionIDName] = dt;

            Int32 iRowCount = 0;

            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;
            }
            else
            {
                ResultMsgLabel.Text = "查無資料";
            }

            LabelQueryRecordCount.Text = string.Format(" {0} Rows ", iRowCount);
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
        #endregion
    }