lu
2024-11-26 6ceeba7c1e8903c850d125a4823cc36507e43de9
DevApp/Gs.DevApp/DevFrm/WOM/Frm_Wompba.cs
@@ -1,13 +1,14 @@
using DevExpress.XtraGrid.Views.Grid;
using DevExpress.XtraGrid.Views.Grid.ViewInfo;
using Gs.DevApp.Entity;
using Gs.DevApp.ToolBox;
using Gs.DevApp.UserControl;
using MES.Service.Modes;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace Gs.DevApp.DevFrm
@@ -42,6 +43,45 @@
                Font f = new Font("微软雅黑", 16);
                Rectangle 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);
            };
            //选择需要入库的明细
            btnSelect.Click += (s, e) =>
            {
                if (string.IsNullOrEmpty(this.txt_pba013.Text))
                {
                    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();
            };
        }
@@ -113,9 +153,9 @@
            }
            if (!MsgHelper.AskQuestion("你选择了【" + rowName + "】,确定删除吗?"))
                return;
               List<dynamic> lst = new List<dynamic>();
          lst.Add(rowGuid);
          var _obj = lst;
            List<dynamic> lst = new List<dynamic>();
            lst.Add(rowGuid);
            var _obj = lst;
            try
            {
                string strJson = UtilityHelper.HttpPost("", _webServiceName + "DeleteModel", JsonConvert.SerializeObject(_obj));
@@ -140,10 +180,10 @@
        /// <param name="e"></param>
        private void ToolBarMenu1_btnLoadClick(object sender, EventArgs e)
        {
              if (xtraTabControl1.SelectedTabPageIndex == 1)
      getModel(lbGuid.Text.Trim(), false, 999);
  else
      getPageList(1, UtilityHelper.GetPageSize());
            if (xtraTabControl1.SelectedTabPageIndex == 1)
                getModel(lbGuid.Text.Trim(), false, 999);
            else
                getPageList(1, UtilityHelper.GetPageSize());
        }
        /// <summary>
        /// 修改事件
@@ -153,7 +193,7 @@
        private void ToolBarMenu1_btnEdtClick(object sender, EventArgs e)
        {
            string rowGuid = "", rowName = "";
            // (rowGuid, rowName) = UtilityHelper.GetCurrentRow(xtraTabControl1, lbGuid, txt_billNo, gridView1);
            (rowGuid, rowName) = UtilityHelper.GetCurrentRow(xtraTabControl1, lbGuid, txt_hNo, gridView1);
            if (string.IsNullOrEmpty(rowGuid))
            {
                ToolBox.MsgHelper.Warning("请先选择你要操作的行!");
@@ -168,12 +208,12 @@
        /// <param name="e"></param>
        private void ToolBarMenu1_btnAddClick(object sender, EventArgs e)
        {
               UtilityHelper.JumpToTab(xtraTabControl1, 1);
    lbGuid.Text = "";
    List<DevExpress.XtraGrid.Views.Grid.GridView> gridViews = new List<DevExpress.XtraGrid.Views.Grid.GridView>();
    gridViews.Add(gvMx1);
    UtilityHelper.CleanValueByControl(this.panel1.Controls, true, gridViews);
    Gs.DevApp.ToolBox.UtilityHelper.SetDefaultTable(gcMx1, gvMx1);
            UtilityHelper.JumpToTab(xtraTabControl1, 1);
            lbGuid.Text = "";
            List<DevExpress.XtraGrid.Views.Grid.GridView> gridViews = new List<DevExpress.XtraGrid.Views.Grid.GridView>();
            gridViews.Add(gvMx1);
            UtilityHelper.CleanValueByControl(this.panel1.Controls, true, gridViews);
            Gs.DevApp.ToolBox.UtilityHelper.SetDefaultTable(gcMx1, gvMx1);
        }
        /// <summary>
        /// 保存事件
@@ -184,15 +224,54 @@
        {
            toolBarMenu1.isSetBtn = false;
            //if (string.IsNullOrEmpty(txt_account.Text.Trim()))
            {
                Gs.DevApp.ToolBox.MsgHelper.Warning("登录账号不能为空!");
                // txt_account.Focus();
                return;
            }
            //{
            //    Gs.DevApp.ToolBox.MsgHelper.Warning("登录账号不能为空!");
            //    txt_account.Focus();
            //    return;
            //}
            var _sb = new StringBuilder();
            var _obj = new
            {
                  guid =UtilityHelper.ToGuid( lbGuid.Text.Trim()), //主建
                guid = UtilityHelper.ToGuid(lbGuid.Text.Trim()), //主建
                bz = txt_pba009.Text.Trim(),
                cjId = 1,
                cxId = 1,
                jhrs = txt_pba015.Text.Trim(),
                list = new List<dynamic>(),
            };
            gvMx1.CloseEditor();
            gvMx1.UpdateCurrentRow();
            if (gvMx1.DataRowCount <= 0)
            {
                MsgHelper.ShowError("明细不能为空,请选择你的收料明细!");
                return;
            }
            for (var i = 0; i < gvMx1.DataRowCount; i++)
            {
                var row = gvMx1.GetDataRow(i);
                if (row != null)
                {
                    Guid? _guid = UtilityHelper.ToGuid(row["guid"].ToString());
                    //string _msl = row["quantity"].ToString();
                    //if (string.IsNullOrEmpty(_msl))
                    //{
                    //    MsgHelper.ShowError("数量不能为空!");
                    //    return;
                    //}
                    _obj.list.Add(new
                    {
                        Guid = _guid,
                        AboutGuid = Gs.DevApp.ToolBox.UtilityHelper.ToGuid(row["aboutGuid"].ToString()),
                        LineId = int.Parse(row["daa015"].ToString()),//产线id
                        Yjkgsj = (row["mesStartProd"].ToString()),//预计开工时间
                        Jhrs = row["daa015"].ToString(),//计划人数
                        Hxsj = row["changeLinetime"].ToString(),//换线时间
                        Bz = row["daa009"].ToString(),//换线时间
                        Blsj = row["prepareTime"].ToString(),//预计备料时间
                        Pcsl = row["daa008"].ToString()//排产数量
                    });
                }
            }
            try
            {
                string strJson = UtilityHelper.HttpPost("", _webServiceName + "EditModel", JsonConvert.SerializeObject(_obj));
@@ -230,22 +309,22 @@
                string strReturn = UtilityHelper.HttpPost("", _webServiceName + "GetListPage", json);
                ReturnModel<PageListModel> dd = UtilityHelper.ReturnToTablePage(strReturn);
                if (dd.rtnCode > 0)
    {
        DataTable dt = dd.rtnData.list;
        gcMain.BindingContext = new BindingContext();
        gcMain.DataSource = dt;
        gcMain.ForceInitialize();
        int dddd = dd.rtnData.pages;//总页
        pageBar1.TotalPages = dddd;
        pageBar1.RecordCount = dd.rtnData.total;//记录总数
        pageBar1.CurrentPage = curPage;//当前页
        pageBar1.RowsCount = pageSize;//每页显示
        pageBar1.setTxt();
    }
    else
    {
        ToolBox.MsgHelper.ShowError("提示:" + dd.rtnMsg);
    }
                {
                    DataTable dt = dd.rtnData.list;
                    gcMain.BindingContext = new BindingContext();
                    gcMain.DataSource = dt;
                    gcMain.ForceInitialize();
                    int dddd = dd.rtnData.pages;//总页
                    pageBar1.TotalPages = dddd;
                    pageBar1.RecordCount = dd.rtnData.total;//记录总数
                    pageBar1.CurrentPage = curPage;//当前页
                    pageBar1.RowsCount = pageSize;//每页显示
                    pageBar1.setTxt();
                }
                else
                {
                    ToolBox.MsgHelper.ShowError("提示:" + dd.rtnMsg);
                }
            }
            catch (Exception ex)
            {
@@ -266,7 +345,7 @@
            };
            try
            {
                string strJson = UtilityHelper.HttpPost("", _webServiceName +"GetModel", JsonConvert.SerializeObject(_obj));
                string strJson = UtilityHelper.HttpPost("", _webServiceName + "GetModel", JsonConvert.SerializeObject(_obj));
                ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.ReturnToDynamic(strJson);
                if (_rtn.rtnCode > 0)
                {