115 lines
4.0 KiB
C#
115 lines
4.0 KiB
C#
|
using Models;
|
|||
|
using Service;
|
|||
|
using SqlSugar;
|
|||
|
using Sunny.UI;
|
|||
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.ComponentModel;
|
|||
|
using System.Data;
|
|||
|
using System.Drawing;
|
|||
|
using System.Linq;
|
|||
|
using System.Linq.Expressions;
|
|||
|
using System.Text;
|
|||
|
using System.Threading.Tasks;
|
|||
|
using System.Windows.Forms;
|
|||
|
|
|||
|
namespace LeatherApp.Page
|
|||
|
{
|
|||
|
public partial class SelectReelFrm : UIEditForm
|
|||
|
{
|
|||
|
//private DataTable ErpTb;
|
|||
|
RecordsService service = new RecordsService();
|
|||
|
List<string[]> ErpData = new List<string[]>();
|
|||
|
List<int> Indexs = new List<int>();
|
|||
|
|
|||
|
public string SelectBatch;
|
|||
|
public string SelectReel;
|
|||
|
public string SelectLen;
|
|||
|
|
|||
|
public int RowIndex = 0;
|
|||
|
public SelectReelFrm(DataTable tb)
|
|||
|
{
|
|||
|
InitializeComponent();
|
|||
|
|
|||
|
txtBatch.Text = tb.Rows[0][2].ToString();
|
|||
|
//ErpTb = tb.Clone();
|
|||
|
label4.Text = $"ERP信息:{tb.Rows.Count}条";
|
|||
|
InitView(tb);
|
|||
|
}
|
|||
|
|
|||
|
private Expression<Func<Records, bool>> createQueryExpression()
|
|||
|
{
|
|||
|
return Expressionable.Create<Records>()
|
|||
|
.And(it => it.CreateTime >= DateTime.Now.SetTime(0, 0, 0).AddDays(-1))
|
|||
|
.And(it => it.CreateTime < DateTime.Now.SetTime(0, 0, 0).AddDays(1))
|
|||
|
.AndIF(!string.IsNullOrWhiteSpace(txtBatch.Text), it => it.BatchId.Contains(txtBatch.Text.Trim()))
|
|||
|
.ToExpression();//注意 这一句 不能少
|
|||
|
}
|
|||
|
|
|||
|
private void InitView(DataTable ErpTb)
|
|||
|
{
|
|||
|
List<string> list = new List<string>();
|
|||
|
int totalCount =0;
|
|||
|
//var list2 = service.GetListNav(1, 10000, ref totalCount, createQueryExpression());
|
|||
|
//if (list2 != null && list2.Count > 0)
|
|||
|
//{
|
|||
|
// for (int i = 0; i < ErpTb.Rows.Count; i++)
|
|||
|
// {
|
|||
|
// var find = list2.Find(x => x.ReelId == ErpTb.Rows[i][3].ToString() || x.BatchId == ErpTb.Rows[i][2].ToString());
|
|||
|
// if (find == null)
|
|||
|
// {
|
|||
|
// Indexs.Add(i);
|
|||
|
// list.Add(ErpTb.Rows[i][3].ToString());
|
|||
|
// ErpData.Add(new string[] { ErpTb.Rows[i][2].ToString(), ErpTb.Rows[i][4].ToString(), ErpTb.Rows[i][1].ToString() });
|
|||
|
// }
|
|||
|
// }
|
|||
|
//}
|
|||
|
//else
|
|||
|
{
|
|||
|
for (int i = 0; i < ErpTb.Rows.Count; i++)
|
|||
|
{
|
|||
|
Indexs.Add(i);
|
|||
|
list.Add(ErpTb.Rows[i][3].ToString());
|
|||
|
ErpData.Add(new string[] { ErpTb.Rows[i][2].ToString(), ErpTb.Rows[i][4].ToString(), ErpTb.Rows[i][1].ToString() });
|
|||
|
}
|
|||
|
}
|
|||
|
if (list.Count > 0)
|
|||
|
{
|
|||
|
cmbReel.DataSource = list;
|
|||
|
cmbReel.SelectedIndex = 0;
|
|||
|
txtLen.Text = ErpData[0][2];
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
lbErr.Visible = true;
|
|||
|
lbErr.Text = $"ERP数据卷号都已经记录-{ErpTb.Rows.Count}";
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private void cmbReel_SelectedIndexChanged(object sender, EventArgs e)
|
|||
|
{
|
|||
|
if (cmbReel.SelectedIndex >= 0)
|
|||
|
{
|
|||
|
txtBatch.Text = ErpData[cmbReel.SelectedIndex][0];
|
|||
|
txtLen.Text = ErpData[cmbReel.SelectedIndex][2];
|
|||
|
RowIndex = Indexs[cmbReel.SelectedIndex];
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private void btnCancel_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
this.DialogResult = DialogResult.Cancel;
|
|||
|
this.Close();
|
|||
|
}
|
|||
|
|
|||
|
private void btnOK_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
RowIndex = Indexs[cmbReel.SelectedIndex];
|
|||
|
SelectBatch = txtBatch.Text;
|
|||
|
SelectReel = cmbReel.Text;
|
|||
|
SelectLen = txtLen.Text;
|
|||
|
this.DialogResult= DialogResult.OK;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|