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.Windows.Forms;
namespace Core.StlMes.Client.Qcm
{
public partial class FrmBaseAddAsk : FrmBase
{
private bool isEx = false;
private string askItemNo = "";
private string errMessage = "";
private int isSelect = 0;
public FrmBaseAddAsk()
{
InitializeComponent();
this.IsLoadUserView = true;
}
private void InitCom()
{
UltraComboEditor uce = new UltraComboEditor();
this.Controls.Add(uce);
uce.Visible = false;
UltraGridBand ugb = ultraGrid1.DisplayLayout.Bands[0];
//所有工序
QcmBaseCommon.InitDrop(uce, "com.steering.pss.qcm.ComBaseQuery.geComBaseProcessAll2", "BASENAME", "BASECODE", true, this.ob);
ugb.Columns["STATION_CODE"].EditorComponent = uce;
ugb.Columns["STATION_CODE"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;
//UltraComboEditor uceIsAllowEdit = new UltraComboEditor();
//this.Controls.Add(uceIsAllowEdit);
//uceIsAllowEdit.Visible = false;
//uceIsAllowEdit.Items.Add("1", "是");
//uceIsAllowEdit.Items.Add("0", "否");
//UltraGridBand ugb1 = ultraGrid1.DisplayLayout.Bands[1];
//ugb1.Columns["IS_ALLOW_EDIT"].EditorComponent = uceIsAllowEdit;
//ugb1.Columns["IS_ALLOW_EDIT"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;
}
private void InitIsAdd()
{
//UltraComboEditor uce = new UltraComboEditor();
//this.Controls.Add(uce);
//uce.Visible = false;
//UltraGridBand ugb = ultraGrid1.DisplayLayout.Bands[1];
//uce.Items.Add("1", "是");
//uce.Items.Add("0", "否");
//ugb.Columns["IS_ADD"].EditorComponent = uce;
//ugb.Columns["IS_ADD"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;
}
private void FrmBaseAddAsk_Load(object sender, EventArgs e)
{
InitCom();
InitIsAdd();
ultraGrid2.Enabled = false;
DoQuery(true);
}
public override void ToolBar_Click(object sender, string ToolbarKey)
{
switch (ToolbarKey)
{
case "Query":
DoQuery(true);
break;
case "Query1":
DoQuery(false);
break;
case "Save":
DoSave();
break;
case "Delete":
DoDeleteOrResume(true);
break;
case "Resume":
DoDeleteOrResume(false);
break;
case "DeleteData":
DeleteData();
break;
case "Refresh":
InitCom();
break;
case "Close":
this.Close();
break;
}
}
///
/// 查询
///
private void DoQuery(bool flag)
{
dataTable2.Rows.Clear();
dataTable1.Rows.Clear();
DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreBaseAddAsk.queryAddAskItem", new Object[] { flag }, this.ob);
GridHelper.CopyDataToDatatable(ref dt, ref this.dataTable1, true);
DataTable dt1 = ServerHelper.GetData("com.steering.pss.qcm.CoreBaseAddAsk.queryAddAskSub", new Object[] { flag }, this.ob);
GridHelper.CopyDataToDatatable(ref dt1, ref this.dataTable2, true);
QcmBaseCommon.DistinguishColor(ultraGrid1, "VALIDFLAG", "有效");
QcmBaseCommon.SetUltraGridNoEdit(ultraGrid1);
UltraGridRow[] rows1 = GridHelper.GetRowsWithKey(ultraGrid1, new string[] { "ASK_ITEM_NO" }, new string[] { askItemNo });
if (rows1.Length > 0)
{
rows1[0].Activate();
if (isEx)
rows1[0].ExpandAll();
}
isEx = false;
askItemNo = "";
}
///
/// 删除
///
private void DoDelete()
{
ultraGrid1.UpdateData();
}
private void DoSave()
{
ultraGrid1.UpdateData();
ultraGrid2.UpdateData();
if (isSelect == 0)
{
MessageBox.Show("请选择记录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
ArrayList listOne = new ArrayList();
ArrayList listTwo = new ArrayList();
ArrayList listThree = new ArrayList();
for (int i = 0; i < ultraGrid1.Rows.Count; i++)
{
UltraGridRow ugr = ultraGrid1.Rows[i];
//主表行
if (Convert.ToBoolean(ugr.Cells["CHC"].Value))
{
BaseAddAskObject com = Qcm.objectData.GetObjectData.GetAddAskData(ugr);
if (!CheckBaseAddAsk(com))
{
MessageBox.Show(errMessage, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
com.CreateName = UserInfo.GetUserName();
listOne.Add(JSONFormat.Format(com));
askItemNo = com.AskItemNo;
}
//从表行
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 ugrC = ugr.ChildBands[0].Rows[j];
if (Convert.ToBoolean(ugrC.Cells["CHC"].Value))
{
BaseAddAskObject comC = Qcm.objectData.GetObjectData.GetAddAskData(ugrC);
if (!CheckBaseAddAsk(comC))
{
MessageBox.Show(errMessage, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
comC.CreateName = UserInfo.GetUserName();
listTwo.Add(JSONFormat.Format(comC));
askItemNo = ugr.Cells["ASK_ITEM_NO"].Value.ToString();
isEx = true;
}
}
}
}
for (int i = 0; i < ultraGrid2.Rows.Count; i++)
{
UltraGridRow ugr = ultraGrid2.Rows[i];
if (Convert.ToBoolean(ugr.Cells["CHC"].Value))
{
BaseAddAskObject com = Qcm.objectData.GetObjectData.GetAddAskData(ugr);
if (!CheckBaseAddAsk(com))
{
MessageBox.Show(errMessage, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
com.CreateName = UserInfo.GetUserName();
listThree.Add(JSONFormat.Format(com));
}
}
if (MessageBox.Show("是否保存选择记录?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
{
return;
}
if (listOne.Count > 0 || listTwo.Count > 0 || listThree.Count > 0)
{
int count = ServerHelper.SetData("com.steering.pss.qcm.CoreBaseAddAsk.saveAddAsk",
new Object[] { listOne, listTwo, listThree }, this.ob);
if (count > 0)
{
MessageBox.Show("保存成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
DoQuery(true);
}
}
}
private void ultraGrid1_AfterRowInsert(object sender, RowEventArgs e)
{
UltraGridRow ugr = ultraGrid1.DisplayLayout.ActiveRow;
string style = "1210";
if (!ugr.HasParent()) //主表自动填充主键(成分索引号)
{
string askItemNo = "";
int temp = 0;
for (int i = 0; i < ultraGrid1.Rows.Count - 1; i++)
{
string str = ultraGrid1.Rows[i].Cells["ASK_ITEM_NO"].Value.ToString().Substring(4, 2);
if (Convert.ToInt32(str) > temp)
temp = Convert.ToInt32(str);
}
askItemNo = style + string.Format("{0:00}", temp + 1);
ugr.Cells["ASK_ITEM_NO"].Value = askItemNo;
}
//从表自动填充序号
if (ugr.HasParent())
{
int index = 0;
string askItemNo = ugr.Cells["ASK_P_ITEM_NO"].Value.ToString();
foreach (UltraGridRow ug in ultraGrid1.Rows)
{
if (ug.Cells["ASK_ITEM_NO"].Value.ToString().Equals(askItemNo))
{
for (int i = 0; i < ug.ChildBands[0].Rows.Count - 1; i++)
{
string str = ug.ChildBands[0].Rows[i].Cells["ASK_ITEM_NO"].Value.ToString();
int indexSeq = Convert.ToInt32(ug.ChildBands[0].Rows[i].Cells["ASK_ITEM_NO"].Value.ToString().Substring(6, 2));
if (indexSeq > index)
index = indexSeq;
}
}
}
ugr.Cells["ASK_ITEM_NO"].Value = askItemNo + string.Format("{0:00}", index + 1);
ugr.Cells["STATION_CODE"].Value = ugr.ParentRow.Cells["STATION_CODE"].Value.ToString();
ugr.Cells["STATION_DESC"].Value = ugr.ParentRow.Cells["STATION_DESC"].Value.ToString();
ugr.Cells["IS_ADD"].Value = "1";
}
//增加行如果没有勾选则不可编辑
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;
}
}
}
private void ultraGrid2_AfterRowInsert(object sender, RowEventArgs e)
{
UltraGridRow ugr = ultraGrid2.DisplayLayout.ActiveRow;
string askItemNo = "";
int temp = 0;
for (int i = 0; i < ultraGrid2.Rows.Count - 1; i++)
{
string str1 = ultraGrid2.Rows[i].Cells["ASK_ITEM_NO"].Value.ToString();
string str = ultraGrid2.Rows[i].Cells["ASK_ITEM_NO"].Value.ToString().Substring(8, 3);
if (Convert.ToInt32(str) > temp)
temp = Convert.ToInt32(str);
}
UltraGridRow ugrItem = ultraGrid1.DisplayLayout.ActiveRow;
if (ugrItem == null)
return;
ugr.Cells["ASK_ITEM_NOONE"].Value = ugrItem.ParentRow.Cells["ASK_ITEM_DESC"].Value.ToString();
ugr.Cells["ASK_ITEM_NOTWO"].Value = ugrItem.Cells["ASK_ITEM_DESC"].Value.ToString();
ugr.Cells["ASK_P_ITEM_NO"].Value = ugrItem.Cells["ASK_ITEM_NO"].Value.ToString();
ugr.Cells["STATION_CODE"].Value = ugrItem.ParentRow.Cells["STATION_CODE"].Value.ToString();
ugr.Cells["STATION_DESC"].Value = ugrItem.ParentRow.Cells["STATION_DESC"].Value.ToString();
askItemNo = ugr.Cells["ASK_P_ITEM_NO"].Value.ToString() + string.Format("{0:000}", temp + 1);
ugr.Cells["ASK_ITEM_NO"].Value = askItemNo;
}
private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
{
try
{
this.Cursor = Cursors.WaitCursor;
UltraGridRow ugrItem = ultraGrid1.DisplayLayout.ActiveRow;
if (ugrItem.HasParent())
{
if (ugrItem.Cells["VALIDFLAG"].Value.Equals("无效"))
{
dataTable3.Rows.Clear();
ultraGrid2.Enabled = false;
}
else if (ugrItem.Cells["VALIDFLAG"].Value.Equals(""))
{
ultraGrid2.Enabled = true;
}
else
{
ultraGrid2.Enabled = true;
DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreBaseAddAsk.queryAddAskStan", new Object[] { ugrItem.Cells["ASK_ITEM_NO"].Value.ToString() }, this.ob);
GridHelper.CopyDataToDatatable(ref dt, ref this.dataTable3, true);
QcmBaseCommon.DistinguishColor(ultraGrid2, "VALIDFLAG", "有效");
UltraGridBand ugb = this.ultraGrid2.DisplayLayout.Bands[0];
UltraGridColumn[] col = new UltraGridColumn[] { ugb.Columns["ASK_ITEM_DESC"], ugb.Columns["STATION_DESC"],
ugb.Columns["PIC"],ugb.Columns["ASK_ITEM_NOONE"],ugb.Columns["ASK_ITEM_NOTWO"]};
GridHelper.RefreshAndAutoSizeExceptColumns(ultraGrid2, col);
QcmBaseCommon.SetUltraGridNoEdit(ultraGrid2);
foreach (UltraGridRow row in ultraGrid2.Rows)
{
ControlAskItemDesc(row);
}
}
}
else
{
for (int i = 0; i < ultraGrid2.Rows.Count; i++)
{
ultraGrid2.Rows[i].Cells["CHC"].Value = false;
}
this.dataTable3.Rows.Clear();
this.ultraGrid2.Enabled = false;
}
}
finally
{
this.Cursor = Cursors.Default;
}
}
///
/// 控制标准说明是否可以编辑
///
///
private void ControlAskItemDesc(UltraGridRow row)
{
if (row.GetValue("VALIDFLAG") != "")
{
row.Cells["ASK_ITEM_DESC"].Activation = Activation.ActivateOnly;
}
}
private void ultraGrid1_CellChange(object sender, CellEventArgs e)
{
ultraGrid1.UpdateData();
UltraGridRow ugr = ultraGrid1.ActiveRow;
if (e.Cell.Column.Key.Equals("STATION_CODE"))
{
ugr.Cells["STATION_DESC"].Value = ugr.Cells["STATION_CODE"].Text;
if (ugr.HasChild())
{
foreach (UltraGridRow ugrC in ugr.ChildBands[0].Rows)
{
ugrC.Cells["STATION_CODE"].Value = ugr.Cells["STATION_CODE"].Value.ToString();
ugrC.Cells["STATION_DESC"].Value = ugr.Cells["STATION_DESC"].Value.ToString();
}
}
}
if (e.Cell.Column.Key.Equals("CHC")) //
{
Activation activation = Activation.ActivateOnly;
if (Convert.ToBoolean(e.Cell.Value))
{
activation = Activation.AllowEdit;
isSelect += 1;
}
else
isSelect -= 1;
CellsCollection cells = e.Cell.Row.Cells;
for (int i = 0; i < cells.Count; i++)
{
if (!cells[i].Column.Key.Equals("CHC"))
{
e.Cell.Row.Cells[i].Activation = activation;
}
}
if (Convert.ToBoolean(e.Cell.Value))
{
if (e.Cell.Row.HasParent())
{
string code = e.Cell.Row.Cells["ASK_ITEM_NO"].Value.ToString();
DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreBaseAddAsk.isLinkStd", new Object[] { code }, this.ob);
if (dt != null && dt.Rows.Count > 0)
{
for (int i = 0; i < e.Cell.Row.Cells.Count; i++)
{
if (!e.Cell.Row.Cells[i].Column.Key.Equals("CHC") && !e.Cell.Row.Cells[i].Column.Key.Equals("IS_ADD")
&& !e.Cell.Row.Cells[i].Column.Key.Equals("IS_ALLOW_EDIT"))
e.Cell.Row.Cells[i].Activation = Activation.ActivateOnly;
}
}
else
{
for (int i = 0; i < e.Cell.Row.Cells.Count; i++)
{
if (!e.Cell.Row.Cells[i].Column.Key.Equals("CHC"))
e.Cell.Row.Cells[i].Activation = Activation.AllowEdit;
}
}
}
else
{
string code = e.Cell.Row.Cells["ASK_ITEM_NO"].Value.ToString();
DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreBaseAddAsk.isLinkStd1", new Object[] { code }, this.ob);
if (dt != null && dt.Rows.Count > 0)
{
for (int i = 0; i < e.Cell.Row.Cells.Count; i++)
{
if (!e.Cell.Row.Cells[i].Column.Key.Equals("CHC"))
e.Cell.Row.Cells[i].Activation = Activation.ActivateOnly;
}
}
else
{
for (int i = 0; i < e.Cell.Row.Cells.Count; i++)
{
if (!e.Cell.Row.Cells[i].Column.Key.Equals("CHC"))
e.Cell.Row.Cells[i].Activation = Activation.AllowEdit;
}
}
}
}
}
if (ugr.HasChild())
{
return;
}
else
{
CreateSequence();
}
}
private void CreateSequence()
{
UltraGridRow ugrItem = ultraGrid1.ActiveRow;
for (int i = 0; i < ultraGrid2.Rows.Count; i++)
{
UltraGridRow ugrStand = ultraGrid2.Rows[i];
ugrStand.Cells["ASK_ITEM_NOONE"].Value = ugrItem.ParentRow.Cells["ASK_ITEM_DESC"].Value.ToString().Trim();
ugrStand.Cells["ASK_ITEM_NOTWO"].Value = ugrItem.Cells["ASK_ITEM_DESC"].Value.ToString().Trim();
ugrStand.Cells["ASK_P_ITEM_NO"].Value = ugrItem.Cells["ASK_ITEM_NO"].Value.ToString().Trim();
ugrStand.Cells["STATION_DESC"].Value = ugrItem.ParentRow.Cells["STATION_DESC"].Value.ToString().Trim();
ugrStand.Cells["STATION_CODE"].Value = ugrItem.ParentRow.Cells["STATION_CODE"].Value.ToString();
if (!ugrStand.Cells["ASK_P_ITEM_NO"].Value.Equals(""))
{
ugrStand.Cells["ASK_ITEM_NO"].Value = ugrItem.Cells["ASK_ITEM_NO"].Value.ToString() + ugrStand.Cells["ASK_ITEM_NO"].Value.ToString().Substring(8, 3);
}
}
}
private void ultraGrid2_CellChange(object sender, CellEventArgs e)
{
ultraGrid2.UpdateData();
if (e.Cell.Column.Key.Equals("CHC")) //
{
Activation activation = Activation.ActivateOnly;
if (Convert.ToBoolean(e.Cell.Value))
{
activation = Activation.AllowEdit;
isSelect += 1;
UltraGridRow ugr1 = ultraGrid1.ActiveRow;
UltraGridRow ugr2 = ultraGrid2.ActiveRow;
string station = ugr1.ParentRow.Cells["STATION_CODE"].Text;
string item = ugr1.ParentRow.Cells["ASK_ITEM_DESC"].Value.ToString();
string subitem = ugr1.Cells["ASK_ITEM_DESC"].Value.ToString();
if (ugr2.Cells["STATION_DESC"].Value.ToString() != station)
{
ugr2.Cells["STATION_DESC"].Value = station;
}
if (ugr2.Cells["ASK_ITEM_NOONE"].Value.ToString() != item)
{
ugr2.Cells["ASK_ITEM_NOONE"].Value = item;
}
if (ugr2.Cells["ASK_ITEM_NOTWO"].Value.ToString() != subitem)
{
ugr2.Cells["ASK_ITEM_NOTWO"].Value = subitem;
}
}
else
isSelect -= 1;
CellsCollection cells = e.Cell.Row.Cells;
for (int i = 0; i < cells.Count; i++)
{
if (!cells[i].Column.Key.Equals("CHC"))
{
e.Cell.Row.Cells[i].Activation = activation;
}
}
if (Convert.ToBoolean(e.Cell.Value))
{
string code = e.Cell.Row.Cells["ASK_ITEM_NO"].Value.ToString();
DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreBaseAddAsk.isLinkStd2", new Object[] { code }, this.ob);
if (dt != null && dt.Rows.Count > 0)
{
for (int i = 0; i < e.Cell.Row.Cells.Count; i++)
{
if (!e.Cell.Row.Cells[i].Column.Key.Equals("CHC") && !e.Cell.Row.Cells[i].Column.Key.Equals("STDFLAG"))
e.Cell.Row.Cells[i].Activation = Activation.ActivateOnly;
}
}
else
{
for (int i = 0; i < e.Cell.Row.Cells.Count; i++)
{
if (!e.Cell.Row.Cells[i].Column.Key.Equals("CHC") && !e.Cell.Row.Cells[i].Column.Key.Equals("STDFLAG"))
e.Cell.Row.Cells[i].Activation = Activation.AllowEdit;
}
}
}
}
ControlAskItemDesc(e.Cell.Row);
}
private bool CheckBaseAddAsk(BaseAddAskObject com)
{
if (com.Validflag.Equals("无效"))
{
errMessage = "无效记录不能保存操作";
return false;
}
string askItemDesc = com.AskItemDesc;
string askItemCode = com.AskItemNo;
if (askItemDesc.Equals(""))
{
errMessage = "项目、分项或者标准说明不能为空";
return false;
}
//if (com.Validflag.Equals(""))
//{
// DataTable dt = ServerHelper.GetData("", new Object[] { askItemDesc, askItemCode }, this.ob);
// if (dt != null && dt.Rows.Count > 0)
// {
// errMessage = askItemDesc + "重复,请重新输入";
// return false;
// }
//}
//else
//{
// DataTable dt = ServerHelper.GetData("", new Object[] { askItemDesc, askItemCode }, this.ob);
// if (dt != null && dt.Rows.Count > 0)
// {
// errMessage = askItemDesc + "重复,请重新输入";
// return false;
// }
//}
return true;
}
private void DeleteData()
{
ultraGrid1.UpdateData();
ultraGrid2.UpdateData();
if (ultraGrid1.ActiveRow == null && !ultraGrid1.ActiveRow.HasParent())
{
MessageUtil.ShowWarning("请选择需要删除的检验分项!");
return;
}
if (MessageUtil.ShowYesNoAndQuestion("是否确认删除?") == DialogResult.No)
{
return;
}
ServerHelper.SetData("com.steering.pss.qcm.CoreBaseAddAsk.deleteData", new object[] {
ultraGrid1.ActiveRow.GetValue("ASK_ITEM_NO") }, ob);
MessageUtil.ShowTips("操作成功!");
}
private void DoDeleteOrResume(bool flag)
{
ultraGrid1.UpdateData();
ultraGrid2.UpdateData();
if (isSelect == 0)
{
MessageBox.Show("请选择记录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
ArrayList listData = new ArrayList();
foreach (UltraGridRow ugr in ultraGrid1.Rows)
{
if (Convert.ToBoolean(ugr.Cells["CHC"].Value))
{
BaseAddAskObject com = Qcm.objectData.GetObjectData.GetAddAskData(ugr);
if (!CheckData(com, flag))
{
MessageBox.Show(errMessage, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
ugr.Activate();
return;
}
if (flag && ugr.HasChild())
{
foreach (UltraGridRow ugrC in ugr.ChildBands[0].Rows)
{
if (!Convert.ToBoolean(ugrC.Cells["CHC"].Value) && ugrC.Cells["VALIDFLAG"].Value.Equals("有效"))
{
MessageBox.Show("请先作废对应子记录", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
}
}
com.DeleteName = UserInfo.GetUserName();
listData.Add(JSONFormat.Format(com));
askItemNo = com.AskItemNo;
}
if (ugr.HasChild())
{
foreach (UltraGridRow ugrC in ugr.ChildBands[0].Rows)
{
if (Convert.ToBoolean(ugrC.Cells["CHC"].Value))
{
BaseAddAskObject com = Qcm.objectData.GetObjectData.GetAddAskData(ugrC);
if (!CheckData(com, flag))
{
MessageBox.Show(errMessage, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
ugrC.Activate();
return;
}
if (flag)
{
foreach (UltraGridRow ugrC2 in ultraGrid2.Rows)
{
if (!Convert.ToBoolean(ugrC2.Cells["CHC"].Value) && ugrC2.Cells["VALIDFLAG"].Value.Equals("有效"))
{
MessageBox.Show("请先作废对应的子项标准说明记录", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
ugrC2.Activate();
return;
}
}
}
else
{
if (!Convert.ToBoolean(ugr.Cells["CHC"].Value) && ugr.Cells["VALIDFLAG"].Value.Equals("无效"))
{
MessageBox.Show("请先恢复对应主记录", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
ugr.Activate();
return;
}
}
listData.Add(JSONFormat.Format(com));
askItemNo = ugr.Cells["ASK_ITEM_NO"].Value.ToString();
isEx = true;
}
}
}
}
foreach (UltraGridRow ugr in ultraGrid2.Rows)
{
if (Convert.ToBoolean(ugr.Cells["CHC"].Value))
{
BaseAddAskObject com = Qcm.objectData.GetObjectData.GetAddAskData(ugr);
if (!CheckData(com, flag))
{
MessageBox.Show(errMessage, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
listData.Add(JSONFormat.Format(com));
}
}
if (MessageBox.Show("是否" + (flag ? "作废" : "恢复") + "选择记录", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
{
return;
}
if (listData.Count > 0)
{
int count = ServerHelper.SetData("com.steering.pss.qcm.CoreBaseAddAsk.deleteOrResume", new Object[] { listData, flag }, this.ob);
if (count > 0)
{
MessageBox.Show((flag ? "作废" : "恢复") + "成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Question);
DoQuery(false);
}
}
}
private bool CheckData(BaseAddAskObject com, bool flag)
{
if (com.Validflag.Equals("无效") && flag)
{
errMessage = "无效记录不能删除";
return false;
}
if (com.Validflag.Equals("有效") && !flag)
{
errMessage = "有效记录不能恢复";
return false;
}
return true;
}
private void ultraGrid1_BeforeRowInsert(object sender, BeforeRowInsertEventArgs e)
{
if (e.Band.Header.Caption.Equals("Table1"))
{
return;
}
if (e.ParentRow.Cells["VALIDFLAG"].Value.ToString().Equals("无效"))
e.Cancel = true;
}
private void ultraGrid2_ClickCellButton(object sender, CellEventArgs e)
{
UltraGridRow ugr = ultraGrid2.ActiveRow;
string path = "";
if (e.Cell.Column.Key.Equals("PIC") && e.Cell.Row.Cells["CHC"].Value.ToString().ToUpper() == "TRUE"
&& e.Cell.Row.Cells["VALIDFLAG"].Value.ToString().Equals("有效"))
{
ArrayList list = FileUpLoad("PIC");
if (list != null && list.Count > 0)
{
for (int i = 0; i < list.Count; i++)
{
if (path == "")
path = list[i].ToString();
else
path = path + "," + list[i];
}
ugr.Cells["PIC"].Value = path;
}
}
}
private ArrayList FileUpLoad(string sFileName)
{
List list = new List();
ArrayList pathList = new ArrayList();
FileBean bean = new FileBean();
OpenFileDialog file = new OpenFileDialog();
file.Multiselect = true;
if (file.ShowDialog() == DialogResult.OK)
{
foreach (string fileName in file.FileNames)
{
bean = new FileBean();
string filena = System.IO.Path.GetFileName(fileName);
bean.setFileName(filena);
bean.setPathName(sFileName);
bean.setFile(FileHelper.FileToArray(fileName));
list.Add(bean);
pathList.Add(sFileName + "/" + filena);
}
bool isSuccess = Core.Mes.Client.Comm.Server.FileHelper.Upload(list);
if (isSuccess)
{
MessageBox.Show("上传成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return pathList;
}
}
return null;
}
private void ultraGrid2_MouseUp(object sender, MouseEventArgs e)
{
foreach (UltraGridRow row in ultraGrid2.Rows)
{
if (row.Selected)
{
row.Cells["CHC"].Value = true;
}
}
ultraGrid2.UpdateData();
}
}
}