lu
2025-05-24 ab7e65d41b7b0d280d45a137a5c6520390a1d7a8
DevApp/Gs.DevApp/DevFrm/Work/Frm_WorkTechnique.cs
@@ -1,5 +1,5 @@
using DevExpress.Utils.MVVM.Services;
using DevExpress.XtraPrinting.Native;

using Gs.DevApp.DevFrm.QC;
using Gs.DevApp.Entity;
using Gs.DevApp.ToolBox;
using Gs.DevApp.UserControl;
@@ -11,12 +11,13 @@
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Gs.DevApp.DevFrm.Work
{
    public partial class Frm_WorkTechnique : DevExpress.XtraEditors.XtraForm
    {
        private List<FilterEntity> _filterList = new List<FilterEntity>();
        private readonly string _webServiceName = "MesItemsManager/";
        private readonly string _webServiceName = "WorkTechnique/";
        public Frm_WorkTechnique()
        {
            InitializeComponent();
@@ -36,6 +37,8 @@
            toolBarMenu1.btnQueryClick += ToolBarMenu1_btnQueryClick;
            this.toolBarMenu1.btnEscClick += ToolBarMenu1_btnEscClick;
            this.toolBarMenu1.btnSaveClick += ToolBarMenu1_btnSaveClick;
            toolBarMenu1.btnChkClick += ToolBarMenu1_btnChkClick;
            toolBarMenu1.btnFChkClick += ToolBarMenu1_btnFChkClick;
            this.toolBarMenu1.getXmlConfig();
            Gs.DevApp.ToolBox.UtilityHelper.SetGridViewParameterMx(gvMx1);
            Gs.DevApp.ToolBox.UtilityHelper.SetGridViewParameter(gridView1, null, null, "", "", (value) =>
@@ -48,7 +51,6 @@
            btnSelect.Click += (s, e) =>
            {
                var frm = new SelectProcess();
                //赋值给明细表
                frm.UpdateParent += (ss, ee) =>
                {
                    try
@@ -58,8 +60,9 @@
                        foreach (dynamic dym in lst)
                        {
                            DataRow _row = _Table.NewRow();
                            _row["guid"] = "";
                            _row["pGuid"] = "";
                            _row["fSeq"] = dym.fSeq;
                            _row["statStatus"] = "Y-是";
                            _row["collectionName"] = "空";
                            _row["processNo"] = dym.processNo;
                            _row["processName"] = dym.processName;
                            _Table.Rows.Add(_row);
@@ -70,12 +73,30 @@
                        gvMx1.CloseEditor();
                        gvMx1.PostEditor();
                        gvMx1.UpdateCurrentRow();
                        gvMx1.BestFitColumns();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                };
                frm.ShowDialog();
            };
            _getListJyxm();
            //复制
            btnCopy.Click += (s, e) =>
            {
                if ((lbGuid.Text.Trim().Length < 10))
                {
                    Gs.DevApp.ToolBox.MsgHelper.ShowInformation("请先保存当前信息!");
                    return;
                }
                if ((txt_isCheck.Checked == false))
                {
                    Gs.DevApp.ToolBox.MsgHelper.ShowInformation("该项目未审核,暂不能复制到其它物料!");
                    return;
                }
                Frm_WorkTechniqueShow frm = new Frm_WorkTechniqueShow(lbGuid.Text.Trim());
                frm.ShowDialog();
            };
        }
@@ -152,14 +173,14 @@
        private void getPageList(int curPage)
        {
            gcMain1.DataSource = null;
            var _sbSqlWhere = UtilityHelper.GetSearchWhere(_filterList);
            gcMain1.DataSource = null; var _sbSqlWhere = UtilityHelper.GetSearchWhere(_filterList);
            var pgq = new PageQueryModel(curPage, this.pageBar1.RowsCount, "org.FNumber asc ,a.item_no asc", "",
                "", _sbSqlWhere.ToString());
            var json = JsonConvert.SerializeObject(pgq);
            try
            {
                var strReturn = UtilityHelper.HttpPost("",
                    _webServiceName + "GetListPage", json);
                    "MesItemsManager/GetListPage", json);
                var dd = UtilityHelper.ReturnToTablePage(strReturn);
                if (dd.rtnCode > 0)
                {
@@ -189,6 +210,27 @@
                MsgHelper.Warning("提示:" + ex.Message);
            }
        }
        /// <summary>
        ///     审核事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ToolBarMenu1_btnChkClick(object sender, EventArgs e)
        {
            _toolCk(1);
        }
        /// <summary>
        ///     反审核
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <exception cref="NotImplementedException"></exception>
        private void ToolBarMenu1_btnFChkClick(object sender, EventArgs e)
        {
            _toolCk(0);
        }
        /// <summary>
        /// 取消事件
        /// </summary>
@@ -199,6 +241,7 @@
            List<DevExpress.XtraGrid.Views.Grid.GridView> gvList = new List<DevExpress.XtraGrid.Views.Grid.GridView>();
            gvList.Add(gvMx1);
            UtilityHelper.ChangeEnableByControl(this.layoutMx1.Controls, false, gvList);
            this.btnCopy.Enabled = true;
        }
        /// <summary>
        /// 保存事件
@@ -208,6 +251,49 @@
        private void ToolBarMenu1_btnSaveClick(object sender, EventArgs e)
        {
            toolBarMenu1.isSetBtn = false;
            if (txt_fType.SelectedIndex <= 0)
            {
                Gs.DevApp.ToolBox.MsgHelper.ShowInformation("生产类型不能为空!");
                txt_fType.Focus();
                return;
            }
            if (txt_fJingDu.SelectedIndex < 0)
            {
                Gs.DevApp.ToolBox.MsgHelper.ShowInformation("管理精度不能为空!");
                txt_fJingDu.Focus(); return;
            }
            if (txt_fBegDate.Text.Length <= 0)
            {
                Gs.DevApp.ToolBox.MsgHelper.ShowInformation("生效日期不能为空!");
                txt_fBegDate.Focus(); return;
            }
            if (txt_fEndDate.Text.Length > 0 && txt_fBegDate.DateTime > txt_fEndDate.DateTime)
            {
                Gs.DevApp.ToolBox.MsgHelper.ShowInformation("生效日期不能大于失效日期!");
                txt_fEndDate.Focus(); return;
            }
            decimal num = 0;
            int num2 = 0;
            if (!int.TryParse(txt_fSumPeople.Text.Trim(), out num2))
            {
                Gs.DevApp.ToolBox.MsgHelper.ShowInformation("请输入正确的定员!");
                txt_fSumPeople.Focus(); return;
            }
            if (!decimal.TryParse(txt_fCapacity.Text.Trim(), out num))
            {
                Gs.DevApp.ToolBox.MsgHelper.ShowInformation("请输入正确的产能!");
                txt_fCapacity.Focus(); return;
            }
            if (!decimal.TryParse(txt_fMaxWeight.Text.Trim(), out num))
            {
                Gs.DevApp.ToolBox.MsgHelper.ShowInformation("请输入正确的重量上限!");
                txt_fMaxWeight.Focus(); return;
            }
            if (!decimal.TryParse(txt_fMinWeight.Text.Trim(), out num))
            {
                Gs.DevApp.ToolBox.MsgHelper.ShowInformation("请输入正确的重量下限!");
                txt_fMinWeight.Focus(); return;
            }
            var _obj = new
            {
                guid = UtilityHelper.ToGuid(lbGuid.Text.Trim()), //主建
@@ -253,6 +339,7 @@
                    gvList.Add(gvMx1);
                    UtilityHelper.ChangeEnableByControl(this.layoutMx1.Controls, false, gvList);
                    toolBarMenu1.currentAction = "";
                    //Gs.DevApp.ToolBox.UtilityHelper.JumpTab(xtraTabControl1, 6);
                }
            }
            catch (Exception ex)
@@ -268,10 +355,21 @@
        /// <param name="e"></param>
        private void ToolBarMenu1_btnEdtClick(object sender, EventArgs e)
        {
            List<DevExpress.XtraGrid.Views.Grid.GridView> gvList = new List<DevExpress.XtraGrid.Views.Grid.GridView>();
            gvList.Add(gvMx1);
            UtilityHelper.ChangeEnableByControl(this.layoutMx1.Controls, true, gvList);
            string rowGuid = "", rowName = "";
            (rowGuid, rowName) = UtilityHelper.GetCurrentRow(xtraTabControl1, lbGuid, txt_itemNo, gridView1);
            if (string.IsNullOrEmpty(rowGuid))
            {
                ToolBox.MsgHelper.Warning("请先选择你要操作的行!");
                return;
            }
            getModel(rowGuid);
        }
        /// <summary>
        /// 读取实体
        /// </summary>
        /// <param name="strGuid"></param>
        private void getModel(string strGuid)
        {
            bool isEdit = false;
@@ -289,7 +387,7 @@
            try
            {
                var strJson = UtilityHelper.HttpPost("",
                     "WorkTechnique/GetModel",
                    _webServiceName + "GetModel",
                    JsonConvert.SerializeObject(_obj));
                var _rtn = UtilityHelper.ReturnToDynamic(strJson);
                if (_rtn.rtnCode > 0)
@@ -299,6 +397,7 @@
                    List<DevExpress.XtraGrid.Views.Grid.GridView> gvList = new List<DevExpress.XtraGrid.Views.Grid.GridView>();
                    gvList.Add(gvMx1);
                    UtilityHelper.SetValueByObj(this.layoutMx1.Controls, dy, isEdit, gvList);
                    this.btnCopy.Enabled = true;
                    JObject _job = JObject.Parse(strJson);
                    JArray array = new JArray();
                    foreach (var a in _job["rtnData"]["list"])
@@ -317,6 +416,7 @@
                    {
                        Gs.DevApp.ToolBox.UtilityHelper.SetDefaultTable(gcMx1, gvMx1);
                    }
                    UtilityHelper.SetCheckIco(null, "", "", "", picCheckBox, this, (txt_isCheck.Checked == true ? 1 : 0).ToString());
                }
                else
                {
@@ -328,5 +428,124 @@
                MsgHelper.Warning("提示:" + ex.Message);
            }
        }
        /// <summary>
        /// 工具条事件
        /// </summary>
        /// <param name="inFieldValue"></param>
        private void _toolCk(int _inFieldValue)
        {
            string strMsg = "";
            switch (_inFieldValue)
            {
                case 1:
                    strMsg = "审核";
                    break;
                case 0:
                    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 = rowGuid,
                inFieldValue = _inFieldValue,
            };
            try
            {
                var strJson = UtilityHelper.HttpPost("",
                    _webServiceName + "EditModelSubmit",
                    JsonConvert.SerializeObject(_obj));
                var _rtn = UtilityHelper.ReturnToDynamic(strJson);
                MsgHelper.Warning(_rtn.rtnData.outMsg.ToString());
                if (_rtn.rtnCode > 0 && _rtn.rtnData.outSum * 1 > 0)
                {
                    getModel(lbGuid.Text.Trim());
                }
            }
            catch (Exception ex)
            {
                MsgHelper.Warning("提示:" + ex.Message);
            }
        }
        /// <summary>
        /// 移出工序
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        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["guid"].ToString();
                if (!MsgHelper.AskQuestion("你选择了1条数据,确定删除吗?"))
                    return;
                if (string.IsNullOrEmpty(mxGuid))
                {
                    gvMx1.DeleteRow(rowhandle);
                    return;
                }
                var _obj = new
                {
                    guid = lbGuid.Text.Trim(),//这是产品的guid
                    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);
                }
            }
        }
        /// <summary>
        /// 读取工序下拉
        /// </summary>
        private void _getListJyxm()
        {
            var pgq = new PageQueryModel(1, 999999, "a.processNo", "asc", "", "");
            var json = JsonConvert.SerializeObject(pgq);
            try
            {
                var strReturn = UtilityHelper.HttpPost("", "WorkPro/GetListPage", json);
                var dd = UtilityHelper.ReturnToTablePage(strReturn);
                DataTable dt = dd.rtnData.list;
                rptGx.Items.Add("空");
                foreach (DataRow dr in dt.Rows)
                {
                    rptGx.Items.Add(dr["processNo"].ToString());
                }
            }
            catch (Exception ex)
            {
                MsgHelper.Warning("提示:" + ex.Message);
            }
        }
    }
}