using Api.Framework;
using Api.Framework.Events;
using Api.Framework.Tools;
using PointManage.Properties;
using System;
using System.Windows.Forms;
using UI.Framework.Forms;
namespace PointManage
{
public partial class MainForm : BaseForm
{
public MainForm()
{
InitializeComponent();
this.Text = Resources.MainFormTitle;
}
public void CloseForm()
{
try
{
if (!this.IsDisposed)
{
this.Invoke(new Action(delegate
{
this.Close();
this.Dispose();
}));
}
}
catch (Exception ex)
{
ShowError(ex.Message);
}
}
private void MainForm_Load(object sender, EventArgs e)
{
try
{
this.settingControl1.Bind(Class1.Config, 215);
}
catch (Exception ex)
{
ShowError(ex);
}
}
///
/// 窗体关闭检验签到积分是否符合规则
///
///
///
private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
{
try
{
if (Class1.Config.Checkin_Reward_Min > Class1.Config.Checkin_Reward_Max)
{
ShowSuccessAutoClose("签到奖励积分:最小值不能大于最大值");
e.Cancel = true;
}
else if (Class1.Config.Exchange_Min_Point > Class1.Config.Exchange_Max_Point)
{
ShowSuccessAutoClose("每次最低提现额度:最小值不能大于最大值");
e.Cancel = true;
}
else if (Class1.Config.Exchange_Min_Point > Class1.Config.Exchange_Transmatic_Maxpoint)
{
ShowSuccessAutoClose("微信自动转账额度应该大于等于每次最低提现额度");
e.Cancel = true;
}
else if (Class1.Config.Exchange_Transmatic_Maxpoint > Class1.Config.Exchange_Max_Point)
{
ShowSuccessAutoClose("微信自动转账额度应该小于等于每次最高提现额度");
e.Cancel = true;
}
else if (Class1.Config.Extra_Award_Min_Point > Class1.Config.Extra_Award_Max_Point)
{
ShowSuccessAutoClose("结算抢红包金额:最小值不能大于最大值");
e.Cancel = true;
}
if (!e.Cancel)
{
Util.Save(Class1.Config);
EventClient.OnEvent(this, MethodType.刷新配置文件);//刷新积分管理中的配置文件
}
}
catch (Exception ex)
{
ShowError(ex);
}
}
}
}