| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Data; |
| | | using System.Drawing; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using System.Windows.Forms; |
| | | using DevExpress.XtraEditors; |
| | |
| | | toolBarMenu1.btnEscClick += ToolBarMenu1_btnEscClick; |
| | | toolBarMenu1.btnQueryClick += ToolBarMenu1_btnQueryClick; |
| | | toolBarMenu1.btnChkClick += ToolBarMenu1_btnChkClick; |
| | | toolBarMenu1.btnFChkClick += ToolBarMenu1_btnFChkClick; |
| | | toolBarMenu1.btnPiZhunClick += ToolBarMenu1_btnPiZhunClick; |
| | | gcMain.MouseDoubleClick += GcMain_MouseDoubleClick; |
| | | gridView1.FocusedRowChanged += (s, e) => |
| | | Gs.DevApp.ToolBox.UtilityHelper.SetGridViewParameterMx(gvMx1); |
| | | Gs.DevApp.ToolBox.UtilityHelper.SetGridViewParameter(gridView1, picCheckBox, this, "foneChecked", "", (value) => |
| | | { |
| | | UtilityHelper.SetCheckIco(s, picCheckBox, this, "foneChecked", ""); |
| | | }; |
| | | Gs.DevApp.ToolBox.UtilityHelper.JumpTab(xtraTabControl1, 0); |
| | | }); |
| | | Gs.DevApp.ToolBox.UtilityHelper.SetTabParameter(gridView1, xtraTabControl1, pageBar1, (value) => |
| | | { |
| | | getModel(value); |
| | | }, (value) => |
| | | { |
| | | getPageList(this.pageBar1.CurrentPage); |
| | | }); |
| | | getPageList(1); |
| | | Gs.DevApp.ToolBox.UtilityHelper.SetGridSear(gridView1); |
| | | pageBar1.PagerEvent += PageBar1_PagerEvent; |
| | | gridView1.CustomDrawRowIndicator += (s, e) => |
| | | { |
| | | if (e.Info.IsRowIndicator && e.RowHandle >= 0) |
| | | e.Info.DisplayText = (e.RowHandle + 1).ToString(); |
| | | }; |
| | | gridView1.CustomDrawEmptyForeground += (s, e) => |
| | | { |
| | | var str = "暂未查找到匹配的数据!"; |
| | | var f = new Font("微软雅黑", 16); |
| | | var r = new Rectangle( |
| | | gridView1.GridControl.Width / 2 - 100, e.Bounds.Top + 45, |
| | | e.Bounds.Right - 5, e.Bounds.Height - 5); |
| | | e.Graphics.DrawString(str, f, Brushes.Gray, r); |
| | | }; |
| | | //初始化物料选择和各种下拉 |
| | | _setIno(); |
| | | btnSave.Click += BtnSave_Click; |
| | | } |
| | | private void GridView1_ColumnFilterChanged(object sender, EventArgs e) |
| | | private void GridView1_ColumnFilterChanged(object sender, EventArgs e) |
| | | { |
| | | _filterList = Gs.DevApp.ToolBox.UtilityHelper.GetDilter(gridView1.Columns); |
| | | Task.Delay(100); |
| | | Task.Delay(100); |
| | | getPageList(1); |
| | | } |
| | | /// <summary> |
| | | /// 双击事件 |
| | | /// </summary> |
| | | /// <param name="sender"></param> |
| | | /// <param name="e"></param> |
| | | private void GcMain_MouseDoubleClick(object sender, MouseEventArgs e) |
| | | { |
| | | var rowGuid = |
| | | UtilityHelper.GetCurrentDoubleRow(gridView1, |
| | | e, "guid"); |
| | | if (!string.IsNullOrEmpty(rowGuid)) |
| | | getModel(rowGuid, false, 999); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <param name="e"></param> |
| | | private void ToolBarMenu1_btnPiZhunClick(object sender, EventArgs e) |
| | | { |
| | | string rowGuid, rowName; |
| | | (rowGuid, rowName) = UtilityHelper.GetCurrentRow(xtraTabControl1, |
| | | lbGuid, txt_itemNo, gridView1); |
| | | try |
| | | { |
| | | string strJson = UtilityHelper.HttpPost("", _webServiceName + "Approval", JsonConvert.SerializeObject(rowGuid)); |
| | | ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.ReturnToDynamic(strJson); |
| | | if (_rtn.rtnCode > 0) |
| | | { |
| | | UtilityHelper.JumpToTab(xtraTabControl1, 0); |
| | | getPageList(1); |
| | | } |
| | | ToolBox.MsgHelper.Warning("提示:" + _rtn.rtnMsg); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | ToolBox.MsgHelper.Warning("提示:" + ex.Message); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 反审核 |
| | | /// </summary> |
| | | /// <param name="sender"></param> |
| | | /// <param name="e"></param> |
| | | /// <exception cref="NotImplementedException"></exception> |
| | | private void ToolBarMenu1_btnFChkClick(object sender, EventArgs e) |
| | | { |
| | | toolBarMenu1.guidKey = ""; |
| | | string rowGuid, rowName; |
| | | (rowGuid, rowName) = UtilityHelper.GetCurrentRow(xtraTabControl1, |
| | | lbGuid, txt_itemNo, gridView1); |
| | | toolBarMenu1.guidKey = rowGuid; |
| | | _toolCk(2); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <param name="e"></param> |
| | | private void ToolBarMenu1_btnChkClick(object sender, EventArgs e) |
| | | { |
| | | toolBarMenu1.guidKey = ""; |
| | | string rowGuid, rowName; |
| | | (rowGuid, rowName) = UtilityHelper.GetCurrentRow(xtraTabControl1, |
| | | lbGuid, txt_itemNo, gridView1); |
| | | toolBarMenu1.guidKey = rowGuid; |
| | | _toolCk(1); |
| | | } |
| | | /// <summary> |
| | | /// 取消事件 |
| | |
| | | /// <param name="e"></param> |
| | | private void ToolBarMenu1_btnDelClick1(object sender, EventArgs e) |
| | | { |
| | | string rowGuid = "", rowName = ""; |
| | | (rowGuid, rowName) = UtilityHelper.GetCurrentRow(xtraTabControl1, lbGuid, txt_itemNo, gridView1); |
| | | if (string.IsNullOrEmpty(rowGuid)) |
| | | { |
| | | MsgHelper.Warning("请先选择你要操作的行!"); |
| | | return; |
| | | } |
| | | |
| | | if (!MsgHelper.AskQuestion("你选择了【" + rowName + "】的检验标准,确定删除吗?")) |
| | | return; |
| | | var lst = new List<dynamic>(); |
| | | lst.Add(rowGuid); |
| | | var _obj = lst; |
| | | try |
| | | { |
| | | var strJson = UtilityHelper.HttpPost("", |
| | | _webServiceName + "DeleteModel", |
| | | JsonConvert.SerializeObject(_obj)); |
| | | var _rtn = |
| | | UtilityHelper.ReturnToDynamic(strJson); |
| | | if (_rtn.rtnCode > 0) |
| | | { |
| | | UtilityHelper.JumpToTab(xtraTabControl1, 0); |
| | | getPageList(1); |
| | | } |
| | | MsgHelper.Warning("提示:" + _rtn.rtnMsg); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | MsgHelper.Warning("提示:" + ex.Message); |
| | | } |
| | | _toolCk(-1); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | private void ToolBarMenu1_btnLoadClick(object sender, EventArgs e) |
| | | { |
| | | if (xtraTabControl1.SelectedTabPageIndex == 1) |
| | | getModel(lbGuid.Text.Trim(), false, 999); |
| | | getModel(lbGuid.Text.Trim()); |
| | | else |
| | | { |
| | | _filterList.Clear(); |
| | |
| | | MsgHelper.Warning("请先选择你要操作的行!"); |
| | | return; |
| | | } |
| | | getModel(rowGuid, true, 1); |
| | | Gs.DevApp.ToolBox.UtilityHelper.JumpTab(xtraTabControl1, 3); |
| | | UtilityHelper.ChangeEnableByControl(panel1.Controls, true); |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <param name="e"></param> |
| | | private void ToolBarMenu1_btnAddClick(object sender, EventArgs e) |
| | | { |
| | | UtilityHelper.JumpToTab(xtraTabControl1, 1); |
| | | lbGuid.Text = ""; |
| | | var gridViews = |
| | | new List<GridView>(); |
| | | Gs.DevApp.ToolBox.UtilityHelper.JumpTab(xtraTabControl1, 4); |
| | | var gridViews = new List<GridView>(); |
| | | gridViews.Add(gvMx1); |
| | | UtilityHelper.CleanValueByControl(panel1.Controls, true, |
| | | gridViews); |
| | | UtilityHelper.CleanValueByControl(panel1.Controls, true, gridViews); |
| | | UtilityHelper.SetDefaultTable(gcMx1, gvMx1); |
| | | xtraTabPageCopy.PageEnabled = false; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | private void ToolBarMenu1_btnSaveClick(object sender, EventArgs e) |
| | | { |
| | | toolBarMenu1.isSetBtn = false; |
| | | string _ItemId = txt_ItemId.GetId() |
| | | ; if (string.IsNullOrEmpty(_ItemId)) |
| | | string _ItemId = txt_ItemId.GetId(); |
| | | if (string.IsNullOrEmpty(_ItemId)) |
| | | { |
| | | MsgHelper.Warning("请选择物料!"); |
| | | txt_ItemId.Focus(); |
| | |
| | | FdownAllow = row["FdownAllow"].ToString(), |
| | | }); |
| | | } |
| | | |
| | | var _obj = new MesQmCheckitem |
| | | { |
| | | Guid = UtilityHelper.ToGuid(lbGuid.Text.Trim()), |
| | | ItemId = long.Parse(_ItemId), |
| | | Memo = txt_memo.Text.Trim(), |
| | | ItemNo = txt_itemNo.Text.Trim(), |
| | | Isenabled = txt_isenabled.Checked, |
| | | Ftype = "1", |
| | | Fversion = Gs.DevApp.ToolBox.UtilityHelper.ToLong(txt_fversion.Text.Trim()), |
| | | list = lst |
| | |
| | | /// </summary> |
| | | /// <param name="curPage">第几页</param> |
| | | /// <param name="pageSize">每页几条</param> |
| | | private void getPageList(int curPage) |
| | | private void getPageList(int curPage) |
| | | { |
| | | |
| | | var _sbSqlWhere = UtilityHelper.GetSearchWhere(_filterList); |
| | | var pgq = new PageQueryModel(curPage, this.pageBar1.RowsCount, |
| | | "a.create_date", "asc", "", _sbSqlWhere.ToString()); |
| | |
| | | { |
| | | MsgHelper.Warning("提示:" + ex.Message); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | private void getModel(string strGuid, bool isEdit, int tabIdx) |
| | | private void getModel(string strGuid) |
| | | { |
| | | bool isEdit = false; |
| | | if (toolBarMenu1.currentAction == "add") return; |
| | | if (toolBarMenu1.currentAction == "edit") isEdit = true; |
| | | if (string.IsNullOrEmpty(strGuid)) |
| | | { |
| | | MsgHelper.Warning("请先选择你要操作的行!"); |
| | | return; |
| | | } |
| | | |
| | | UtilityHelper.JumpToTab(xtraTabControl1, tabIdx); |
| | | xtraTabPageCopy.PageEnabled = !isEdit; |
| | | var _obj = new |
| | | { |
| | | guid = strGuid //主建 |
| | |
| | | var _job = JObject.Parse(strJson); |
| | | var array = new JArray(); |
| | | foreach (var a in _job["rtnData"]["list"]) array.Add(a); |
| | | |
| | | var dt = |
| | | JsonConvert.DeserializeObject<DataTable>( |
| | | array.ToString()); |
| | |
| | | } |
| | | else |
| | | { |
| | | UtilityHelper.SetDefaultTable(gcMx1, |
| | | gvMx1); |
| | | UtilityHelper.SetDefaultTable(gcMx1,gvMx1); |
| | | } |
| | | UtilityHelper.SetDefaultTable(gridControl2, gridView2); |
| | | } |
| | | else |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | #region 以下为种种下拉 |
| | | |
| | | private void getCopyMx(string strGuid) |
| | | /// <summary> |
| | | /// 工具条事件 |
| | | /// </summary> |
| | | /// <param name="inFieldValue"></param> |
| | | private void _toolCk(int _inFieldValue) |
| | | { |
| | | if (string.IsNullOrEmpty(strGuid)) |
| | | string strMsg = ""; |
| | | switch (_inFieldValue) |
| | | { |
| | | MsgHelper.Warning("请先选择你要复制的行!"); |
| | | case -1: |
| | | strMsg = "删除"; |
| | | break; |
| | | case 1: |
| | | strMsg = "审核"; |
| | | break; |
| | | case 2: |
| | | strMsg = "批准"; |
| | | break; |
| | | }; |
| | | toolBarMenu1.guidKey = ""; |
| | | string rowGuid, rowName; |
| | | (rowGuid, rowName) = UtilityHelper.GetCurrentRow(xtraTabControl1, lbGuid, txt_itemNo, gridView1, "itemNo"); |
| | | if (string.IsNullOrEmpty(rowGuid)) |
| | | { |
| | | MsgHelper.Warning("请先选择你要操作的行!"); |
| | | return; |
| | | } |
| | | if (!MsgHelper.AskQuestion("你选择了【" + rowName + "】,确定" + strMsg + "吗?")) |
| | | return; |
| | | |
| | | var _obj = new |
| | | { |
| | | guid = strGuid |
| | | guid = rowGuid, |
| | | inFieldValue = _inFieldValue, |
| | | }; |
| | | try |
| | | { |
| | | var strJson = UtilityHelper.HttpPost("", |
| | | _webServiceName + "GetModelIQC", |
| | | _webServiceName + "EditModelSubmit", |
| | | JsonConvert.SerializeObject(_obj)); |
| | | var _rtn = |
| | | UtilityHelper.ReturnToDynamic(strJson); |
| | | if (_rtn.rtnCode > 0) |
| | | var _rtn = UtilityHelper.ReturnToDynamic(strJson); |
| | | MsgHelper.Warning(_rtn.rtnData.outMsg.ToString()); |
| | | if (_rtn.rtnCode > 0 && _rtn.rtnData.outSum * 1 > 0) |
| | | { |
| | | var dy = _rtn.rtnData; |
| | | var _job = JObject.Parse(strJson); |
| | | var array = new JArray(); |
| | | foreach (var a in _job["rtnData"]["list"]) array.Add(a); |
| | | var dt = |
| | | JsonConvert.DeserializeObject<DataTable>( |
| | | array.ToString()); |
| | | if (dt.Rows.Count > 0) |
| | | { |
| | | gcMx1.BindingContext = new BindingContext(); |
| | | gcMx1.DataSource = dt; |
| | | gcMx1.ForceInitialize(); |
| | | } |
| | | if (xtraTabControl1.SelectedTabPageIndex == 1) |
| | | getModel(lbGuid.Text.Trim()); |
| | | else |
| | | { |
| | | MsgHelper.Warning("提示:没找到相应的明细,请选择其它试试!"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | MsgHelper.Warning("提示:" + _rtn.rtnMsg); |
| | | getPageList(this.pageBar1.CurrentPage); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | MsgHelper.Warning("提示:" + ex.Message); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | #region 以下为种种下拉 |
| | | private void _setIno() |
| | | { |
| | | txt_ItemId.EditChanged += (s, e) => |
| | |
| | | var frm = new SelectCheckDt(); |
| | | frm.UpdateParent += (ss, ee) => |
| | | { |
| | | var lst = new List<string>(); |
| | | lst = ee.StringList; |
| | | getCopyMx(lst[0]); |
| | | |
| | | var lst = ee.DynamicList; |
| | | var json = JsonConvert.SerializeObject(lst); |
| | | DataTable _newTable = (DataTable)JsonConvert.DeserializeObject(json, (typeof(DataTable))); |
| | | DataTable _oldTable = (DataTable)gridControl2.DataSource; |
| | | DataRow[] sourceRows = _newTable.Select(); |
| | | for (int i = 0; i < sourceRows.Length; i++) |
| | | { |
| | | _oldTable.ImportRow(sourceRows[i]); |
| | | } |
| | | gridControl2.BindingContext = new BindingContext(); |
| | | gridControl2.DataSource = _oldTable; |
| | | gridControl2.ForceInitialize(); |
| | | }; |
| | | frm.ShowDialog(); |
| | | }; |
| | |
| | | _webServiceName + "DeleteModelMx", |
| | | JsonConvert.SerializeObject(lst)); |
| | | var _rtn = UtilityHelper.ReturnToDynamic(strJson); |
| | | if (_rtn.rtnCode > 0) getModel(lbGuid.Text, true, 1); |
| | | if (_rtn.rtnCode > 0) getModel(lbGuid.Text); |
| | | MsgHelper.Warning("提示:" + _rtn.rtnMsg); |
| | | } |
| | | catch (Exception ex) |
| | |
| | | } |
| | | } |
| | | #endregion |
| | | /// <summary> |
| | | /// 删除复制项 |
| | | /// </summary> |
| | | /// <param name="sender"></param> |
| | | /// <param name="e"></param> |
| | | private void repositoryItemButtonEdit3_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e) |
| | | { |
| | | gridView2.CloseEditor(); |
| | | gridView2.UpdateCurrentRow(); |
| | | var rowhandle = gridView2.FocusedRowHandle; |
| | | if (rowhandle < 0) |
| | | return; |
| | | if (e.Button.Index == 0) |
| | | { |
| | | var dr = gridView2.GetDataRow(rowhandle); |
| | | if (!MsgHelper.AskQuestion("你选择了1条数据,确定删除吗?")) |
| | | return; |
| | | gridView2.DeleteRow(rowhandle); |
| | | return; |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// 提交物料复制 |
| | | /// </summary> |
| | | /// <param name="sender"></param> |
| | | /// <param name="e"></param> |
| | | /// <exception cref="NotImplementedException"></exception> |
| | | private void BtnSave_Click(object sender, EventArgs e) |
| | | { |
| | | int _rows = gridView2.RowCount; |
| | | if (_rows <= 0) |
| | | { |
| | | MsgHelper.ShowInformation("请选择你需要复制的物料!"); |
| | | return; |
| | | } |
| | | |
| | | if (!MsgHelper.AskQuestion("你选择了" + _rows.ToString() + "条数据,确定保存吗?")) |
| | | return; |
| | | System.Text.StringBuilder _sbGuids = new System.Text.StringBuilder(); |
| | | for (var i = 0; i < gridView2.DataRowCount; i++) |
| | | { |
| | | var row = gridView2.GetDataRow(i); |
| | | if (_sbGuids.Length > 0) |
| | | _sbGuids.Append(","); |
| | | Guid? _guid = UtilityHelper.ToGuid(row["guid"].ToString()); |
| | | _sbGuids.Append(_guid.ToString()); |
| | | } |
| | | var _obj = new |
| | | { |
| | | sourceGuid = UtilityHelper.ToGuid(lbGuid.Text.Trim()), |
| | | itemGuids = _sbGuids.ToString() |
| | | }; |
| | | try |
| | | { |
| | | var strJson = UtilityHelper.HttpPost("", _webServiceName + "ItemsComyMx", JsonConvert.SerializeObject(_obj)); |
| | | var _rtn = UtilityHelper.ReturnToDynamic(strJson); |
| | | MsgHelper.Warning("提示:" + _rtn.rtnMsg); |
| | | if (_rtn.rtnCode > 0) |
| | | { |
| | | UtilityHelper.SetDefaultTable(gridControl2, gridView2); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | MsgHelper.Warning("提示:" + ex.Message); |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |