old_flsystem/应用/监听违规/AddForm.cs

49 lines
1.5 KiB
C#
Raw Normal View History

2022-09-20 03:10:29 +00:00
using Api.Framework;
using Api.Framework.Tools;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using .Entitys;
namespace
{
public partial class AddForm : Form
{
public AddForm()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
try
{
var username = tb_username.Text;
if (string.IsNullOrWhiteSpace(username)) throw new Exception("用户账号不能为空");
var session = ApiClient.GetSession();
var user = session.FindSingle<UserLists_db>("wxid = @wxid", new { wxid = username });
if (user != null) throw new Exception("已经存在该用户,无需重复添加");
var utype = (UserType)Enum.Parse(typeof(UserType), cb_usertype.Text);
var nick = tb_nick.Text;
user = new UserLists_db() { wxid = username, user_type = utype, nick_name = nick };
session.Insertable(user).ExecuteCommand();
Common.FlushWhiteUserListsCache(true);
MessageBox.Show("添加成功");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
}