using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using QMAPP.WinForm.Common; using QMAPP.FJC.Entity.Operation; using QMAPP.Entity; namespace QMAPP.WinForm.Forms.Mend { public partial class ProductCheckValuesFrom : Form { CheckValueItem searchModel = new CheckValueItem(); CheckWithMaterial recorder = new CheckWithMaterial(); ProductCheckAddForm addForm = new ProductCheckAddForm(); public ProductCheckValuesFrom(ProductCheckAddForm checkcode) { addForm = checkcode; recorder.CHECKITEMCODE = addForm.DGData.SelectedRows[0].Cells["CHECKITEMCODE"].Value.ToString(); InitializeComponent(); } #region 窗体加载 /// /// 窗体加载 /// /// /// private void ProductCheckValuesFrom_Load(object sender, EventArgs e) { new KeyEvent().SetKeyToTxt(this); #region 绑定下拉列表 BasicData basicData = new BasicData(); //获取检测值下拉信息 string checkcode = recorder.CHECKITEMCODE; OutReason searchModelType = new OutReason(); this.comInputValue.DataSource = basicData.GetInputValueList(checkcode, true); this.comInputValue.DisplayMember = "INPUTVALUE"; this.comInputValue.ValueMember = "INPUTVALUE"; #endregion #region 加载编辑 //判断是否为编辑加载编辑数据 if (string.IsNullOrEmpty(addForm.DGData.SelectedRows[0].Cells["CHECKITEMCODE"].Value.ToString()) == false) { CheckWithMaterial searchInfo = new CheckWithMaterial(); //QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent(); //searchInfo = agent.InvokeServiceFunction("ProductCheckBLL_GetCheckWithMaterial", recorder); searchInfo.INPUTTYPE = addForm.DGData.SelectedRows[0].Cells["INPUTTYPE"].Value.ToString(); //一定是存在的 this.txtCheckItem.Text = addForm.DGData.SelectedRows[0].Cells["CHECKITEMCODE"].Value.ToString(); this.txtValueUp.Text = addForm.DGData.SelectedRows[0].Cells["STANDERDVALUE_UPPER"].Value.ToString(); this.txtValueDown.Text = addForm.DGData.SelectedRows[0].Cells["STANDERDVALUE_DOWN"].Value.ToString(); if (addForm.DGData.SelectedRows[0].Cells["INPUTVALUE"].Value!=null) { if (searchInfo.INPUTTYPE == "1") { this.comInputValue.SelectedValue = addForm.DGData.SelectedRows[0].Cells["INPUTVALUE"].Value.ToString(); } else { this.txtInputValue.Text = addForm.DGData.SelectedRows[0].Cells["INPUTVALUE"].Value.ToString(); } } //下拉为1 if(searchInfo.INPUTTYPE=="1") { this.comInputValue.Visible = true; this.txtInputValue.Visible=false; this.comInputValue.Focus(); } else { this.txtInputValue.Visible = true; this.comInputValue.Visible = false; this.txtInputValue.Focus(); } } } #endregion #endregion #region 窗体关闭 /// /// 点击关闭返回 /// /// /// private void tsbBack_Click(object sender, EventArgs e) { //this.DialogResult = DialogResult.OK; this.Close(); } /// /// 点击右上角X关闭窗口 /// /// /// private void SendCodeForm_FormClosing(object sender, FormClosingEventArgs e) { //this.DialogResult = DialogResult.OK; e.Cancel = false; } #endregion #region 保存 /// /// 保存 /// /// /// private void tsbSave_Click(object sender, EventArgs e) { if (this.txtInputValue.Text == string.Empty && this.comInputValue.Text.ToString() == "") { this.labelError.Text = "请输入检测值!"; return; } //校验输入的值是否正确 recorder.CHECKITEMCODE=this.txtCheckItem.Text; recorder.STANDERDVALUE_UPPER=this.txtValueUp.Text; recorder.STANDERDVALUE_DOWN = this.txtValueDown.Text; if (string.IsNullOrEmpty(this.txtInputValue.Text)==false) { recorder.INPUTVALUE = this.txtInputValue.Text; } else { recorder.INPUTVALUE = this.comInputValue.Text; } this.UpdateAddGrid(recorder); this.Close(); } #endregion #region 更新界面Grid /// /// 更新界面Grid /// /// private void UpdateAddGrid(CheckWithMaterial recorder) { addForm.UpdateGrid(recorder.CHECKITEMCODE, recorder.INPUTVALUE); } #endregion } }