old_flsystem/应用/Delivery.Plugin/InsertQCode.cs

59 lines
2.0 KiB
C#

using Api.Framework.Model;
using Delivery.Plugin.Model;
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 Delivery.Plugin
{
public partial class InsertQCode : Form
{
public InsertQCode()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
var session = Api.Framework.ApiClient.GetSession();
try
{
session.Ado.BeginTran();
var member = session.Queryable<fl_member_info>().Single(f=>f.id == this.numericUpDown1.Value);
if (member == null) throw new Exception("用户编号不存在!");
var msg = MessageBox.Show($"您确定要生成{this.numericUpDown2.Value}个免单码给{member.usernick}吗?","请确认",MessageBoxButtons.YesNo,MessageBoxIcon.Question);
if (msg == DialogResult.Yes)
{
List<fl_plugin_delivery_hist> list = new List<fl_plugin_delivery_hist>();
for (int i = 0; i < this.numericUpDown2.Value; i++)
{
list.Add(new fl_plugin_delivery_hist()
{
effective = true,
ordertable_cratetime = DateTime.MinValue,
order_code = Class1.GetRandomCode(session),
userid = member.id
});
}
session.Insertable<fl_plugin_delivery_hist>(list).ExecuteCommand();
BaseForm.ShowSuccess("已生成!");
}
session.Ado.CommitTran();
}
catch (Exception ex)
{
session.Ado.RollbackTran();
BaseForm.ShowError(ex);
}
}
}
}