/// <summary> /// 開窗結果回傳事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Button1_Click(object sender, EventArgs e) { string resultValue = Dialog.GetReturnValue(); DataTable table = JsonConvert.DeserializeObject <DataTable>(resultValue); Dictionary <string, List <string> > result = new Dictionary <string, List <string> >(); foreach (DataRow dr in table.Rows) { string GID = dr["GROUP_ID"].ToString(); if (!result.ContainsKey(GID)) { result.Add(GID, new List <string>()); } result[GID].Add(dr["GUID"].ToString()); } JArray jArray = new JArray(); foreach (KeyValuePair <string, List <string> > item in result) { JObject jObj = new JObject(); jObj.Add(new JProperty("Group", item.Key)); jObj.Add(new JProperty("Users", item.Value)); jArray.Add(jObj); } this.SelectedUsers = JsonConvert.SerializeObject(jArray); DialogReturn.Invoke(sender, resultValue); }
/// <summary> /// 開窗結果回傳事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Button1_Click(object sender, EventArgs e) { string resultValue = Dialog.GetReturnValue(); DataTable table = JsonConvert.DeserializeObject <DataTable>(resultValue); Dictionary <string, List <string> > result = new Dictionary <string, List <string> >(); foreach (DataRow dr in table.Rows) { string GID = dr["GROUP_ID"].ToString(); if (!result.ContainsKey(GID)) { result.Add(GID, new List <string>()); } result[GID].Add(dr["GUID"].ToString()); } JArray jArray = new JArray(); foreach (KeyValuePair <string, List <string> > item in result) { JObject jObj = new JObject(); jObj.Add(new JProperty("Group", item.Key)); jObj.Add(new JProperty("Users", item.Value)); jArray.Add(jObj); } this.SelectedUsers = JsonConvert.SerializeObject(jArray); DialogReturn.Invoke(sender, resultValue); //string value = Dialog.GetReturnValue(); //if (string.IsNullOrEmpty(value)) //{ // if (DialogReturn != null) // DialogReturn.Invoke(null); // return; //} //DataSet table = JsonConvert.DeserializeObject<DataSet>(value); //Dictionary<string, List<string>> result = new Dictionary<string, List<string>>(); //foreach (DataRow dr in table.Tables["TB_EB_GROUP"].Rows) //{ // string GID = dr["GROUP_ID"].ToString(); // if (!result.ContainsKey(GID)) result.Add(GID, new List<string>()); //} //for (int i = 0; i < table.Tables["TB_EB_USER"].Rows.Count; i++) //{ // DataRow groupRow = table.Tables["TB_EB_GROUP"].Rows[i]; // DataRow userRow = table.Tables["TB_EB_USER"].Rows[i]; // result[groupRow["GROUP_ID"].ToString()].Add(userRow["USER_GUID"].ToString()); //} //JArray jArray = new JArray(); //foreach (KeyValuePair<string, List<string>> item in result) //{ // JObject jObj = new JObject(); // jObj.Add(new JProperty("Group", item.Key)); // jObj.Add(new JProperty("Users", item.Value)); // jArray.Add(jObj); //} //hidSelectedUser.Value = JsonConvert.SerializeObject(jArray); //this.GroupID = hidGroup.Value; //if (DialogReturn != null) // DialogReturn.Invoke(table); }