lu
2025-03-03 f4ac9a6acdbd2c5120d72f3dfebb1c53a9477505
DevApp/Gs.DevApp/DevFrm/WW/Frm_WwPc.cs
@@ -1,7 +1,3 @@
using DevExpress.RichEdit.Export;
using DevExpress.XtraEditors;
using DevExpress.XtraGrid.Views.Grid;
using DevExpress.XtraGrid.Views.Grid.ViewInfo;
using Gs.DevApp.Entity;
using Gs.DevApp.ToolBox;
using Gs.DevApp.UserControl;
@@ -10,7 +6,6 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Drawing;
using System.Threading.Tasks;
using System.Windows.Forms;
@@ -32,8 +27,9 @@
            this.toolBarMenu1.btnQueryClick += ToolBarMenu1_btnQueryClick;
            toolBarMenu1.btnChkClick += ToolBarMenu1_btnChkClick;
            toolBarMenu1.btnFChkClick += ToolBarMenu1_btnFChkClick;
            Gs.DevApp.ToolBox.UtilityHelper.SetGridViewParameterMx(gvMx1);
            Gs.DevApp.ToolBox.UtilityHelper.SetGridViewParameter(gridView1, picCheckBox, this, "shState", "", (value) =>
            this.toolBarMenu1.getXmlConfig();
            Gs.DevApp.ToolBox.UtilityHelper.SetGridViewParameterMx( gvMx1);
            Gs.DevApp.ToolBox.UtilityHelper.SetGridViewParameter( gridView1, picCheckBox, this, "shChk", "", (value) =>
            {
                Gs.DevApp.ToolBox.UtilityHelper.JumpTab(xtraTabControl1, 0);
            });
@@ -46,54 +42,44 @@
            });
            getPageList(1);
            pageBar1.PagerEvent += PageBar1_PagerEvent;
            //txt_pba013.EditChanged += (s, e) =>
            //{
            //    string workGuid = this.txt_pba013.GetGuid();
            //    _getListJybz(workGuid);
            //};
            ////选择需要入库的明细
            //btnSelect.Click += (s, e) =>
            //{
            //    if (string.IsNullOrEmpty(this.txt_pba013.GetId()))
            //    {
            //        Gs.DevApp.ToolBox.MsgHelper.ShowError("请先选择车间,才能选择任务单!");
            //        return;
            //    }
            //    var frm = new SelectWompba(this.txt_pba013.Text);
            //    //赋值给明细表
            //    frm.UpdateParent += (ss, ee) =>
            //    {
            //        try
            //        {
            //            var lst = new List<string>();
            //            lst = ee.StringList;
            //            var _obj = lst;
            //            var strReturn = UtilityHelper.HttpPost("",
            //                "WompbaManager/SelectPbaToView",
            //                JsonConvert.SerializeObject(_obj));
            //            var dt = UtilityHelper.ReturnToList(strReturn);
            //            DataTable _newTable = dt.rtnData;
            //            DataTable _oldTable = (DataTable)gcMx1.DataSource;
            //            DataRow[] sourceRows = _newTable.Select();
            //            for (int i = 0; i < sourceRows.Length; i++)
            //            {
            //                _oldTable.ImportRow(sourceRows[i]);
            //            }
            //            gcMx1.BindingContext = new BindingContext();
            //            gcMx1.DataSource = _oldTable;
            //            gcMx1.ForceInitialize();
            //        }
            //        catch (Exception ex)
            //        {
            //            MessageBox.Show(ex.Message);
            //        }
            //    };
            //    frm.ShowDialog();
            //};
            btnSelect.Click += (s, e) =>
            {
                var frm = new SelectWwPc("");
                //赋值给明细表
                frm.UpdateParent += (ss, ee) =>
                {
                    try
                    {
                        var lst = new List<string>();
                        lst = ee.StringList;
                        var _obj = lst;
                        var strReturn = UtilityHelper.HttpPost("",
                            "WWPCManager/SelectFormTo",
                            JsonConvert.SerializeObject(_obj));
                        var dt = UtilityHelper.ReturnToList(strReturn);
                        DataTable _newTable = dt.rtnData;
                        DataTable _oldTable = (DataTable)gcMx1.DataSource;
                        DataRow[] sourceRows = _newTable.Select();
                        for (int i = 0; i < sourceRows.Length; i++)
                        {
                            _oldTable.ImportRow(sourceRows[i]);
                        }
                        gcMx1.BindingContext = new BindingContext();
                        gcMx1.DataSource = _oldTable;
                        gcMx1.ForceInitialize();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                };
                frm.ShowDialog();
            };
        }
        private void GridView1_ColumnFilterChanged(object sender, EventArgs e)
        {
            _filterList = Gs.DevApp.ToolBox.UtilityHelper.GetDilter(gridView1.Columns);
            Gs.DevApp.ToolBox.UtilityHelper.GetDilter(gridView1.Columns, gridView1);
            Task.Delay(100);
            getPageList(1);
        }
@@ -139,7 +125,7 @@
        /// <param name="e"></param>
        private void ToolBarMenu1_btnChkClick(object sender, EventArgs e)
        {
            _toolCk(1, "EditModelSubmit");
            _toolCk(1);
        }
        /// <summary>
@@ -150,7 +136,7 @@
        /// <exception cref="NotImplementedException"></exception>
        private void ToolBarMenu1_btnFChkClick(object sender, EventArgs e)
        {
            _toolCk(0, "EditModelSubmitFSH");
            _toolCk(0);
        }
        /// <summary>
@@ -194,9 +180,10 @@
                if (_rtn.rtnCode > 0)
                {
                    if (xtraTabControl1.SelectedTabPageIndex == 0)
                        getPageList(this.pageBar1.CurrentPage);
                    { }
                    else
                        Gs.DevApp.ToolBox.UtilityHelper.JumpTab(xtraTabControl1, 2);
                    getPageList(this.pageBar1.CurrentPage);
                }
                MsgHelper.Warning("提示:" + _rtn.rtnMsg);
            }
@@ -217,14 +204,15 @@
                getModel(lbGuid.Text.Trim());
            else
            {
                _filterList.Clear();
                if (gridView1.ActiveFilter.Count > 0)
                {
                    gridView1.ColumnFilterChanged -= GridView1_ColumnFilterChanged;
                    gridView1.ActiveFilter.Clear();
                    gridView1.ColumnFilterChanged += GridView1_ColumnFilterChanged;
                }
                getPageList(1);
                //_filterList.Clear();
                //if (gridView1.ActiveFilter.Count > 0)
                //{
                //    gridView1.ColumnFilterChanged -= GridView1_ColumnFilterChanged;
                //    gridView1.ActiveFilter.Clear();
                //    gridView1.ColumnFilterChanged += GridView1_ColumnFilterChanged;
                //}
                //getPageList(1);
                getPageList(this.pageBar1.CurrentPage);
            }
        }
        /// <summary>
@@ -244,7 +232,7 @@
            Gs.DevApp.ToolBox.UtilityHelper.JumpTab(xtraTabControl1, 3);
            List<DevExpress.XtraGrid.Views.Grid.GridView> gvList = new List<DevExpress.XtraGrid.Views.Grid.GridView>();
            gvList.Add(gvMx1);
            UtilityHelper.ChangeEnableByControl(panel1.Controls, true);
            UtilityHelper.ChangeEnableByControl(this.layoutMx1.Controls, true, gvList);
        }
        /// <summary>
        /// 新增事件
@@ -255,7 +243,9 @@
        {
            lbGuid.Text = "";
            Gs.DevApp.ToolBox.UtilityHelper.JumpTab(xtraTabControl1, 4);
            UtilityHelper.CleanValueByControl(panel1.Controls, true);
            List<DevExpress.XtraGrid.Views.Grid.GridView> gvList = new List<DevExpress.XtraGrid.Views.Grid.GridView>();
            gvList.Add(gvMx1);
            UtilityHelper.CleanValueByControl(this.layoutMx1.Controls, true, gvList);
            Gs.DevApp.ToolBox.UtilityHelper.SetDefaultTable(gcMx1, gvMx1);
        }
        /// <summary>
@@ -266,25 +256,17 @@
        private void ToolBarMenu1_btnSaveClick(object sender, EventArgs e)
        {
            toolBarMenu1.isSetBtn = false;
            //string workId = txt_pba013.GetId();
            //if (string.IsNullOrEmpty(workId.Trim()))
            //{
            //    Gs.DevApp.ToolBox.MsgHelper.Warning("请选择车间!");
            //    txt_pba013.Focus();
            //    return;
            //}
            //var _obj = new
            //{
            //    guid = UtilityHelper.ToGuid(lbGuid.Text.Trim()), //主建
            //    bz = txt_pba009.Text.Trim(),
            //    cjId = workId,
            //    list = new List<dynamic>(),
            //};
            var _obj = new
            {
                guid = UtilityHelper.ToGuid(lbGuid.Text.Trim()), //主建
                bz = "",
                list = new List<dynamic>(),
            };
            gvMx1.CloseEditor();
            gvMx1.UpdateCurrentRow();
            if (gvMx1.DataRowCount <= 0)
            {
                MsgHelper.ShowError("明细不能为空,请选择你的收料明细!");
                MsgHelper.ShowError("明细不能为空,请选择你的明细!");
                return;
            }
            for (var i = 0; i < gvMx1.DataRowCount; i++)
@@ -292,13 +274,7 @@
                var row = gvMx1.GetDataRow(i);
                if (row != null)
                {
                    Guid? _guid = UtilityHelper.ToGuid(row["guid"].ToString());
                    //string _LineId = row["daa015"].ToString();
                    //if (string.IsNullOrEmpty(_LineId))
                    //{
                    //    MsgHelper.ShowError("产线编码不能为空!");
                    //    return;
                    //}
                    Guid? _guid = UtilityHelper.ToGuid(row["id"].ToString());
                    string _Pcsl = row["daa008"].ToString();
                    if (string.IsNullOrEmpty(_Pcsl))
                    {
@@ -311,64 +287,37 @@
                        MsgHelper.ShowError("预计开工时间不能为空!");
                        return;
                    }
                    //string _prepareTime = row["prepareTime"].ToString();
                    //if (string.IsNullOrEmpty(_prepareTime))
                    //{
                    //    MsgHelper.ShowError("预计备料时间不能为空!");
                    //    return;
                    //}
                    //string _planPersonnel = row["planPersonnel"].ToString();
                    //if (string.IsNullOrEmpty(_planPersonnel))
                    //{
                    //    MsgHelper.ShowError("计划人数!");
                    //    return;
                    //}
                    //string _changeLinetime = row["changeLinetime"].ToString();
                    //if (string.IsNullOrEmpty(_changeLinetime))
                    //{
                    //    MsgHelper.ShowError("换线时间不能为空!");
                    //    return;
                    //}
                    string _mesEndProd = row["mesEndProd"].ToString();
                    if (string.IsNullOrEmpty(_mesEndProd))
                    {
                        MsgHelper.ShowError("预计完工时间不能为空!");
                        return;
                    }
                    //string _restTime = row["restTime"].ToString();
                    //if (string.IsNullOrEmpty(_prepareTime))
                    //{
                    //    MsgHelper.ShowError("休息时间不能为空!");
                    //    return;
                    //}
                    //_obj.list.Add(new
                    //{
                    //    Guid = _guid,
                    //    AboutGuid = Gs.DevApp.ToolBox.UtilityHelper.ToGuid(row["caaGuid"].ToString()),
                    //    LineId = row["daa015"].ToString(),//产线id
                    //    Yjkgsj = (row["mesStartProd"].ToString()),//预计开工时间
                    //    Jhrs = row["planPersonnel"].ToString(),//计划人数
                    //    Hxsj = row["changeLinetime"].ToString(),//换线时间
                    //    Bz = row["daa009"].ToString(),//备注
                    //    Blsj = row["prepareTime"].ToString(),//预计备料时间
                    //    Pcsl = row["daa008"].ToString(),//排产数量
                    //    Yjwgsj = row["mesEndProd"].ToString()//预计完工时间
                    //});
                    _obj.list.Add(new
                    {
                        Guid = _guid,
                        AboutGuid = Gs.DevApp.ToolBox.UtilityHelper.ToGuid(row["rwdGuid"].ToString()),//相当于caaGuid
                        Yjkgsj = (row["mesStartProd"].ToString()),//预计开工时间
                        Bz = row["remark"].ToString(),//备注
                        Pcsl = row["daa008"].ToString(),//排产数量
                        Yjwgsj = row["mesEndProd"].ToString()//预计完工时间
                    });
                }
            }
            try
            {
                //string strJson = UtilityHelper.HttpPost("", _webServiceName + "EditModel", JsonConvert.SerializeObject(_obj));
                //ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.ReturnToDynamic(strJson);
                //ToolBox.MsgHelper.Warning("提示:" + _rtn.rtnMsg);
                //if (_rtn.rtnCode > 0)
                //{
                //    lbGuid.Text = _rtn.rtnData;
                //    toolBarMenu1.isSetBtn = true;
                //    List<DevExpress.XtraGrid.Views.Grid.GridView> gvList = new List<DevExpress.XtraGrid.Views.Grid.GridView>();
                //    gvList.Add(gvMx1);
                //    UtilityHelper.ChangeEnableByControl(this.panel1.Controls, false, gvList);
                //}
                string strJson = UtilityHelper.HttpPost("", _webServiceName + "EditModel", JsonConvert.SerializeObject(_obj));
                ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.ReturnToDynamic(strJson);
                ToolBox.MsgHelper.Warning("提示:" + _rtn.rtnMsg);
                if (_rtn.rtnCode > 0)
                {
                    lbGuid.Text = _rtn.rtnData;
                    txt_hNo.Text = _rtn.rtnData.outNo;
                    toolBarMenu1.isSetBtn = true;
                    List<DevExpress.XtraGrid.Views.Grid.GridView> gvList = new List<DevExpress.XtraGrid.Views.Grid.GridView>();
                    gvList.Add(gvMx1);
                    UtilityHelper.ChangeEnableByControl(this.layoutMx1.Controls, false, gvList);
                }
            }
            catch (Exception ex)
            {
@@ -394,15 +343,16 @@
                if (dd.rtnCode > 0)
                {
                    DataTable dt = dd.rtnData.list;
                    gcMain.BindingContext = new BindingContext();
                    gcMain1.BindingContext = new BindingContext();
                    gridView1.ColumnFilterChanged -= GridView1_ColumnFilterChanged;
                    if (dt.Rows.Count > 0)
                    {
                        gcMain.DataSource = dt;
                        gcMain.ForceInitialize();
                        gcMain1.DataSource = dt;
                        gcMain1.ForceInitialize();
                        gridView1.BestFitColumns();
                    }
                    else
                        UtilityHelper.SetDefaultTable(gcMain, gridView1);
                        UtilityHelper.SetDefaultTable(gcMain1, gridView1);
                    gridView1.ColumnFilterChanged += GridView1_ColumnFilterChanged;
                    pageBar1.TotalPages = dd.rtnData.pages;//总页
                    pageBar1.CurrentPage = curPage;//当前页
@@ -447,7 +397,7 @@
                    lbGuid.Text = strGuid;
                    List<DevExpress.XtraGrid.Views.Grid.GridView> gvList = new List<DevExpress.XtraGrid.Views.Grid.GridView>();
                    gvList.Add(gvMx1);
                    UtilityHelper.SetValueByObj(this.panel1.Controls, dy, isEdit, gvList);
                    UtilityHelper.SetValueByObj(this.layoutMx1.Controls, dy, isEdit, gvList);
                    JObject _job = JObject.Parse(strJson);
                    JArray array = new JArray();
                    foreach (var a in _job["rtnData"]["list"])
@@ -460,6 +410,7 @@
                        gcMx1.BindingContext = new BindingContext();
                        gcMx1.DataSource = dt;
                        gcMx1.ForceInitialize();
                        gvMx1.BestFitColumns();
                    }
                    else
                    {
@@ -476,12 +427,11 @@
        }
        /// <summary>
        /// 工具条事件
        /// </summary>
        /// <param name="inFieldValue"></param>
        private void _toolCk(int _inFieldValue, string _mth)
        private void _toolCk(int _inFieldValue)
        {
            string strMsg = "";
            switch (_inFieldValue)
@@ -511,16 +461,19 @@
            try
            {
                var strJson = UtilityHelper.HttpPost("",
                    _webServiceName + _mth,
                    _webServiceName + "EditModelSubmit",
                    JsonConvert.SerializeObject(_obj));
                var _rtn = UtilityHelper.ReturnToDynamic(strJson);
                MsgHelper.Warning(_rtn.rtnData.outMsg.ToString());
                if (_rtn.rtnCode > 0)
                if (_rtn.rtnCode > 0 && _rtn.rtnData.outSum * 1 > 0)
                {
                    if (xtraTabControl1.SelectedTabPageIndex == 1)
                    {
                        getModel(lbGuid.Text.Trim());
                    else
                        getPageList(this.pageBar1.CurrentPage);
                    }
                    int rowHandle = gridView1.LocateByValue(1, gridView1.Columns["guid"], rowGuid);
                    gridView1.FocusedRowHandle = rowHandle;
                    UtilityHelper.SetCheckIco(gridView1, "shChk", "shBy", "shTime", picCheckBox, this, _inFieldValue.ToString());
                }
            }
            catch (Exception ex)
@@ -529,5 +482,45 @@
            }
        }
        private void repositoryItemButtonEdit1_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        {
            var rowhandle = gvMx1.FocusedRowHandle;
            if (rowhandle < 0)
                return;
            if (e.Button.Index == 0)
            {
                var dr = gvMx1.GetDataRow(rowhandle);
                var mxGuid = dr["id"].ToString();
                if (!MsgHelper.AskQuestion("你选择了1条数据,确定删除吗?"))
                    return;
                if (string.IsNullOrEmpty(mxGuid))
                {
                    gvMx1.DeleteRow(rowhandle);
                    return;
                }
                var _obj = new
                {
                    guid = lbGuid.Text.Trim(),
                    mxGuid = mxGuid,
                };
                try
                {
                    var strJson = UtilityHelper.HttpPost("",
                        _webServiceName + "DeleteModelOrMx",
                        JsonConvert.SerializeObject(_obj));
                    var _rtn = UtilityHelper.ReturnToDynamic(strJson);
                    if (_rtn.rtnCode > 0)
                    {
                        if (_rtn.rtnCode > 0) getModel(lbGuid.Text);
                    }
                    MsgHelper.Warning("提示:" + _rtn.rtnMsg);
                }
                catch (Exception ex)
                {
                    MsgHelper.Warning("提示:" + ex.Message);
                }
            }
        }
    }
}