old_flsystem/应用/Delivery.Plugin/会员数据操作.cs

331 lines
12 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using Api.Framework;
using Api.Framework.Enums;
using Api.Framework.Model;
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 : BaseForm
{
public ()
{
InitializeComponent();
ShowList();
this.tabPane1.SelectedPageIndex = 0;
}
private void ShowList()
{
try
{
var session = ApiClient.GetSession();
List<fl_plugin_delivery_group> list = null;
//总记录数
list = Class1.GetGroups(true);
this.gridControl1.DataSource = list;
this.gridControl4.DataSource = list;
}
catch (Exception ex)
{
BaseForm.ShowError(ex);
}
}
private void gridView1_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e)
{
}
private void ToolStripMenuItem_Click(object sender, EventArgs e)
{
}
private void ToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
var rows = this.gridView1.GetSelectedRows();
if (rows != null && rows.Length > 0)
{
//获取选中数据
var group = this.gridView1.GetRow(rows[0]) as fl_plugin_delivery_group;
this.settingControl1.Bind(group);
}
else
{
this.settingControl1.Bind(new object());
}
}
catch (Exception)
{
}
}
private void ToolStripMenuItem_Click(object sender, EventArgs e)
{
this.settingControl1.Bind(new object());
}
private void ToolStripMenuItem_Click_1(object sender, EventArgs e)
{
this.settingControl1.Bind(new fl_plugin_delivery_group());
}
private void ToolStripMenuItem_Click(object sender, EventArgs e)
{
ShowList();
}
private void simpleButton1_Click(object sender, EventArgs e)
{
try
{
var group = this.settingControl1.PropertyControl.SelectedObject as fl_plugin_delivery_group;
if (group == null || group.GetType() != typeof(fl_plugin_delivery_group)) throw new Exception("保存失败,没有对象!");
var session = ApiClient.GetSession();
if (group.id == 0)
{
session.Insertable<fl_plugin_delivery_group>(group).ExecuteCommand();
ShowList();
}
else session.Updateable<fl_plugin_delivery_group>(group).ExecuteCommand();
BaseForm.ShowSuccess("保存成功!");
}
catch (Exception ex)
{
BaseForm.ShowError(ex);
}
}
private void ToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
var group = this.settingControl1.PropertyControl.SelectedObject as fl_plugin_delivery_group;
if (group == null || group.GetType() != typeof(fl_plugin_delivery_group)) throw new Exception("保存失败,没有对象!");
var msg = MessageBox.Show($"您确定要删除{group.name}吗?","是否删除,删除后不可找回",MessageBoxButtons.YesNo,MessageBoxIcon.Question);
if (msg != DialogResult.Yes) return;
var session = ApiClient.GetSession();
if (group.id != 0)
{
session.Deleteable<fl_plugin_delivery_group>(group).ExecuteCommand();
}
ShowList();
BaseForm.ShowSuccess("删除成功!");
}
catch (Exception ex)
{
BaseForm.ShowError(ex);
}
}
public class temp_mcode_entity
{
public long id { get; set; }
public string username { get; set; }
public string usernick { get; set; }
public long userid { get; set; }
public string m_code { get; set; }
public long usingid { get; set; }
public long orderid { get; set; }
public bool status { get; set; }
public CpsType order_type { get; set; }
public DateTime crt_time { get; set; }
}
private void ToolStripMenuItem1_Click(object sender, EventArgs e)
{
this.pageControl1.GotoPage(1);
}
private void _Load(object sender, EventArgs e)
{
try
{
this.pageControl1.Bind(delegate(int index,int pagesize)
{
try
{
var session = ApiClient.GetSession();
var list = session.SqlQueryable<temp_mcode_entity>($"select h.order_code m_code, h.id id,m.username username,m.usernick usernick,h.using_userid usingid,h.ordertable_type order_type,h.ordertable_id orderid,h.effective status,h.ordertable_cratetime crt_time from fl_plugin_delivery_hist h,fl_member_info m where h.userid=m.id order by h.id desc limit {(index-1) * pagesize},{pagesize}").ToList();
var row = session.FindRow("select count(id) count from fl_plugin_delivery_hist", null);
var count = int.Parse(row[0].ToString());
return new UI.Framework.Controls.PageControl.SerchResult() { Result = list, Total = count };
}
catch (Exception ex)
{
BaseForm.ShowError(ex);
}
return null;
},this.gridControl2, 30,true);
this.pageControl2.Bind(delegate(int index,int pagesize) {
try
{
if (grid3_group == null) return null;
var session = ApiClient.GetSession();
int toal = 0;
var str = DateTime.Parse(dateTimePicker1.Value.ToString("yyyy-MM-dd 00:00:00"));
var end = DateTime.Parse(dateTimePicker1.Value.ToString("yyyy-MM-dd 00:00:00")).AddDays(1);
var rst = session.Queryable<fl_plugin_delivery_item>().Where(f => f.groupid == grid3_group.id && f.crt_time>=str&& f.crt_time< end).OrderBy(f => f.crt_time, SqlSugar.OrderByType.Desc).ToPageList(index, pagesize, ref toal);
return new UI.Framework.Controls.PageControl.SerchResult() { Total = toal, Result = rst };
}
catch (Exception ex) { }
return null;
},this.gridControl3,100,false);
}
catch (Exception ex)
{
BaseForm.ShowError(ex);
}
}
private void ToolStripMenuItem_Click(object sender, EventArgs e)
{
new InsertQCode().ShowDialog();
this.pageControl1.GotoPage(1);
}
private fl_plugin_delivery_group grid3_group;
private void gridView4_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e)
{
try
{
this.gridControl3.DataSource = null;
var rows = this.gridView4.GetSelectedRows();
if (rows != null && rows.Length > 0)
{
grid3_group = this.gridView4.GetRow(rows[0]) as fl_plugin_delivery_group;
this.pageControl2.GotoPage(1);
}
}
catch (Exception )
{
}
}
private void gridView4_RowClick(object sender, DevExpress.XtraGrid.Views.Grid.RowClickEventArgs e)
{
try
{
this.gridControl3.DataSource = null;
var rows = this.gridView4.GetSelectedRows();
if (rows != null && rows.Length > 0)
{
grid3_group = this.gridView4.GetRow(rows[0]) as fl_plugin_delivery_group;
label1.Text = grid3_group.name;
this.pageControl2.GotoPage(1);
}
else
{
grid3_group = null;
label1.Text = string.Empty;
}
}
catch (Exception)
{
}
}
private void ToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
var rows = this.gridView3.GetSelectedRows();
if (rows != null && rows.Length > 0)
{
var info = this.gridView3.GetRow(rows[0]) as fl_plugin_delivery_item;
new SettingForm(info).ShowDialog();
var session = ApiClient.GetSession();
session.Updateable<fl_plugin_delivery_item>(info).ExecuteCommand();
}
}
catch (Exception)
{
}
}
private void ToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
var rows = this.gridView3.GetSelectedRows();
if (rows != null && rows.Length > 0)
{
var info = this.gridView3.GetRow(rows[0]) as fl_plugin_delivery_item;
var input = new InputKeywordForm();
input.ShowDialog();
if (!string.IsNullOrEmpty(input.Code))
{
var session = ApiClient.GetSession();
session.Deleteable<fl_plugin_delivery_item>(info).ExecuteCommand();
this.gridView3.DeleteRow(rows[0]);
var member = session.FindMemberInfoById(info.userid);
if (member == null) return;
var robot = session.FindRobotInfo(member.robot_name,member.robot_type);
if (robot == null) return;
ApiClient.SendMessage(robot,member.username, $"一一一一代 取 失 败一一一一\r\n取件码{info.q_code}\r\n免单码{info.m_code}\r\n备注说明{input.Code}");
}
}
}
catch (Exception) { }
}
private void simpleButton2_Click(object sender, EventArgs e)
{
this.pageControl2.GotoPage(1);
}
private void gridView1_RowClick(object sender, DevExpress.XtraGrid.Views.Grid.RowClickEventArgs e)
{
ToolStripMenuItem_Click(null,null);
}
private void ToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
var rows = this.gridView1.GetSelectedRows();
if (rows != null && rows.Length > 0)
{
//获取选中数据
var group = this.gridView1.GetRow(rows[0]) as fl_plugin_delivery_group;
new KuaidiForm(group).ShowDialog();
group.GetPositions(true);
}
}
catch (Exception)
{
}
}
}
}