| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788 |
- 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;
- }
- }
- /// <summary>
- /// 查询
- /// </summary>
- 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 = "";
- }
- /// <summary>
- /// 删除
- /// </summary>
- 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;
- }
- }
- /// <summary>
- /// 控制标准说明是否可以编辑
- /// </summary>
- /// <param name="row"></param>
- 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<FileBean> list = new List<FileBean>();
- 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();
- }
- }
- }
|