锐腾搅拌上料功能
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

136 lines
4.4 KiB

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 FormEcAdd : DevExpress.XtraEditors.XtraForm
{
List<SelectItemExt> ItemList = new List<SelectItemExt>();
public List<IcsLotEcDataDto> EcDatas { get; set; }
public FormEcAdd( Func<List<SelectItemExt>> GetEcMes, List<IcsLotEcDataDto> ecDatas)
{
InitializeComponent();
this.ItemList= GetEcMes.Invoke();
this.EcDatas = ecDatas;
}
public void LoadEcSource()
{
try
{
txtEcCode.Properties.ValueMember = "Value";
txtEcCode.Properties.DisplayMember = "Text";
txtEcCode.Properties.DataSource = ItemList;
var column= txtEcCode.Properties.View.Columns;
txtEcCode.Properties.NullText = "";//空时的值
txtEcCode.Properties.ImmediatePopup = true;//输入值是否马上弹出窗体
txtEcCode.Properties.ValidateOnEnterKey = true;//回车确认
txtEcCode.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;//要使用户可以输入,这里须设为Standard
txtEcCode.Properties.AllowNullInput = DevExpress.Utils.DefaultBoolean.True; //可用Ctrl + Delete清空选择內容 //自适应宽度
txtEcCode.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup;
grdDetail.DataSource = EcDatas;
grvDetail.RefreshData();
//grvDetail.BestFitColumns();
}
catch (Exception ex)
{
ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
}
}
private void btnOK_Click(object sender, EventArgs e)
{
this.DialogResult = DialogResult.OK;
this.Close();
}
private void FormEcAdd_Load(object sender, EventArgs e)
{
LoadEcSource();
}
private void btnBigenOrSuspend_Click(object sender, EventArgs e)
{
try
{
if (string.IsNullOrEmpty(txtEcCode.EditValue?.ToString()))
throw new Exception("请先选择不良代码!");
if (string.IsNullOrEmpty(txtEcQty.EditValue?.ToString()))
throw new Exception("请先输入不良数量!");
if (EcDatas.Where(a => a.EcCode == txtEcCode.EditValue.ToString()).FirstOrDefault() != null)
throw new Exception("已录入改不良代码,请勿重复操作!");
IcsLotEcDataDto ecDto = new IcsLotEcDataDto();
ecDto.EcCode = txtEcCode.EditValue.ToString();
ecDto.EcName = txtEcCode.Text.ToString();
ecDto.OpNgQty =Convert.ToDecimal(txtEcQty.EditValue);
EcDatas.Add(ecDto);
grvDetail.RefreshData();
}
catch (Exception ex)
{
ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
}
}
private void btnEditDel_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
{
try
{
var selectValue = grvDetail.GetFocusedRowCellValue(colEcCode).ToString();
EcDatas.Remove(EcDatas.Where(a => a.EcCode == 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();
}
}
}