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 CoreFS.CA03;
using CoreFS.CA04;
using CoreFS.CA06;
using System.Collections;
using Infragistics.Win.UltraWinGrid;
using Core.Mes.Client.Comm.Server;
using Core.Mes.Client.Comm.Control;
using Core.Mes.Client.Comm.Tool;
namespace Core.StlMes.Client.Lims.Data.Mat
{
public partial class FrmBaseMatCheckItem : FrmBase
{
public FrmBaseMatCheckItem()
{
InitializeComponent();
}
private void FrmBaseMatCheckItem_Load(object sender, EventArgs e)
{
InitColumns();
}
private void InitColumns()
{
string[] arrColumnsBase = new string[] { "DEPT_ID", "DEPT_ID_DESC", "MAT_CODE", "MAT_NAME", "MAT_TYPE", "MAT_TYPE_DESC", "MAT_UNIT", "VALUE_TYPE", "VALUE_TYPE_DESC", "SHOW_SEQ", "REMARK", "CREATE_NAME", "CREATE_TIME", "UPDATE_NAME", "UPDATE_TIME" };
string[] arrCaptionBase = new string[] { "试验室", "试验室", "项目编号", "项目名称", "项目类型", "项目类型", "结果单位", "结果类型", "结果类型", "显示顺序", "备注", "创建人", "创建时间", "修改人", "修改时间" };
PublicMat.InitColumns(arrColumnsBase, arrCaptionBase, dataTable1);
PublicMat.setColumnShowOrHidden(ultraGrid1, new string[] { "DEPT_ID", "MAT_TYPE", "VALUE_TYPE" }, false);
PublicMat.setOtherColumnReadOnly(ultraGrid1, null);//可编辑列
}
///
/// 重写基类方法
///
///
///
public override void ToolBar_Click(object sender, string ToolbarKey)
{
switch (ToolbarKey)
{
case "Query":
QueryMatCheckItem();
break;
case "Add":
AddMatCheckItem();
break;
case "Update":
UpdateMatCheckItem();
break;
case "Delete":
DeleteMatCheckItem();
break;
case "Close":
if (MessageUtil.ShowYesNoAndQuestion("是否确认关闭页面?") == DialogResult.Yes)
{
this.Close();
}
break;
}
}
//查询检验项目基本信息
private void QueryMatCheckItem()
{
try
{
dataTable1.Rows.Clear();
ArrayList al = new ArrayList();
al.Add(ultraQueryDEPT_ID.UltDept_ID);
al.Add(ultraQueryDEPT_ID.UltDept_ID);
al.Add(ultraQueryDEPT_ID.UltDept_ID);
al.Add(txtQueryMAT_NAME.Text.Trim());
DataTable dt = PublicServer.GetData("com.steering.lims.data.base.FrmBaseMatCheckItem.QueryMatCheckItem",
new Object[] { al }, this.ob);
if (dt == null || dt.Rows.Count == 0)
{
return;
}
GridHelper.CopyDataToDatatable(dt, dataTable1, true);//把dt复制给dataTable1
GridHelper.RefreshAndAutoSize(ultraGrid1);//刷新Grid
}
catch (Exception ex)
{
MessageUtil.ShowWarning(ex.Message);
}
}
private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
{
ultraDEPT_ID.UltDept_Name = ultraGrid1.ActiveRow.Cells["DEPT_ID_DESC"].Text.Trim();
txtMAT_CODE.Text = ultraGrid1.ActiveRow.Cells["MAT_CODE"].Text.Trim();
txtMAT_NAME.Text = ultraGrid1.ActiveRow.Cells["MAT_NAME"].Text.Trim();
ultraMAT_TYPE.Text = ultraGrid1.ActiveRow.Cells["MAT_TYPE_DESC"].Text.Trim();
txtMAT_UNIT.Text = ultraGrid1.ActiveRow.Cells["MAT_UNIT"].Text.Trim();
ultraVALUE_TYPE.Text = ultraGrid1.ActiveRow.Cells["VALUE_TYPE_DESC"].Text.Trim();
txtSHOW_SEQ.Text = ultraGrid1.ActiveRow.Cells["SHOW_SEQ"].Text.Trim();
txtREMARK.Text = ultraGrid1.ActiveRow.Cells["REMARK"].Text.Trim();
}
//判断录入是否符合规则
private string isRule()
{
if (ultraDEPT_ID.UltDept_Name == "")
{
return "试验室不能为空!";
}
if (txtMAT_NAME.Text.Trim() == "")
{
return "项目名称不能为空!";
}
//if (txtMAT_UNIT.Text.Trim() == "")
//{
// return "结果单位不能为空!";
//}
return "";
}
//增加检验项目基本信息
private void AddMatCheckItem()
{
try
{
string strAddChem = isRule();
if (strAddChem != "")
{
MessageUtil.ShowWarning(strAddChem);
return;
}
if (MessageUtil.ShowYesNoAndQuestion("是否确认新增?") == DialogResult.Yes)
{
string strMat_Name = txtMAT_NAME.Text.Trim();
ArrayList al = new ArrayList();
//al.Add(txtCHECK_METHOD_NO.Text.Trim());//方法编号
al.Add(ultraDEPT_ID.UltDept_ID);//所属试验室
al.Add(strMat_Name);//名称
al.Add(ultraMAT_TYPE.Value.ToString());//类型
al.Add(txtMAT_UNIT.Text.Trim());//单位
al.Add(ultraVALUE_TYPE.Value.ToString());//结果类型
//al.Add(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
al.Add("");
al.Add(txtREMARK.Text.Trim());
al.Add(UserInfo.GetUserName());
PublicServer.SetData("com.steering.lims.data.base.FrmBaseMatCheckItem.AddMatCheckItem",
new Object[] { al, strMat_Name }, this.ob);
QueryMatCheckItem();
PublicMat.ActiveOperateRow(ultraGrid1, "MAT_NAME", strMat_Name);
MessageUtil.ShowTips("新增成功!");
}
}
catch (Exception ex)
{
MessageUtil.ShowWarning(ex.Message);
}
}
//修改检验项目基本信息
private void UpdateMatCheckItem()
{
try
{
if (ultraGrid1.ActiveRow == null || ultraGrid1.ActiveRow.Activated == false)
{
return;
}
string strAddChem = isRule();
if (strAddChem != "")
{
MessageUtil.ShowWarning(strAddChem);
return;
}
if (MessageUtil.ShowYesNoAndQuestion("是否确认修改?") == DialogResult.Yes)
{
string strMat_Name = txtMAT_NAME.Text.Trim();
ArrayList al = new ArrayList();
//al.Add(txtCHECK_METHOD_NO.Text.Trim());//方法编号
al.Add(ultraDEPT_ID.UltDept_ID);//所属试验室
al.Add(strMat_Name);//名称
al.Add(ultraMAT_TYPE.Value.ToString());//类型
al.Add(txtMAT_UNIT.Text.Trim());//单位
al.Add(ultraVALUE_TYPE.Value.ToString());//结果类型
//al.Add(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
al.Add("");
al.Add(txtSHOW_SEQ.Text.Trim());
al.Add(txtREMARK.Text.Trim());
al.Add(UserInfo.GetUserName());
al.Add(txtMAT_CODE.Text.Trim());
PublicServer.SetData("com.steering.lims.data.base.FrmBaseMatCheckItem.UpdateMatCheckItem",
new Object[] { al, ultraGrid1.ActiveRow.Cells["MAT_NAME"].Text.Trim() == strMat_Name ? "" : strMat_Name }, this.ob);
QueryMatCheckItem();
PublicMat.ActiveOperateRow(ultraGrid1, "MAT_NAME", strMat_Name);
MessageUtil.ShowTips("修改成功!");
}
}
catch (Exception ex)
{
MessageUtil.ShowWarning(ex.Message);
}
}
//删除检验项目基本信息
private void DeleteMatCheckItem()
{
try
{
if (ultraGrid1.ActiveRow == null || ultraGrid1.ActiveRow.Activated == false)
{
return;
}
if (MessageUtil.ShowYesNoAndQuestion("是否确认删除?") == DialogResult.Yes)
{
ArrayList al = new ArrayList();
al.Add(ultraGrid1.ActiveRow.Cells["MAT_CODE"].Text.Trim());
PublicServer.SetData("com.steering.lims.data.base.FrmBaseMatCheckItem.DeleteMatCheckItem",
new Object[] { al }, this.ob);
QueryMatCheckItem();
//PublicMat.ActiveOperateRow(ultraGrid1, "MAT_NAME", strMat_Name);
MessageUtil.ShowTips("删除成功!");
}
}
catch (Exception ex)
{
MessageUtil.ShowWarning(ex.Message);
}
}
private void txtSHOW_SEQ_TextChanged(object sender, EventArgs e)
{
if (txtSHOW_SEQ.Text.Trim() != "" && !StringUtil.IsNumber(txtSHOW_SEQ.Text.Trim()))
{
MessageUtil.ShowTips("显示顺序只能为数字!");
txtSHOW_SEQ.Text = "";
return;
}
}
}
}