196 lines
7.0 KiB
C#
196 lines
7.0 KiB
C#
|
using Api.Framework;
|
|||
|
using Api.Framework.Model;
|
|||
|
using Api.Framework.Tools;
|
|||
|
using DevExpress.XtraEditors;
|
|||
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Linq;
|
|||
|
using System.Windows.Forms;
|
|||
|
|
|||
|
namespace FLSystem.Forms
|
|||
|
{
|
|||
|
|
|||
|
public partial class group_manage_control : DevExpress.XtraEditors.XtraUserControl
|
|||
|
{
|
|||
|
private class fl_group_person_temp
|
|||
|
{
|
|||
|
public long id { get; set; }
|
|||
|
/// <summary>
|
|||
|
/// 用户ID
|
|||
|
/// </summary>
|
|||
|
public long mid { get; set; }
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 用户账号
|
|||
|
/// </summary>
|
|||
|
public string username { get; set; }
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 用户昵称
|
|||
|
/// </summary>
|
|||
|
public string usernick { get; set; }
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 群号
|
|||
|
/// </summary>
|
|||
|
public string groupid { get; set; }
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 群名
|
|||
|
/// </summary>
|
|||
|
public string groupname { get; set; }
|
|||
|
}
|
|||
|
|
|||
|
public group_manage_control()
|
|||
|
{
|
|||
|
InitializeComponent();
|
|||
|
|
|||
|
#region 增加所有的机器人账号
|
|||
|
this.comboBoxEdit3.Properties.Items.Clear();
|
|||
|
var weixinBases = Chat.Framework.ChatClient.WXClient.Values.ToList();
|
|||
|
var objList = new List<object>() { "全部平台" };
|
|||
|
foreach (var item in weixinBases)
|
|||
|
{
|
|||
|
objList.Add(item.WeixinHao);
|
|||
|
}
|
|||
|
|
|||
|
var qqBases = Chat.Framework.ChatClient.QQClients.Values;
|
|||
|
foreach (var item in qqBases)
|
|||
|
{
|
|||
|
objList.Add(item.QQ.ToString());
|
|||
|
}
|
|||
|
|
|||
|
this.comboBoxEdit3.Properties.Items.AddRange(objList);
|
|||
|
#endregion
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
private void group_manage_control_Load(object sender, EventArgs e)
|
|||
|
{
|
|||
|
this.pageControl1.Bind(delegate (int page, int pagesize)
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
var session = ApiClient.GetSession();
|
|||
|
var map = session.NewParamMap();
|
|||
|
map.setPageParamters(page, pagesize);
|
|||
|
string where = string.Empty;
|
|||
|
if (!string.IsNullOrEmpty(this.textEdit1.Text))
|
|||
|
where = " where (g.groupid like '%" + textEdit1.Text.Trim() + "%' or g.groupname like '%" + textEdit1.Text.Trim() + "%' or m.username like '%" + textEdit1.Text.Trim() + "%' or m.usernick like '%" + textEdit1.Text.Trim() + "%') ";
|
|||
|
|
|||
|
if (comboBoxEdit3.SelectedIndex != 0)
|
|||
|
where += string.IsNullOrWhiteSpace(where) ? " where m.robot_name = '" + comboBoxEdit3.Text + "'" : " and m.robot_name = '" + comboBoxEdit3.Text + "'";
|
|||
|
|
|||
|
var rest = session.FindPage<fl_group_person_temp>($"select g.id,m.id as mid,m.username,m.usernick,g.groupid,g.groupname from fl_group_person g inner join fl_member_info m on g.mid = m.id {where} ", map);
|
|||
|
|
|||
|
return new UI.Framework.Controls.PageControl.SerchResult() { Result = rest.DataList, Total = rest.Total };
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
XtraMessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|||
|
}
|
|||
|
return new UI.Framework.Controls.PageControl.SerchResult() { Result = null, Total = 0 };
|
|||
|
}, this.gridControl1, 50, true, true);
|
|||
|
}
|
|||
|
|
|||
|
private void simpleButton1_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
pageControl1.Go(sender, e);
|
|||
|
}
|
|||
|
|
|||
|
EditGroup editForm = null;
|
|||
|
private void 增加ToolStripMenuItem_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
editForm = new EditGroup();
|
|||
|
editForm.ShowDialog();
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
XtraMessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK);
|
|||
|
}
|
|||
|
finally
|
|||
|
{
|
|||
|
pageControl1.GotoPage(1);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private void 删除ToolStripMenuItem_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
var selectRow = gridView1.GetSelectedRows()[0];
|
|||
|
var id = this.gridView1.GetRowCellValue(selectRow, "id").ToString();//获取列的数据
|
|||
|
var session = ApiClient.GetSession();
|
|||
|
session.Deleteable<fl_group_person>().Where(f => f.id == int.Parse(id)).ExecuteCommand();
|
|||
|
XtraMessageBox.Show("删除成功", "提示", MessageBoxButtons.OK);
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
XtraMessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK);
|
|||
|
}
|
|||
|
finally
|
|||
|
{
|
|||
|
pageControl1.GotoPage(1);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private void 修改ToolStripMenuItem_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
var selectRow = gridView1.GetSelectedRows()[0];
|
|||
|
var id = this.gridView1.GetRowCellValue(selectRow, "id").ToString();//获取列的数据
|
|||
|
var session = ApiClient.GetSession();
|
|||
|
var group = session.Queryable<fl_group_person>().First(f => f.id == int.Parse(id));
|
|||
|
editForm = new EditGroup(group);
|
|||
|
editForm.ShowDialog();
|
|||
|
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
XtraMessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK);
|
|||
|
}
|
|||
|
finally
|
|||
|
{
|
|||
|
pageControl1.GotoPage(1);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private void gridView1_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e)
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
var selectRow = gridView1.GetSelectedRows()[0];
|
|||
|
var id = this.gridView1.GetRowCellValue(selectRow, "id").ToString();//获取列的数据
|
|||
|
//点击数大于2弹出窗体进行推广位的选择
|
|||
|
if (e.Clicks >= 2)
|
|||
|
{
|
|||
|
if (e.Column.FieldName == "username")
|
|||
|
{
|
|||
|
var memberForm = new MemberForm();
|
|||
|
if (memberForm.ShowDialog() == DialogResult.OK)
|
|||
|
{
|
|||
|
if (memberForm.member != null)
|
|||
|
{
|
|||
|
var session = ApiClient.GetSession();
|
|||
|
session.ExcuteSQL("update fl_group_person set mid = @mid where id = @id", new { mid = memberForm.member.id, id = id });
|
|||
|
XtraMessageBox.Show("修改成功", "提示", MessageBoxButtons.OK);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
XtraMessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK);
|
|||
|
}
|
|||
|
finally
|
|||
|
{
|
|||
|
pageControl1.GotoPage(1);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|