lu
2024-10-25 4bc7030c4cea5b3deed0c938ec388ae94e33c51c
DevApp/Gs.DevApp/DevFrm/Warehouse/Frm_MesInvItemArn.cs
@@ -1,7 +1,9 @@
using DevExpress.XtraGrid.Views.Base.ViewInfo;
using DevExpress.XtraGrid.Views.Grid;
using DevExpress.XtraGrid.Views.Grid.ViewInfo;
using Gs.DevApp.Entity;
using Gs.DevApp.ToolBox;
using MES.Service.Modes;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
@@ -26,6 +28,8 @@
            this.toolBarMenu1.btnDelClick += ToolBarMenu1_btnDelClick1;
            this.toolBarMenu1.btnEscClick += ToolBarMenu1_btnEscClick;
            this.toolBarMenu1.btnQueryClick += ToolBarMenu1_btnQueryClick;
            this.toolBarMenu1.btnJianYanClick += ToolBarMenu1_btnJianYanClick;
            this.toolBarMenu1.btnFjianYanClick += ToolBarMenu1_btnFjianYanClick;
            gcMain.MouseDoubleClick += GcMain_MouseDoubleClick;
            getPageList(1, UtilityHelper.GetPageSize());
            pageBar1.PagerEvent += PageBar1_PagerEvent;
@@ -46,19 +50,62 @@
            ucLookSupplier1.EditChanged += (s, e) =>
            {
                var ddd = this.ucLookSupplier1.GetValue();
                lbSupplierName.Text = ddd[1];
              //  lbSupplierName.Text = ddd[1];
            };
            btnSelect.Click += (s, e) =>
            {
                Gs.DevApp.UserControl.SelectCgMx frm = new UserControl.SelectCgMx();
                frm.UpdateParent += (ss, ee) =>
                {
                    List<string> _StringList = new List<string>();
                    _StringList = ee.StringList;
                    MessageBox.Show(_StringList.Count.ToString());
                    List<string> lst = new List<string>();
                    lst = ee.StringList;
                    var _obj = lst;
                    string strReturn = UtilityHelper.HttpPost("", "MesInvItemArnDetailManager/GetListPageByCgmxGuid", JsonConvert.SerializeObject(_obj));
                    ReturnModel<DataTable> dt = UtilityHelper.ReturnToList(strReturn);
                    gcMx1.BindingContext = new BindingContext();
                    gcMx1.DataSource = dt.rtnData;
                    gcMx1.ForceInitialize();
                };
                frm.ShowDialog();
            };
            ucLookCk1.EditChanged += (s, e) =>
            {
                var ddd = this.ucLookCk1.GetValue();
                //lbCkName.Text = ddd[1];
            };
        }
        private void ToolBarMenu1_btnFjianYanClick1(object sender, EventArgs e)
        {
            throw new NotImplementedException();
        }
        /// <summary>
        /// 反检验
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <exception cref="NotImplementedException"></exception>
        private void ToolBarMenu1_btnFjianYanClick(object sender, EventArgs e)
        {
            this.toolBarMenu1.guidKey = "";
            string rowGuid, rowName;
            (rowGuid, rowName) = UtilityHelper.GetCurrentRow(xtraTabControl1, lbGuid, txt_billNo, gridView1);
            this.toolBarMenu1.guidKey = rowGuid;
        }
        /// <summary>
        /// 检验
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <exception cref="NotImplementedException"></exception>
        private void ToolBarMenu1_btnJianYanClick(object sender, EventArgs e)
        {
            this.toolBarMenu1.guidKey = "";
            string rowGuid, rowName;
            (rowGuid, rowName) = UtilityHelper.GetCurrentRow(xtraTabControl1, lbGuid, txt_billNo, gridView1);
            this.toolBarMenu1.guidKey = rowGuid;
        }
        /// <summary>
@@ -121,7 +168,7 @@
        private void ToolBarMenu1_btnDelClick1(object sender, EventArgs e)
        {
            string rowGuid = "", rowName = "";
            // (rowGuid, rowName) = UtilityHelper.GetCurrentRow(xtraTabControl1, lbGuid, txt_billNo, gridView1);
            (rowGuid, rowName) = UtilityHelper.GetCurrentRow(xtraTabControl1, lbGuid, txt_billNo, gridView1);
            if (string.IsNullOrEmpty(rowGuid))
            {
                ToolBox.MsgHelper.Warning("请先选择你要操作的行!");
@@ -167,7 +214,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_billNo, gridView1);
            if (string.IsNullOrEmpty(rowGuid))
            {
                ToolBox.MsgHelper.Warning("请先选择你要操作的行!");
@@ -197,17 +244,56 @@
        private void ToolBarMenu1_btnSaveClick(object sender, EventArgs e)
        {
            toolBarMenu1.isSetBtn = false;
            //if (string.IsNullOrEmpty(txt_account.Text.Trim()))
            string _ckCode = ucLookCk1.GetValue()[2];//仓库编号 depots_code
            string _gysCode = ucLookSupplier1.GetValue()[2];//供应商编号
            if (string.IsNullOrEmpty(_ckCode))
            {
                Gs.DevApp.ToolBox.MsgHelper.Warning("登录账号不能为空!");
                // txt_account.Focus();
                Gs.DevApp.ToolBox.MsgHelper.Warning("请选择仓库!");
                ucLookCk1.Focus();
                return;
            }
            var _obj = new
            if (string.IsNullOrEmpty(_gysCode))
            {
                guid = lbGuid.Text.Trim(),//主建
            };
                Gs.DevApp.ToolBox.MsgHelper.Warning("请选择供应商!");
                ucLookSupplier1.Focus();
                return;
            }
            if (string.IsNullOrEmpty(txt_paperBillNo.Text.Trim()))
            {
                Gs.DevApp.ToolBox.MsgHelper.Warning("请选择送货单号!");
                txt_paperBillNo.Focus();
                return;
            }
            MesInvItemArn _obj = new MesInvItemArn();
            _obj.Guid = null;//到货单主键
            _obj.PaperBillNo = txt_paperBillNo.Text.Trim();//送货单号;
            _obj.Remark = "";//备注
            _obj.SuppNo = _gysCode;//供应商编号
            _obj.DepotsCode = _ckCode;//仓库编号 depots_code
            _obj.FType = 1; //0=采购,1=委外
            _obj.list = new List<MesInvItemArnDetail>();
            gvMx1.CloseEditor();
            gvMx1.UpdateCurrentRow();
            for (int i = 0; i < gvMx1.DataRowCount; i++)
            {
                DataRow row = gvMx1.GetDataRow(i);
                if (row != null)
                {
                    Guid? _guid = null;
                    if (string.IsNullOrEmpty(row["guid"].ToString()))
                        _guid = null;
                    else
                        _guid = Guid.Parse(row["guid"].ToString());
                    _obj.list.Add(new MesInvItemArnDetail
                    {
                        Guid = _guid,
                        AboutGuid = Guid.Parse(row["aboutGuid"].ToString()),
                        ItemNo = row["itemNo"].ToString(),
                        //ItemId= int.Parse( row["itemId"].ToString()),
                        Quantity = decimal.Parse(row["quantity"].ToString()),
                    });
                }
            }
            try
            {
                string strJson = UtilityHelper.HttpPost("", _webServiceName + "EditModel", JsonConvert.SerializeObject(_obj));
@@ -309,5 +395,36 @@
                ToolBox.MsgHelper.Warning("提示:" + ex.Message);
            }
        }
        private void repositoryItemButtonEdit1_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        {
            int rowhandle = gvMx1.FocusedRowHandle;
            if (rowhandle < 0)
                return;
            if (e.Button.Index == 0)
            {
                DataRow dr = gvMx1.GetDataRow(rowhandle);
                string mxGuid = dr["guid"].ToString();
                if (!MsgHelper.AskQuestion("你选择了1条数据,确定删除吗?"))
                    return;
                string strJson = "";
                List<string> lst = new List<string>();
                lst.Add(mxGuid);
                try
                {
                    strJson = UtilityHelper.HttpPost("", _webServiceName + "DeleteModelMx", JsonConvert.SerializeObject(lst));
                    ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.ReturnToDynamic(strJson);
                    if (_rtn.rtnCode > 0)
                    {
                        getModel(lbGuid.Text, true, 1);
                    }
                    ToolBox.MsgHelper.Warning("提示:" + _rtn.rtnMsg);
                }
                catch (Exception ex)
                {
                    ToolBox.MsgHelper.Warning("提示:" + ex.Message);
                }
            }
        }
    }
}