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 UI.Framework.Forms; namespace FissionData { public partial class CashForm : BaseForm { FissionClass fissionClass = null; public CashForm(FissionClass fissionClass) { InitializeComponent(); this.fissionClass = fissionClass; } private void CashForm_Load(object sender, EventArgs e) { try { labelControl5.Text = fissionClass.invited.ToString(); labelControl6.Text = fissionClass.consumed.ToString(); labelControl7.Text = fissionClass.fle.ToString(); numericUpDown1.Value = Class1.Config.cash_rule; } catch (Exception ex) { ShowError(ex); } } private void CashForm_FormClosing(object sender, FormClosingEventArgs e) { Util.Save(Class1.Config); } bool isSuccess = true; private void simpleButton1_Click(object sender, EventArgs e) { if (!isSuccess) return; isSuccess = false; try { int num = (int)numericUpDown1.Value; if (fissionClass.fle < num) throw new Exception("兑换人数不足"); fissionClass.fle -= num; fissionClass.consumed += num; var session = ApiClient.GetSession(); session.Updateable(fissionClass).ExecuteCommand(); this.DialogResult = DialogResult.OK; ShowSuccessAutoClose("兑换成功",3000); } catch (Exception ex) { ShowError(ex); } finally { isSuccess = true; } } } }