lu
2025-04-05 d70880a3d9ae6c9f99ec380ccd16f5524bb622e6
DevApp/Gs.DevApp/DevFrm/Warehouse/Frm_ArrivalBarcode.cs
@@ -1,12 +1,12 @@
using Gs.DevApp.Entity;
using Gs.DevApp.ToolBox;
using Gs.DevApp.UserControl;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Data;
using System.Drawing;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Gs.DevApp.DevFrm
@@ -20,65 +20,80 @@
            InitializeComponent();
            this.toolBarMenu1.btnLoadClick += ToolBarMenu1_btnLoadClick;
            this.toolBarMenu1.btnQueryClick += ToolBarMenu1_btnQueryClick;
            toolBarMenu1.btnReportClick += ToolBarMenu1_btnReportClick;
            toolBarMenu1.btnDesignClick += ToolBarMenu1_btnDesignClick;
            gcMain.MouseDoubleClick += GcMain_MouseDoubleClick;
            getPageList(1, UtilityHelper.GetPageSize());
            this.toolBarMenu1.getXmlConfig();
            Gs.DevApp.ToolBox.UtilityHelper.SetGridViewParameterMx(gvMx1);
            Gs.DevApp.ToolBox.UtilityHelper.SetGridViewParameterMx(gvMx2);
            Gs.DevApp.ToolBox.UtilityHelper.SetGridViewParameter(gridView1, null, null, "", "", (value) =>
            {
                Gs.DevApp.ToolBox.UtilityHelper.JumpTab(xtraTabControl1, 0);
            });
            Gs.DevApp.ToolBox.UtilityHelper.SetTabParameter(gridView1, xtraTabControl1, pageBar1, (value) =>
            {
                getModel(value);
            }, (value) =>
            {
                getPageList(this.pageBar1.CurrentPage);
            }, lbGuid);
            getPageList(1);
            pageBar1.PagerEvent += PageBar1_PagerEvent;
            gridView1.CustomDrawRowIndicator += (s, e) =>
            this.ucBtnPrint1.btnDesignClick += (s, e) =>
            {
                if (e.Info.IsRowIndicator && e.RowHandle >= 0)
                ucBtnPrint1.rptParameter = "rpt_Arrival{}";
            };
            this.ucBtnPrint1.btnReportClick += (s, e) =>
            {
                string rowGuid = lbMxGuid.Text.Trim();
                ucBtnPrint1.guidKey = rowGuid;
                if (string.IsNullOrEmpty(txt_iCount_1.Text.Trim()))
                {
                    e.Info.DisplayText = (e.RowHandle + 1).ToString();
                    Gs.DevApp.ToolBox.MsgHelper.ShowError("请选择打印条码张数!");
                    txt_iCount_1.Focus();
                    this.ucBtnPrint1.rptParameter = "return false";
                    return;
                }
                if (string.IsNullOrEmpty(txt_psnQty_1.Text.Trim()))
                {
                    Gs.DevApp.ToolBox.MsgHelper.ShowError("请选择打印条码数量!");
                    txt_psnQty_1.Focus();
                    this.ucBtnPrint1.rptParameter = "return false";
                    return;
                }
                if (lbMxGuid.Text.Trim().Length < 10)
                {
                    Gs.DevApp.ToolBox.MsgHelper.ShowError("请选择打印的行!");
                    this.ucBtnPrint1.rptParameter = "return false";
                    return;
                }
                this.ucBtnPrint1.rptParameter = "rpt_Arrival{" + lbMxGuid.Text.Trim()
                       + "," + ""
                       + "," + ""
                       + "," + txt_iCount_1.Text.Trim()
                       + "," + txt_psnQty_1.Text.Trim()
                       + "}";
                txt_iCount_1.Text = "";
                txt_psnQty_1.Text = "";
            };
            gridView1.CustomDrawEmptyForeground += (s, e) =>
            {
                string str = "暂未查找到匹配的数据!";
                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);
            };
            //设置仓库选择
            this.txt_depotsId.KeyFile = "depotId";
            this.txt_depotsId.EditChanged += (s, e) =>
            {
                txtDepotsId.Text = this.txt_depotsId.GetId();
            };
            //设置供应商选择
            this.txt_suppId.KeyFile = "id";
            this.txt_suppId.EditChanged += (s, e) =>
            {
                txtSupplierId.Text = this.txt_suppId.GetId();
            };
            gcMx1.MouseClick += GcMx1_MouseClick;
            gvMx1.FocusedRowChanged += GvMx1_FocusedRowChanged;
        }
        private void GcMx1_MouseClick(object sender, MouseEventArgs e)
        private void GridView1_ColumnFilterChanged(object sender, EventArgs e)
        {
            string rowGuid = Gs.DevApp.ToolBox.UtilityHelper.GetCurrentDoubleRow(gvMx1, e, "guid");
            if (string.IsNullOrEmpty(rowGuid))
                return;
            lbMxGuid.Text = rowGuid;
            toolBarMenu1.guidKey = rowGuid;
            var info = gvMx1.CalcHitInfo(e.Location);
            var view = info.View;
            var row = view.GetDataRow(info.RowHandle);
            txtWlid.Text = row["itemId"].ToString();
            txtWlgg.Text = row["itemModel"].ToString();
            txtWlmc.Text = row["itemName"].ToString();
            txtQuantity.Text = row["Quantity"].ToString();
            kyPrtQty.Text = row["kyPrtQty"].ToString();
            _filterList= Gs.DevApp.ToolBox.UtilityHelper.GetDilter(gridView1.Columns, gridView1);
            Task.Delay(100);
            getPageList(1);
        }
        /// <summary>
        /// 双击事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void GcMain_MouseDoubleClick(object sender, MouseEventArgs e)
        private void GvMx1_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
        {
            string rowGuid = Gs.DevApp.ToolBox.UtilityHelper.GetCurrentDoubleRow(gridView1, e, "guid");
            if (!string.IsNullOrEmpty(rowGuid))
                getModel(rowGuid, false, 999);
            if (e.FocusedRowHandle >= 0)
            {
                DataRow row = gvMx1.GetDataRow(e.FocusedRowHandle);
                lbMxGuid.Text = row["guid"].ToString();
                txtWlid.Text = row["itemNo"].ToString();
                txtWlgg.Text = row["itemModel"].ToString();
                txtWlmc.Text = row["itemName"].ToString();
                txtQuantity.Text = row["quantity"].ToString();//本次收货总量
                txtYdy.Text = row["yQty"].ToString();//已打印总量
                txtKdy.Text = row["kQty"].ToString(); //可打印总量
            }
        }
        /// <summary>
        /// 分页事件
@@ -87,7 +102,7 @@
        /// <param name="pageSize"></param>
        private void PageBar1_PagerEvent(int curPage, int pageSize)
        {
            getPageList(curPage, pageSize);
            getPageList(curPage);
        }
        /// <summary>
        /// 查询事件
@@ -96,7 +111,10 @@
        /// <param name="e"></param>
        private void ToolBarMenu1_btnQueryClick(object sender, EventArgs e)
        {
            Gs.DevApp.UserControl.ShowFilter frm = new Gs.DevApp.UserControl.ShowFilter(gridView1.Columns, _filterList);
            gridView1.ColumnFilterChanged -= GridView1_ColumnFilterChanged;
            gridView1.ActiveFilter.Clear();
            gridView1.ColumnFilterChanged += GridView1_ColumnFilterChanged;
              var frm = new ShowFilter(gridView1.Columns, _filterList, this.GetType().FullName);
            frm.UpdateParent += Frm_UpdateParent;
            frm.ShowDialog();
        }
@@ -108,56 +126,7 @@
        private void Frm_UpdateParent(object sender, UpdateParentEventArgs e)
        {
            _filterList = e.FilterList;
            getPageList(1, pageBar1.RowsCount);
        }
        private void ToolBarMenu1_btnDesignClick(object sender, EventArgs e)
        {
            toolBarMenu1.guidKey = "";
            string rowGuid, rowName;
            (rowGuid, rowName) = UtilityHelper.GetCurrentRow(xtraTabControl1,
                lbGuid, txt_billNo, gridView1);
            toolBarMenu1.guidKey = rowGuid;
            toolBarMenu1.rptParameter = "rpt_Arrival{}";
        }
        private void ToolBarMenu1_btnReportClick(object sender, EventArgs e)
        {
            toolBarMenu1.guidKey = "";
            string rowGuid, rowName;
            (rowGuid, rowName) = UtilityHelper.GetCurrentRow(xtraTabControl1,
                lbGuid, txt_billNo, gridView1);
            toolBarMenu1.guidKey = rowGuid;
            if (xtraTabControl1.SelectedTabPageIndex == 0)
            {
                getModel(rowGuid, false, 999);
                this.toolBarMenu1.rptParameter = "return false";
                return;
            }
            if (lbMxGuid.Text.Trim().Length < 36)
            {
                Gs.DevApp.ToolBox.MsgHelper.ShowError("请选择你要打印的行!");
                this.toolBarMenu1.rptParameter = "return false";
                return;
            }
            if (string.IsNullOrEmpty(txt_iCount_1.Text.Trim()))
            {
                Gs.DevApp.ToolBox.MsgHelper.ShowError("请选择打印条码张数!");
                txt_iCount_1.Focus();
                this.toolBarMenu1.rptParameter = "return false";
                return;
            }
            if (string.IsNullOrEmpty(txt_psnQty_1.Text.Trim()))
            {
                Gs.DevApp.ToolBox.MsgHelper.ShowError("请选择打印条码数量!");
                txt_psnQty_1.Focus();
                this.toolBarMenu1.rptParameter = "return false";
                return;
            }
            this.toolBarMenu1.rptParameter = "rpt_Arrival{" + ""
                   + "," + ""
                   + "," + ""
                   + "," + txt_iCount_1.Text.Trim()
                   + "," + txt_psnQty_1.Text.Trim()
                   + "}";
            getPageList(1);
        }
        /// <summary>
@@ -167,21 +136,30 @@
        /// <param name="e"></param>
        private void ToolBarMenu1_btnLoadClick(object sender, EventArgs e)
        {
            UtilityHelper.JumpToTab(xtraTabControl1, 0);
            getPageList(1, UtilityHelper.GetPageSize());
            if (xtraTabControl1.SelectedTabPageIndex == 1)
                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);
                getPageList(this.pageBar1.CurrentPage);
            }
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="curPage">第几页</param>
        /// <param name="pageSize">每页几条</param>
        private void getPageList(int curPage, int pageSize)
        private void getPageList(int curPage)
        {
            var _sbSqlWhere = new StringBuilder();
            foreach (var itm in _filterList)
                _sbSqlWhere.Append(" and " + itm.fileId + itm.fileOper + "'" +
                                   itm.fileValue + "'");
            var pgq = new PageQueryModel(curPage, pageSize, "create_date",
            var _sbSqlWhere = UtilityHelper.GetSearchWhere(_filterList);
            var pgq = new PageQueryModel(curPage, this.pageBar1.RowsCount, "create_date",
                "asc", "", _sbSqlWhere.ToString());
            var json = JsonConvert.SerializeObject(pgq);
            try
@@ -189,30 +167,45 @@
                var strReturn = UtilityHelper.HttpPost("",
                    _webServiceName + "GetListPage", json);
                var dd = UtilityHelper.ReturnToTablePage(strReturn);
                var dt = dd.rtnData.list;
                gcMain.BindingContext = new BindingContext();
                gcMain.DataSource = dt;
                gcMain.ForceInitialize();
                var dddd = dd.rtnData.pages; //总页
                pageBar1.TotalPages = dddd;
                pageBar1.RecordCount = dd.rtnData.total; //记录总数
                pageBar1.CurrentPage = curPage; //当前页
                pageBar1.RowsCount = pageSize; //每页显示
                pageBar1.setTxt();
                if (dd.rtnCode > 0)
                {
                    DataTable dt = dd.rtnData.list;
                    gcMain1.BindingContext = new BindingContext();
                    gridView1.ColumnFilterChanged -= GridView1_ColumnFilterChanged;
                    if (dt.Rows.Count > 0)
                    {
                        gcMain1.DataSource = dt;
                        gcMain1.ForceInitialize();
                        gridView1.BestFitColumns(); Gs.DevApp.ToolBox.UtilityHelper.SetGridLayout(gridView1);
                    }
                    else
                        UtilityHelper.SetDefaultTable(gcMain1, gridView1);
                    gridView1.ColumnFilterChanged += GridView1_ColumnFilterChanged;
                    pageBar1.TotalPages = dd.rtnData.pages;//总页
                    pageBar1.CurrentPage = curPage;//当前页
                    pageBar1.RecordCount = dd.rtnData.total;//总记录数
                }
                else
                {
                    ToolBox.MsgHelper.ShowError("提示:" + dd.rtnMsg);
                }
            }
            catch (Exception ex)
            {
                MsgHelper.Warning("提示:" + ex.Message);
            }
        }
        private void getModel(string strGuid, bool isEdit, int tabIdx)
        private void getModel(string strGuid)
        {
            gcMx1.DataSource = null;
            bool isEdit = false;
            if (toolBarMenu1.currentAction == "add") return;
            if (toolBarMenu1.currentAction == "edit") isEdit = true;
            if (string.IsNullOrEmpty(strGuid))
            {
                ToolBox.MsgHelper.Warning("请先选择你要操作的行!");
                return;
            }
            UtilityHelper.JumpToTab(xtraTabControl1, tabIdx);
            var _obj = new
            {
                guid = strGuid,//主建
@@ -227,39 +220,45 @@
                    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);
                    gvList.Add(gvMx2);
                    UtilityHelper.SetValueByObj(this.layoutMx1.Controls, dy, isEdit, gvList);
                    JArray array1 = new JArray();
                    foreach (var a in dy["list1"])
                    {
                        array1.Add(a);
                    }
                    DataTable dt1 = JsonConvert.DeserializeObject<DataTable>(array1.ToString());
                    if (dt1.Rows.Count > 0)
                    {
                        gcMx1.BindingContext = new BindingContext();
                        gcMx1.DataSource = dt1;
                        gcMx1.ForceInitialize();
                        gvMx1.BestFitColumns();
                        Gs.DevApp.ToolBox.UtilityHelper.SetGridLayout(gvMx1);
                    }
                    else
                    {
                        Gs.DevApp.ToolBox.UtilityHelper.SetDefaultTable(gcMx1, gvMx1);
                    }
                    //foreach (var a in _job["rtnData"]["list3"])
                    //{
                    //    list3.Add(a);
                    //}
                    //DataTable dt1 = JsonConvert.DeserializeObject<DataTable>(list3.ToString());
                    //if (dt1.Rows.Count > 0)
                    //{
                    //    gcMx2.BindingContext = new BindingContext();
                    //    gcMx2.DataSource = dt1;
                    //    gcMx2.ForceInitialize();
                    //}
                    //else
                    //{
                    //    Gs.DevApp.ToolBox.UtilityHelper.SetDefaultTable(gcMx2, gvMx2);
                    //}
                    JArray array2 = new JArray();
                    foreach (var a in dy["list2"])
                    {
                        array2.Add(a);
                    }
                    DataTable dt2 = JsonConvert.DeserializeObject<DataTable>(array2.ToString());
                    if (dt2.Rows.Count > 0)
                    {
                        gcMx2.BindingContext = new BindingContext();
                        gcMx2.DataSource = dt2;
                        gcMx2.ForceInitialize();
                        gvMx2.BestFitColumns();
                        Gs.DevApp.ToolBox.UtilityHelper.SetGridLayout(gvMx2);
                    }
                    else
                    {
                        Gs.DevApp.ToolBox.UtilityHelper.SetDefaultTable(gcMx2, gvMx2);
                    }
                }
                else
                    ToolBox.MsgHelper.Warning("提示:" + _rtn.rtnMsg);
@@ -269,5 +268,40 @@
                ToolBox.MsgHelper.Warning("提示:" + ex.Message);
            }
        }
        private void repositoryItemButtonEdit1_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        {
            var rowhandle = gvMx2.FocusedRowHandle;
            if (rowhandle < 0)
                return;
            if (e.Button.Index == 0)
            {
                var dr = gvMx2.GetDataRow(rowhandle);
                var mxGuid = dr["guid"].ToString();
                if (!MsgHelper.AskQuestion("你选择了1条数据,确定删除吗?"))
                    return;
                var _obj = new
                {
                    mxGuid = mxGuid,
                    inType = "dhtm"
                };
                try
                {
                    var strJson = UtilityHelper.HttpPost("",
                        _webServiceName + "DeleteBarcode",
                        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);
                }
            }
        }
    }
}