private void button5_Click(object sender, EventArgs e) { string str = ExecuteHttp(textBox2.Text, CreateSearchModel()); string str1 = str.ToJsonObject <string>(); ExcuteResultMsg msg = str1.ToJsonObject <ExcuteResultMsg>(); if (msg.Code == ResultCode.Success) { var lst = msg.Result.ToJsonObject <List <JZ.Models.Test> >(); if (lst != null && lst.Count > 0) { lst[0].Value = Guid.NewGuid().ToString(); str = ExecuteHttp(textBox2.Text, CreateEditModel(lst[0])); str1 = str.ToJsonObject <string>(); msg = str1.ToJsonObject <ExcuteResultMsg>(); if (msg.Code == ResultCode.Success) { MessageBox.Show("修改成功\n\r" + str); } else { MessageBox.Show("修改失败:" + str); } } else { MessageBox.Show("没有查询到数据"); return; } } else { MessageBox.Show("查询数据失败:" + str); } }
private void button4_Click(object sender, EventArgs e) { JZWCF.JZWCFClient wcf = new JZWCF.JZWCFClient(); string str = wcf.PostSource(CreateSearchModel()); ExcuteResultMsg msg = str.ToJsonObject <ExcuteResultMsg>(); if (msg.Code == ResultCode.Success) { var lst = msg.Result.ToJsonObject <List <JZ.Models.Test> >(); if (lst != null && lst.Count > 0) { lst[0].Value = Guid.NewGuid().ToString(); str = wcf.PostSource(CreateEditModel(lst[0])); msg = str.ToJsonObject <ExcuteResultMsg>(); if (msg.Code == ResultCode.Success) { MessageBox.Show("修改成功\n\r" + str); } else { MessageBox.Show("修改失败:" + str); } } else { MessageBox.Show("没有查询到数据"); return; } } else { MessageBox.Show("查询数据失败:" + str); } }
private void button1_Click(object sender, EventArgs e) { JZWCF.JZWCFClient wcf = new JZWCF.JZWCFClient(); string str = wcf.PostSource(CreateAddModel()); ExcuteResultMsg msg = str.ToJsonObject <ExcuteResultMsg>(); if (msg.Code == ResultCode.Success) { MessageBox.Show("成功\n\r" + str); } else { MessageBox.Show("失败:" + str); } }
private void button6_Click(object sender, EventArgs e) { string str = ExecuteHttp(textBox2.Text, CreateDeleteModel()); string str1 = str.ToJsonObject <string>(); ExcuteResultMsg msg = str1.ToJsonObject <ExcuteResultMsg>(); if (msg.Code == ResultCode.Success) { MessageBox.Show("成功\n\r" + str); } else { MessageBox.Show("失败:" + str); } }
/// <summary> /// 处理推送过来的消息 /// </summary> /// <param name="rec"></param> private void Rec(SocketHelper.Sockets sks) { if (sks.ex != null) { //在这里判断ErrorCode 可以自由扩展 switch (sks.ErrorCode) { case SocketHelper.Sockets.ErrorCodes.objectNull: break; case SocketHelper.Sockets.ErrorCodes.ConnectError: break; case SocketHelper.Sockets.ErrorCodes.ConnectSuccess: break; case SocketHelper.Sockets.ErrorCodes.TrySendData: break; default: break; } MessageBox.Show(sks.ex.ToString()); } else { byte[] buffer = new byte[sks.Offset]; Array.Copy(sks.RecBuffer, buffer, sks.Offset); string str = Encoding.UTF8.GetString(buffer); if (str == "ServerOff") { MessageBox.Show("服务端主动关闭"); } else { ExcuteResultMsg msg = str.ToJsonObject <ExcuteResultMsg>(); if (blnUpdate) { blnUpdate = false; var lst = msg.Result.ToJsonObject <List <JZ.Models.Test> >(); if (lst != null && lst.Count > 0) { lst[0].Value = Guid.NewGuid().ToString(); client.SendData(CreateEditModel(lst[0])); } else { MessageBox.Show("没有查询到数据"); return; } } else { if (msg.Code == ResultCode.Success) { MessageBox.Show("成功\n\r" + str); } else { MessageBox.Show("失败:" + str); } } } } }