using Core.Mes.Client.Comm.Control;
using Core.Mes.Client.Comm.Format;
using Core.Mes.Client.Comm.Server;
using Core.Mes.Client.Comm.Tool;
using Core.StlMes.Client.Qcm.model;
using CoreFS.CA06;
using Infragistics.Win.UltraWinEditors;
using Infragistics.Win.UltraWinGrid;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Windows.Forms;
namespace Core.StlMes.Client.Qcm
{
///
/// 探伤要求
///
public partial class FrmComMSCStdDetection : FrmBase
{
private bool isPasting = false;
//全局变量 错误信息
private string errMessage = "";
//用于判断是否勾选
//private int isSelect = 0;
private string _dic = "";
private bool _isEx = false;
private string dic = "";
public string Dic
{
get { return dic; }
set { dic = value; }
}
private string msc = "";
public string Msc
{
get { return msc; }
set { msc = value; }
}
private string codeJg = "DefaultValue";
public string CodeJg
{
get { return codeJg; }
set { codeJg = value; }
}
private string stdCode = "";
public string StdCode
{
get { return stdCode; }
set { stdCode = value; }
}
//用于过滤内控适用标准集合
private string stdCodesNk = "";
public string StdCodesNk
{
get { return stdCodesNk; }
set { stdCodesNk = value; }
}
private string stdStylesNk = "";
public string StdStylesNk
{
get { return stdStylesNk; }
set { stdStylesNk = value; }
}
//是否是内控维护界面
private string isNkEdite = "0";
public string IsNkEdite
{
get { return isNkEdite; }
set { isNkEdite = value; }
}
private ArrayList steelCodes = new ArrayList();
public ArrayList SteelCodes
{
get { return steelCodes; }
set { steelCodes = value; }
}
private string produccodeNk = "";
public string ProduccodeNk
{
get { return produccodeNk; }
set { produccodeNk = value; }
}
private string steelcodeNk = "";
public string SteelcodeNk
{
get { return steelcodeNk; }
set { steelcodeNk = value; }
}
private string processCode = "";
public string ProcessCode
{
get { return processCode; }
set { processCode = value; }
}
private string modelCode = "";
public string ModelCode
{
get { return modelCode; }
set { modelCode = value; }
}
private string acceptBid = "";
public string AcceptBid
{
get { return acceptBid; }
set { acceptBid = value; }
}
private UltraComboEditor[] ultras = new UltraComboEditor[11];
public FrmComMSCStdDetection()
{
IsLoadUserView = true;
InitializeComponent();
ExceptionHelper.RegistException();
}
public void PopupLoad(string customInfo, OpeBase ob)
{
this.CustomInfo = customInfo;
this.ob = ob;
FrmComMSCStdDetection_Load(null, null);
}
public void PopupRefresh()
{
UltraGridBand ugb = ultraGrid1.DisplayLayout.Bands[0];
if (CustomInfo == "1")
{ //冶金规范码
QcmBaseQuery.NitializeMSC(ultras[0], false, this.ob, msc);
//QcmBaseCommon.InitDrop(ultras[0], "com.steering.pss.qcm.ComBaseQuery.getMsc", "MSC", "MSC", false, this.ob);
ugb.Columns["MSC"].EditorComponent = ultras[0];
ugb.Columns["MSC"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;
}
}
///
/// 初始化下拉框
///
private void InitDownList()
{
for (int i = 0; i < ultras.Length; i++)
{
ultras[i] = new UltraComboEditor();
this.Controls.Add(ultras[i]);
ultras[i].Visible = false;
ultras[i].DropDownListWidth = -1;
}
//主表
UltraGridBand ugb = ultraGrid1.DisplayLayout.Bands[0];
//从表
UltraGridBand ugbC = ultraGrid1.DisplayLayout.Bands[1];
if (CustomInfo == "1")
{ //冶金规范码
QcmBaseQuery.NitializeMSC(ultras[0], false, this.ob, msc);
//QcmBaseCommon.InitDrop(ultras[0], "com.steering.pss.qcm.ComBaseQuery.getMsc", "MSC", "MSC", false, this.ob);
ugb.Columns["MSC"].EditorComponent = ultras[0];
ugb.Columns["MSC"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;
}
if (CustomInfo != "1")
{ //标准名称
if (CustomInfo == "2")
{
QcmBaseCommon.InitDrop(ultras[1], "com.steering.pss.qcm.ComBaseQuery.geComBaseStdN", "STD_NAME", "STD_CODE", false, this.ob);
InnerChange();
}
else if (CustomInfo == "3")
QcmBaseCommon.InitDrop(ultras[1], "com.steering.pss.qcm.ComBaseQuery.geComBaseStdK", "STD_NAME", "STD_CODE", false, this.ob);
else
QcmBaseCommon.InitDrop(ultras[1], "com.steering.pss.qcm.ComBaseQuery.geComBaseStdS", "STD_NAME", "STD_CODE", false, this.ob);
ugb.Columns["STD_CODE_NK"].EditorComponent = ultras[1];
ugb.Columns["STD_CODE_NK"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;
}
//探伤位置
QcmBaseCommon.InitDrop(ultras[2], "com.steering.pss.qcm.ComBaseQuery.geComBaseInfo4020", "BASENAME", "BASECODE", false, this.ob);
ugbC.Columns["POSITION_CODE"].EditorComponent = ultras[2];
ugbC.Columns["POSITION_CODE"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;
//所有工序
QcmBaseCommon.InitDrop(ultras[5], "com.steering.pss.qcm.ComBaseQuery.geComBaseProcessAll", "PROCESS_DESC", "PROCESS_CODE", true, this.ob);
ugb.Columns["PROCESS_CODE"].EditorComponent = ultras[5];
ugb.Columns["PROCESS_CODE"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;
//检验项
QcmBaseCommon.InitDrop(ultras[6], "com.steering.pss.qcm.ComBaseQuery.getComBasePhyD", "PHY_NAME", "PHY_CODE", true, this.ob);
ugbC.Columns["PHY_CODE"].EditorComponent = ultras[6];
ugbC.Columns["PHY_CODE"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;
//刻槽位置
QcmBaseCommon.InitDrop(ultras[7], "com.steering.pss.qcm.ComBaseQuery.geComBaseInfo4023", "BASENAME", "BASENAME", false, this.ob);
ugbC.Columns["GROOVE_POS"].EditorComponent = ultras[7];
ugbC.Columns["GROOVE_POS"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;
//刻槽方向
QcmBaseCommon.InitDrop(ultras[8], "com.steering.pss.qcm.ComBaseQuery.geComBaseInfo4024", "BASENAME", "BASENAME", false, this.ob);
ugbC.Columns["GROOVE_DIR"].EditorComponent = ultras[8];
ugbC.Columns["GROOVE_DIR"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;
//检验频次
QcmBaseCommon.InitDrop(ultras[9], "com.steering.pss.qcm.ComBaseQuery.geComBaseInfo4011", "BASENAME", "BASECODE", false, this.ob);
ugbC.Columns["DESC_RATE"].EditorComponent = ultras[9];
ugbC.Columns["DESC_RATE"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;
QcmBaseQuery.NitializeProductBigType(ultras[10], false, ob);
QcmBaseQuery.BindColumn(ultras[10], "PRODUC_HEAD", ugb);
ClsBaseInfo.SetComboItemHeight(ultras[10]);
}
public override void ToolBar_Click(object sender, string ToolbarKey)
{
switch (ToolbarKey)
{
case "Query":
this.DoQuery();
break;
case "Delete":
DoUpdateOrResume(true);
break;
case "Resume":
DoUpdateOrResume(false);
break;
case "Save":
DoSave();
break;
case "Copy":
Copy();
break;
case "Paste":
isPasting = true;
try
{
Paste();
}
finally
{
isPasting = false;
}
break;
case "Refresh":
InitDownList();
break;
case "Group":
DoGroup();
break;
case "Cancel":
CancelGroup();
break;
case "Close":
this.Close();
break;
}
}
///
/// 复制
///
private void Copy()
{
if (ultraGrid1.ActiveRow == null)
{
MessageUtil.ShowWarning("请选择记录后,再进行操作!");
return;
}
ultraGrid1.UpdateData();
DataTable copyTab = dataTable2.Copy();
DataTable copyTab2 = dataTable1.Copy();
copyTab.Clear();
copyTab2.Clear();
if (ultraGrid1.ActiveRow.HasParent())
{
foreach (UltraGridRow row in ultraGrid1.ActiveRow.ParentRow.ChildBands[0].Rows)
{
if (row.GetValue("CHC") != "True") continue;
DataRow dr = copyTab.NewRow();
CopyRowToRow(((DataRowView)row.ListObject).Row, dr);
copyTab.Rows.Add(dr);
}
}
else
{
foreach (UltraGridRow row in ultraGrid1.ActiveRow.ChildBands[0].Rows)
{
DataRow dr = copyTab.NewRow();
CopyRowToRow(((DataRowView)row.ListObject).Row, dr);
copyTab.Rows.Add(dr);
}
DataRow dr2 = copyTab2.NewRow();
CopyRowToRow(((DataRowView)ultraGrid1.ActiveRow.ListObject).Row, dr2);
copyTab2.Rows.Add(dr2);
}
DataTable[] copyTabs = new DataTable[] { copyTab, copyTab2 };
Clipboard.SetData("Dic", copyTabs);
}
private void CopyRowToRow(DataRow srcRow, DataRow desRow)
{
for (int i = 0; i < srcRow.Table.Columns.Count; i++)
{
string columnName = srcRow.Table.Columns[i].ColumnName;
desRow[columnName] = srcRow[columnName];
}
}
///
/// 粘贴
///
private void Paste()
{
DataTable[] copyTabs = (DataTable[])Clipboard.GetData("Dic");
if (copyTabs == null)
{
MessageUtil.ShowWarning("没有数据,请复制后再进行操作!");
return;
}
DataTable copyTab = copyTabs[0];
DataTable copyTab2 = copyTabs[1];
if (copyTab == null || copyTab.Rows.Count == 0)
{
MessageUtil.ShowWarning("没有数据,请复制后再进行操作!");
return;
}
dataTable2.BeginInit();
string dic = "";
UltraGridRow rowParent;
if (ultraGrid1.ActiveRow.HasParent())
{
//if (ultraGrid1.ActiveRow.ParentRow.ChildBands[0].Rows.Count > 0)
//{
// MessageUtil.ShowWarning("该记录下存在子记录,不能进行粘贴操作!");
// return;
//}
dic = ultraGrid1.ActiveRow.ParentRow.GetValue("DIC");
rowParent = ultraGrid1.ActiveRow.ParentRow;
}
else
{
//if (ultraGrid1.ActiveRow.ChildBands[0].Rows.Count > 0)
//{
// MessageUtil.ShowWarning("该记录下存在子记录,不能进行粘贴操作!");
// return;
//}
dic = ultraGrid1.GetActiveRowValue("DIC");
rowParent = ultraGrid1.ActiveRow;
}
List notCopyColumns = new List();
notCopyColumns.AddRange("CHC", "CREATE_TIME", "CREATE_NAME", "UPDATE_TIME", "UPDATE_NAME",
"DELETE_TIME", "DELETE_NAME", "VALIDFLAG", "DIC", "MSC", "PSC_DESC", "PSC", "STD_CODE_NK", "STD_NAME_NK",
"STDSTYLE", "STD_NAME", "PRODUCNAME", "STEELNAME", "PROCESS_CODE", "STD_STYLE_DESC",
"PRODUCCODE_NK", "PRODUCNAME_NK", "PROCESS_CODE", "PROCESS_DESC", "STEELCODE_NK", "STEELNAME_NK");
if (copyTab2.Rows.Count > 0)
{
DataRow drParent = ((DataRowView)rowParent.ListObject).Row;
foreach (DataColumn column in dataTable1.Columns)
{
string columnName = column.ColumnName;
if (notCopyColumns.Contains(columnName) == true) continue;
drParent[columnName] = copyTab2.Rows[0][columnName];
}
}
foreach (DataRow row in copyTab.Rows)
{
DataRow tempRow = dataTable2.NewRow();
foreach (DataColumn column in dataTable2.Columns)
{
string columnName = column.ColumnName;
if (notCopyColumns.Contains(columnName) == true) continue;
tempRow[columnName] = row[columnName];
}
tempRow["DIC"] = dic;
dataTable2.Rows.Add(tempRow);
}
dataTable2.EndInit();
if (copyTab.Rows.Count > 0 && ultraGrid1.ActiveRow != null)
{
ultraGrid1.ActiveRow.ExpandAll();
}
ultraGrid1.UpdateData();
}
///
/// 根据交付标准、内控标准和Alpha分别隐藏不同的列
///
private void HideColumn()
{
if (CustomInfo == "1")//交付标准
{
ultraGrid1.DisplayLayout.Bands[0].Columns["STD_CODE_NK"].Hidden = true;
ultraGrid1.DisplayLayout.Bands[0].Columns["PROCESS_DESC"].Hidden = true;
this.ultraGrid1.DisplayLayout.Bands[0].Columns["STEELNAME_NK"].Hidden = true;
this.ultraGrid1.DisplayLayout.Bands[0].Columns["MODEL_DESC_NK"].Hidden = true;
this.ultraGrid1.DisplayLayout.Bands[0].Columns["PRODUCCODE_NK"].Hidden = true;
this.ultraGrid1.DisplayLayout.Bands[0].Columns["PRODUCNAME_NK"].Hidden = true;
this.ultraGrid1.DisplayLayout.Bands[0].Columns["STD_NAME_S_NK"].Hidden = true;
this.ultraGrid1.DisplayLayout.Bands[0].Columns["STD_STYLE_DESC_S_NK"].Hidden = true;
}
if (CustomInfo == "2" || CustomInfo == "4")//内控
{
ultraGrid1.DisplayLayout.Bands[0].Columns["MSC"].Hidden = true;
ultraGrid1.DisplayLayout.Bands[0].Columns["PSC_DESC"].Hidden = true;
ultraGrid1.DisplayLayout.Bands[0].Columns["STD_NAME"].Hidden = true;
ultraGrid1.DisplayLayout.Bands[0].Columns["STEELNAME"].Hidden = true;
ultraGrid1.DisplayLayout.Bands[0].Columns["STD_STYLE_DESC"].Hidden = true;
ultraGrid1.DisplayLayout.Bands[0].Columns["PRODUCNAME"].Hidden = true;
if (CustomInfo == "2")
{
ultraGrid1.DisplayLayout.Bands[0].Columns["STD_CODE_NK"].Header.Caption = "内控管理编号";
}
ultraCheckMSC.Visible = false;
ultraTextMSC.Visible = false;
}
if (CustomInfo == "3")//试验标准
{
ultraGrid1.DisplayLayout.Bands[0].Columns["PROCESS_CODE"].Hidden = true;
ultraGrid1.DisplayLayout.Bands[0].Columns["MSC"].Hidden = true;
ultraGrid1.DisplayLayout.Bands[0].Columns["PSC_DESC"].Hidden = true;
ultraGrid1.DisplayLayout.Bands[0].Columns["STD_NAME"].Hidden = true;
ultraGrid1.DisplayLayout.Bands[0].Columns["STEELNAME"].Hidden = true;
ultraGrid1.DisplayLayout.Bands[0].Columns["STD_STYLE_DESC"].Hidden = true;
ultraGrid1.DisplayLayout.Bands[0].Columns["PRODUCNAME"].Hidden = true;
ultraCheckMSC.Visible = false;
ultraTextMSC.Visible = false;
ultraGrid1.DisplayLayout.Bands[0].Columns["PROCESS_DESC"].Hidden = true;
this.ultraGrid1.DisplayLayout.Bands[0].Columns["STEELNAME_NK"].Hidden = true;
this.ultraGrid1.DisplayLayout.Bands[0].Columns["MODEL_DESC_NK"].Hidden = true;
this.ultraGrid1.DisplayLayout.Bands[0].Columns["PRODUCCODE_NK"].Hidden = true;
this.ultraGrid1.DisplayLayout.Bands[0].Columns["PRODUCNAME_NK"].Hidden = true;
this.ultraGrid1.DisplayLayout.Bands[0].Columns["STD_NAME_S_NK"].Hidden = true;
this.ultraGrid1.DisplayLayout.Bands[0].Columns["STD_STYLE_DESC_S_NK"].Hidden = true;
}
}
///
/// 查询条件
///
///
private ArrayList QueryCondition()
{
ArrayList conditionList = new ArrayList();
//标准名称
string stdName = "";
if (ultraCheckStd.Checked)
stdName = ultraTextStd.Text.Trim();
conditionList.Add(stdName);
//产品规范描述
string pscDesc = "";
if (CustomInfo == "1")
{
if (ultraCheckMSC.Checked)
pscDesc = ultraTextMSC.Text.Trim();
}
conditionList.Add(pscDesc);
//包含无效
string valid = "1";
if (ultraCheckValid.Checked)
valid = "0";
conditionList.Add(valid);
conditionList.Add(stdCode);
return conditionList;
}
///
/// 查询
///
private void DoQuery()
{
ArrayList condition = QueryCondition();
//主表查询
DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreDetection.getCoreDetection",
new Object[] { condition, CustomInfo, dic, msc, codeJg, produccodeNk,
steelcodeNk, stdCodesNk, stdStylesNk, isNkEdite, processCode, modelCode}, this.ob);
dataTable2.Clear();
GridHelper.CopyDataToDatatable(ref dt, ref this.dataTable1, true);
//从表查询
//包含无效
string valid = "1";
if (ultraCheckValid.Checked)
valid = "0";
DataTable dt1 = ServerHelper.GetData("com.steering.pss.qcm.CoreDetection.getCoreDetectionC",
new Object[] { CustomInfo, valid, stdCode, msc, codeJg, produccodeNk, steelcodeNk, processCode, modelCode }, this.ob);
dt1 = QcmBaseCommon.FilterTable(dt, dt1, "DIC");
GridHelper.CopyDataToDatatable(ref dt1, ref this.dataTable2, true);
UltraGridColumn[] col = new UltraGridColumn[] { this.ultraGrid1.DisplayLayout.Bands[0].Columns["MEMO"], this.ultraGrid1.DisplayLayout.Bands[0].Columns["MSC"],
this.ultraGrid1.DisplayLayout.Bands[0].Columns["PSC_DESC"],this.ultraGrid1.DisplayLayout.Bands[0].Columns["STD_CODE_NK"],
this.ultraGrid1.DisplayLayout.Bands[0].Columns["MODEL_DESC"]};
//GridHelper.RefreshAndAutoSizeExceptRows(ultraGrid1, col);
QcmBaseCommon.SetGridColor(ultraGrid1, "VALIDFLAG", "无效");
QcmBaseCommon.SetUltraGridNoEdit(ultraGrid1);
//isSelect = 0;
//展开或者定位
UltraGridRow[] rows1 = GridHelper.GetRowsWithKey(ultraGrid1, new string[] { "DIC" }, new string[] { _dic });
if (rows1.Length > 0)
{
rows1[0].Activate();
if (_isEx)
rows1[0].ExpandAll();
}
_isEx = false;
_dic = "";
foreach (UltraGridRow ugr in ultraGrid1.Rows)
{
ugr.Cells["CHKNK"].Value = "选择";
}
dataTable1.AcceptChanges();
dataTable2.AcceptChanges();
//清空复制数据
//_copyedRows.Clear();
}
public void QueryPurchaseAgreement(string stdCodeNk)
{
dataTable2.Clear();
dataTable1.Clear();
DataTable dtP = ServerHelper.GetData("com.steering.pss.qcm.CoreDetection.getPurchaseAgreementDic",
new object[] { stdCodeNk }, ob);
GridHelper.CopyDataToDatatable(ref dtP, ref this.dataTable1, true);
DataTable dtC = ServerHelper.GetData("com.steering.pss.qcm.CoreDetection.getPurchaseAgreementDetec",
new object[] { stdCodeNk }, ob);
GridHelper.CopyDataToDatatable(ref dtC, ref this.dataTable2, true);
QcmBaseCommon.SetGridColor(ultraGrid1, "VALIDFLAG", "无效");
QcmBaseCommon.SetUltraGridNoEdit(ultraGrid1);
}
private int GetGridSelectCount()
{
foreach (UltraGridRow row in ultraGrid1.Rows)
{
if (row.Cells["CHC"].Value.ToString() == "True")
{
return 1;
}
UltraGridRow[] rows = GridHelper.GetRowsWithKey(row.ChildBands[0],
new string[] { "CHC" }, new string[] { "True" });
if (rows.Length > 0)
{
return 1;
}
}
return 0;
}
private DataRow GetComBaseStdRowByPk(string stdCode)
{
DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.ComStandard.getComBaseStdByPk",
new object[] { stdCode }, ob);
return dt.Rows[0];
}
///
/// 保存
///
private void DoSave()
{
ultraGrid1.UpdateData();
DataRow comBaseStdRow = null;
string style = "G";
if (CustomInfo == "2") //内控的编码特殊处理
{
comBaseStdRow = GetComBaseStdRowByPk(stdCode);
if (comBaseStdRow["ACCEPT_BID"].ToString() == "1")
{
style = "N";
}
else
{
style = "L";
}
}
if (CustomInfo == "3")
style = "K";
if (CustomInfo == "4")
style = "S";
if (GetGridSelectCount() == 0)
{
MessageBox.Show("请选择记录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
if (CustomInfo == "2")
{
if (comBaseStdRow["ACCEPT_BID"].ToString() == "1" && comBaseStdRow["UNIT_CODE"].ToString() != UserInfo.GetDeptid()
&& UserInfo.GetUserID() != "admin" && UserInfo.GetUserID() != "longjinhua")
{
MessageUtil.ShowWarning("该记录只有[" + comBaseStdRow["UNIT_DESC"].ToString() + "]的成员才能操作!");
return;
}
}
ArrayList baseList = new ArrayList();
ArrayList childList = new ArrayList();
for (int i = 0; i < ultraGrid1.Rows.Count; i++)
{
UltraGridRow ugr = ultraGrid1.Rows[i];
DataRow rowDic = null;
//主表行
if (Convert.ToBoolean(ugr.Cells["CHC"].Value))
{
if (ugr.GetValue("VALIDFLAG") != "")
{
rowDic = GetMscDicByDic(ugr.GetValue("DIC"));
}
if (comBaseStdRow != null && comBaseStdRow["ACCEPT_BID"].ToString() == "0" && rowDic != null)
{
string[] units = ClsBaseInfo.GetUnitByUserName(rowDic["CREATE_NAME"].ToString(), ob, "002001007", "002001001", "002023005");
if (units[0] != UserInfo.GetDeptid() && UserInfo.GetUserID() != "admin")
{
MessageUtil.ShowWarning("该记录只有[" + units[1] + "]才能操作!");
ugr.Activate();
return;
}
}
DectionObject comM = GetBaseData(ugr, rowDic);
if (comM == null)
{
MessageBox.Show(errMessage, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
baseList.Add(JSONFormat.Format(comM));
_dic = comM.Dic;
}
//从表行
if (ugr.HasChild())
{
if (ugr.Cells["VALIDFLAG"].Value.ToString().Equals("") && !Convert.ToBoolean(ugr.Cells["CHC"].Value))
{
MessageBox.Show("请选择主记录", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
for (int j = 0; j < ugr.ChildBands[0].Rows.Count; j++)
{
UltraGridRow ugrChild = ugr.ChildBands[0].Rows[j];
if (Convert.ToBoolean(ugrChild.Cells["CHC"].Value))
{
if (ugr.GetValue("VALIDFLAG") != "")
{
rowDic = GetMscDicByDic(ugr.GetValue("DIC"));
}
if (comBaseStdRow != null && comBaseStdRow["ACCEPT_BID"].ToString() == "0" && rowDic != null)
{
string[] units = ClsBaseInfo.GetUnitByUserName(rowDic["CREATE_NAME"].ToString(), ob, "002001007", "002001001", "002023005");
if (units[0] != UserInfo.GetDeptid() && UserInfo.GetUserID() != "admin")
{
MessageUtil.ShowWarning("该记录只有[" + units[1] + "]才能操作!");
ugrChild.Activate();
return;
}
}
DectionCObject comMC = GetChildData(ugrChild, rowDic);
if (comMC == null)
{
MessageBox.Show(errMessage, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
childList.Add(JSONFormat.Format(comMC));
_dic = comMC.Dic;
_isEx = true;
}
}
}
}
if (MessageBox.Show("是否保存选择记录?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
{
return;
}
if (baseList.Count > 0 || childList.Count > 0)
{
int count = ServerHelper.SetData("com.steering.pss.qcm.CoreDetection.saveCoreDetection",
new Object[] { baseList, childList, style }, this.ob);
if (count > 0)
{
MessageBox.Show("保存成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
DoQuery();
}
}
}
private DataTable GetMscTabByMsc(string msc)
{
DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreFrmProPSCMSC2.getComMscByMsc",
new object[] { msc }, ob);
return dt;
}
private string GetMscByDic(string dic)
{
DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreDetection.getComDicByDic",
new object[] { dic }, ob);
if (dt.Rows.Count > 0)
{
return dt.Rows[0]["MSC"].ToString();
}
return "";
}
///
/// 通过主键查询探伤主表
///
///
private DataRow GetMscDicByDic(string dic)
{
DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreDetection.getComDicByDic",
new object[] { dic }, ob);
if (dt.Rows.Count == 0)
{
return null;
}
else
{
return dt.Rows[0];
}
}
private bool CheckAuthority(UltraGridRow row)
{
if (CustomInfo == "1")
{
string mscOld;
if (row.GetValue("VALIDFLAG") != "")
{
mscOld = GetMscByDic(row.GetValue("DIC"));
}
else
{
mscOld = row.HasParent() ? row.ParentRow.GetValue("MSC") : row.GetValue("MSC");
}
DataTable dtMsc = GetMscTabByMsc(mscOld);
//if (dtMsc.Rows[0]["UNIT_CODE"].ToString() != UserInfo.GetDeptid() && UserInfo.GetUserID() != "admin")
//{
// errMessage = "该条记录对应的冶金规范是[" + dtMsc.Rows[0]["UNIT_DESC"].ToString() + "]科室维护的,您没有权限!";
// row.Activate();
// return false;
//}
}
return true;
}
///
/// 主表操作项
///
///
private DectionObject GetBaseData(UltraGridRow ugr, DataRow rowDic)
{
DectionObject comM = new DectionObject();
string dic = ugr.Cells["DIC"].Value.ToString().Trim();
string psc = ugr.Cells["PSC"].Value.ToString().Trim();
string msc = ugr.Cells["MSC"].Value.ToString().Trim();
if (psc.Equals("") && CustomInfo == "1")
{
errMessage = "请选择冶金规范码";
return null;
}
if (CheckAuthority(ugr) == false) return null;
string stdStyle = ugr.Cells["STDSTYLE"].Value.ToString().Trim();
if (stdStyle.Equals("内控"))
stdStyle = "N";
else if (stdStyle.Equals("订货标准"))
stdStyle = "G";
else if (stdStyle.Equals("协议标准"))
stdStyle = "X";
else if (stdStyle.Equals("Alpha"))
stdStyle = "K";
else if (stdStyle.Equals("试验标准"))
stdStyle = "S";
else if (stdStyle.Equals("成分偏差标准"))
stdStyle = "P";
else
stdStyle = "";
string process_code = ugr.Cells["PROCESS_CODE"].Value.ToString().Trim();
string process_desc = ugr.Cells["PROCESS_DESC"].Value.ToString().Trim();
string std_code_nk = ugr.Cells["STD_CODE_NK"].Value.ToString().Trim();
string std_name_nk = ugr.Cells["STD_NAME_NK"].Value.ToString().Trim();
if (CustomInfo != "1" && std_name_nk.Equals(""))
{
errMessage = "请选择内控标准";
return null;
}
string model_code = ugr.Cells["MODEL_CODE"].Value.ToString().Trim();
string model_desc = ugr.Cells["MODEL_DESC"].Value.ToString().Trim();
string create_name = UserInfo.GetUserName();
string create_time = ugr.Cells["CREATE_TIME"].Value.ToString().Trim();
string update_name = UserInfo.GetUserName();
string update_time = ugr.Cells["UPDATE_TIME"].Value.ToString().Trim();
string delete_name = UserInfo.GetUserName();
string delete_time = ugr.Cells["DELETE_TIME"].Value.ToString().Trim();
string validflag = ugr.Cells["VALIDFLAG"].Value.ToString().Trim();
if (rowDic != null && (rowDic["VALIDFLAG"].ToString() == "2" || rowDic["VALIDFLAG"].ToString() == "3"))
{
errMessage = "提交审核或已审核记录不能保存";
return null;
}
//if (CustomInfo == "2" && ugr.GetValue("PRODUCCODE_NK") == "")
//{
// errMessage = "请选择品名!";
// return null;
//}
string memo = ugr.Cells["MEMO"].Value.ToString().Trim();
comM.Dic = dic;
comM.Psc = psc;
comM.Msc = msc;
comM.StdStyle = stdStyle;
comM.ProcessCode = process_code;
comM.ProcessDesc = process_desc;
comM.StdCodeNk = std_code_nk;
comM.StdNameNk = std_name_nk;
comM.ModelCode = model_code;
comM.ModelDesc = model_desc;
comM.CreateName = create_name;
comM.CreateTime = create_time;
comM.UpdateName = update_name;
comM.UpdateTime = update_time;
comM.DeleteName = delete_name;
comM.DeleteTime = delete_time;
comM.Memo = memo;
comM.ProducHead = ugr.GetValue("PRODUC_HEAD");
comM.CodeJg = codeJg == "DefaultValue" ? "" : codeJg;
comM.Validflag = validflag;
comM.SteelcodeNk = ugr.GetValue("STEELCODE_NK");
comM.SteelnameNk = ugr.GetValue("STEELNAME_NK");
comM.ModelCodeNk = ugr.GetValue("MODEL_CODE_NK");
comM.ModelDescNk = ugr.GetValue("MODEL_DESC_NK");
comM.ProduccodeNk = ugr.GetValue("PRODUCCODE_NK");
comM.ProducnameNk = ugr.GetValue("PRODUCNAME_NK");
comM.StdCodeSNk = ugr.GetValue("STD_CODE_S_NK");
comM.StdNameSNk = ugr.GetValue("STD_NAME_S_NK");
comM.StdStyleSNk = ugr.GetValue("STD_STYLE_S_NK");
comM.StdStyleDescSNk = ugr.GetValue("STD_STYLE_DESC_S_NK");
return comM;
}
///
/// 从表操作项
///
///
///
private DectionCObject GetChildData(UltraGridRow ugr, DataRow rowDic)
{
if (CheckAuthority(ugr) == false) return null;
if (rowDic != null && (rowDic["VALIDFLAG"].ToString() == "2" || rowDic["VALIDFLAG"].ToString() == "2"))
{
errMessage = "主记录为提交审核或已审核状态时,无法修改";
return null;
}
string dic = ugr.Cells["DIC"].Value.ToString().Trim();
string xh = ugr.Cells["XH"].Value.ToString().Trim();
string phy_code = ugr.Cells["PHY_CODE"].Value.ToString().Trim();
string phy_name = ugr.Cells["PHY_CODE"].Text;
string rate = ugr.Cells["RATE"].Value.ToString().Trim();
string rate_desc = ugr.Cells["DESC_RATE"].Text.Trim();
string rateval = ugr.Cells["DESC_VAL"].Value.ToString().Trim();
string position_code = ugr.Cells["POSITION_CODE"].Value.ToString().Trim();
string position_desc = ugr.Cells["POSITION_CODE"].Text;
string std_desc = ugr.Cells["STD_CODE"].Value.ToString().Trim();
string lv_code = ugr.Cells["LV_CODE"].Value.ToString().Trim();
string lv_desc = ugr.Cells["LV_DESC"].Value.ToString().Trim();
string coverage = ugr.Cells["COVERAGE"].Value.ToString();
string groove_pos = ugr.Cells["GROOVE_POS"].Value.ToString().Trim();
string groove_dir = ugr.Cells["GROOVE_DIR"].Value.ToString().Trim();
string create_name = UserInfo.GetUserName();
string create_time = ugr.Cells["CREATE_TIME"].Value.ToString().Trim();
string update_name = UserInfo.GetUserName();
string update_time = ugr.Cells["UPDATE_TIME"].Value.ToString().Trim();
string delete_name = UserInfo.GetUserName();
string delete_time = ugr.Cells["DELETE_TIME"].Value.ToString().Trim();
string validflag = ugr.Cells["VALIDFLAG"].Value.ToString().Trim();
string minD = ugr.GetValue("MIN_D").Trim();
string maxD = ugr.GetValue("MAX_D").Trim();
string minH = ugr.GetValue("MIN_H").Trim();
string maxH = ugr.GetValue("MAX_H").Trim();
string memo = ugr.Cells["MEMO"].Text.Trim();
if (phy_name.Equals(""))
{
errMessage = "请选择材质检验项";
return null;
}
if (rate_desc == "")
{
errMessage = "请选择检验频次!";
return null;
}
else
{
if (rate_desc == "按比例")
{
if (rateval == "")
{
errMessage = "请输入频率值!";
return null;
}
if (!StringUtil.IsNumber(rateval))
{
errMessage = "频率值:请输入数字!";
return null;
}
if (Convert.ToDouble(rateval) <= 0 || Convert.ToDouble(rateval) > 100)
{
errMessage = "频率值:请输入大于0小于等于100的数字";
return null;
}
}
}
if (position_desc.Equals(""))
{
errMessage = "请选择探伤位置";
return null;
}
if (std_desc.Equals(""))
{
errMessage = "请选择探伤参考标准";
return null;
}
if (lv_desc.Equals(""))
{
errMessage = "请选择探伤级别";
return null;
}
if (coverage != "" && (!StringUtil.IsNumber(coverage) || Convert.ToDouble(coverage) > 150 || Convert.ToDouble(coverage) < 0))
{
errMessage = "请输入探伤覆盖率:0~150";
return null;
}
if (!coverage.Equals("") && coverage.StartsWith("."))
coverage = "0" + coverage;
if (groove_pos.Equals(""))
{
errMessage = "请选择刻槽位置";
return null;
}
if (minD != "" || maxD != "")
{
if (minD == "")
{
errMessage = "请输入适用规格-外径下限!";
ugr.SetCellActive("MIN_D");
return null;
}
else if (minD.TryParseDouble() == false)
{
errMessage = "适用规格-外径下限:请输入数字";
ugr.SetCellActive("MIN_D");
return null;
}
if (maxD == "")
{
errMessage = "请输入适用规格-外径上限!";
ugr.SetCellActive("MAX_D");
return null;
}
else if (maxD.TryParseDouble() == false)
{
errMessage = "适用规格-外径上限:请输入数字";
ugr.SetCellActive("MAX_D");
return null;
}
}
if (minH != "" || maxH != "")
{
if (minH == "")
{
errMessage = "请输入适用规格-壁厚下限!";
ugr.SetCellActive("MIN_H");
return null;
}
else if (minH.TryParseDouble() == false)
{
errMessage = "适用规格-壁厚下限:请输入数字";
ugr.SetCellActive("MIN_H");
return null;
}
if (maxH == "")
{
errMessage = "请输入适用规格-壁厚上限!";
ugr.SetCellActive("MAX_H");
return null;
}
else if (maxH.TryParseDouble() == false)
{
errMessage = "适用规格-壁厚上限:请输入数字";
ugr.SetCellActive("MAX_H");
return null;
}
}
DectionCObject comMC = new DectionCObject();
comMC.Dic = dic;
comMC.Xh = xh;
comMC.PhyCode = phy_code;
comMC.PhyName = phy_name;
comMC.PositionCode = position_code;
comMC.PositionDesc = position_desc;
comMC.StdDesc = std_desc;
comMC.LvCode = lv_code;
comMC.LvDesc = lv_desc;
comMC.Coverage = coverage;
comMC.GroovePos = groove_pos;
comMC.GrooveDir = groove_dir;
comMC.CreateName = create_name;
comMC.CreateTime = create_time;
comMC.UpdateName = update_name;
comMC.DeleteName = delete_name;
comMC.UpdateTime = update_time;
comMC.DeleteTime = delete_time;
comMC.Validflag = validflag;
comMC.Memo = memo;
comMC.Rate = rate;
comMC.Ratedesc = rate_desc;
comMC.Rateval = rateval;
comMC.MinD = minD;
comMC.MaxD = maxD;
comMC.MinH = minH;
comMC.MaxH = maxH;
comMC.GroupSeq = ugr.GetValue("GROUP_SEQ");
return comMC;
}
///
/// 删除或者恢复
///
private void DoUpdateOrResume(Boolean flag)
{
ultraGrid1.UpdateData();
if (GetGridSelectCount() == 0)
{
MessageBox.Show("请选择记录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
DataRow comBaseStdRow = null;
if (CustomInfo == "2")
{
comBaseStdRow = GetComBaseStdRowByPk(stdCode);
if (comBaseStdRow["ACCEPT_BID"].ToString() == "1" && comBaseStdRow["UNIT_CODE"].ToString() != UserInfo.GetDeptid()
&& UserInfo.GetUserID() != "admin")
{
MessageUtil.ShowWarning("该记录只有[" + comBaseStdRow["UNIT_DESC"].ToString() + "]的成员才能" + (flag ? "作废" : "恢复") + "!");
return;
}
}
ultraGrid1.UpdateData();
ArrayList baseList = new ArrayList();
ArrayList childList = new ArrayList();
for (int i = 0; i < ultraGrid1.Rows.Count; i++)
{
UltraGridRow ugr = ultraGrid1.Rows[i];
if (Convert.ToBoolean(ugr.Cells["CHC"].Value))
{
DataRow rowDic = null;
if (ugr.GetValue("VALIDFLAG") != "")
{
rowDic = GetMscDicByDic(ugr.GetValue("DIC"));
}
if (comBaseStdRow != null && comBaseStdRow["ACCEPT_BID"].ToString() == "0" && rowDic != null)
{
string[] units = ClsBaseInfo.GetUnitByUserName(rowDic["CREATE_NAME"].ToString(), ob, "002001007", "002001001", "002023005");
if (units[0] != UserInfo.GetDeptid() && UserInfo.GetUserID() != "admin")
{
MessageUtil.ShowWarning("该记录只有[" + units[1] + "]才能操作!");
ugr.Activate();
return;
}
}
if (CheckAuthority(ugr) == false)
{
MessageUtil.ShowWarning(errMessage);
return;
}
DectionObject comM = new DectionObject();
comM.DeleteName = UserInfo.GetUserName();
comM.Dic = ugr.Cells["DIC"].Value.ToString();
if (ugr.Cells["VALIDFLAG"].Value.Equals("无效") && flag)
{
MessageBox.Show("无效记录不能作废", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
if (flag && (ugr.Cells["VALIDFLAG"].Value.Equals("提交审核") || ugr.Cells["VALIDFLAG"].Value.Equals("已审核")))
{
MessageBox.Show("提交审核或已审核记录不能作废", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
if (ugr.Cells["VALIDFLAG"].Value.Equals("有效") && (!flag))
{
MessageBox.Show("有效记录不能恢复", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
if (ugr.HasChild())
{
if (MessageBox.Show("对应子记录将全部作废!", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
{
return;
}
foreach (UltraGridRow ugrc in ugr.ChildBands[0].Rows)
{
//子记录全部删除
DectionCObject comMC = new DectionCObject();
comMC.DeleteName = UserInfo.GetUserName();
comMC.Dic = ugrc.Cells["DIC"].Value.ToString();
comMC.Xh = ugrc.Cells["XH"].Value.ToString();
childList.Add(JSONFormat.Format(comMC));
}
}
baseList.Add(JSONFormat.Format(comM));
}
if (ugr.HasChild())
{
for (int j = 0; j < ugr.ChildBands[0].Rows.Count; j++)
{
UltraGridRow ugrc = ugr.ChildBands[0].Rows[j];
if (Convert.ToBoolean(ugrc.Cells["CHC"].Value))
{
DataRow rowDic = null;
if (ugr.GetValue("VALIDFLAG") != "")
{
rowDic = GetMscDicByDic(ugr.GetValue("DIC"));
}
if (comBaseStdRow != null && comBaseStdRow["ACCEPT_BID"].ToString() == "0" && rowDic != null)
{
string[] units = ClsBaseInfo.GetUnitByUserName(rowDic["CREATE_NAME"].ToString(), ob, "002001007", "002001001", "002023005");
if (units[0] != UserInfo.GetDeptid() && UserInfo.GetUserID() != "admin")
{
MessageUtil.ShowWarning("该记录只有[" + units[1] + "]才能操作!");
ugrc.Activate();
return;
}
}
if (CheckAuthority(ugrc) == false)
{
MessageUtil.ShowWarning(errMessage);
return;
}
if (!flag && ugrc.ParentRow.Cells["VALIDFLAG"].Value.Equals("无效") && !Convert.ToBoolean(ugrc.ParentRow.Cells["CHC"].Value))
{
MessageBox.Show("请选择主记录", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
if (ugrc.ParentRow.Cells["VALIDFLAG"].Value.ToString() != "录入状态"
&& ugrc.ParentRow.Cells["VALIDFLAG"].Value.ToString() != "无效"
&& ugr.Cells["VALIDFLAG"].Value.ToString() != "")
{
MessageUtil.ShowWarning("主记录为提交审核或已审核状态时,无法修改");
return;
}
DectionCObject comMC = new DectionCObject();
comMC.DeleteName = UserInfo.GetUserName();
comMC.Dic = ugrc.Cells["DIC"].Value.ToString();
comMC.Xh = ugrc.Cells["XH"].Value.ToString();
if (ugrc.Cells["VALIDFLAG"].Value.Equals("无效") && flag)
{
MessageBox.Show("无效记录不能作废", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
if (ugrc.Cells["VALIDFLAG"].Value.Equals("有效") && !flag)
{
MessageBox.Show("有效记录不能恢复", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
childList.Add(JSONFormat.Format(comMC));
}
}
}
}
if (flag)
{
if (MessageBox.Show("作废选中记录,您是否继续?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
{
return;
}
}
else
{
if (MessageBox.Show("恢复选中记录,您是否继续?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
{
return;
}
}
if (baseList.Count > 0 || childList.Count > 0)
{
int count = ServerHelper.SetData("com.steering.pss.qcm.CoreDetection.deleteOrResume", new Object[] { baseList, childList, flag }, this.ob);
if (count > 0)
{
DoQuery();
if (flag)
MessageBox.Show("作废成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
else
MessageBox.Show("恢复成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
private void FrmComMSCStdDetection_Load(object sender, EventArgs e)
{
HideColumn();
InitDownList();
ultraTextStd.Enabled = false;
ultraTextMSC.Enabled = false;
}
///
/// 新增一行
///
///
///
private void ultraGrid1_AfterRowInsert(object sender, RowEventArgs e)
{
UltraGridRow ugr = ultraGrid1.DisplayLayout.ActiveRow;
string style = "G";
if (CustomInfo == "2")
style = "N";
if (CustomInfo == "3")
style = "K";
if (CustomInfo == "4")
style = "S";
if (!ugr.HasParent()) //主表自动填充主键(成分索引号)
{
string dic = "";
int temp = 0;
for (int i = 0; i < ultraGrid1.Rows.Count - 1; i++)
{
string str = ultraGrid1.Rows[i].Cells["DIC"].Value.ToString().Substring(4, 6);
if (Convert.ToInt32(str) > temp)
temp = Convert.ToInt32(str);
}
dic = "DIC" + style + string.Format("{0:000000}", temp + 1);
ugr.Cells["DIC"].Value = dic;
}
//从表自动填充序号
if (ugr.HasParent())
{
int index = 0;
string cic = ugr.Cells["DIC"].Value.ToString();
foreach (UltraGridRow ug in ultraGrid1.Rows)
{
if (ug.Cells["DIC"].Value.ToString().Equals(cic))
{
for (int i = 0; i < ug.ChildBands[0].Rows.Count - 1; i++)
{
int indexSeq = Convert.ToInt32(ug.ChildBands[0].Rows[i].Cells["XH"].Value.ToString());
if (indexSeq > index)
index = indexSeq;
}
}
}
ugr.Cells["XH"].Value = index + 1;
ugr.Cells["DESC_VAL"].Activation = Activation.NoEdit;
}
//增加行如果没有勾选则不可编辑
if (!Convert.ToBoolean(ugr.Cells["CHC"].Value))
{
for (int i = 0; i < ugr.Cells.Count; i++)
{
if (!ugr.Cells[i].Column.Key.Equals("CHC"))
ugr.Cells[i].Activation = Activation.ActivateOnly;
if (ugr.Cells[i].Column.Key.Equals("CHKNK"))
ugr.Cells["CHKNK"].Value = "选择";
}
}
e.Row.Update();
}
FrmComMSCStdDetection _frmComMSCStdDetection = null;
///
/// 扣型选择
///
///
///
private void ultraGrid1_ClickCellButton(object sender, CellEventArgs e)
{
if (e.Cell.Column.Key.Equals("MODEL_DESC") && Convert.ToBoolean(ultraGrid1.DisplayLayout.ActiveRow.Cells["CHC"].Value))
{
UltraGridRow row = this.ultraGrid1.DisplayLayout.ActiveRow;
FrmModel frms = new FrmModel();
frms.FrmOb = this.ob;
frms.Desc = row.Cells["MODEL_DESC"].Value.ToString();
frms.ShowDialog();
row.Cells["MODEL_CODE"].Value = frms.Code;
row.Cells["MODEL_DESC"].Value = frms.Desc;
}
if (e.Cell.Column.Key.Equals("CHKNK"))
{
UltraGridRow ugr = ultraGrid1.ActiveRow;
_frmComMSCStdDetection = new FrmComMSCStdDetection();
_frmComMSCStdDetection.PopupLoad("3", ob);
//_frmComMSCStdDetection.UltraPanel1.Visible = false;
_frmComMSCStdDetection.ultraToolbarsManager1.Visible = true;
_frmComMSCStdDetection.Msc = msc;
_frmComMSCStdDetection.CodeJg = "";
_frmComMSCStdDetection.DoQuery1();
if (_frmComMSCStdDetection.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
DataRow CurRow, NewRow;
for (int i = 0; i < _frmComMSCStdDetection.dataTable2.Rows.Count; i++)
{
CurRow = _frmComMSCStdDetection.dataTable2.Rows[i];
NewRow = dataTable2.NewRow();
if (!_frmComMSCStdDetection.Ids.Contains(CurRow["DIC"].ToString2()))
{
continue;
}
for (int j = 0; j < _frmComMSCStdDetection.dataTable2.Columns.Count; j++)
{
try
{
if (dataTable2.Columns.Contains(_frmComMSCStdDetection.dataTable2.Columns[j].ColumnName))
{
if (_frmComMSCStdDetection.dataTable2.Columns[j].ColumnName == "DIC")
{
NewRow[_frmComMSCStdDetection.dataTable2.Columns[j].ColumnName] = ultraGrid1.ActiveRow.GetValue("DIC");
}
else
{
NewRow[_frmComMSCStdDetection.dataTable2.Columns[j].ColumnName] = CurRow[j];
}
}
}
catch { }
}
dataTable2.Rows.Add(NewRow);
}
ultraGrid1.UpdateData();
ultraGrid1.ActiveRow.ExpandAll();
}
}
}
///
/// 单元格值变化事件
///
///
///
public void ultraGrid1_CellChange(object sender, CellEventArgs e)
{
ultraGrid1.UpdateData();
UltraGridRow ugr = ultraGrid1.DisplayLayout.ActiveRow;
if (e.Cell.Column.Key.Equals("MSC"))//
{
string msc = ugr.Cells["MSC"].Value.ToString();
DataRow[] dr = ((DataTable)ultras[0].DataSource).Select("MSC='" + msc + "'");
if (dr.Length > 0)
{
ugr.Cells["PSC"].Value = dr[0][2];
ugr.Cells["PSC_DESC"].Value = dr[0][3];
ugr.Cells["PRODUCNAME"].Value = dr[0][4];
ugr.Cells["STD_NAME"].Value = dr[0][5];
ugr.Cells["STEELNAME"].Value = dr[0][6];
ugr.Cells["STD_STYLE_DESC"].Value = dr[0][7];
ugr.Cells["STDSTYLE"].Value = dr[0][8];
}
}
//工序
if (e.Cell.Column.Key.Equals("PROCESS_CODE"))
{
ugr.Cells["PROCESS_DESC"].Value = ugr.Cells["PROCESS_CODE"].Text.ToString();
}
//标准内控
if (e.Cell.Column.Key.Equals("STD_CODE_NK"))
{
string stdCode = ugr.Cells["STD_CODE_NK"].Value.ToString();
ugr.Cells["STD_NAME_NK"].Value = ugr.Cells["STD_CODE_NK"].Text.Trim();
DataRow[] dr = ((DataTable)ultras[1].DataSource).Select("STD_CODE='" + stdCode + "'");
if (dr.Length > 0)
{
ugr.Cells["STDSTYLE"].Value = dr[0][2];
}
}
//检验项
if (e.Cell.Column.Key.Equals("PHY_CODE"))
{
ugr.Cells["PHY_NAME"].Value = ugr.Cells["PHY_CODE"].Text.ToString();
ugr.Cells["STD_DESC"].Value = "";
ugr.Cells["STD_CODE"].Value = "";
ugr.Cells["LV_DESC"].Value = "";
ugr.Cells["LV_CODE"].Value = "";
}
//探伤位置
if (e.Cell.Column.Key.Equals("POSITION_CODE"))
{
ugr.Cells["POSITION_DESC"].Value = ugr.Cells["POSITION_CODE"].Text.ToString();
}
//检验频次
if (e.Cell.Column.Key.Equals("DESC_RATE"))
{
ugr.Cells["RATE"].Value = ugr.Cells["DESC_RATE"].Value.ToString();
if (ugr.Cells["DESC_RATE"].Text.Trim() != "按比例")
{
ugr.Cells["DESC_VAL"].Activation = Activation.NoEdit;
}
else
{
ugr.Cells["DESC_VAL"].Activation = Activation.AllowEdit;
}
}
//选择
if (e.Cell.Column.Key.Equals("CHC"))
{
Activation activation = Activation.ActivateOnly;
if (Convert.ToBoolean(e.Cell.Value))
{
activation = Activation.AllowEdit;
//isSelect += 1;
if (e.Cell.Row.HasParent())
{
if (e.Cell.Row.Cells["DESC_RATE"].Value.ToString() == "按比例")
e.Cell.Row.Cells["DESC_VAL"].Activation = Activation.AllowEdit;
else
e.Cell.Row.Cells["DESC_VAL"].Activation = Activation.NoEdit;
}
}
else
{
if (e.Cell.Row.HasParent())
e.Cell.Row.Cells["DESC_VAL"].Activation = Activation.NoEdit;
}
//else
// isSelect -= 1;
CellsCollection cells = e.Cell.Row.Cells;
for (int i = 0; i < cells.Count; i++)
{
if (!cells[i].Column.Key.Equals("CHC"))
{
if (!cells[i].Column.Key.Equals("DESC_VAL"))
e.Cell.Row.Cells[i].Activation = activation;
}
}
}
}
///
/// 标准名称
///
///
///
private void ultraCheckStd_CheckedChanged(object sender, EventArgs e)
{
if (ultraCheckStd.Checked)
ultraTextStd.Enabled = true;
else
ultraTextStd.Enabled = false;
}
private void ultraCheckMSC_CheckedChanged(object sender, EventArgs e)
{
if (ultraCheckMSC.Checked)
ultraTextMSC.Enabled = true;
else
ultraTextMSC.Enabled = false;
}
private void DoGroup()
{
ArrayList list = new ArrayList();
int ischeck = 0; //是否勾选
int isselect = 0; //勾选项是否已写入数据库
int isvalid = 0; //是否有效
//是否有数据修改
foreach (DataRow dr in dataTable2.Rows)
{
IQueryable rows = ultraGrid1.Rows.AsQueryable().Where(a => ((DataRowView)a.ListObject).Row == dr
&& a.GetValue("CHK") == "True");
if ((dr.RowState == DataRowState.Added || dr.RowState == DataRowState.Modified)
&& rows.Count() > 0)
{
MessageUtil.ShowWarning("理化标准有数据修改,请保存后再进行分组操作!");
return;
}
}
foreach (UltraGridRow row in ultraGrid1.Rows)
{
if (row.HasChild() && row.Cells["CHC"].Value.ToString().ToUpper() == "TRUE")
{
MessageBox.Show("主表不能进行分组操作", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
ArrayList plist = new ArrayList(); //分为几组。
Dictionary dicStation = new Dictionary();
int i = 0;
foreach (UltraGridRow crow in row.ChildBands[0].Rows)
{
ArrayList clist = new ArrayList(); //哪些分为一组。
if (crow.Cells["CHC"].Value.ToString().ToUpper() == "TRUE")
{
if (crow.Cells["VALIDFLAG"].Value.ToString().Equals(""))
{
isselect += 1;
}
if (crow.Cells["VALIDFLAG"].Value.ToString().Equals("无效"))
{
isvalid += 1;
}
ischeck += 1;
clist.Add(crow.Cells["DIC"].Value.ToString());
clist.Add(crow.Cells["XH"].Value.ToString());
plist.Add(clist);
_dic = crow.Cells["DIC"].Value.ToString();
_isEx = true;
//验证是否同一工序点
DataTable dtStation = GetStationByPhyCode(crow.GetValue("PHY_CODE"));
dicStation.Add(i, dtStation);
if (i != 0)
{
bool isSame = false;
foreach (DataRow dr in dicStation[i].Rows)
{
for (int j = i - 1; j >= 0; j--)
{
if (dicStation[j].Rows.Count == 0 || dicStation[i].Rows.Count == 0)
{
isSame = true;
}
int cnt = dicStation[j].Select("PROCESS_CODE = '" + dr["PROCESS_CODE"] + "'").Length;
if (cnt > 0)
{
isSame = true;
}
else
{
isSame = false;
break;
}
}
if (isSame)
{
break;
}
}
if (isSame == false)
{
MessageUtil.ShowWarning("不能将工序不一样的检验项分组到一组中!");
return;
}
}
i++;
}
}
list.Add(plist);
}
if (ischeck == 0)
{
MessageBox.Show("请选择你要分组的记录", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
if (isselect > 0)
{
MessageBox.Show("您选择的分组记录中存在未保存的项,请先保存后再分组", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
if (isvalid > 0)
{
MessageBox.Show("您选择的分组记录中存在无效数据,无法分组", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
if (MessageBox.Show("是否确认对所选项进行分组?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
{
return;
}
CoreClientParam ccp = new CoreClientParam(); //CoreClientParam是平台用来向服务端传递存放所有相关参数信息的。
ccp.ServerName = "com.steering.pss.qcm.CoreDetection"; //服务名指的是服务端的包名+类名
ccp.MethodName = "doGroup"; //方法名指的是服务名指定类里的方法
ccp.ServerParams = new object[] { list };//服务端方法的参数
//ExecuteNonQuery主要用来执行添加、修改、删除、存储过程的操作。
ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
if (ccp.ReturnCode == -1)
return;
MessageBox.Show("分组成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
DoQuery();
}
private DataTable GetStationByPhyCode(string phyCode)
{
DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreDetection.getStationByPhyCode",
new object[] { phyCode }, ob);
return dt;
}
private void CancelGroup()
{
int ischeck = 0; //是否勾选
int isselect = 0; //勾选项是否已写入数据库
int isvalid = 0; //是否有效
int hasindex = 0;
ArrayList plist = new ArrayList();
foreach (UltraGridRow row in ultraGrid1.Rows)
{
if (row.HasChild() && row.Cells["CHC"].Value.ToString().ToUpper() == "TRUE")
{
MessageBox.Show("主表不能进行取消分组操作", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
foreach (UltraGridRow crow in row.ChildBands[0].Rows)
{
ArrayList clist = new ArrayList(); //需要取消的GIC和XH
if (crow.Cells["CHC"].Value.ToString().ToUpper() == "TRUE")
{
if (crow.Cells["VALIDFLAG"].Value.ToString().Equals(""))
{
isselect += 1;
}
if (crow.Cells["VALIDFLAG"].Value.ToString().Equals("无效"))
{
isvalid += 1;
}
if (crow.Cells["GROUP_SEQ"].Value.ToString().Equals(""))
{
hasindex += 1;
}
ischeck += 1;
clist.Add(crow.Cells["DIC"].Value.ToString());
clist.Add(crow.Cells["XH"].Value.ToString());
plist.Add(clist);
_dic = crow.Cells["DIC"].Value.ToString();
_isEx = true;
}
}
}
if (ischeck == 0)
{
MessageBox.Show("请选择你要取消分组的记录", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
if (isselect > 0)
{
MessageBox.Show("您选择的记录中存在未保存的项,不能对其进行取消分组操作", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
if (isvalid > 0)
{
MessageBox.Show("您选择的记录中存在无效数据,无法取消分组", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
if (hasindex > 0)
{
MessageBox.Show("您选择的记录中存在未分组的数据,无法取消分组", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
if (MessageBox.Show("是否确认对所选项进行取消分组?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
{
return;
}
int count = ServerHelper.SetData("com.steering.pss.qcm.CoreDetection.cancleGroup", new Object[] { plist }, this.ob);
if (count > 0)
{
MessageBox.Show("取消分组成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
DoQuery();
}
}
private void ultraGrid1_InitializeRow(object sender, InitializeRowEventArgs e)
{
if (isPasting)
{
e.Row.SetValue("CHC", "True");
}
}
///
/// 2015-07-15 PDY
///
private void InnerChange()
{
ultraGrid1.DisplayLayout.Bands[0].Columns["PROCESS_CODE"].CellActivation = Activation.ActivateOnly;
ultraGrid1.DisplayLayout.Bands[0].Columns["STD_CODE_NK"].CellActivation = Activation.ActivateOnly;
ultraGrid1.DisplayLayout.Bands[0].Columns["MODEL_DESC"].Hidden = true;
}
private void ultraTextEditor3_EditorButtonClick(object sender, EditorButtonEventArgs e)
{
if (ultraGrid1.ActiveCell.Column.Key == "PROCESS_DESC")
{
string processCodes = ultraGrid1.ActiveRow.GetValue("PROCESS_CODE");
ChoiceProcessPopup choiceProcessPopup = new ChoiceProcessPopup(processCodes, this.ob);
if (choiceProcessPopup.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.ComStandard.getProcessByStdCode",
new object[] { this.stdCode }, ob);
string stdProcessCodes = dt.Rows[0]["PROCESS_CODE"].ToString();
string[] processCodesAry = choiceProcessPopup.ProcessCodes.Split(',');
for (int i = 0; i < processCodesAry.Length; i++)
{
if (!stdProcessCodes.Contains(processCodesAry[i].Trim()))
{
DataTable dtBaseProcess = ServerHelper.GetData("com.steering.pss.qcm.ComStandard.getProcessDescByCode",
new object[] { processCodesAry[i].Trim() }, ob);
string processDesc = dtBaseProcess.Rows[0]["PROCESS_DESC"].ToString();
MessageUtil.ShowWarning("该标准下不包含工序" + processDesc + ", 不能选择!");
return;
}
}
ultraGrid1.ActiveRow.SetValue("PROCESS_CODE", choiceProcessPopup.ProcessCodes);
ultraGrid1.ActiveRow.SetValue("PROCESS_DESC", choiceProcessPopup.ProcessDescs);
}
}
else if (ultraGrid1.ActiveCell.Column.Key == "STEELNAME_NK")
{
FrmRepSteel frmSteel = new FrmRepSteel();
frmSteel.Ob1 = this.ob;
frmSteel.Code = ultraGrid1.ActiveRow.GetValue("STEELCODE_NK");
if (frmSteel.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
ultraGrid1.ActiveRow.SetValue("STEELCODE_NK", frmSteel.Code);
ultraGrid1.ActiveRow.SetValue("STEELNAME_NK", frmSteel.Desc);
}
}
else if (ultraGrid1.ActiveCell.Column.Key == "MODEL_DESC_NK")
{
FrmModel frmModel = new FrmModel();
frmModel.FrmOb = this.ob;
frmModel.Code = ultraGrid1.ActiveRow.GetValue("MODEL_CODE_NK");
frmModel.Desc = ultraGrid1.ActiveCell.Value.ToString();
if (frmModel.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
ultraGrid1.ActiveRow.SetValue("MODEL_CODE_NK", frmModel.Code);
ultraGrid1.ActiveRow.SetValue("MODEL_DESC_NK", frmModel.Desc);
}
}
else if (ultraGrid1.ActiveCell.Column.Key == "PRODUCNAME_NK")
{
PopupProductName popupProductName = new PopupProductName(
ultraGrid1.ActiveRow.GetValue("PRODUCCODE_NK"), ob);
if (popupProductName.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
ultraGrid1.ActiveRow.SetValue("PRODUCCODE_NK", popupProductName.ProductCodes);
ultraGrid1.ActiveRow.SetValue("PRODUCNAME_NK", popupProductName.ProductNames);
}
}
else if (ultraGrid1.ActiveCell.Column.Key == "STD_NAME_S_NK")
{
string stdCodes = ultraGrid1.ActiveRow.GetValue("STD_CODE_S_NK");
FrmStandardChoice standardChoice = new FrmStandardChoice(stdCodes, ob);
if (standardChoice.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
ultraGrid1.ActiveRow.SetValue("STD_CODE_S_NK", standardChoice.StdCodes);
ultraGrid1.ActiveRow.SetValue("STD_NAME_S_NK", standardChoice.StdNames);
}
}
else if (ultraGrid1.ActiveCell.Column.Key == "STD_STYLE_DESC_S_NK")
{
string stdStyles = ultraGrid1.ActiveRow.GetValue("STD_STYLE_S_NK");
FrmStandardStyleChoice standardStyleChoice = new FrmStandardStyleChoice(stdStyles, ob);
if (standardStyleChoice.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
ultraGrid1.ActiveRow.SetValue("STD_STYLE_S_NK", standardStyleChoice.StdStyles);
ultraGrid1.ActiveRow.SetValue("STD_STYLE_DESC_S_NK", standardStyleChoice.StdStyleDescs);
}
}
else if (ultraGrid1.ActiveCell.Column.Key == "STD_DESC")
{
var row = ultraGrid1.ActiveRow;
if (row.GetValue("PHY_CODE") == "")
{
MessageUtil.ShowWarning("请选择探伤项!");
row.Cells["PHY_CODE"].Activate();
return;
}
DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.DAL.ComBaseDetectionRltDAL.QueryStdBaseInfo", new object[] { row.GetValue("PHY_CODE") }, ob);
dt.Columns["STD_DESC"].Caption = "参考标准";
BaseInfoPopup baseInfoPopup = new BaseInfoPopup(dt, "STD_DESC", "PHY_CODE", "PHY_NAME", "STD_CODE", "LV_CODE", "LV_DESC", "ID");
baseInfoPopup.Text = "参考标准";
baseInfoPopup.LabelTextBox1.Caption = "参考标准";
baseInfoPopup.Shown += new EventHandler((c, d) =>
{
IQueryable rows = baseInfoPopup.UltraGrid1.Rows.AsQueryable().Where(
a => a.GetValue("STD_CODE") == ultraGrid1.ActiveRow.GetValue("STD_CODE"));
if (rows.Count() > 0)
{
rows.First().Activate();
}
});
if (baseInfoPopup.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
ultraGrid1.ActiveRow.SetValue("STD_DESC", baseInfoPopup.ChoicedRow.GetValue("STD_DESC"));
ultraGrid1.ActiveRow.SetValue("STD_CODE", baseInfoPopup.ChoicedRow.GetValue("STD_CODE"));
ultraGrid1.ActiveRow.Cells["LV_DESC"].Value = "";
ultraGrid1.ActiveRow.Cells["LV_CODE"].Value = "";
}
}
else if (ultraGrid1.ActiveCell.Column.Key == "LV_DESC")
{
var row = ultraGrid1.ActiveRow;
if (row.GetValue("STD_CODE") == "")
{
MessageUtil.ShowWarning("请选择参考标准!");
row.Cells["STD_CODE"].Activate();
return;
}
DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.DAL.ComBaseDetectionRltDAL.QueryLvBaseInfo", new object[] { row.GetValue("STD_CODE") }, ob);
dt.Columns["LV_DESC"].Caption = "探伤级别";
BaseInfoPopup baseInfoPopup = new BaseInfoPopup(dt, "LV_DESC", "PHY_CODE", "PHY_NAME", "STD_DESC", "STD_CODE", "LV_CODE", "ID");
baseInfoPopup.Text = "探伤级别";
baseInfoPopup.LabelTextBox1.Caption = "探伤级别";
baseInfoPopup.Shown += new EventHandler((c, d) =>
{
IQueryable rows = baseInfoPopup.UltraGrid1.Rows.AsQueryable().Where(
a => a.GetValue("LV_CODE") == ultraGrid1.ActiveRow.GetValue("LV_CODE"));
if (rows.Count() > 0)
{
rows.First().Activate();
}
});
if (baseInfoPopup.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
ultraGrid1.ActiveRow.SetValue("LV_DESC", baseInfoPopup.ChoicedRow.GetValue("LV_DESC"));
ultraGrid1.ActiveRow.SetValue("LV_CODE", baseInfoPopup.ChoicedRow.GetValue("LV_CODE"));
}
}
ultraGrid1.UpdateData();
}
private void ultraGrid1_AfterSelectChange(object sender, AfterSelectChangeEventArgs e)
{
foreach (Infragistics.Win.UltraWinGrid.UltraGridRow ugr in this.ultraGrid1.Selected.Rows)
{
ugr.Cells["CHC"].Value = true;
Activation activation = Activation.ActivateOnly;
if (Convert.ToBoolean(ugr.Cells["CHC"].Value))
{
activation = Activation.AllowEdit;
//isSelect += 1;
}
//else
//isSelect -= 1;
CellsCollection cells = ugr.Cells;
for (int i = 0; i < cells.Count; i++)
{
if (!cells[i].Column.Key.Equals("CHC"))
{
ugr.Cells[i].Activation = activation;
}
}
}
}
private void ultraToolbarsManager1_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
{
switch (e.Tool.Key)
{
case "查询":
DoQuery1();
break;
case "确认选择":
Choice();
break;
}
}
private DataRow[] rows;
public DataRow[] Rows
{
get { return rows; }
set { rows = value; }
}
List ids;
public List Ids
{
get { return ids; }
set { ids = value; }
}
private void DoQuery1()
{
//主表查询
DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreDetection.getComDetectionNK",
new Object[] { msc }, this.ob);
dataTable2.Clear();
GridHelper.CopyDataToDatatable(ref dt, ref this.dataTable1, true);
//从表查询
DataTable dt1 = ServerHelper.GetData("com.steering.pss.qcm.CoreDetection.getComDetectionNKC",
new Object[] { msc }, this.ob);
dt1 = QcmBaseCommon.FilterTable(dt, dt1, "DIC");
GridHelper.CopyDataToDatatable(ref dt1, ref this.dataTable2, true);
UltraGridColumn[] col = new UltraGridColumn[] { this.ultraGrid1.DisplayLayout.Bands[0].Columns["MEMO"], this.ultraGrid1.DisplayLayout.Bands[0].Columns["MSC"],
this.ultraGrid1.DisplayLayout.Bands[0].Columns["PSC_DESC"],this.ultraGrid1.DisplayLayout.Bands[0].Columns["STD_CODE_NK"],
this.ultraGrid1.DisplayLayout.Bands[0].Columns["MODEL_DESC"]};
//GridHelper.RefreshAndAutoSizeExceptRows(ultraGrid1, col);
QcmBaseCommon.SetGridColor(ultraGrid1, "VALIDFLAG", "无效");
QcmBaseCommon.SetUltraGridNoEdit(ultraGrid1);
//isSelect = 0;
//展开或者定位
UltraGridRow[] rows1 = GridHelper.GetRowsWithKey(ultraGrid1, new string[] { "DIC" }, new string[] { _dic });
if (rows1.Length > 0)
{
rows1[0].Activate();
if (_isEx)
rows1[0].ExpandAll();
}
_isEx = false;
_dic = "";
dataTable1.AcceptChanges();
dataTable2.AcceptChanges();
//清空复制数据
//_copyedRows.Clear();
}
private void Choice()
{
ultraGrid1.UpdateData();
int count = ultraGrid1.Rows.Where(a => Convert.ToBoolean(a.GetValue("CHC"))).Count();
if (count > 1)
{
MessageUtil.ShowTips("请选择一条数据!");
return;
}
foreach (UltraGridRow ugr in ultraGrid1.Rows.Where(a => Convert.ToBoolean(a.GetValue("CHC"))))
{
//从表操作
if (ugr.HasChild())
{
Ids = ugr.ChildBands[0].Rows.Select(p => p.GetValue("DIC")).ToList();
Rows = dataTable2.Select("DIC IN ('" + string.Join("','", Ids) + "')");
}
}
this.DialogResult = System.Windows.Forms.DialogResult.OK;
}
}
}