using Api.Framework; 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 InsertGroup : BaseForm { public InsertGroup(fl_plugin_delivery_group group) { InitializeComponent(); if (group != null) { this.group = group; this.textBox1.Enabled = false; this.textBox1.Text = group.name; this.textBox2.Text = group.position; this.textBox3.Text = group.weixinhao; } } fl_plugin_delivery_group group = null; private void simpleButton1_Click(object sender, EventArgs e) { try { if (string.IsNullOrEmpty(this.textBox1.Text)) throw new Exception("不能为空名称!"); var session = ApiClient.GetSession(); if (group == null) { group = session.Queryable().Where(f => f.name != this.textBox1.Text).Single(); if (group != null) throw new Exception("此名称已经存在!"); group = new fl_plugin_delivery_group() { name = this.textBox1.Text }; } group.position = this.textBox2.Text; group.weixinhao = this.textBox3.Text; session.Saveable(group).ExecuteCommand(); BaseForm.ShowSuccess("设置成功!"); this.Close(); } catch (Exception ex) { BaseForm.ShowError(ex); } } private void InsertGroup_Load(object sender, EventArgs e) { } } }