using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using DevExpress.XtraEditors; using System.Data.SqlClient; using ICSSoft.Frame.APP; using System.Configuration; using ICSSoft.Frame.APP.Helper; using ICSSoft.Frame.APP.Model; using DevExpress.XtraGrid.Columns; using System.Linq; namespace ICSSoft.Frame.APP { public partial class FormItemLotBatchInput : DevExpress.XtraEditors.XtraForm { public DataTable itemLotnoMsg { get; set; } Func, DataTable> Func { get; set; } public FormItemLotBatchInput(Func,DataTable> func) { InitializeComponent(); this.Func = func; } private void btnOK_Click(object sender, EventArgs e) { if (this.itemLotnoMsg == null || this.itemLotnoMsg.Rows.Count <= 0) { ICSBaseSimpleCode.AppshowMessageBox("请先扫描物料条码!"); return; } this.DialogResult = DialogResult.OK; this.Close(); } private void FormEcAdd_Load(object sender, EventArgs e) { } private void btnEditDel_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e) { try { var selectValue = grvDetail.GetFocusedRowCellValue(colItemLotNo).ToString(); itemLotnoMsg.Rows.Remove(itemLotnoMsg.AsEnumerable().Where(a => a["ItemLotNo"].ToString() == selectValue).FirstOrDefault()); grvDetail.RefreshData(); } catch (Exception ex) { ICSBaseSimpleCode.AppshowMessageBox(ex.Message); } } private void btnCancle_Click(object sender, EventArgs e) { this.DialogResult = DialogResult.Cancel; this.Close(); } private void btnClose_Click(object sender, EventArgs e) { this.DialogResult = DialogResult.Cancel; this.Close(); } private void txtItemLotNo_KeyPress(object sender, KeyPressEventArgs e) { try { if (e.KeyChar != (char)Keys.Enter) return; List itemlotNos = new List(); if (itemLotnoMsg != null && itemLotnoMsg.Rows.Count > 0) { itemlotNos = itemLotnoMsg.AsEnumerable().Select(a => a["ItemLotNo"].ToString()).ToList(); } itemlotNos.Add(this.txtItemLotNo.Text); var table=Func.Invoke(itemlotNos); itemLotnoMsg = table; this.grdDetail.DataSource = itemLotnoMsg; this.grvDetail.BestFitColumns(); txtItemLotNo.Focus(); txtItemLotNo.Text = ""; } catch (Exception ex) { ICSBaseSimpleCode.AppshowMessageBox(ex.Message); } } } }