using Api.Framework;
using Api.Framework.Model;
using Api.Framework.Tools;
using DevExpress.XtraEditors;
using System;
using System.Windows.Forms;
namespace FLSystem.Forms
{
public partial class member_order_lastnum : UserControl
{
public class view_member_order_lastnum
{
///
/// id
///
public long id { get; set; }
private string _username;
///
/// 用户账号
///
public string username
{
get { return _username; }
set { if (string.IsNullOrEmpty(value)) _username = string.Empty; else _username = value; }
}
private string _usernick;
///
/// 用户昵称
///
public string usernick
{
get { return _usernick; }
set { if (string.IsNullOrEmpty(value)) _usernick = string.Empty; else _usernick = value; }
}
///
/// 商品单价
///
public string lastnumber { get; set; }
}
public member_order_lastnum()
{
InitializeComponent();
try
{
this.pageControl1.Bind(delegate (int page, int pagesize)
{
try
{
var session = ApiClient.GetSession();
var map = session.NewParamMap();
map.setPageParamters(page, pagesize);
string where = string.Empty;
if (!string.IsNullOrEmpty(this.textEdit1.Text.Trim()))
{
where = " where ";
switch (this.comboBoxEdit1.Text)
{
case "客户账号":
{
where += " username like @username";
map.setParameter("username", "%" + this.textEdit1.Text.Trim() + "%");
break;
}
case "客户昵称":
{
where += " usernick like @usernick";
map.setParameter("usernick", "%" + this.textEdit1.Text.Trim() + "%");
break;
}
case "订单尾号":
{
where += " lastnumber = @lastnumber";
map.setParameter("lastnumber", this.textEdit1.Text.Trim());
break;
}
}
}
var rest = session.FindPage($"select aol.id,mi.username,mi.usernick,aol.lastnumber from fl_alimama_order_lastnum aol LEFT JOIN fl_member_info mi on aol.userid = mi.id {where} ", map);
return new UI.Framework.Controls.PageControl.SerchResult() { Result = rest.DataList, Total = rest.Total };
}
catch (Exception ex)
{
XtraMessageBox.Show(ex.Message, "搜索标题", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
return new UI.Framework.Controls.PageControl.SerchResult() { Result = null, Total = 0 };
}, this.gridControl1, 30, true, true);
}
catch (Exception ex)
{
XtraMessageBox.Show(ex.Message, "删除选中项", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void simpleButton1_Click(object sender, EventArgs e)
{
this.pageControl1.Go(sender, e);
}
private void comboBoxEdit1_SelectedIndexChanged(object sender, EventArgs e)
{
if (comboBoxEdit1.SelectedIndex == 0)
{
this.textEdit1.Enabled = false;
this.textEdit1.Text = "";
}
else this.textEdit1.Enabled = true;
}
private void 删除选中项ToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
if (XtraMessageBox.Show("是否删除选中项", "温馨提示", MessageBoxButtons.OKCancel) == DialogResult.Cancel) return;
var session = ApiClient.GetSession();
var selectRow = gridView1.GetSelectedRows()[0];
var id = this.gridView1.GetRowCellValue(selectRow, "id").ToString();//获取列的数据
session.Deleteable().Where(f => f.id == int.Parse(id)).ExecuteCommand();
pageControl1.GotoPage(1);
XtraMessageBox.Show("删除成功", "温馨实体", MessageBoxButtons.OK);
}
catch (Exception ex)
{
XtraMessageBox.Show(ex.Message, "删除选中项", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void 删除所有数据ToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
if (XtraMessageBox.Show("确定删除所有项", "温馨提示", MessageBoxButtons.OKCancel) == DialogResult.OK)
{
var session = ApiClient.GetSession();
session.ExcuteSQL("delete from fl_alimama_order_lastnum");
pageControl1.GotoPage(1);
XtraMessageBox.Show("删除成功", "温馨提示", MessageBoxButtons.OK);
}
}
catch (Exception ex)
{
XtraMessageBox.Show(ex.Message, "删除选中项", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void 手动添加尾号ToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
var from = new member_order_lastnum_custom();
from.ShowDialog();
}
catch (Exception ex)
{
XtraMessageBox.Show(ex.Message, "手动添加尾号", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}