72 lines
2.6 KiB
C#
72 lines
2.6 KiB
C#
using Api.Framework;
|
|
using Api.Framework.Model;
|
|
using Api.Framework.Tools;
|
|
using DevExpress.XtraEditors;
|
|
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 FLSystem.Forms
|
|
{
|
|
public partial class member_order_lastnum_custom : BaseForm
|
|
{
|
|
public member_order_lastnum_custom()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void button2_Click(object sender, EventArgs e)
|
|
{
|
|
this.Close();
|
|
}
|
|
|
|
private void button1_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (string.IsNullOrWhiteSpace(textEdit1.Text)) throw new Exception("用户编号不能为空");
|
|
if (string.IsNullOrWhiteSpace(textEdit2.Text)) throw new Exception("用户订单尾号不能为空");
|
|
if (textEdit2.Text.Length != 6) throw new Exception("用户订单尾号只能为6位");
|
|
if (textEdit1.Tag == null) throw new Exception("用户编码对应的用户不存在,请核对");
|
|
|
|
var db = ApiClient.GetSession();
|
|
var last = db.FindAlimamaOrderLastnums().FirstOrDefault(f => textEdit2.Text.Trim() == f.lastnumber && f.userid == long.Parse(textEdit1.Text.Trim()));
|
|
if (last != null)
|
|
throw new Exception("用户已存在,无需重复添加");
|
|
last = new fl_alimama_order_lastnum() { lastnumber = textEdit2.Text.Trim(), userid = long.Parse(textEdit1.Text.Trim()) };
|
|
db.Saveable(last).ExecuteCommand();
|
|
XtraMessageBox.Show("添加成功", "温馨提示", MessageBoxButtons.OK);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
XtraMessageBox.Show(ex.Message, "异常提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
}
|
|
}
|
|
|
|
private void textEdit1_EditValueChanged(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (textEdit1.Text.Trim() == "0") throw new Exception("无");
|
|
var session = ApiClient.GetSession();
|
|
var member = session.FindMemberInfoById(int.Parse(textEdit1.Text.Trim()));
|
|
if (member == null) throw new Exception("数据异常");
|
|
textEdit3.Text = member.usernick;
|
|
textEdit1.Tag = member;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
textEdit3.Text = ex.Message;
|
|
textEdit1.Tag = null;
|
|
}
|
|
}
|
|
}
|
|
}
|