old_flsystem/FLSystem/Forms/change_point_form.cs

101 lines
3.2 KiB
C#
Raw Normal View History

2022-09-20 03:10:29 +00:00
using Api.Framework;
using Api.Framework.Enums;
using Api.Framework.Model;
using Api.Framework.Tools;
using DevExpress.XtraEditors;
using SqlSugar;
using System;
using System.Linq;
using System.Threading;
using System.Windows.Forms;
using UI.Framework.Forms;
namespace FLSystem.Forms
{
public partial class change_point_form : BaseForm
{
private long uid;
private fl_member_info member = null;
private SqlSugarClient session = null;
public change_point_form(long uid)
{
InitializeComponent();
session = ApiClient.GetSession();
this.uid = uid;
hyperlinkLabelControl1_Click(null, null);
}
private void button1_Click(object sender, EventArgs e)
{
try
{
if (member != null)
{
if (numericUpDown1.Value == 0m) throw new Exception("积分值不能为0");
member = session.ChangePoint(PointType., (double)numericUpDown1.Value, member.id, string.IsNullOrWhiteSpace(textBox1.Text) ? $"手动修改积分:{numericUpDown1.Value} 积分" : textBox1.Text.Trim());
#region
if (!string.IsNullOrWhiteSpace(memoEdit1.Text))
{
var robot = session.FindRobots().FirstOrDefault(f => f.type == member.robot_type && f.name == member.robot_name);
if (robot != null)
ApiClient.SendMessage(robot, member.username, new VariateReplace().CommonReplace(memoEdit1.Text.Replace("[修改金额]", numericUpDown1.Value.ToString("0.00")), member));
}
#endregion
ShowSuccess("修改成功");
label1.Text = member.cur_point.ToString();
}
}
catch (Exception ex)
{
ShowError(ex);
}
}
private void button2_Click(object sender, EventArgs e)
{
this.Close();
}
/// <summary>
/// 刷新
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void hyperlinkLabelControl1_Click(object sender, EventArgs e)
{
try
{
hyperlinkLabelControl1.Enabled = false;
if (uid != 0)
{
member = session.FindMemberInfoById(uid);
if (member != null)
{
label1.Text = member.cur_point.ToString();
Thread.Sleep(1000);
}
}
}
catch (Exception ex)
{
ShowError(ex);
}
finally
{
hyperlinkLabelControl1.Enabled = true;
}
}
private void hyperlinkLabelControl_Click(object sender, EventArgs e)
{
if (sender is HyperlinkLabelControl)
{
var label = sender as HyperlinkLabelControl;
memoEdit1.Text += label.Text;
}
}
}
}