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.PipeAndOutdec
{
public partial class FrmOutdecCheckPrice : FrmBase
{
private DataTable m_dtLH;//理化
private DataTable m_dtHX;//化学
public FrmOutdecCheckPrice()
{
InitializeComponent();
}
private void FrmOutdecCheckPrice_Load(object sender, EventArgs e)
{
InitColumns();
QueryPhyMaxItems();
QueryChemItems();
ultraCHECK_PRICE_TYPE.Text = "";
ultraCHECK_PRICE_TYPE.Text = "理化";
}
private void InitColumns()
{
string[] arrColumns = new string[] { "CHECK_PRICE_NO", "CHECK_PRICE_TYPE", "CHECK_PRICE_TYPE_DESC", "PHY_CODE_MAX", "PHY_NAME_MAX", "JG_PRICE", "CHECK_PRICE", "CREATE_NAME", "CREATE_TIME", "UPDATE_NAME", "UPDATE_TIME", "VALIDFLAG", "REMARK" };
string[] arrCaption = new string[] { "编号", "项目类型", "项目类型", "检验项编号", "检验项名称", "加工费用", "试验费用", "创建人", "创建时间", "修改人", "修改时间", "有效标志", "备注" };
PublicPipeAndOutdec.InitColumns(arrColumns, arrCaption, dataTable1);
PublicPipeAndOutdec.setColumnShowOrHidden(ultraGrid1, new string[] { "CHECK_PRICE_TYPE", "PHY_CODE_MAX", "VALIDFLAG" }, false);
PublicPipeAndOutdec.setOtherColumnReadOnly(ultraGrid1, null);
}
//查询理化项目大类信息
private void QueryPhyMaxItems()
{
try
{
DataTable dt = PublicServer.GetData("com.steering.lims.data.base.FrmBaseSelectItems.QueryPhySampleCode",
new Object[] { }, this.ob);
if (dt == null || dt.Rows.Count == 0)
{
return;
}
m_dtLH = dt.Copy();
ultraPHY_NAME_MAX.DataSource = dt;
ultraPHY_NAME_MAX.ValueMember = "PHY_CODE_MAX";
ultraPHY_NAME_MAX.DisplayMember = "PHY_NAME_MAX";
}
catch (Exception e)
{
MessageUtil.ShowWarning(e.Message);
return;
}
}
//查询理化项目大类信息
private void QueryChemItems()
{
try
{
DataTable dtHX = new DataTable();
DataColumn dc = new DataColumn("PHY_CODE");
dc.Caption = "检测项目编号";
dtHX.Columns.Add(dc);
dc = new DataColumn("PHY_TYPE");
dc.Caption = "检测项目名称";
dtHX.Columns.Add(dc);
DataRow dr = dtHX.NewRow();
string[] arrchemMin = PublicPipeAndOutdec.chemMin.Split(' ');
for (int i = 0; i < arrchemMin.Length; i++)
{
dr = dtHX.NewRow();
dr[0] = arrchemMin[i].ToUpper();
dr[0] = arrchemMin[i];
dtHX.Rows.Add(dr);
}
m_dtHX = dtHX.Copy();
//ultraPHY_NAME_MAX.DataSource = dt;
//ultraPHY_NAME_MAX.ValueMember = "PHY_CODE";
//ultraPHY_NAME_MAX.DisplayMember = "PHY_TYPE";
}
catch (Exception e)
{
MessageUtil.ShowWarning(e.Message);
return;
}
}
///
/// 重写基类方法
///
///
///
public override void ToolBar_Click(object sender, string ToolbarKey)
{
switch (ToolbarKey)
{
case "Query":
QueryCheckPriceInfo();
break;
case "Add":
AddCheckPriceInfo();
break;
case "Update":
UpdateCheckPriceInfo();
break;
case "Delete":
DeleteCheckPriceInfo();
break;
case "Close":
if (MessageUtil.ShowYesNoAndQuestion("是否确认关闭页面?") == DialogResult.Yes)
{
this.Close();
}
break;
}
}
//查询检验委托基本信息
private void QueryCheckPriceInfo()
{
try
{
ArrayList al = new ArrayList();
//al.Add(chkVALIDFLAG.Checked ? "01" : "1");
al.Add(chkCHECK_PRICE_TYPE.Checked == false || ultraQueryCHECK_PRICE_TYPE.Text.Trim() == "" ? "" : ultraQueryCHECK_PRICE_TYPE.Value.ToString());
DataTable dt = PublicServer.GetData("com.steering.lims.data.outdec.FrmOutdecCheckPrice.QueryCheckPriceInfo",
new Object[] { al }, ob);
if (dt == null || dt.Rows.Count == 0)
{
dataTable1.Rows.Clear();
txtREMARK.Text = "";
return;
}
GridHelper.CopyDataToDatatable(dt, dataTable1, true);//把dt复制给dataTable1
GridHelper.RefreshAndAutoSize(ultraGrid1);//刷新Grid
}
catch (Exception e)
{
MessageUtil.ShowWarning(e.Message);
return;
}
}
//增加试验方法基本信息
private void AddCheckPriceInfo()
{
try
{
if (ultraPHY_NAME_MAX.Text.Trim() == "")
{
MessageUtil.ShowWarning("检测项目不能为空!");
return;
}
if (txtJG_PRICE.Text == "")
{
MessageUtil.ShowWarning("加工费用不能为空!");
return;
}
if (txtCHECK_PRICE.Text == "")
{
MessageUtil.ShowWarning("试验费用不能为空!");
return;
}
string strPHY_NAME_MAX = ultraPHY_NAME_MAX.Text.Trim();
PublicServer.GetDataTips("com.steering.lims.data.outdec.FrmOutdecCheckPrice.QueryCheckPriceInfoTips",
new Object[] { strPHY_NAME_MAX, "1", "此检验项目已经维护!" }, ob);
if (MessageUtil.ShowYesNoAndQuestion("是否确认新增?") == DialogResult.Yes)
{
ArrayList al = new ArrayList();
//al.Add(txtCHECK_METHOD_NO.Text.Trim());//方法编号
al.Add(ultraCHECK_PRICE_TYPE.Value.ToString());//方法类型
al.Add(ultraPHY_NAME_MAX.Value);
al.Add(strPHY_NAME_MAX);
al.Add(txtJG_PRICE.Value);
al.Add(txtCHECK_PRICE.Value);//试验费用
al.Add(UserInfo.GetUserName());//人
//al.Add(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));//时间
//al.Add("1");//状态位
al.Add(txtREMARK.Text.Trim());
PublicServer.SetData("com.steering.lims.data.outdec.FrmOutdecCheckPrice.AddCheckPriceInfo",
new Object[] { al }, this.ob);
QueryCheckPriceInfo();
PublicPipeAndOutdec.ActiveOperateRow(ultraGrid1, "PHY_NAME_MAX", strPHY_NAME_MAX);
MessageUtil.ShowTips("新增成功!");
}
}
catch (Exception e)
{
MessageUtil.ShowWarning(e.Message);
return;
}
}
//增加试验方法基本信息
private void UpdateCheckPriceInfo()
{
try
{
if (ultraGrid1 == null || ultraGrid1.ActiveRow == null || ultraGrid1.ActiveRow.Activated == false)
{
MessageUtil.ShowWarning("请点击选择一条需要修改的数据!");
return;
}
if (ultraPHY_NAME_MAX.Text.Trim() == "")
{
MessageUtil.ShowWarning("检测项目不能为空!");
return;
}
if (txtJG_PRICE.Text == "")
{
MessageUtil.ShowWarning("加工费用不能为空!");
return;
}
if (txtCHECK_PRICE.Text == "")
{
MessageUtil.ShowWarning("试验费用不能为空!");
return;
}
string strPHY_NAME_MAX = ultraPHY_NAME_MAX.Text.Trim();
if (strPHY_NAME_MAX != ultraGrid1.ActiveRow.Cells["PHY_NAME_MAX"].Text.Trim())
{
MessageUtil.ShowWarning("检验项目不能修改!");
return;
}
if (MessageUtil.ShowYesNoAndQuestion("是否确认修改?") == DialogResult.Yes)
{
ArrayList al = new ArrayList();
//al.Add(txtCHECK_METHOD_NO.Text.Trim());//方法编号
al.Add(ultraCHECK_PRICE_TYPE.Value.ToString());//方法类型
al.Add(ultraPHY_NAME_MAX.Value);
al.Add(ultraPHY_NAME_MAX.Text.Trim());
al.Add(txtJG_PRICE.Value);
al.Add(txtCHECK_PRICE.Value);//试验费用
al.Add(UserInfo.GetUserName());//人
//al.Add(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));//时间
//al.Add("1");//状态位
al.Add(txtREMARK.Text.Trim());
al.Add(ultraGrid1.ActiveRow.Cells["CHECK_PRICE_NO"].Text.Trim());
PublicServer.SetData("com.steering.lims.data.outdec.FrmOutdecCheckPrice.UpdateCheckPriceInfo",
new Object[] { al }, this.ob);
QueryCheckPriceInfo();
PublicPipeAndOutdec.ActiveOperateRow(ultraGrid1, "PHY_NAME_MAX", strPHY_NAME_MAX);
MessageUtil.ShowTips("修改成功!");
}
}
catch (Exception e)
{
MessageUtil.ShowWarning(e.Message);
return;
}
}
//增加试验方法基本信息
private void DeleteCheckPriceInfo()
{
try
{
if (ultraGrid1 == null || ultraGrid1.ActiveRow == null || ultraGrid1.ActiveRow.Activated == false)
{
MessageUtil.ShowWarning("请点击选择一条需要删除的数据!");
return;
}
if (MessageUtil.ShowYesNoAndQuestion("是否确认删除?") == DialogResult.Yes)
{
ArrayList al = new ArrayList();
al.Add(ultraGrid1.ActiveRow.Cells["CHECK_PRICE_NO"].Text.Trim());
PublicServer.SetData("com.steering.lims.data.outdec.FrmOutdecCheckPrice.DeleteCheckPriceInfo",
new Object[] { al }, this.ob);
QueryCheckPriceInfo();
//PublicPipeAndOutdec.ActiveOperateRow(ultraGrid1, "PHY_NAME_MAX", ultraPHY_NAME_MAX.Text.Trim());
MessageUtil.ShowTips("删除成功!");
}
}
catch (Exception e)
{
MessageUtil.ShowWarning(e.Message);
return;
}
}
private void ultraCHECK_PRICE_TYPE_TextChanged(object sender, EventArgs e)
{
if (ultraCHECK_PRICE_TYPE.Text == "理化")
{
ultraPHY_NAME_MAX.DataSource = m_dtLH;
ultraPHY_NAME_MAX.ValueMember = "PHY_CODE_MAX";
ultraPHY_NAME_MAX.DisplayMember = "PHY_NAME_MAX";
}
else
{
ultraPHY_NAME_MAX.DataSource = m_dtHX;
ultraPHY_NAME_MAX.ValueMember = "PHY_CODE";
ultraPHY_NAME_MAX.DisplayMember = "PHY_TYPE";
}
}
private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
{
ultraCHECK_PRICE_TYPE.Text = ultraGrid1.ActiveRow.Cells["CHECK_PRICE_TYPE_DESC"].Text.Trim();
ultraPHY_NAME_MAX.Text = ultraGrid1.ActiveRow.Cells["PHY_NAME_MAX"].Text.Trim();
txtJG_PRICE.Text = (ultraGrid1.ActiveRow.Cells["JG_PRICE"].Text.Trim() == "" ? "0" : ultraGrid1.ActiveRow.Cells["JG_PRICE"].Text.Trim());
txtCHECK_PRICE.Text = (ultraGrid1.ActiveRow.Cells["CHECK_PRICE"].Text.Trim() == "" ? "0" : ultraGrid1.ActiveRow.Cells["CHECK_PRICE"].Text.Trim());
txtREMARK.Text = ultraGrid1.ActiveRow.Cells["REMARK"].Text.Trim();
}
private void chkCHECK_PRICE_TYPE_CheckedChanged(object sender, EventArgs e)
{
ultraQueryCHECK_PRICE_TYPE.Enabled = chkCHECK_PRICE_TYPE.Checked;
}
}
}