using Core.Mes.Client.Comm.Format;
using Core.Mes.Client.Comm.Server;
using Core.Mes.Client.Comm.Tool;
using Core.StlMes.Client.Lims.Data.PipeAndOutdec.封装类.实体类;
using CoreFS.CA06;
using Infragistics.Win.UltraWinEditors;
using Infragistics.Win.UltraWinGrid;
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Core.StlMes.Client.Lims.Data.PipeAndOutdec.数据管理.外委实验管理
{
//商检金属物理试验条件
public partial class FrmOutdecLabMetDataParm : FrmBase
{
private string CHECK_NO = "";
private string SAMPLE_NO = "";
private string PHY_CODE_MAX = "";
private OpeBase _ob;
public FrmOutdecLabMetDataParm(string checkNo, string sampleNo, string phyCodeMax, OpeBase ob)
{
InitializeComponent();
CHECK_NO = checkNo;
SAMPLE_NO = sampleNo;
PHY_CODE_MAX = phyCodeMax;
_ob = ob;
Query();
}
private void FrmOutdecLabMecDataParm_Load(object sender, EventArgs e)
{
if (PHY_CODE_MAX == "C0114" ) //晶间腐蚀试验
{
ultraTabControl1.Tabs[1].Visible = false;
}
else // 金相检验试验
{
ultraTabControl1.Tabs[0].Visible = false;
if (PHY_CODE_MAX == "C0013" || PHY_CODE_MAX == "C0015" || PHY_CODE_MAX == "C0050" )
{
ultraLabel104.Text = "组织";
}
else if (PHY_CODE_MAX == "C0012" || PHY_CODE_MAX == "C0104" )
{
ultraLabel104.Text = "晶粒度";
}
else if (PHY_CODE_MAX == "C0011" || PHY_CODE_MAX == "C0115")
{
ultraLabel104.Text = "非金属夹杂物";
}
else if (PHY_CODE_MAX == "C0014")
{
ultraLabel104.Text = "脱碳层";
}
}
}
///
/// 查询
///
private void Query()
{
ArrayList list = new ArrayList();
list.Add(CHECK_NO);
list.Add(SAMPLE_NO);
list.Add(PHY_CODE_MAX);
DataTable dt = PublicServer.GetData("com.steering.lims.data.outdec.FrmOutdecLabDateParm.QueryOutdecCheckconsignDetail", new Object[] { list }, _ob);
if (dt.Rows.Count > 0)
{
DataRow ur = dt.Rows[0];
ShowBaseInfo(ur);
}
}
///
/// 点击Grid编辑区显示基本信息
///
///
public void ShowBaseInfo(DataRow ur)
{
if (ur != null)
{
if (PHY_CODE_MAX == "C0114") //晶间腐蚀试验
{
foreach (DataColumn uc in ur.Table.Columns)
{
if (ultraPanel3.ClientArea.Controls.ContainsKey("kk" + uc.ColumnName) == true)//判定是否存在text
{
((UltraTextEditor)ultraPanel3.ClientArea.Controls["kk" + uc.ColumnName]).Text = ur[uc.ColumnName].ToString();
}
}
}
else //金相检验试验
{
foreach (DataColumn uc in ur.Table.Columns)
{
if (ultraPanel6.ClientArea.Controls.ContainsKey("yd" + uc.ColumnName) == true)//判定是否存在text
{
((UltraTextEditor)ultraPanel6.ClientArea.Controls["yd" + uc.ColumnName]).Text = ur[uc.ColumnName].ToString();
}
}
}
}
}
///
/// 保存晶间腐蚀条件
///
///
///
private void ultraButton3_Click(object sender, EventArgs e)
{
OutdecCheckconsignLabResultEntity outdecDetail = new OutdecCheckconsignLabResultEntity();
outdecDetail.TechnicalStandard = kkTECHNICAL_STANDARD.Text;
outdecDetail.Note = kkNOTE.Text;
outdecDetail.Note2 = kkNOTE2.Text;
outdecDetail.CheckNo = CHECK_NO;
outdecDetail.SampleNo = SAMPLE_NO;
outdecDetail.PhyCodeMax = PHY_CODE_MAX;
string outdecDetailStr = JSONFormat.Format(outdecDetail);
PublicServer.SetData("com.steering.lims.data.outdec.FrmOutdecLabDateParm.SaveCheckconsignDetailParm",
new Object[] { outdecDetailStr }, _ob);
MessageUtil.ShowTips("保存成功!");
}
///
/// 保存金相检验实验条件
///
///
///
private void ultraButton6_Click(object sender, EventArgs e)
{
OutdecCheckconsignLabResultEntity outdecDetail = new OutdecCheckconsignLabResultEntity();
outdecDetail.TechnicalStandard = ydTECHNICAL_STANDARD.Text;
outdecDetail.Note = ydNOTE.Text;
outdecDetail.Note2 = ydNOTE2.Text;
outdecDetail.Note3 = ydNOTE3.Text;
outdecDetail.CheckNo = CHECK_NO;
outdecDetail.SampleNo = SAMPLE_NO;
outdecDetail.PhyCodeMax = PHY_CODE_MAX;
string outdecDetailStr = JSONFormat.Format(outdecDetail);
PublicServer.SetData("com.steering.lims.data.outdec.FrmOutdecLabDateParm.SaveCheckconsignDetailParm",
new Object[] { outdecDetailStr }, _ob);
MessageUtil.ShowTips("保存成功!");
}
///
/// 查看图片
///
///
private void selectFiel()
{
string filePath = "Inspection/" + CHECK_NO + "/" + SAMPLE_NO + "/" + PHY_CODE_MAX + "/";
//if (!ultra.Text.Equals(""))
//{
// filePath = ultra.Value.ToString();
//}
dlgOrderAskDown down = new dlgOrderAskDown(this.ob, filePath);
//down.DeleteButton.Visible = false;
down.ShowDialog();
}
///
/// 上传图片
///
///
private void updateFile()
{
string path = "Inspection/" + CHECK_NO + "/" + SAMPLE_NO + "/" + PHY_CODE_MAX + "/";
var serverFileList = FileHelper.Download(path);
List list = new List();
FileBean bean = new FileBean();
OpenFileDialog file = new OpenFileDialog();
file.Multiselect = true;
file.Title = "选择需要上传的图片";
file.Filter = "图片文件(*.jpg);(*.gif);(*.png);(*.bmp)|*.jpg;*.gif;*.png;*.bmp";
DialogResult drStat;
drStat = file.ShowDialog();
if (drStat == DialogResult.OK)
{
foreach (string fileName in file.FileNames)
{
string name = System.IO.Path.GetFileName(fileName);
bean = new FileBean();
bean.setFileName(name);
bean.setPathName(path);
bean.setFile(FileHelper.FileToArray(fileName));
list.Add(bean);
}
bool isSuccess = Core.Mes.Client.Comm.Server.FileHelper.Upload(list);
if (isSuccess)
{
string fileNames = "";
List fileBeans = FileHelper.Download(path);
foreach (var fileBean in fileBeans)
{
if (fileNames == "")
{
fileNames = path + fileBean.getFileName();
}
else
{
fileNames += "#" + path + fileBean.getFileName();
}
}
UpdatePath(fileNames, CHECK_NO,SAMPLE_NO, PHY_CODE_MAX);
MessageUtil.ShowTips("上传成功!");
}
else
{
MessageUtil.ShowTips("上传失败,请重试!");
}
}
}
private void UpdatePath(string path, string checkNo, string SAMPLE_NO, string PHY_CODE_MAX)
{
ServerHelper.SetData("com.steering.lims.data.outdec.FrmOutdecLabDateParm.updateMetallographicTestFile",
new object[] { path, checkNo, SAMPLE_NO, PHY_CODE_MAX }, _ob);
}
private void ydFILE_PATH1_EditorButtonClick(object sender, EditorButtonEventArgs e)
{
if (e.Button.Key.ToLower().Equals("select"))
{
selectFiel();
}
else if (e.Button.Key.ToLower().Equals("update"))
{
updateFile();
Query();
}
}
}
}