private void frmAddContent_FooterBarLayoutItemClick(object sender, MobileFormLayoutItemEventArgs e) { try { if (txtGroup.Text.Trim().Length <= 0) { throw new Exception("请输入群组名称"); } if (groupuserCount < 0) { throw new Exception("请选择群组成员"); } string[] users = new string[groupuserCount + 1]; string guser = ""; int n = 0; foreach (GridViewRow ROW in GridView1.Rows) { if (Convert.ToBoolean(ROW.Cell.Items["Check"].DefaultValue) == true) { if (string.IsNullOrWhiteSpace(guser) == false) { guser += "," + ROW.Cell.Items["lblUSER_ID"].DefaultValue; } else { guser = ROW.Cell.Items["lblUSER_ID"].DefaultValue.ToString(); } users[n] = ROW.Cell.Items["lblUSER_ID"].DefaultValue.ToString(); n += 1; } } //添加群组到数据库 //.... // im.CreateGroup(users, "G0001", txtGroup.Text.Trim()); MessageBox.Show("群组已添加", (Object s, MessageBoxHandlerArgs args) => Close()); } catch (Exception ex) { Toast(ex.Message, ToastLength.SHORT); } }
private void btnSave_Click(object sender, EventArgs e) { try { switch (ctype) { case ConcentState.Concent: //ContactInputDto cInputDto = new ContactInputDto(); //ReturnInfo r = AutofacConfig.contactService.AddContact(cInputDto); //if (r.IsSuccess == true) //{ // this.ShowResult = ShowResult.Yes; // this.Close(); // Toast("消费记录提交成功!", ToastLength.SHORT); //} //else //{ // throw new Exception(r.ErrorInfo); //} break; case ConcentState.Group: if (txtName.Text.Trim().Length <= 0) { throw new Exception("请输入群组名称!"); } CGroupInputDto cgroupInputDto = new CGroupInputDto(); cgroupInputDto.G_NAME = txtName.Text.Trim(); string guser = ""; foreach (ListViewRow rows in listView1.Rows) { if (Convert.ToBoolean(((Layout.frmAddUserLayout)(rows.Control)).Check.BindDisplayValue) == true) { if (guser.Length <= 0) { guser = ((Layout.frmAddUserLayout)(rows.Control)).lblUser.BindDataValue.ToString(); } else { guser = guser + "," + ((Layout.frmAddUserLayout)(rows.Control)).lblUser.BindDataValue.ToString(); } } } if (guser.Length <= 0) { throw new Exception("请选择群组成员!"); } guser = guser + "," + Client.Session["U_ID"].ToString(); cgroupInputDto.G_USER = guser; cgroupInputDto.G_CreateUser = Client.Session["U_ID"].ToString(); cgroupInputDto.G_UpdateUser = Client.Session["U_ID"].ToString(); ReturnInfo r = AutofacConfig.cGroupService.AddGroup(cgroupInputDto); if (r.IsSuccess == true) { string[] guser1 = guser.Split(','); string groupid = r.ErrorInfo; //当返回true时,返回群组编号 //创建群组 im1.CreateGroup(guser1, groupid, cgroupInputDto.G_NAME); this.ShowResult = ShowResult.Yes; this.Close(); Toast("群组创建成功!", ToastLength.SHORT); } else { throw new Exception(r.ErrorInfo); } break; } } catch (Exception ex) { Toast(ex.Message, ToastLength.SHORT); } }