259 lines
8.6 KiB
C#
259 lines
8.6 KiB
C#
using Api.Framework;
|
|
using Api.Framework.Tools;
|
|
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 WindowsForm : BaseForm
|
|
{
|
|
public void CloseForm()
|
|
{
|
|
try
|
|
{
|
|
if (!this.IsDisposed)
|
|
{
|
|
this.Invoke(new Action(delegate
|
|
{
|
|
this.Close();
|
|
this.Dispose();
|
|
}));
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ShowError(ex);
|
|
}
|
|
}
|
|
|
|
public WindowsForm()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void 增加学校ToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
new InsertGroup(null).ShowDialog();
|
|
simpleButton1_Click(null,null);
|
|
}
|
|
|
|
private void 修改属性ToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void simpleButton1_Click(object sender, EventArgs e)
|
|
{
|
|
//this.pageControl1.GotoPage(1);
|
|
}
|
|
|
|
private void 删除学校ToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
var rst = MessageBox.Show("您确定要删除吗?","友情提示",MessageBoxButtons.YesNo,MessageBoxIcon.Question);
|
|
if (rst == DialogResult.Yes)
|
|
{
|
|
var rows = this.gridView1.GetSelectedRows();
|
|
if (rows != null && rows.Length > 0)
|
|
{
|
|
//获取选中数据
|
|
var row = this.gridView1.GetRow(rows[0]) as fl_plugin_delivery_group;
|
|
var session = ApiClient.GetSession();
|
|
session.Ado.ExecuteCommand("DELETE FROM fl_plugin_delivery_group WHERE ID=" + row.id);
|
|
simpleButton1_Click(null, null);
|
|
}
|
|
}
|
|
|
|
}
|
|
catch (Exception)
|
|
{
|
|
|
|
}
|
|
}
|
|
private void ShowList()
|
|
{
|
|
try
|
|
{
|
|
this.settingControl1.Bind(Class1.config);
|
|
var session = ApiClient.GetSession();
|
|
List<fl_plugin_delivery_group> list = null;
|
|
//总记录数
|
|
|
|
if (!string.IsNullOrEmpty(this.textBox1.Text))
|
|
{
|
|
list = session.Queryable<fl_plugin_delivery_group>().Where(f => f.name.Contains(this.textBox1.Text) || f.weixinhao.Contains(this.textBox1.Text)).ToList();
|
|
}
|
|
else
|
|
{
|
|
list = session.Queryable<fl_plugin_delivery_group>().ToList();
|
|
}
|
|
|
|
this.gridControl1.DataSource = list;
|
|
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
BaseForm.ShowError(ex);
|
|
}
|
|
}
|
|
private string serch_mdm_keword = string.Empty;
|
|
private int serch_mdm_type = 0;
|
|
private void WindowsForm_Load(object sender, EventArgs e)
|
|
{
|
|
ShowList();
|
|
|
|
this.pageControl1.Bind(delegate (int index, int size)
|
|
{
|
|
try
|
|
{
|
|
var session = ApiClient.GetSession();
|
|
var count = 0;
|
|
List<fl_plugin_delivery_hist> list = null;
|
|
if (!string.IsNullOrEmpty(serch_mdm_keword))
|
|
{
|
|
switch (serch_mdm_type)
|
|
{
|
|
case 1:
|
|
list = session.Queryable<fl_plugin_delivery_hist>().Where(f=>f.userid == int.Parse(serch_mdm_keword)).OrderBy(f => f.id, SqlSugar.OrderByType.Desc).ToPageList(index, size, ref count);
|
|
break;
|
|
case 2:
|
|
list = session.Queryable<fl_plugin_delivery_hist>().Where(f => f.order_code == serch_mdm_keword).OrderBy(f => f.id, SqlSugar.OrderByType.Desc).ToPageList(index, size, ref count);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}else list = session.Queryable<fl_plugin_delivery_hist>().OrderBy(f=>f.id, SqlSugar.OrderByType.Desc).ToPageList(index, size, ref count);
|
|
|
|
return new UI.Framework.Controls.PageControl.SerchResult() { Result = list,Total = count};
|
|
}
|
|
catch (Exception)
|
|
{
|
|
}
|
|
return null;
|
|
|
|
}, this.gridControl2, 50);
|
|
|
|
|
|
}
|
|
|
|
private void simpleButton2_Click(object sender, EventArgs e)
|
|
{
|
|
group = null;
|
|
this.textBox4.Text = this.textBox2.Text = this.textBox3.Text = this.textBox5.Text = string.Empty;
|
|
}
|
|
fl_plugin_delivery_group group = null;
|
|
private void gridView1_RowClick(object sender, DevExpress.XtraGrid.Views.Grid.RowClickEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
var rows = this.gridView1.GetSelectedRows();
|
|
if (rows != null && rows.Length > 0)
|
|
{
|
|
//获取选中数据
|
|
group = this.gridView1.GetRow(rows[0]) as fl_plugin_delivery_group;
|
|
this.textBox4.Text = group.name;
|
|
this.textBox2.Text = group.position;
|
|
this.textBox3.Text = group.weixinhao;
|
|
this.textBox5.Text = group.admins;
|
|
}
|
|
else
|
|
{
|
|
simpleButton2_Click(null,null);
|
|
}
|
|
}
|
|
catch (Exception)
|
|
{
|
|
|
|
}
|
|
}
|
|
|
|
private void simpleButton1_Click_1(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (string.IsNullOrEmpty(this.textBox4.Text)) throw new Exception("不能为空名称!");
|
|
var session = ApiClient.GetSession();
|
|
if (group == null)
|
|
{
|
|
group = session.Queryable<fl_plugin_delivery_group>().Where(f => f.name == this.textBox4.Text).Single();
|
|
if (group != null) throw new Exception("此名称已经存在!");
|
|
group = new fl_plugin_delivery_group() { name = this.textBox4.Text };
|
|
}
|
|
|
|
group.name = this.textBox4.Text;
|
|
group.position = this.textBox2.Text;
|
|
group.weixinhao = this.textBox3.Text;
|
|
group.admins = this.textBox5.Text;
|
|
session.Saveable<fl_plugin_delivery_group>(group).ExecuteReturnEntity();
|
|
Class1.GetGroups(true);
|
|
BaseForm.ShowSuccess("设置成功!");
|
|
ShowList();
|
|
//this.Close();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
BaseForm.ShowError(ex);
|
|
}
|
|
}
|
|
|
|
private void gridView1_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e)
|
|
{
|
|
gridView1_RowClick(null,null);
|
|
|
|
}
|
|
|
|
private void simpleButton3_Click(object sender, EventArgs e)
|
|
{
|
|
group = null;
|
|
simpleButton1_Click_1(null,null);
|
|
ShowList();
|
|
Class1.GetGroups(true);
|
|
}
|
|
|
|
private void WindowsForm_FormClosing(object sender, FormClosingEventArgs e)
|
|
{
|
|
Util.Save(Class1.config);
|
|
}
|
|
|
|
private void 增加免单码ToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
new InsertQCode().ShowDialog();
|
|
}
|
|
|
|
private void 刷新免单码ToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
this.serch_mdm_keword = string.Empty;
|
|
this.pageControl1.GotoPage(1);
|
|
}
|
|
|
|
private void toolStripMenuItem1_Click(object sender, EventArgs e)
|
|
{
|
|
var f = new InputKeywordForm();
|
|
f.ShowDialog();
|
|
this.serch_mdm_keword = f.Code;
|
|
this.serch_mdm_type = 1;
|
|
this.pageControl1.GotoPage(1);
|
|
}
|
|
|
|
private void 通过免单码搜索ToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
var f = new InputKeywordForm();
|
|
f.ShowDialog();
|
|
this.serch_mdm_keword = f.Code;
|
|
this.serch_mdm_type = 2;
|
|
this.pageControl1.GotoPage(1);
|
|
}
|
|
}
|
|
}
|