diff --git a/Gatedge.ScanCode.Basis.PlugIn/Bill/BAR_BarCodePrint/FormPlugIn/BarCodePrintEditRewrite.cs b/Gatedge.ScanCode.Basis.PlugIn/Bill/BAR_BarCodePrint/FormPlugIn/BarCodePrintEditRewrite.cs deleted file mode 100644 index 99a9782..0000000 --- a/Gatedge.ScanCode.Basis.PlugIn/Bill/BAR_BarCodePrint/FormPlugIn/BarCodePrintEditRewrite.cs +++ /dev/null @@ -1,6871 +0,0 @@ -using Kingdee.BOS; -using Kingdee.BOS.App; -using Kingdee.BOS.App.Data; -using Kingdee.BOS.Contracts; -using Kingdee.BOS.Core; -using Kingdee.BOS.Core.Bill; -using Kingdee.BOS.Core.Bill.PlugIn; -using Kingdee.BOS.Core.Bill.PlugIn.Args; -using Kingdee.BOS.Core.CommonFilter; -using Kingdee.BOS.Core.DynamicForm; -using Kingdee.BOS.Core.DynamicForm.PlugIn.Args; -using Kingdee.BOS.Core.DynamicForm.PlugIn.ControlModel; -using Kingdee.BOS.Core.Enums; -using Kingdee.BOS.Core.Interaction; -using Kingdee.BOS.Core.List; -using Kingdee.BOS.Core.Metadata; -using Kingdee.BOS.Core.Metadata.EntityElement; -using Kingdee.BOS.Core.Metadata.FieldElement; -using Kingdee.BOS.Core.Metadata.FormElement; -using Kingdee.BOS.Core.NotePrint; -using Kingdee.BOS.Core.SqlBuilder; -using Kingdee.BOS.FileServer.Core.Object; -using Kingdee.BOS.FileServer.ProxyService; -using Kingdee.BOS.JSON; -using Kingdee.BOS.KDThread; -using Kingdee.BOS.Orm; -using Kingdee.BOS.Orm.DataEntity; -using Kingdee.BOS.Orm.Metadata.DataEntity; -using Kingdee.BOS.Resource; -using Kingdee.BOS.ServiceHelper; -using Kingdee.BOS.ServiceHelper.Report; -using Kingdee.BOS.Util; -using Kingdee.K3.BD.BarCode.App.Core; -using Kingdee.K3.BD.BarCode.App.Core.BarCodeItem; -using Kingdee.K3.BD.BarCode.Business.PlugIn; -using Kingdee.K3.BD.BarCode.Core; -using Kingdee.K3.BD.BarCode.Core.DataModel.Service; -using Kingdee.K3.BD.BarCode.ServiceHelper; -using Kingdee.K3.BD.NewCode.Core.Utils; -using Kingdee.K3.BD.ServiceHelper; -using Kingdee.K3.Core.BD; -using Kingdee.K3.Core.BD.ServiceArgs; -using Kingdee.K3.Core.SCM; -using Kingdee.K3.Core.SCM.STK; -using Kingdee.K3.SCM.App.Core.Util; -using Newtonsoft.Json.Linq; -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Linq; -using System.Net; -using System.Reflection; -using System.Text; -using System.Text.RegularExpressions; -using StockServiceHelper = Kingdee.K3.SCM.ServiceHelper.StockServiceHelper; - -namespace Gatedge.ScanCode.Basis.PlugIn.Bill.BAR_BarCodePrint.FormPlugIn -{ - [Description("条码打印重写"), HotUpdate] - public class BarCodePrintEditRewrite : AbstractBillPlugIn - { - private int totalCount = 0; - private int currentCount = 0; - private List _noteTemplates; - private string barcodeToPrint = string.Empty; - private List printDatas = new List(); - - private List newPrintDatas = new List(); - - private string printOperationType = string.Empty; - - private int currPrintIndex = -1; - - private int currPrintQty = 0; - - private string flagPrintType = string.Empty; - - private string _permissionConst = string.Empty; - - private long _sRuleId = 0L; - - private long _sBoxRuleId = 0L; - - private long _sCenterBoxRuleId = 0L; - - private long _sBigBoxRuleId = 0L; - - private long _sFieldRuleId = 0L; - - protected string _sFormId = string.Empty; - - protected Dictionary SelectRowId = new Dictionary(); - - protected int IsCheck = 0; - - protected string _sourceId = string.Empty; - - protected string _sourceEntryId = string.Empty; - - protected string _sEntityKey = string.Empty; - - private FormMetadata _billFormMetaData = null; - - private int _isFromBill = 0; - - private bool _isAutoPacking = false; - - private bool _isCustomerPolicy = false; - - private bool _isThreePacking = false; - - private bool _controlCreateNumber = false; - - private ListSelectedRowCollection listData = new ListSelectedRowCollection(); - - private int _isFromPrintList = 0; - - private string billPageId = string.Empty; - - protected BarCodeSysParamsModel barcodeSysParm = null; - - public string Msg = ""; - - private Dictionary _baseBusinessInfo = new Dictionary(); - - private Dictionary _baseDataInfo = new Dictionary(); - - private bool _ctrlBatchCreate = false; - - private List MergeID = new List(); - - private List caculateCountInfos; - - private int _progressValue = 0; - - private int _proIncrement = 100; - - private string _pPageId = string.Empty; - - private bool _isEditQty = false; - - protected string identification = "UHIK_BAR_BarCodePrint"; - - public override void OnInitialize(InitializeEventArgs e) - { - try - { - base.OnInitialize(e); - _permissionConst = "UHIK_BAR_BarCodePrint"; - if (_permissionConst != "SCP_BarCodePrint") - { - InitBillNameFilter(); - } - - if (_noteTemplates == null) - { - BarCodeSysParamsModel barCodeBillSystemParameters = BarCodeCommonServiceHelper.GetBarCodeBillSystemParameters(base.Context, base.Context.CurrentOrganizationInfo.ID, _sFormId); - if (barCodeBillSystemParameters.FTemplatePolicyType.Equals("1")) - { - _noteTemplates = BarCodeCommonServiceHelper.GetValidNoteTemplatesByBillId_Org(base.View.Context, "UHIK_BAR_BarCodePrint"); - } - else if (barCodeBillSystemParameters.FTemplatePolicyType.Equals("2")) - { - _noteTemplates = BarCodeCommonServiceHelper.GetValidNoteTemplatesByBillId_User(base.View.Context, "UHIK_BAR_BarCodePrint"); - } - - if (_noteTemplates == null || _noteTemplates.Count == 0 || barCodeBillSystemParameters.FTemplatepercon) - { - _noteTemplates = BarCodeCommonServiceHelper.GetValidNoteTemplatesByBillId(base.View.Context, "UHIK_BAR_BarCodePrint"); - if (_noteTemplates != null && barCodeBillSystemParameters.FTemplatepercon) - { - _noteTemplates = GetPrint(_noteTemplates, "UHIK_BAR_BarCodePrint"); - } - } - - barcodeSysParm = barCodeBillSystemParameters; - } - - Field field = base.View.Model.BusinessInfo.GetField("FBCLOT"); - - base.View.GetBarItem("FEntityToBill", "tbCreateBarcodeLot").Visible = field != null; - - SetComboField(); - InitCustParam(e); - } - catch (Exception ex) - { - ////UNWLogger.Error(base.Context, "BarCodePrintEdit", "OnInitialize error:" + ex.Message + ex.StackTrace, ex); - throw ex; - } - } - - public override void OnLoad(EventArgs e) - { - IsCheck = 0; - try - { - base.OnLoad(e); - if (_isFromBill == 1) - { - base.View.Model.SetValue("FBillId", _sFormId); - base.View.Model.SetValue("FBarCodeRule", _sRuleId); - } - - if (base.View.OpenParameter.Status != OperationStatus.VIEW) - { - SetDefData(); - } - - if (_isFromBill == 1) - { - ApplyReturnData(listData); - } - - string defaultPrinter = GetDefaultPrinter(); - if (!string.IsNullOrWhiteSpace(defaultPrinter)) - { - base.View.Model.SetValue("FPrintAddress", defaultPrinter); - } - - if (_isFromBill == 1) - { - BarCodeSysParamsModel barCodeBillSystemParameters = BarCodeCommonServiceHelper.GetBarCodeBillSystemParameters(base.Context, base.Context.CurrentOrganizationInfo.ID, _sFormId); - if (barCodeBillSystemParameters.FAutoCreateBarCode) - { - base.View.Model.SetValue("FBillCheckBox", true); - CreateBarCode("TBCREBARCODEROW"); - WirteBackBarcodeSign(base.View.Context); - } - } - } - catch (Exception ex) - { - //UNWLogger.Error(base.Context, "BarCodePrintEdit", "OnLoad error:" + ex.Message + ex.StackTrace, ex); - throw ex; - } - } - - public List GetPrint(List _noteTemplates, string type = "") - { - List list = new List(); - PrintTemplateSetting printTemplateSetting = PrintServiceHelper.GetPrintTemplateSetting(base.View.Context, type, base.Context.UserId); - foreach (EnumItem _noteTemplate in _noteTemplates) - { - if (printTemplateSetting.NoteTemplateEnable(_noteTemplate.EnumId)) - { - EnumItem enumItem = new EnumItem(); - enumItem.EnumId = _noteTemplate.EnumId; - enumItem.Value = _noteTemplate.EnumId; - enumItem.Caption = _noteTemplate.Caption; - list.Add(enumItem); - } - } - - return list; - } - - private void IsAutoPacking() - { - barcodeSysParm = BarCodeCommonServiceHelper.GetBarCodeBillSystemParameters(base.Context, base.Context.CurrentOrganizationInfo.ID, _sFormId); - base.View.Model.SetValue("FAutoPacking", barcodeSysParm.AutoCreatePaking); - _isAutoPacking = barcodeSysParm.AutoCreatePaking; - base.View.InvokeFieldUpdateService("FAutoPacking", 0); - base.View.Model.SetValue("FIsCustomerPolicy", barcodeSysParm.FTemplatePolicyType.Equals("3")); - _isCustomerPolicy = barcodeSysParm.FTemplatePolicyType.Equals("3"); - base.View.InvokeFieldUpdateService("FIsCustomerPolicy", 0); - if (barcodeSysParm.FTemplatePolicyType.Equals("3")) - { - base.View.Model.SetValue("FTempRadioGroup", 1); - } - - base.View.Model.SetValue("FLevelThreePacking", barcodeSysParm.FThreeLevelPacking); - _isThreePacking = barcodeSysParm.FThreeLevelPacking; - base.View.InvokeFieldUpdateService("FLevelThreePacking", 0); - base.View.Model.SetValue("FControlCreateNumber", barcodeSysParm.FControlCreateNumber); - _controlCreateNumber = barcodeSysParm.FControlCreateNumber; - base.View.InvokeFieldUpdateService("FControlCreateNumber", 0); - } - - public override void AfterBindData(EventArgs e) - { - try - { - base.AfterBindData(e); - BarCodeSysParamsModel barCodeBillSystemParameters = BarCodeCommonServiceHelper.GetBarCodeBillSystemParameters(base.Context, base.Context.CurrentOrganizationInfo.ID, _sFormId); - if (barCodeBillSystemParameters.FOpenBarPrintChainReq) - { - JSONObject jSONObject = new JSONObject(); - string typeName = "Kingdee.BOS.Core.ViewUtils,Kingdee.BOS.Core"; - Type type = Type.GetType(typeName); - MethodInfo methodInfo = ((type != null) ? type.GetMethod("FireClientCustomEvents", new Type[5] - { - typeof(IDynamicFormView), - typeof(string), - typeof(string), - typeof(int), - typeof(JSONObject) - }) : null); - if (methodInfo != null) - { - methodInfo.Invoke(null, new object[5] { base.View, "SetClientParams", "Custom.SetClientParams.SeqReqEnabled", 3000, jSONObject }); - } - } - - if (base.View.OpenParameter.Status != OperationStatus.VIEW) - { - SetDefData(); - } - - SetComboItems(); - ControlTempRadio(); - if (_isFromPrintList == 1) - { - LockPrintInfo(); - } - else - { - IsAutoPacking(); - } - - Field field = base.View.Model.BusinessInfo.GetField("FBCLOT"); - if (field != null) - { - base.View.GetBarItem("FEntityToBill", "tbCreateBarcodeLot").Visible = true; - } - else - { - base.View.GetBarItem("FEntityToBill", "tbCreateBarcodeLot").Visible = false; - } - - ResetIsPrint(); - } - catch (Exception ex) - { - throw ex; - } - } - - public void ResetIsPrint() - { - BarCodeSysParamsModel barCodeBillSystemParameters = BarCodeCommonServiceHelper.GetBarCodeBillSystemParameters(base.Context, base.Context.CurrentOrganizationInfo.ID, _sFormId); - if (!barCodeBillSystemParameters.IsPrintNoCanPrint) - { - Entity entity = base.View.BusinessInfo.GetEntity("FEntityToBar"); - DynamicObjectCollection entityDataObject = base.View.Model.GetEntityDataObject(entity); - for (int i = 0; i < entityDataObject.Count(); i++) - { - base.View.Model.SetValue("IsPrinted", false, i); - } - } - } - - private void ControlTempRadio() - { - string text = Model.GetValue("FTempRadioGroup").ToString(); - if (text.Equals("1")) - { - Model.SetValue("FAssistantType", null); - Model.SetValue("FAssistant", null); - base.View.GetControl("FCustomer").Enabled = true; - base.View.GetControl("FAssistantType").Enabled = false; - base.View.GetControl("FAssistant").Enabled = false; - return; - } - - if (text.Equals("2")) - { - Model.SetValue("FCustomer", null); - base.View.GetControl("FCustomer").Enabled = false; - base.View.GetControl("FAssistantType").Enabled = true; - base.View.GetControl("FAssistant").Enabled = true; - return; - } - - Model.SetValue("FAssistantType", null); - Model.SetValue("FAssistant", null); - if (!barcodeSysParm.FTemplatePolicyType.Equals("3")) - { - Model.SetValue("FCustomer", null); - } - - base.View.GetControl("FCustomer").Enabled = false; - base.View.GetControl("FAssistantType").Enabled = false; - base.View.GetControl("FAssistant").Enabled = false; - } - - private void InitBillNameFilter() - { - Field field = base.View.BusinessInfo.GetField("FBillId"); - BarCodeCommonServiceHelper.GetBarCodeBillFilter(base.Context, (BaseDataField)field); - } - - public void SetComboItems() - { - Entity entity = base.View.BusinessInfo.GetEntity("FEntityToBar"); - DynamicObjectCollection entityDataObject = base.View.Model.GetEntityDataObject(entity); - ComboFieldEditor control = base.View.GetControl("FBarCodeModelToBar"); - control.SetComboItems(_noteTemplates); - } - - private bool IsCheckPermission(Context ctx, string formId, string permissionId) - { - return false; - - } - - public override void AfterCreateNewEntryRow(CreateNewEntryEventArgs e) - { - try - { - if (e.Entity.Key.EqualsIgnoreCase("FEntityToBill")) - { - base.View.Model.SetValue("FBARCODEMODELToBill", base.View.Model.GetValue("FBarCodeModel"), e.Row); - } - - base.AfterCreateNewEntryRow(e); - } - catch (Exception ex) - { - - throw ex; - } - } - - public override void BarItemClick(BarItemClickEventArgs e) - { - try - { - switch (e.BarItemKey.ToUpperInvariant()) - { - case "TBNEW": - _isFromPrintList = 0; - _isFromBill = 0; - _sRuleId = 0L; - _sFormId = string.Empty; - _sourceId = string.Empty; - break; - case "TBCHOOSEBILL": - { - int entryRowCount = base.View.Model.GetEntryRowCount("FEntityToBill"); - if (entryRowCount > 0) - { - base.View.ShowWarnningMessage(ResManager.LoadKDString("暂不支持追加选单!", "0011019000003945", SubSystemType.BASE)); - return; - } - - if (IsCheckPermission(base.Context, _permissionConst, "5709b1a2a857e6")) - { - e.Cancel = true; - base.View.ShowWarnningMessage(ResManager.LoadKDString("没有该操作权限!", "0011019000003162", SubSystemType.BASE)); - return; - } - - if (ChooseBillCtrl(_sFormId)) - { - e.Cancel = true; - return; - } - - OpenBarCodeGetBill(); - break; - } - } - - base.BarItemClick(e); - } - catch (Exception ex) - { - throw ex; - } - } - - public override void EntryBarItemClick(BarItemClickEventArgs e) - { - try - { - switch (e.BarItemKey.ToUpperInvariant()) - { - - case "TBBATCHFILL": - BatchFill(); - break; - case "BTNSELECTEDTICK": - SelectedTick(check: true); - break; - case "BTNSELECTEDNOTICK": - SelectedTick(check: false); - break; - case "BTNBARCODESELECTTICK": - BarcodeSelectedTick(check: true); - break; - case "BTNBARCODESELECTNOTICK": - BarcodeSelectedTick(check: false); - break; - case "TBCREBARCODESUM": - case "TBCREBARCODEROW": - { - Msg = ""; - DateTime now = DateTime.Now; - base.View.Model.Save(); - e.Cancel = CreateBarCode(e.BarItemKey.ToUpperInvariant()); - WirteBackBarcodeSign(base.View.Context); - //拓展功能-添加工单号-2025-6-24 - DynamicObject billtype = base.View.Model.GetValue("FBillId") as DynamicObject; - string formid = billtype["Id"].ToString(); - - base.View.UpdateView("FEntityToBar"); - ////拓展功能--返回源单单号 - if (Msg != "") - { - double num = DateTime.Now.Subtract(now).TotalMilliseconds / 1000.0; - Msg = Msg + Environment.NewLine + ResManager.LoadKDString("生成条码总耗时:", "1867c782d18041fe", "APP_ISVPAAC2016062210550") + Convert.ToString(num) + ResManager.LoadKDString("秒", "1c66015500d04260", "APP_ISVPAAC2016062210550"); - BarCodeSysParamsModel barCodeBillSystemParameters = BarCodeCommonServiceHelper.GetBarCodeBillSystemParameters(base.Context, base.Context.CurrentOrganizationInfo.ID, _sFormId); - if (barCodeBillSystemParameters.IsTimeConsumReminder) - { - base.View.ShowWarnningMessage(Msg); - } - e.Cancel = true; - return; - } - //// TODO 同步条码主档 - //SynchronizeCodeMain(); - break; - } - case "TBDELETELIST": - base.View.Model.DeleteEntryData("FEntityToBill"); - base.View.Model.DeleteEntryData("FEntityToBar"); - if (barcodeSysParm.FTemplatePolicyType.Equals("3")) - { - base.View.Model.SetValue("FCustomer", null); - } - - break; - case "TBGETNEWDATA": - base.View.Model.DeleteEntryData("FEntityToBill"); - base.View.Model.DeleteEntryData("FEntityToBar"); - BindBillData(); - base.View.UpdateView("FEntityToBill"); - break; - case "TBPRINTBARCODE": - if (IsCheckPermission(base.Context, _permissionConst, "570756a559fbbd")) - { - e.Cancel = true; - base.View.ShowMessage(ResManager.LoadKDString("您没有打印条码权限!", "0011019000003088", SubSystemType.BASE)); - return; - } - - PrintBarCode("print"); - break; - case "TBVIEWBARCODE": - if (IsCheckPermission(base.Context, _permissionConst, "570756a559fbbd")) - { - e.Cancel = true; - base.View.ShowMessage(ResManager.LoadKDString("您没有打印条码权限!", "0011019000003088", SubSystemType.BASE)); - return; - } - - PrintBarCode("preview"); - break; - case "TBBUTTONSAVING": - { - if (IsCheckPermission(base.Context, _permissionConst, "570756a559fbbd")) - { - e.Cancel = true; - base.View.ShowMessage(ResManager.LoadKDString("您没有打印条码权限!", "0011019000003088", SubSystemType.BASE)); - return; - } - - StringBuilder stringBuilder = CheckPrint(); - if (stringBuilder.Length > 0) - { - e.Cancel = true; - base.View.ShowMessage(stringBuilder.ToString()); - return; - } - - IOperationResult operationResult = base.View.Model.Save(); - SavingPrintBarCode(); - break; - } - case "TBSPLITCOPYROW": - { - ExtendedDataEntitySet extendedDataEntitySet2 = new ExtendedDataEntitySet(); - extendedDataEntitySet2.Parse(new DynamicObject[1] { base.View.Model.DataObject }, base.View.Model.BusinessInfo); - ExtendedDataEntity[] source = (from p in extendedDataEntitySet2.FindByEntityKey("FEntityToBill") - where p.DataEntity["BillCheckBox"].ToString().EqualsIgnoreCase("True") - select p).ToArray(); - if (source.Count() < 1) - { - e.Cancel = true; - base.View.ShowWarnningMessage(ResManager.LoadKDString("请先选择源单明细行!", "0011019000003163", SubSystemType.BASE)); - return; - } - - if (source.Count() > 1) - { - e.Cancel = true; - base.View.ShowErrMessage(ResManager.LoadKDString("仅支持选择一个源单明细行进行复制", "a7144aece14441c4", "APP_ISVPAAC2016062210550")); - return; - } - - OpenBarcodePrintSplitCopyRowEdit(source.FirstOrDefault()); - break; - } - case "COPYROW": - { - int[] selectedRows = base.View.GetControl("FEntityToBill").GetSelectedRows(); - selectedRows = selectedRows.OrderBy((int x) => x).ToArray(); - if (selectedRows.Count() < 1) - { - e.Cancel = true; - base.View.ShowWarnningMessage(ResManager.LoadKDString("请先选择需要复制的源单明细行!", "0011019000003163", SubSystemType.BASE)); - return; - } - - int rowIndex = 0; - int count = base.View.Model.GetEntryRowCount("FEntityToBill"); - Util.ForEach((IEnumerable)selectedRows, (Action)delegate (int X) - { - AssociatedCopyRowUtil.CopyRow(base.View, "FEntityToBill", Convert.ToInt32(X), count + rowIndex, false, (OperationParmListParameter)null, true, (List)null); - rowIndex++; - }); - break; - } - case "TBCREATEBARCODELOT": - { - Field field = base.View.BusinessInfo.GetField("FBCLOT"); - int entryRowCount = base.View.Model.GetEntryRowCount("FEntityToBill"); - if (field == null || entryRowCount <= 0) - { - e.Cancel = true; - return; - } - - string strSQL = "SELECT ISNULL(MAX(FBCLOT),0)+1 as NEWBCLOT FROM T_UN_BARCODELOT;"; - DynamicObject dynamicObject = DBUtils.ExecuteDynamicObject(base.Context, strSQL, null, null, CommandType.Text).FirstOrDefault(); - string text = Convert.ToString(dynamicObject["NEWBCLOT"]).PadLeft(6, '0'); - for (int j = 0; j < entryRowCount; j++) - { - base.View.Model.SetValue(field.Key, text, j); - } - - string strSQL2 = ((text == "000001") ? string.Format("INSERT INTO T_UN_BARCODELOT(FBCLOT,FLASTUPDATETIME,FLASTUSERID) VALUES(1,{0},{1});", (base.Context.DatabaseType == DatabaseType.MS_SQL_Server) ? "getdate()" : "sysdate", base.Context.UserId) : string.Format("UPDATE T_UN_BARCODELOT SET FBCLOT=FBCLOT+1,FLASTUPDATETIME={0},FLASTUSERID={1};", (base.Context.DatabaseType == DatabaseType.MS_SQL_Server) ? "getdate()" : "sysdate", base.Context.UserId)); - DBUtils.Execute(base.Context, strSQL2); - break; - } - case "TBBARCODEPACKING": - { - long defaultPackageRule = BarCodeCommonServiceHelper.GetDefaultPackageRule(base.Context); - if (defaultPackageRule > 0) - { - ExtendedDataEntitySet extendedDataEntitySet = new ExtendedDataEntitySet(); - extendedDataEntitySet.Parse(new DynamicObject[1] { base.View.Model.DataObject }, base.View.Model.BusinessInfo); - ExtendedDataEntity[] array = (from p in extendedDataEntitySet.FindByEntityKey("FEntityToBar") - where p.DataEntity["BarCodeCheck"].ToString().EqualsIgnoreCase("True") - select p).ToArray(); - if (array.Count() < 1) - { - base.View.ShowWarnningMessage(ResManager.LoadKDString("请先选择需要装箱的条码", "630d107d728e4b6a", "APP_ISVPAAC2016062210550")); - e.Cancel = true; - return; - } - - List list = new List(); - ExtendedDataEntity[] array2 = array; - for (int i = 0; i < array2.Length; i++) - { - ExtendedDataEntity extendedDataEntity = array2[i]; - list.Add(extendedDataEntity.DataEntity); - } - - BarcodePacking(defaultPackageRule, list.ToArray()); - break; - } - - base.View.ShowWarnningMessage(ResManager.LoadKDString("没有设置默认的包装条码规则!", "06558d54344e4daa", "APP_ISVPAAC2016062210550")); - e.Cancel = true; - return; - } - case "TBSYNCHRONIZE": - { - // 同步条码主档 - SynchronizeCodeMain(); - return; - } - } - - base.EntryBarItemClick(e); - } - catch (Exception ex) - { - //UNWLogger.Error(base.Context, "BarCodePrintEdit", "BarItemClick error:" + ex.Message + ex.StackTrace, ex); - throw ex; - } - } - - private StringBuilder CheckPrint() - { - DynamicObjectCollection source = base.View.Model.DataObject["BD_BARCODEPRINTENTRYBAR"] as DynamicObjectCollection; - DynamicObject[] source2 = source.Where((DynamicObject p) => p["BarCodeCheck"].ToString().EqualsIgnoreCase("True")).ToArray(); - StringBuilder text = new StringBuilder(); - if (source2.Count() > 0) - { - Util.ForEach(source2.Where((DynamicObject p) => KUtil.Get(p, "PrintNumber") == 0m), (Action)delegate (DynamicObject p, int r) - { - text.AppendFormat(ResManager.LoadKDString("第【{0}】行 ,打印数不能为空!", "b1158e1effdf4a84", "APP_ISVPAAC2016062210550"), r + 1).AppendLine(); - }); - } - else - { - text.AppendFormat(ResManager.LoadKDString("请选择要打印的行!", "334a1b226b0243e1", "APP_ISVPAAC2016062210550")); - } - - return text; - } - - private void BatchFill() - { - string entryCurrentFieldKey = Model.GetEntryCurrentFieldKey("FEntityToBill"); - if (entryCurrentFieldKey.ToUpper() == "FBARCODEFIELDRULETOBILL") - { - int entryCurrentRowIndex = Model.GetEntryCurrentRowIndex("FEntityToBill"); - ExtendedDataEntitySet extendedDataEntitySet = new ExtendedDataEntitySet(); - extendedDataEntitySet.Parse(new DynamicObject[1] { base.View.Model.DataObject }, base.View.Model.BusinessInfo); - ExtendedDataEntity[] array = extendedDataEntitySet.FindByEntityKey("FEntityToBill").ToArray(); - DynamicObject dataEntity = array[entryCurrentRowIndex].DataEntity; - DynamicObject dynamicObject = dataEntity["BARCODEFIELDRULE"] as DynamicObject; - int num = 0; - if (dynamicObject != null) - { - num = Convert.ToInt32(dynamicObject["Id"]); - } - - int num2 = array.Count(); - for (int i = 0; i < num2; i++) - { - DynamicObject dataEntity2 = array[i].DataEntity; - dataEntity2["BARCODEFIELDRULE"] = dynamicObject; - dataEntity2["BARCODEFIELDRULE_Id"] = Convert.ToString(num); - } - - base.View.UpdateView("FEntityToBill"); - } - } - - private void BarcodePacking(long packCodeRuleId, DynamicObject[] detailCodes) - { - //IL_005d: Unknown result type (might be due to invalid IL or missing references) - //IL_0063: Expected O, but got Unknown - //IL_015b: Unknown result type (might be due to invalid IL or missing references) - //IL_0162: Expected O, but got Unknown - DynamicObjectType dynamicObjectType = base.View.BusinessInfo.GetEntryEntity("FEntityToBill").DynamicObjectType; - DynamicObject dynamicObject = new DynamicObject(dynamicObjectType); - dynamicObject["CreateNumber"] = 1; - dynamicObject["BARCODERULE_Id"] = packCodeRuleId; - ExtendedDataEntity[] sourceArray = new ExtendedDataEntity[1] - { - new ExtendedDataEntity(dynamicObject, 0, 0) - }; - BarCodeCreateResult val = new BarCodeCreateResult(); - ExtendedDataEntity[] array = new ExtendedDataEntity[1]; - Array.ConstrainedCopy(sourceArray, 0, array, 0, 1); - val = BarCodeCreateServiceHelper.BarCodeCreateByRule(base.Context, base.View.BusinessInfo, packCodeRuleId, array); - string text = ""; - if (val.AllDataRight) - { - Dictionary> value = val.BoxContrastNumbers[0].Value; - foreach (KeyValuePair> item4 in value) - { - List value2 = item4.Value; - List list = (from p in item4.Value.Distinct() - where !p.IsNullOrEmptyOrWhiteSpace() - select p).ToList(); - text = list[0].ToString(); - } - } - - if (!text.IsNullOrEmptyOrWhiteSpace()) - { - List list2 = new List(); - BarCodeBoxUpArgs val2 = new BarCodeBoxUpArgs(); - val2.OperationType = 0L; - val2.PackageBarCode = text; - foreach (DynamicObject dynamicObject2 in detailCodes) - { - string item = Convert.ToString(dynamicObject2["BarCode"]); - decimal item2 = Convert.ToDecimal(Convert.ToString(dynamicObject2["QtyToBar"])); - string item3 = ""; - val2.ListChilds.Add(item); - val2.ListChildsQty.Add(item2); - val2.ListChildsRemark.Add(item3); - } - - string[] array2 = DBServiceHelper.CreateTemporaryTableName(base.Context, 3); - string createSql = string.Format("IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = '{0}' ) \r\n CREATE TABLE {0}\r\n (\r\n FPACKAGING NVARCHAR(255) NOT NULL DEFAULT ' '\r\n );", array2[0]); - string createSql2 = string.Format("IF NOT EXISTS(SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = '{0}')\r\n CREATE TABLE {0}\r\n (\r\n\t FID INT NOT NULL DEFAULT(0),\r\n FENTRYID INT NOT NULL DEFAULT(0),\r\n\t FBARCODE NVARCHAR(255) NOT NULL DEFAULT ' '\r\n );", array2[1]); - DataTable dataTable = new DataTable(); - dataTable.TableName = array2[0]; - dataTable.Columns.Add("FPACKAGING", typeof(string)); - dataTable.BeginLoadData(); - DataTable dataTable2 = new DataTable(); - dataTable2.TableName = array2[1]; - dataTable2.Columns.Add("FID", typeof(int)); - dataTable2.Columns.Add("FENTRYID", typeof(int)); - dataTable2.Columns.Add("FBARCODE", typeof(string)); - dataTable2.BeginLoadData(); - List list3 = new List { dataTable, dataTable2 }; - StringBuilder stringBuilder = new StringBuilder(); - stringBuilder = BarCodePackingServiceHelper.GetPackInfoSQL(base.Context, new List { val2 }, ref list2, ref list3); - list3[0].EndLoadData(); - DBServiceHelper.BulkInserts(base.Context, string.Empty, createSql, list3[0]); - list3[1].EndLoadData(); - DBServiceHelper.BulkInserts(base.Context, string.Empty, createSql2, list3[1]); - stringBuilder.AppendFormat("IF NOT EXISTS(SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = '{0}')\r\n CREATE TABLE {0}\r\n (\r\n FPACKAGING NVARCHAR(255) NOT NULL DEFAULT ' ',\r\n\t FSUMQTY DECIMAL(23,10) NOT NULL DEFAULT 0,\r\n\t FENTRYCOUNT INT NOT NULL DEFAULT 0\r\n );", array2[2]); - DBUtils.Execute(base.Context, stringBuilder.ToString()); - try - { - bool flag = BarCodePackingServiceHelper.UpdateUpPackage(base.Context, array2); - } - finally - { - DBServiceHelper.DeleteTemporaryTableName(base.Context, array2); - } - - if (list2 != null && list2.Count() > 0) - { - OpenUnPackagingForm(list2.FirstOrDefault()); - } - } - } - - private void OpenUnPackagingForm(string packagingId) - { - BillShowParameter billShowParameter = new BillShowParameter(); - billShowParameter.ParentPageId = base.View.PageId; - billShowParameter.MultiSelect = false; - billShowParameter.FormId = "UN_Packaging"; - billShowParameter.PKey = packagingId; - billShowParameter.Status = OperationStatus.EDIT; - billShowParameter.OpenStyle.ShowType = ShowType.Default; - base.View.ShowForm(billShowParameter); - } - - private void OpenBarcodePrintSplitCopyRowEdit(ExtendedDataEntity entity) - { - DynamicObject dataEntity = entity.DataEntity; - decimal num = Convert.ToDecimal(dataEntity["Qty"]); - int rowIndex = entity.RowIndex; - DynamicFormShowParameter dynamicFormShowParameter = new DynamicFormShowParameter(); - dynamicFormShowParameter.MultiSelect = false; - dynamicFormShowParameter.ParentPageId = base.View.PageId; - dynamicFormShowParameter.FormId = "BarCodePrintCopyRow"; - dynamicFormShowParameter.CustomParams.Add("srcQty", Convert.ToString(num)); - dynamicFormShowParameter.CustomParams.Add("srcIndex", rowIndex.ToString()); - base.View.ShowForm(dynamicFormShowParameter, AfterShowLock); - } - - protected void AfterShowLock(FormResult result) - { - if (result.ReturnData != null) - { - JObject val = (JObject)result.ReturnData; - string value = ((object)val["srcQty"]).ToString(); - string value2 = ((object)val["srcIndex"]).ToString(); - decimal num = Convert.ToDecimal(((object)val["newQty"]).ToString()); - decimal num2 = Convert.ToDecimal(((object)val["minPackCount"]).ToString()); - int num3 = Convert.ToInt32(((object)val["createNum"]).ToString()); - string text = Convert.ToString(val["copyLoc"]); - Entity entity = base.View.BusinessInfo.GetEntity("FEntityToBill"); - base.View.Model.SetValue("FQty", Convert.ToDecimal(value), Convert.ToInt32(value2)); - int num4 = ((!text.IsNullOrEmptyOrWhiteSpace() && text.Equals("B")) ? base.View.Model.GetEntryRowCount("FEntityToBill") : (Convert.ToInt32(value2) + 1)); - AssociatedCopyRowUtil.CopyRow(base.View, "FEntityToBill", Convert.ToInt32(value2), num4, false, (OperationParmListParameter)null, true, (List)null); - DynamicObject entityDataObject = base.View.Model.GetEntityDataObject(entity, Convert.ToInt32(value2)); - DynamicObject entityDataObject2 = base.View.Model.GetEntityDataObject(entity, num4); - entityDataObject2["LOT_Id"] = entityDataObject["LOT_Id"]; - entityDataObject2["LOT"] = entityDataObject["LOT"]; - entityDataObject2["LOT_Text"] = entityDataObject["LOT_Text"]; - IDBService service = ServiceHelper.GetService(); - service.AutoSetPrimaryKey(base.Context, new DynamicObject[1] { entityDataObject2 }, entity.DynamicObjectType); - base.View.Model.SetValue("FQty", num, num4); - base.View.Model.SetValue("FMinPackCount", 1, num4); - base.View.Model.SetValue("FCreateNumber", 1, num4); - base.View.UpdateView("FEntityToBill"); - } - } - - public void SelectedTick(bool check) - { - List list = base.View.GetControl("FEntityToBill").GetSelectedRows().ToList(); - list.ForEach(delegate (int X) - { - Model.SetValue("FBillCheckBox", check, X); - }); - } - - public void BarcodeSelectedTick(bool check) - { - List list = base.View.GetControl("FEntityToBar").GetSelectedRows().ToList(); - list.ForEach(delegate (int X) - { - Model.SetValue("FBarCodeCheck", check, X); - }); - } - - private bool CreateBarCode(string sType) - { - BarCodeSysParamsModel barcodecreatesysparam = BarCodeCommonServiceHelper.GetBarCodeBillSystemParameters(base.Context, base.Context.CurrentOrganizationInfo.ID, _sFormId); - - - if (_isAutoPacking && _sBoxRuleId == 0) - { - base.View.ShowWarnningMessage(ResManager.LoadKDString("请先录入默认包装条码规则!", "58d194b2aae944ca", "APP_ISVPAAC2016062210550")); - return true; - } - - if (_isThreePacking && _sCenterBoxRuleId == 0) - { - base.View.ShowWarnningMessage(ResManager.LoadKDString("请先录入中包装条码规则!", "2d6674718ec34edf", "APP_ISVPAAC2016062210550")); - return true; - } - - ExtendedDataEntitySet extendedDataEntitySet = new ExtendedDataEntitySet(); - extendedDataEntitySet.Parse(new DynamicObject[1] { base.View.Model.DataObject }, base.View.Model.BusinessInfo); - ExtendedDataEntity[] entitys = (from p in extendedDataEntitySet.FindByEntityKey("FEntityToBill") - where p.DataEntity["BillCheckBox"].ToString().EqualsIgnoreCase("True") - select p).ToArray(); - if (entitys.Count() < 1) - { - base.View.ShowWarnningMessage(ResManager.LoadKDString("请先选择源单明细行!", "0011019000003163", SubSystemType.BASE)); - return true; - } - - caculateCountInfos = GetCountMsg(entitys, GetCaculateCount()); - int iCount = entitys.Count(); - int num = 0; - long num2 = 0L; - _ctrlBatchCreate = false; - HashSet hashSet = new HashSet(); - List list = new List(); - for (int i = 0; i < iCount; i++) - { - CheckCreateQty(entitys[i].RowIndex, barcodecreatesysparam); - DynamicObject dataEntity = entitys[i].DataEntity; - int num3 = ((dataEntity["CreateNumber"] != null) ? Convert.ToInt32(dataEntity["CreateNumber"]) : 0); - int num4 = ((dataEntity["MaterialId_Id"] != null) ? Convert.ToInt32(dataEntity["MaterialId_Id"]) : 0); - if (dataEntity["MinPackCount"] == null || Convert.ToDecimal(dataEntity["MinPackCount"]) <= 0m) - { - base.View.ShowWarnningMessage(ResManager.LoadKDString("最小包装数不可为零!", "2b03fcaca96444e5", "APP_ISVPAAC2016062210550")); - return true; - } - - DynamicObject dynamicObject = dataEntity["BARCODERULE"] as DynamicObject; - long num5 = ((dynamicObject != null) ? Convert.ToInt64(dynamicObject["Id"]) : 0); - if (hashSet.Add(num5) || list == null || list.Count <= 0) - { - list = GetRuleBarcodeItem(num5); - } - - if (list != null && list.Count() > 0) - { - string text = string.Empty; - foreach (string item in list) - { - Field field = base.View.BusinessInfo.GetField(item); - if (field == null || !field.IsMustInput()) - { - continue; - } - - string value = Convert.ToString(dataEntity[field.PropertyName]); - if (field is LotField && value.IsNullOrEmptyOrWhiteSpace()) - { - value = Convert.ToString(dataEntity[field.PropertyName + "_Text"]); - } - - if (!value.IsNullOrEmptyOrWhiteSpace()) - { - continue; - } - - if (field.FieldName.Equals("FLOT") || field.FieldName.Equals("FPRODUCTIONDATE") || field.FieldName.Equals("FEXPIRATIONDATE")) - { - if (IsWarningByMaterial(field, num4)) - { - text = text + field.Name.ToString(base.Context.UserLocale) + ","; - } - } - else - { - text = text + field.Name.ToString(base.Context.UserLocale) + ","; - } - } - - if (!text.IsNullOrEmptyOrWhiteSpace()) - { - base.View.ShowWarnningMessage(string.Format(ResManager.LoadKDString("存在必录字段{0}为空,不允许生成条码", "cfa79f2c6ec0488e", "APP_ISVPAAC2016062210550"), text.TrimEnd(','))); - return true; - } - } - - if (i == 0) - { - num2 = num5; - } - - if (i != 0 && dynamicObject != null && Convert.ToBoolean(dynamicObject["FBatchCreateBarcode"]) && !num2.Equals(num5)) - { - base.View.ShowWarnningMessage(ResManager.LoadKDString("条码规则允许批量生成条码时,不可以使用多个规则!", "429b4cf05c444463", "APP_ISVPAAC2016062210550")); - return true; - } - - if (dynamicObject != null && Convert.ToBoolean(dynamicObject["FBatchCreateBarcode"])) - { - _ctrlBatchCreate = true; - } - - num += num3; - } - - if (num > 10000 && !_ctrlBatchCreate) - { - base.View.ShowWarnningMessage(ResManager.LoadKDString("一次性生成条码数量过多可能会造成系统错误,建议一次生成条码总数不要超过10000!", "0011019000003983", SubSystemType.BASE)); - return true; - } - - if (num > 200000 && _ctrlBatchCreate) - { - base.View.ShowWarnningMessage(ResManager.LoadKDString("一次性生成条码数量过多可能会造成系统错误,建议一次生成条码总数不要超过200000!", "6ff0e30220d441f8", "APP_ISVPAAC2016062210550")); - return true; - } - - //UNWLogger.Info(base.Context, "BarCode EntryBarItemClick", "AllowScanCreate:" + barcodecreatesysparam.AllowScanCreate + "OrgID" + base.Context.CurrentOrganizationInfo.ID + "FormID" + _sFormId); - if (!barcodecreatesysparam.AllowScanCreate.EqualsIgnoreCase("1")) - { - string text2 = string.Empty; - string empty = string.Empty; - Dictionary> dictionary = new Dictionary>(); - for (int j = 0; j < iCount; j++) - { - DynamicObject dataEntity2 = entitys[j].DataEntity; - empty = ((dataEntity2["BILLCODE"] != null) ? Convert.ToString(dataEntity2["BILLCODE"]) : string.Empty); - if (!empty.IsEmpty()) - { - string key = empty + "," + dataEntity2["BILLSEQ"]; - if (dictionary.ContainsKey(key)) - { - List list2 = dictionary[key]; - list2.Add(j + 1); - } - else - { - List list3 = new List(); - list3.Add(j + 1); - dictionary.Add(key, list3); - } - } - } - - if (dictionary.Count() > 0) - { - string text3 = string.Join("','", dictionary.Keys.Select((string p) => p.Split(',')[0]).ToArray()); - string text4 = string.Join(",", dictionary.Keys.Select((string p) => p.Split(',')[1]).ToArray()); - DynamicObjectCollection dynamicObjectCollection = BarCodePrintServiceHelper.IsRepetPrinted(base.Context, text3, text4, _sFormId); - foreach (DynamicObject item2 in dynamicObjectCollection) - { - string text5 = Convert.ToString(item2["FBILLCODE"]); - string text6 = Convert.ToString(item2["FBILLSEQ"]); - string key2 = text5 + "," + text6; - if (dictionary.ContainsKey(key2)) - { - List values = dictionary[key2]; - text2 = text2 + "," + string.Join(",", values); - } - } - } - - //UNWLogger.Info(base.Context, "BarCode EntryBarItemClick", "isCreateMsg:" + text2); - if (!text2.IsEmpty() && text2.Length > 0) - { - if (barcodecreatesysparam.AllowScanCreate.EqualsIgnoreCase("3")) - { - base.View.ShowMessage(string.Format(ResManager.LoadKDString("当前行【{0}】对应的单据和物料已经生成过条码!", "53a1b34d8ef2408f", "APP_ISVPAAC2016062210550"), text2.Substring(1))); - return true; - } - - if (barcodecreatesysparam.AllowScanCreate.EqualsIgnoreCase("2")) - { - base.View.ShowMessage(string.Format(ResManager.LoadKDString("当前行【{0}】对应的单据和物料已经生成过条码!", "53a1b34d8ef2408f", "APP_ISVPAAC2016062210550"), text2.Substring(1)), MessageBoxOptions.YesNo, delegate (MessageBoxResult result) - { - if (result == MessageBoxResult.Yes) - { - if (barcodecreatesysparam.AsyncCreateBarCode) - { - AsyncCreateBarCode(entitys, iCount, sType); - } - else - { - SyncCreateBarCode(entitys, iCount, sType); - } - } - }); - } - } - else if (barcodecreatesysparam.AsyncCreateBarCode) - { - AsyncCreateBarCode(entitys, iCount, sType); - } - else - { - SyncCreateBarCode(entitys, iCount, sType); - } - } - else if (barcodecreatesysparam.AsyncCreateBarCode) - { - AsyncCreateBarCode(entitys, iCount, sType); - } - else - { - SyncCreateBarCode(entitys, iCount, sType); - } - - - - return false; - } - - private bool IsWarningByMaterial(Field field, long materialId) - { - try - { - if (materialId > 0) - { - string strSQL = "SELECT FISBATCHMANAGE,FISKFPERIOD FROM T_BD_MATERIAL T1\r\n INNER JOIN t_BD_MaterialStock T2 ON T1.FMASTERID=T2.FMATERIALID\r\n AND T1.FMATERIALID=@materialId AND T1.FUSEORGID=@useOrgId"; - SqlParam sqlParam = new SqlParam("@materialId", KDDbType.Int64, materialId); - SqlParam sqlParam2 = new SqlParam("@useOrgId", KDDbType.Int64, base.Context.CurrentOrganizationInfo.ID); - DynamicObject dynamicObject = DBUtils.ExecuteDynamicObject(base.Context, strSQL, null, null, CommandType.Text, sqlParam, sqlParam2).FirstOrDefault(); - if (dynamicObject != null) - { - string text = Convert.ToString(dynamicObject["FISBATCHMANAGE"]); - string text2 = Convert.ToString(dynamicObject["FISKFPERIOD"]); - if (text.Equals("1") && field is LotField && field.FieldName.Equals("FLOT")) - { - return true; - } - - if (text2.Equals("1") && field is DateTimeField && (field.FieldName.Equals("FPRODUCTIONDATE") || field.FieldName.Equals("FEXPIRATIONDATE"))) - { - return true; - } - } - } - } - catch (Exception ex) - { - throw new Exception(ex.Message); - } - - return false; - } - - private int GetCaculateCount() - { - BarCodeSysParamsModel barCodeBillSystemParameters = BarCodeCommonServiceHelper.GetBarCodeBillSystemParameters(base.Context, base.Context.CurrentOrganizationInfo.ID, ""); - int result = 0; - if (barCodeBillSystemParameters.FCaculateCount == "2") - { - if (barCodeBillSystemParameters.AutoCreatePaking) - { - result = 2; - } - - if (barCodeBillSystemParameters.FThreeLevelPacking) - { - result = 3; - } - - if (!barCodeBillSystemParameters.AutoCreatePaking && !barCodeBillSystemParameters.FThreeLevelPacking) - { - result = 1; - } - } - - if (barCodeBillSystemParameters.FCaculateCount == "3") - { - if (barCodeBillSystemParameters.AutoCreatePaking) - { - result = 5; - } - - if (barCodeBillSystemParameters.FThreeLevelPacking) - { - result = 6; - } - - if (!barCodeBillSystemParameters.AutoCreatePaking && !barCodeBillSystemParameters.FThreeLevelPacking) - { - result = 4; - } - } - - return result; - } - - private List GetCountMsg(ExtendedDataEntity[] entitys, int count) - { - List list = new List(); - int num = entitys.Count(); - if (count == 1) - { - for (int i = 0; i < num; i++) - { - bool flag = false; - CaculateCountInfo caculateCountInfo = new CaculateCountInfo(); - caculateCountInfo.bigRule = "0"; - caculateCountInfo.midRule = "0"; - caculateCountInfo.materialId = 0; - caculateCountInfo.index = 0; - caculateCountInfo.caculateCount = 0; - DynamicObject dataEntity = entitys[i].DataEntity; - int num2 = ((dataEntity["CreateNumber"] != null) ? Convert.ToInt32(dataEntity["CreateNumber"]) : 0); - int MaterialId3 = ((dataEntity["MaterialId_Id"] != null) ? Convert.ToInt32(dataEntity["MaterialId_Id"]) : 0); - if (!(MaterialId3.ToString() != "0")) - { - continue; - } - - if (list.Where((CaculateCountInfo u) => u.materialId == MaterialId3).Count() > 0) - { - caculateCountInfo = list.Where((CaculateCountInfo u) => u.materialId == MaterialId3).FirstOrDefault(); - flag = true; - } - - caculateCountInfo.materialId = MaterialId3; - caculateCountInfo.caculateCount += num2; - if (!flag) - { - list.Add(caculateCountInfo); - } - } - } - - if (count == 4) - { - CaculateCountInfo caculateCountInfo2 = new CaculateCountInfo(); - caculateCountInfo2.bigRule = "0"; - caculateCountInfo2.midRule = "0"; - caculateCountInfo2.materialId = 0; - caculateCountInfo2.index = 0; - for (int j = 0; j < num; j++) - { - DynamicObject dataEntity2 = entitys[j].DataEntity; - int num3 = ((dataEntity2["CreateNumber"] != null) ? Convert.ToInt32(dataEntity2["CreateNumber"]) : 0); - caculateCountInfo2.caculateCount += num3; - } - - list.Add(caculateCountInfo2); - } - - if (count == 2) - { - for (int k = 0; k < num; k++) - { - bool flag2 = false; - CaculateCountInfo caculateCountInfo3 = new CaculateCountInfo(); - caculateCountInfo3.bigRule = "0"; - caculateCountInfo3.midRule = "0"; - caculateCountInfo3.barcodeboxrule = 0; - caculateCountInfo3.materialId = 0; - caculateCountInfo3.index = 0; - caculateCountInfo3.caculateCount = 0; - DynamicObject dataEntity3 = entitys[k].DataEntity; - int num4 = ((dataEntity3["CreateBoxNumber"] != null) ? Convert.ToInt32(dataEntity3["CreateBoxNumber"]) : 0); - int MaterialId2 = ((dataEntity3["MaterialId_Id"] != null) ? Convert.ToInt32(dataEntity3["MaterialId_Id"]) : 0); - int barcodeboxrule2 = ((dataEntity3["BARCODEBOXRULE_Id"] != null) ? Convert.ToInt32(dataEntity3["BARCODEBOXRULE_Id"]) : 0); - if (list.Where((CaculateCountInfo u) => u.materialId == MaterialId2 && u.barcodeboxrule == barcodeboxrule2).Count() > 0) - { - caculateCountInfo3 = list.Where((CaculateCountInfo u) => u.materialId == MaterialId2 && u.barcodeboxrule == barcodeboxrule2).FirstOrDefault(); - flag2 = true; - } - - caculateCountInfo3.materialId = MaterialId2; - caculateCountInfo3.caculateCount += num4; - caculateCountInfo3.barcodeboxrule = barcodeboxrule2; - if (!flag2) - { - list.Add(caculateCountInfo3); - } - } - } - - if (count == 5) - { - CaculateCountInfo caculateCountInfo4 = new CaculateCountInfo(); - bool flag3 = false; - caculateCountInfo4.bigRule = "0"; - caculateCountInfo4.midRule = "0"; - caculateCountInfo4.barcodeboxrule = 0; - caculateCountInfo4.materialId = 0; - caculateCountInfo4.index = 0; - caculateCountInfo4.caculateCount = 0; - for (int l = 0; l < num; l++) - { - DynamicObject dataEntity4 = entitys[l].DataEntity; - int num5 = ((dataEntity4["CreateBoxNumber"] != null) ? Convert.ToInt32(dataEntity4["CreateBoxNumber"]) : 0); - int barcodeboxrule = ((dataEntity4["BARCODEBOXRULE_Id"] != null) ? Convert.ToInt32(dataEntity4["BARCODEBOXRULE_Id"]) : 0); - if (list.Where((CaculateCountInfo u) => u.barcodeboxrule == barcodeboxrule).Count() > 0) - { - caculateCountInfo4 = list.Where((CaculateCountInfo u) => u.barcodeboxrule == barcodeboxrule).FirstOrDefault(); - flag3 = true; - } - - caculateCountInfo4.caculateCount += num5; - caculateCountInfo4.barcodeboxrule = barcodeboxrule; - if (!flag3) - { - list.Add(caculateCountInfo4); - } - } - } - - if (count == 3) - { - for (int m = 0; m < num; m++) - { - bool flag4 = false; - CaculateCountInfo caculateCountInfo5 = new CaculateCountInfo(); - caculateCountInfo5.bigRule = "0"; - caculateCountInfo5.midRule = "0"; - caculateCountInfo5.barcodeboxrule = 0; - caculateCountInfo5.materialId = 0; - caculateCountInfo5.index = 0; - caculateCountInfo5.caculateCount = 0; - DynamicObject dataEntity5 = entitys[m].DataEntity; - int num6 = ((dataEntity5["FCenterCreateNumber"] != null) ? Convert.ToInt32(dataEntity5["FCenterCreateNumber"]) : 0); - int num7 = ((dataEntity5["FBigCreateNumber"] != null) ? Convert.ToInt32(dataEntity5["FBigCreateNumber"]) : 0); - int MaterialId = ((dataEntity5["MaterialId_Id"] != null) ? Convert.ToInt32(dataEntity5["MaterialId_Id"]) : 0); - int midRule2 = ((dataEntity5["FCentreBoxRuleToBill_Id"] != null) ? Convert.ToInt32(dataEntity5["FCentreBoxRuleToBill_Id"]) : 0); - int bigRule2 = ((dataEntity5["FBigBoxRuleToBill_Id"] != null) ? Convert.ToInt32(dataEntity5["FBigBoxRuleToBill_Id"]) : 0); - if (bigRule2 != 0) - { - if (list.Where((CaculateCountInfo u) => u.materialId == MaterialId && u.bigRule == bigRule2.ToString()).Count() > 0) - { - caculateCountInfo5 = list.Where((CaculateCountInfo u) => u.materialId == MaterialId && u.bigRule == bigRule2.ToString()).FirstOrDefault(); - flag4 = true; - } - - caculateCountInfo5.materialId = MaterialId; - caculateCountInfo5.caculateCount += num7; - caculateCountInfo5.bigRule = bigRule2.ToString(); - if (!flag4) - { - list.Add(caculateCountInfo5); - } - - continue; - } - - if (list.Where((CaculateCountInfo u) => u.materialId == MaterialId && u.midRule == midRule2.ToString()).Count() > 0) - { - caculateCountInfo5 = list.Where((CaculateCountInfo u) => u.materialId == MaterialId && u.midRule == midRule2.ToString()).FirstOrDefault(); - flag4 = true; - } - - caculateCountInfo5.materialId = MaterialId; - caculateCountInfo5.caculateCount += num6; - caculateCountInfo5.midRule = midRule2.ToString(); - if (!flag4) - { - list.Add(caculateCountInfo5); - } - } - } - - if (count == 6) - { - for (int n = 0; n < num; n++) - { - bool flag5 = false; - CaculateCountInfo caculateCountInfo6 = new CaculateCountInfo(); - caculateCountInfo6.bigRule = "0"; - caculateCountInfo6.midRule = "0"; - caculateCountInfo6.barcodeboxrule = 0; - caculateCountInfo6.materialId = 0; - caculateCountInfo6.index = 0; - caculateCountInfo6.caculateCount = 0; - DynamicObject dataEntity6 = entitys[n].DataEntity; - int num8 = ((dataEntity6["FCenterCreateNumber"] != null) ? Convert.ToInt32(dataEntity6["FCenterCreateNumber"]) : 0); - int num9 = ((dataEntity6["FBigCreateNumber"] != null) ? Convert.ToInt32(dataEntity6["FBigCreateNumber"]) : 0); - int midRule = ((dataEntity6["FCentreBoxRuleToBill_Id"] != null) ? Convert.ToInt32(dataEntity6["FCentreBoxRuleToBill_Id"]) : 0); - int bigRule = ((dataEntity6["FBigBoxRuleToBill_Id"] != null) ? Convert.ToInt32(dataEntity6["FBigBoxRuleToBill_Id"]) : 0); - if (bigRule != 0) - { - if (list.Where((CaculateCountInfo u) => u.bigRule == bigRule.ToString()).Count() > 0) - { - caculateCountInfo6 = list.Where((CaculateCountInfo u) => u.bigRule == bigRule.ToString()).FirstOrDefault(); - flag5 = true; - } - - caculateCountInfo6.caculateCount += num9; - caculateCountInfo6.bigRule = bigRule.ToString(); - if (!flag5) - { - list.Add(caculateCountInfo6); - } - - continue; - } - - if (list.Where((CaculateCountInfo u) => u.midRule == midRule.ToString()).Count() > 0) - { - caculateCountInfo6 = list.Where((CaculateCountInfo u) => u.midRule == midRule.ToString()).FirstOrDefault(); - flag5 = true; - } - - caculateCountInfo6.caculateCount += num8; - caculateCountInfo6.midRule = midRule.ToString(); - if (!flag5) - { - list.Add(caculateCountInfo6); - } - } - } - - return list; - } - - private void setCaculate() - { - int caculateCount = GetCaculateCount(); - DynamicObjectCollection dynamicObjectCollection = (DynamicObjectCollection)Model.DataObject["BD_BARCODEPRINTENTRYBAR"]; - if (caculateCount == 1) - { - int caculateCount2 = dynamicObjectCollection.Where((DynamicObject p) => Convert.ToString(p["MaterialIdToBar_Id"]).Equals("0")).Count(); - CaculateCountInfo caculateCountInfo = new CaculateCountInfo(); - caculateCountInfo.bigRule = "0"; - caculateCountInfo.midRule = "0"; - caculateCountInfo.materialId = 0; - caculateCountInfo.index = 0; - caculateCountInfo.caculateCount = caculateCount2; - caculateCountInfos.Add(caculateCountInfo); - for (int i = 0; i < dynamicObjectCollection.Count(); i++) - { - int materialId2 = Convert.ToInt32(dynamicObjectCollection[i]["MaterialIdToBar_Id"]); - CaculateCountInfo caculateCountInfo2 = caculateCountInfos.Where((CaculateCountInfo u) => u.materialId == materialId2).FirstOrDefault(); - if (caculateCountInfo2 != null) - { - caculateCountInfo2.index++; - dynamicObjectCollection[i]["FCaculateCountTobar"] = caculateCountInfo2.index + "/" + caculateCountInfo2.caculateCount; - } - } - } - - if (caculateCount == 4) - { - for (int j = 0; j < dynamicObjectCollection.Count(); j++) - { - int num = j + 1; - dynamicObjectCollection[j]["FCaculateCountTobar"] = num + "/" + caculateCountInfos[0].caculateCount; - } - } - - if (caculateCount == 2) - { - for (int k = 0; k < dynamicObjectCollection.Count(); k++) - { - int materialId3 = Convert.ToInt32(dynamicObjectCollection[k]["MaterialIdToBar_Id"]); - int barCodeRuleId4 = Convert.ToInt32(dynamicObjectCollection[k]["BarCodeRule_Id"]); - CaculateCountInfo caculateCountInfo3 = caculateCountInfos.Where((CaculateCountInfo u) => u.materialId == materialId3 && u.barcodeboxrule == barCodeRuleId4).FirstOrDefault(); - if (caculateCountInfo3 != null) - { - caculateCountInfo3.index++; - dynamicObjectCollection[k]["FCaculateCountTobar"] = caculateCountInfo3.index + "/" + caculateCountInfo3.caculateCount; - } - } - } - - if (caculateCount == 5) - { - for (int l = 0; l < dynamicObjectCollection.Count(); l++) - { - int barCodeRuleId3 = Convert.ToInt32(dynamicObjectCollection[l]["BarCodeRule_Id"]); - CaculateCountInfo caculateCountInfo4 = caculateCountInfos.Where((CaculateCountInfo u) => u.barcodeboxrule == barCodeRuleId3).FirstOrDefault(); - if (caculateCountInfo4 != null) - { - caculateCountInfo4.index++; - dynamicObjectCollection[l]["FCaculateCountTobar"] = caculateCountInfo4.index + "/" + caculateCountInfo4.caculateCount; - } - } - } - - if (caculateCount == 3) - { - for (int m = 0; m < dynamicObjectCollection.Count(); m++) - { - int materialId = Convert.ToInt32(dynamicObjectCollection[m]["MaterialIdToBar_Id"]); - string barCodeRuleId2 = Convert.ToString(dynamicObjectCollection[m]["BarCodeRule_Id"]); - string barcode = Convert.ToString(dynamicObjectCollection[m]["BarCode"]); - CaculateCountInfo caculateCountInfo5 = caculateCountInfos.Where((CaculateCountInfo u) => u.materialId == materialId && u.bigRule == barCodeRuleId2).FirstOrDefault(); - if (caculateCountInfo5 != null) - { - caculateCountInfo5.index++; - dynamicObjectCollection[m]["FCaculateCountTobar"] = caculateCountInfo5.index + "/" + caculateCountInfo5.caculateCount; - continue; - } - - CaculateCountInfo caculateCountInfo6 = caculateCountInfos.Where((CaculateCountInfo u) => u.materialId == materialId && u.midRule == barCodeRuleId2).FirstOrDefault(); - if (caculateCountInfo6 != null && !CheckBarcodeIsHaveBox(barcode)) - { - caculateCountInfo6.index++; - dynamicObjectCollection[m]["FCaculateCountTobar"] = caculateCountInfo6.index + "/" + caculateCountInfo6.caculateCount; - } - } - } - - if (caculateCount != 6) - { - return; - } - - for (int n = 0; n < dynamicObjectCollection.Count(); n++) - { - int num2 = Convert.ToInt32(dynamicObjectCollection[n]["MaterialIdToBar_Id"]); - string barCodeRuleId = Convert.ToString(dynamicObjectCollection[n]["BarCodeRule_Id"]); - CaculateCountInfo caculateCountInfo7 = caculateCountInfos.Where((CaculateCountInfo u) => u.bigRule == barCodeRuleId).FirstOrDefault(); - string barcode2 = Convert.ToString(dynamicObjectCollection[n]["BarCode"]); - if (caculateCountInfo7 != null) - { - caculateCountInfo7.index++; - dynamicObjectCollection[n]["FCaculateCountTobar"] = caculateCountInfo7.index + "/" + caculateCountInfo7.caculateCount; - continue; - } - - CaculateCountInfo caculateCountInfo8 = caculateCountInfos.Where((CaculateCountInfo u) => u.midRule == barCodeRuleId).FirstOrDefault(); - if (caculateCountInfo8 != null && !CheckBarcodeIsHaveBox(barcode2)) - { - caculateCountInfo8.index++; - dynamicObjectCollection[n]["FCaculateCountTobar"] = caculateCountInfo8.index + "/" + caculateCountInfo8.caculateCount; - } - } - } - - private bool CheckBarcodeIsHaveBox(string barcode) - { - bool result = false; - List list = new List(); - string strSQL = "select * from t_UN_PackagingEntry where FENTRYBARCODE=@barcode;"; - List list2 = new List(); - list2.Add(new SqlParam("@barcode", KDDbType.String, barcode)); - DynamicObjectCollection dynamicObjectCollection = DBUtils.ExecuteDynamicObject(base.Context, strSQL, null, null, CommandType.Text, list2.ToArray()); - if (dynamicObjectCollection != null && dynamicObjectCollection.Count() > 0) - { - result = true; - } - - return result; - } - - private List GetRuleBarcodeItem(long ruleId) - { - List list = new List(); - string strSQL = @" -SELECT T.FBARCODEFIELDKEY -FROM T_BD_BARCODERULEENTRY R - INNER JOIN T_BD_BARCODEITEM T ON R.FBARCODEPROPERTYID = T.FID -WHERE R.FID = @ruleId; "; - List list2 = new List(); - list2.Add(new SqlParam("@ruleId", KDDbType.Int64, ruleId)); - DynamicObjectCollection dynamicObjectCollection = DBUtils.ExecuteDynamicObject(base.Context, strSQL, null, null, CommandType.Text, list2.ToArray()); - if (dynamicObjectCollection != null && dynamicObjectCollection.Count() > 0) - { - foreach (DynamicObject item in dynamicObjectCollection) - { - list.Add(Convert.ToString(item["FBARCODEFIELDKEY"])); - } - } - - return list; - } - - private void SyncCreateBarCode(ExtendedDataEntity[] entitys, int iCount, string sType) - { - //IL_001e: Unknown result type (might be due to invalid IL or missing references) - //IL_0024: Expected O, but got Unknown - try - { - DateTime now = DateTime.Now; - //UNWLogger.Info(base.Context, "BarCodePrintEdit", "CreateBarCode Start"); - BarCodeCreateResult val = new BarCodeCreateResult(); - int num = (iCount - 1) / 1000; - ExtendedDataEntity[] array = new ExtendedDataEntity[1000]; - for (int i = 1; i <= num + 1; i++) - { - if (1000 * i < iCount) - { - DateTime now2 = DateTime.Now; - Array.ConstrainedCopy(entitys, (i - 1) * 1000, array, 0, 1000); - val = BarCodeCreateServiceHelper.BarCodeCreateByRule(base.Context, base.View.BusinessInfo, _sRuleId, array, _sFormId, (Dictionary)null, false); - CaculateTime(now2, i, ResManager.LoadKDString("条码生成完成", "8b2aa21f52404b8f", "APP_ISVPAAC2016062210550")); - if (!val.AllDataRight) - { - base.View.ShowErrMessage(val.ErrInfo); - return; - } - - if (!_ctrlBatchCreate) - { - DateTime now3 = DateTime.Now; - SetBarCodeValue(val.BoxContrastNumbers, val.SecurityCodes, sType, val.FieldCodes, val.CodeQtyDic, val.BarCodeCorrespondings, (i - 1) * 1000, val.ExistedNumbers); - CaculateTime(now2, i, ResManager.LoadKDString("条码明细绑定完成", "039a8fe456064630", "APP_ISVPAAC2016062210550")); - //UNWLogger.Info(base.Context, "BarCodePrintEdit", ResManager.LoadKDString("CreateBarCode SetBarCodeValue 完成", "a6f0846f8a86458c", "APP_ISVPAAC2016062210550")); - } - } - else - { - DateTime now4 = DateTime.Now; - array = new ExtendedDataEntity[iCount - (i - 1) * 1000]; - Array.ConstrainedCopy(entitys, (i - 1) * 1000, array, 0, iCount - (i - 1) * 1000); - val = BarCodeCreateServiceHelper.BarCodeCreateByRule(base.Context, base.View.BusinessInfo, _sRuleId, array, _sFormId, (Dictionary)null, false); - CaculateTime(now4, i, ResManager.LoadKDString("条码生成完成", "8b2aa21f52404b8f", "APP_ISVPAAC2016062210550")); - if (!val.AllDataRight) - { - base.View.ShowErrMessage(val.ErrInfo); - return; - } - - if (!_ctrlBatchCreate) - { - DateTime now5 = DateTime.Now; - SetBarCodeValue(val.BoxContrastNumbers, val.SecurityCodes, sType, val.FieldCodes, val.CodeQtyDic, val.BarCodeCorrespondings, (i - 1) * 1000, val.ExistedNumbers); - CaculateTime(now4, i, ResManager.LoadKDString("条码明细绑定完成", "039a8fe456064630", "APP_ISVPAAC2016062210550")); - } - } - } - - SetComboItems(); - barcodeSysParm = BarCodeCommonServiceHelper.GetBarCodeBillSystemParameters(base.Context, base.Context.CurrentOrganizationInfo.ID, _sFormId); - if (barcodeSysParm.AutoSavePrintRecord) - { - OperateOption option = OperateOption.Create(); - option.SetCacheMetadata(value: false); - DynamicObject dataObject = Model.DataObject; - dataObject["FFormId"] = Model.BillBusinessInfo.GetForm().Id; - IOperationResult operationResult = BusinessDataServiceHelper.Save(base.Context, Model.BillBusinessInfo, dataObject, option); - base.View.UpdateView("FBILLCODEHEAD"); - Model.DataChanged = false; - } - - WriteBackBarcodeToBill(); - DateTime now6 = DateTime.Now; - TimeSpan timeSpan = now6 - now; - //UNWLogger.Info(base.Context, "BarCodePrintEdit", "CreateBarCode End" + timeSpan.ToString("g")); - base.View.GetControl("FTab").SelectedIndex = 1; - List billRowLocked = entitys.Select((ExtendedDataEntity p) => Convert.ToInt32(p.DataEntity["Seq"])).ToList(); - SetBillRowLocked(billRowLocked); - base.View.UpdateView("FEntityToBar"); - base.View.ShowMessage(ResManager.LoadKDString("条码生成成功", "c7bb1e5475fc4589", "APP_ISVPAAC2016062210550")); - UpdateQtyToQuaty(val); - } - catch (Exception ex) - { - //UNWLogger.Info(base.Context, "BarCodePrintEdit", string.Format(ResManager.LoadKDString("CreateBarCode错误:{0}", "b0e764f5c3874f24", "APP_ISVPAAC2016062210550"), ex.Message)); - base.View.Model.DeleteEntryData("FEntityToBar"); - base.View.ShowErrMessage(ex.Message); - } - } - - private void CaculateTime(DateTime dtstart, int i, string desc) - { - double num = DateTime.Now.Subtract(dtstart).Duration().TotalMilliseconds / 1000.0; - Msg = Msg + Environment.NewLine + ResManager.LoadKDString("第", "5e2976b208924f20", "APP_ISVPAAC2016062210550") + i + ResManager.LoadKDString("页", "963b741b750d4763", "APP_ISVPAAC2016062210550") + desc + ResManager.LoadKDString(",耗时", "e8940ad77237459a", "APP_ISVPAAC2016062210550") + Convert.ToString(num) + ResManager.LoadKDString("秒", "1c66015500d04260", "APP_ISVPAAC2016062210550"); - } - - private void AsyncCreateBarCode(ExtendedDataEntity[] entitys, int iCount, string sType) - { - DateTime currfirstTime = DateTime.Now; - DynamicFormShowParameter processForm = base.View.ShowProcessForm(delegate - { - }, bUseTruePro: true, ResManager.LoadKDString("正在加载界面", "cabf052101c44f41", "APP_ISVPAAC2016062210550")); - base.View.Session["ProcessRateValue"] = 0; - MainWorker.QuequeTask(base.Context, delegate - { - //IL_001d: Unknown result type (might be due to invalid IL or missing references) - //IL_0023: Expected O, but got Unknown - try - { - //UNWLogger.Info(base.Context, "BarCodePrintEdit", "AsyncCreateBarCode Start"); - BarCodeCreateResult val = new BarCodeCreateResult(); - int num = (iCount - 1) / 1000; - ExtendedDataEntity[] array = new ExtendedDataEntity[1000]; - _proIncrement = ((num > 0) ? (99 / num) : 99); - for (int i = 1; i <= num + 1; i++) - { - if (1000 * i < iCount) - { - Array.ConstrainedCopy(entitys, (i - 1) * 1000, array, 0, 1000); - DateTime now2 = DateTime.Now; - val = BarCodeCreateServiceHelper.BarCodeCreateByRule(base.Context, base.View.BusinessInfo, _sRuleId, array, _sFormId, (Dictionary)null, false); - CaculateTime(now2, i, ResManager.LoadKDString("条码生成完成", "8b2aa21f52404b8f", "APP_ISVPAAC2016062210550")); - if (!val.AllDataRight) - { - base.View.ShowErrMessage(val.ErrInfo); - return; - } - - if (_ctrlBatchCreate) - { - continue; - } - - DateTime now3 = DateTime.Now; - SetBarCodeValue(val.BoxContrastNumbers, val.SecurityCodes, sType, val.FieldCodes, val.CodeQtyDic, val.BarCodeCorrespondings, (i - 1) * 1000, val.ExistedNumbers); - //UNWLogger.Info(base.Context, "BarCodePrintEdit", ResManager.LoadKDString("AsyncCreateBarCode SetBarCodeValue 结束", "e68d6317957045b2", "APP_ISVPAAC2016062210550")); - CaculateTime(now3, i, ResManager.LoadKDString("条码明细绑定完成", "039a8fe456064630", "APP_ISVPAAC2016062210550")); - } - else - { - array = new ExtendedDataEntity[iCount - (i - 1) * 1000]; - Array.ConstrainedCopy(entitys, (i - 1) * 1000, array, 0, iCount - (i - 1) * 1000); - DateTime now4 = DateTime.Now; - val = BarCodeCreateServiceHelper.BarCodeCreateByRule(base.Context, base.View.BusinessInfo, _sRuleId, array, _sFormId, (Dictionary)null, false); - CaculateTime(now4, i, ResManager.LoadKDString("条码生成完成", "8b2aa21f52404b8f", "APP_ISVPAAC2016062210550")); - //UNWLogger.Info(base.Context, "BarCodePrintEdit", ResManager.LoadKDString("AsyncCreateBarCode BarCodeCreateByRule 结束", "83caaae197f245ca", "APP_ISVPAAC2016062210550")); - if (!val.AllDataRight) - { - base.View.ShowErrMessage(val.ErrInfo); - return; - } - - if (_ctrlBatchCreate) - { - continue; - } - - DateTime now5 = DateTime.Now; - SetBarCodeValue(val.BoxContrastNumbers, val.SecurityCodes, sType, val.FieldCodes, val.CodeQtyDic, val.BarCodeCorrespondings, (i - 1) * 1000, val.ExistedNumbers); - CaculateTime(now5, i, ResManager.LoadKDString("条码明细绑定完成", "039a8fe456064630", "APP_ISVPAAC2016062210550")); - } - - base.View.Session["ProcessRateValue"] = i * _proIncrement; - } - - WriteBackBarcodeToBill(); - SetComboItems(); - UpdateQtyToQuaty(val); - } - catch (Exception ex) - { - //UNWLogger.Info(base.Context, "BarCodePrintEdit", string.Format(ResManager.LoadKDString("CreateBarCode错误:{0}", "b0e764f5c3874f24", "APP_ISVPAAC2016062210550"), ex.Message)); - throw ex; - } - }, delegate (AsynResult result) - { - base.View.Session["ProcessRateValue"] = 101; - IDynamicFormView view = base.View.GetView(processForm.PageId); - if (view != null) - { - view.Close(); - base.View.SendDynamicFormAction(view); - } - - if (!result.Success) - { - base.View.Model.DeleteEntryData("FEntityToBar"); - if (result.Exception != null) - { - if (result.Exception.InnerException != null) - { - base.View.ShowErrMessage(result.Exception.InnerException.Message); - } - else - { - base.View.ShowErrMessage(result.Exception.Message); - } - } - } - else - { - base.View.UpdateView("FEntityToBar"); - List billRowLocked = entitys.Select((ExtendedDataEntity p) => Convert.ToInt32(p.DataEntity["Seq"])).ToList(); - SetBillRowLocked(billRowLocked); - base.View.GetControl("FTab").SelectedIndex = 1; - barcodeSysParm = BarCodeCommonServiceHelper.GetBarCodeBillSystemParameters(base.Context, base.Context.CurrentOrganizationInfo.ID, _sFormId); - if (barcodeSysParm.AutoSavePrintRecord) - { - OperateOption option = OperateOption.Create(); - option.SetCacheMetadata(value: false); - DynamicObject dataObject = Model.DataObject; - dataObject["FFormId"] = Model.BillBusinessInfo.GetForm().Id; - IOperationResult operationResult = BusinessDataServiceHelper.Save(base.Context, Model.BillBusinessInfo, dataObject, option); - base.View.UpdateView("FBILLCODEHEAD"); - Model.DataChanged = false; - } - } - - DateTime now = DateTime.Now; - TimeSpan timeSpan = now - currfirstTime; - //UNWLogger.Info(base.Context, "BarCodePrintEdit", ResManager.LoadKDString("AsyncCreateBarCode End 耗时:", "af1a7988425d4c2a", "APP_ISVPAAC2016062210550") + timeSpan.ToString("g")); - }); - } - - private void UpdateQtyToQuaty(BarCodeCreateResult barcode) - { - StringBuilder stringBuilder = new StringBuilder(); - string strSQL = "SELECT * FROM T_BD_BARCODERULEENTRY WHERE FID=@ruleId AND FBARCODEPROPERTYID =61"; - List list = new List(); - list.Add(new SqlParam("@ruleId", KDDbType.Int64, _sRuleId)); - DynamicObjectCollection dynamicObjectCollection = DBUtils.ExecuteDynamicObject(base.Context, strSQL, null, null, CommandType.Text, list.ToArray()); - Dictionary codeQtyDic = barcode.CodeQtyDic; - if ((!(_sFormId == "SFC_OperationPlanning") && !(_sFormId == "SFC_OperationReport") && !(_sFormId == "SFC_OperationTransfer")) || dynamicObjectCollection.Count != 0) - { - return; - } - - for (int i = 0; i < barcode.CodeNumbers.Count(); i++) - { - foreach (KeyValuePair item in codeQtyDic) - { - stringBuilder.AppendFormat("UPDATE T_BD_BARCODEMAIN SET FQuaQty = {0} WHERE FBARCODE = '{1}'", item.Value, item.Key); - } - } - - DBUtils.Execute(base.Context, stringBuilder.ToString()); - } - - //public override void OnAfterPrint(AfterPrintEventArgs e) - //{ - // try - // { - // base.OnAfterPrint(e); - // JObject jsonObj = BarCodePrintService.GetJsonObj(e); - // if (jsonObj == null || jsonObj["Items"] == null) - // { - // return; - // } - - // JToken obj = jsonObj["Items"]; - // JArray val = (JArray)(object)((obj is JArray) ? obj : null); - // foreach (JToken item in (IEnumerable)val) - // { - // if (Convert.ToString(item[(object)"isSuccessfull"]).Equals("True")) - // { - // UpdatePrintCountAfterPrintOP(); - // printOperationType = string.Empty; - // printDatas = new List(); - // newPrintDatas = new List(); - // } - // } - // } - // catch (Exception ex) - // { - // //UNWLogger.Error(base.Context, "BarCodePrintEdit", "OnAfterPrint error:" + ex.Message + ex.StackTrace, ex); - // throw ex; - // } - //} - - public override void OnPrepareNotePrintData(PreparePrintDataEventArgs e) - { - //UNWLogger.Info(base.Context, "OnPrepareNotePrintData:", "Start DataSourceId=" + e.DataSourceId + " Id=" + string.Join(",", e.BillIds)); - try - { - if (e.DataSourceId.Equals("FEntityToBar", StringComparison.OrdinalIgnoreCase)) - { - List list = new List(); - string value = e.BillIds.FirstOrDefault(); - if (newPrintDatas != null && newPrintDatas.Count > 0) - { - DynamicObject dynamicObject = newPrintDatas[Convert.ToInt32(value)]; - if (dynamicObject != null) - { - //UNWLogger.Info(base.Context, "OnPrepareNotePrintData:", dynamicObject["BarCode"].ToString()); - DynamicObject dynamicObject2 = new DynamicObject(e.DynamicObjectType); - foreach (object field2 in e.Fields) - { - string text = field2.ToString(); - if (text == "FExpPeriod") - { - continue; - } - - object obj = ""; - string text2 = ""; - bool flag = false; - bool flag2 = false; - string text3 = string.Empty; - if (text.Contains(".")) - { - string[] array = text.Split('.'); - string text4 = array[0]; - string text5 = array[1]; - if (array.Count() > 2) - { - text3 = array[2]; - } - - if (base.View.BusinessInfo.GetField(text4) == null) - { - continue; - } - - text2 = base.View.BusinessInfo.GetField(text4).PropertyName; - if (!(dynamicObject[text2] is DynamicObject dynamicObject3)) - { - if (text2.EqualsIgnoreCase("LotToBar") || text4.EqualsIgnoreCase("FLotToBar")) - { - obj = dynamicObject[text2 + "_Text"]; - text = $"{text4}_{text5}"; - dynamicObject2[text] = obj; - } - - continue; - } - - if (dynamicObject3.DynamicObjectType.Properties.Contains("Image") && dynamicObject3["Image"] == null) - { - RepackData(dynamicObject3); - } - - if (dynamicObject3.DynamicObjectType.Name.ToUpperInvariant() == "BD_FLEXSITEMDETAILV") - { - flag = true; - } - - if (dynamicObject3.DynamicObjectType.Name.ToUpperInvariant() == "BD_FLEXVALUESDETAIL") - { - flag2 = true; - } - - text = string.Format("{0}_{1}{2}", text4, text5, text3.IsNullOrEmptyOrWhiteSpace() ? "" : ("_" + text3)); - if (dynamicObject3.DynamicObjectType.Properties.Contains(text5.Remove(0, 1))) - { - obj = dynamicObject3[text5.Remove(0, 1)]; - } - else if (dynamicObject3.DynamicObjectType.Properties.Contains(text5)) - { - obj = dynamicObject3[text5]; - } - else if (field2.Equals("FMaterialIdToBar.FStockPlaceId") && dynamicObject3.DynamicObjectType.Properties.Contains("MaterialStock") && dynamicObject3["MaterialStock"] is DynamicObjectCollection) - { - obj = (dynamicObject3["MaterialStock"] as DynamicObjectCollection)[0]; - } - - if (obj.IsNullOrEmptyOrWhiteSpace() && base.View.BusinessInfo.GetField(text4) is BaseDataField) - { - string formId = ((BaseDataField)base.View.BusinessInfo.GetField(text4)).LookUpObject.FormId; - obj = GetBaseDataPropByBaseData(formId, text5, dynamicObject3); - } - } - else if (base.View.BusinessInfo.GetField(text) is BasePropertyField) - { - string controlFieldKey = base.View.BusinessInfo.GetField(text).ControlFieldKey; - text2 = base.View.BusinessInfo.GetField(text).PropertyName; - string name = base.View.BusinessInfo.GetField(text).ControlField.DynamicProperty.Name; - if (dynamicObject[name] is DynamicObject dynamicObject4) - { - obj = Convert.ToString(dynamicObject4[text2]); - } - } - else if (base.View.BusinessInfo.GetField(text) != null) - { - text2 = base.View.BusinessInfo.GetField(text).PropertyName; - obj = dynamicObject[text2]; - } - - if (obj is DynamicObject) - { - if (flag) - { - text3 = (text3.IsNullOrEmptyOrWhiteSpace() ? "FDataValue" : text3); - if ((obj as DynamicObject).DynamicObjectType.Properties.Contains(text3)) - { - dynamicObject2[text] = (obj as DynamicObject)[text3].ToString(); - string text6 = text.Split('_')[0]; - if (dynamicObject2.DynamicObjectType.Properties.Contains(text6)) - { - string propertyName = base.View.BusinessInfo.GetField(text6).PropertyName; - if (dynamicObject.DynamicObjectType.Properties.Contains(propertyName + "_Id")) - { - dynamicObject2[text6] = dynamicObject[propertyName + "_Id"]; - } - } - - if (dynamicObject2.DynamicObjectType.Properties.Contains("FMaterialIdToBar_Ref")) - { - string propertyName2 = base.View.BusinessInfo.GetField("FMaterialIdToBar").PropertyName; - if (dynamicObject.DynamicObjectType.Properties.Contains(propertyName2) && dynamicObject.DynamicObjectType.Properties.Contains(propertyName2 + "_Id")) - { - dynamicObject2["FMaterialIdToBar_Ref"] = dynamicObject[propertyName2]; - dynamicObject2["FMaterialIdToBar_Id"] = dynamicObject[propertyName2 + "_Id"]; - } - } - } - else - { - text3 = ((text3.IsNullOrEmptyOrWhiteSpace() || !text3.Contains("Number")) ? "Name" : "Number"); - if ((obj as DynamicObject).DynamicObjectType.Properties.Contains(text3)) - { - dynamicObject2[text] = (obj as DynamicObject)[text3].ToString(); - } - } - } - else if (flag2) - { - text3 = (text3.IsNullOrEmptyOrWhiteSpace() ? "Name" : text3); - if (text.StartsWith("FSTOCKLOCIDToBar_FF") && text.EndsWith("_FNumber")) - { - text3 = text3.Remove(0, 1); - } - - if ((obj as DynamicObject).DynamicObjectType.Properties.Contains(text3)) - { - dynamicObject2[text] = (obj as DynamicObject)[text3].ToString(); - string text7 = text.Split('_')[0]; - if (dynamicObject2.DynamicObjectType.Properties.Contains(text7)) - { - string propertyName3 = base.View.BusinessInfo.GetField(text7).PropertyName; - if (dynamicObject.DynamicObjectType.Properties.Contains(propertyName3 + "_Id")) - { - dynamicObject2[text7] = dynamicObject[propertyName3 + "_Id"]; - } - } - - if (dynamicObject2.DynamicObjectType.Properties.Contains("FStockIdToBar_Ref")) - { - string propertyName4 = base.View.BusinessInfo.GetField("FStockIdToBar").PropertyName; - if (dynamicObject.DynamicObjectType.Properties.Contains(propertyName4) && dynamicObject.DynamicObjectType.Properties.Contains(propertyName4 + "_Id")) - { - dynamicObject2["FStockIdToBar_Ref"] = dynamicObject[propertyName4]; - dynamicObject2["FStockIdToBar_Id"] = dynamicObject[propertyName4 + "_Id"]; - } - } - - if (dynamicObject2.DynamicObjectType.Properties.Contains("FINSTOCKIDToBar_Ref")) - { - string propertyName5 = base.View.BusinessInfo.GetField("FINSTOCKIDToBar").PropertyName; - if (dynamicObject.DynamicObjectType.Properties.Contains(propertyName5) && dynamicObject.DynamicObjectType.Properties.Contains(propertyName5 + "_Id")) - { - dynamicObject2["FINSTOCKIDToBar_Ref"] = dynamicObject[propertyName5]; - dynamicObject2["FINSTOCKIDToBar_Id"] = dynamicObject[propertyName5 + "_Id"]; - } - } - } - } - else if (field2.ToString() == "FSTOCKLOCIDToBar" || field2.ToString().Equals("FAuxPropIdToBar")) - { - string value2 = (obj as DynamicObject)["Id"].ToString(); - dynamicObject2[text] = value2; - } - else - { - text3 = (text3.IsNullOrEmptyOrWhiteSpace() ? "Name" : text3); - if ((obj as DynamicObject).DynamicObjectType.Properties.Contains(text3)) - { - dynamicObject2[text] = (obj as DynamicObject)[text3].ToString(); - } - else if (field2.Equals("FMaterialIdToBar.FStockPlaceId") && dynamicObject2.DynamicObjectType.Properties.Contains("FMaterialIdToBar_Ref")) - { - string propertyName6 = base.View.BusinessInfo.GetField("FMaterialIdToBar").PropertyName; - if (dynamicObject.DynamicObjectType.Properties.Contains(propertyName6) && dynamicObject.DynamicObjectType.Properties.Contains(propertyName6 + "_Id")) - { - dynamicObject2["FMaterialIdToBar_Ref"] = dynamicObject[propertyName6]; - dynamicObject2["FMaterialIdToBar_Id"] = dynamicObject[propertyName6 + "_Id"]; - } - } - } - } - else if (dynamicObject2.DynamicObjectType.Properties.Contains(text)) - { - if (obj.IsNullOrEmptyOrWhiteSpace() && text.Contains("_")) - { - string[] array2 = text.Split('_'); - string text8 = ""; - text8 = array2[1].Remove(0, 1); - if (!text8.Equals("") && dynamicObject.DynamicObjectType.Properties.Contains(text8)) - { - obj = dynamicObject[text8]; - } - } - - dynamicObject2[text] = obj; - if (flag) - { - dynamicObject2[text] = obj; - string text9 = text.Split('_')[0]; - Field field = base.View.BusinessInfo.GetField(text9); - if (field is RelatedFlexGroupField && obj != null) - { - RelatedFlexGroupField element = (RelatedFlexGroupField)field; - dynamicObject2[text] = GetElementValue(element, obj); - } - - if (dynamicObject2.DynamicObjectType.Properties.Contains(text9)) - { - string propertyName7 = base.View.BusinessInfo.GetField(text9).PropertyName; - if (dynamicObject.DynamicObjectType.Properties.Contains(propertyName7 + "_Id")) - { - dynamicObject2[text9] = dynamicObject[propertyName7 + "_Id"]; - } - } - - if (dynamicObject2.DynamicObjectType.Properties.Contains("FMaterialIdToBar_Ref")) - { - string propertyName8 = base.View.BusinessInfo.GetField("FMaterialIdToBar").PropertyName; - if (dynamicObject.DynamicObjectType.Properties.Contains(propertyName8) && dynamicObject.DynamicObjectType.Properties.Contains(propertyName8 + "_Id")) - { - dynamicObject2["FMaterialIdToBar_Ref"] = dynamicObject[propertyName8]; - dynamicObject2["FMaterialIdToBar_Id"] = dynamicObject[propertyName8 + "_Id"]; - } - } - } - } - - if (dynamicObject2[text] is LocaleValue && !dynamicObject2[text].IsNullOrEmptyOrWhiteSpace()) - { - List list2 = new List(); - list2.Add(dynamicObject2[text] as LocaleValue); - List value3 = list2; - dynamicObject2[text] = value3; - } - } - - if (dynamicObject2.Contains("FMaterialIdToBar_FImageFileServer")) - { - object ret = new object(); - GetImageByte(dynamicObject2["FMaterialIdToBar_FImageFileServer"], ref ret); - dynamicObject2["FMaterialIdToBar_FImageFileServer"] = ret; - } - - list.Add(dynamicObject2); - } - } - - e.DataObjects = list.ToArray(); - } - - base.OnPrepareNotePrintData(e); - } - catch (Exception ex) - { - //UNWLogger.Error(base.Context, "BarCodePrintEdit", "OnPrepareNotePrintData error:" + ex.Message + ex.StackTrace, ex); - } - } - - private object GetElementValue(RelatedFlexGroupField element, object data) - { - IOrderedEnumerable orderedEnumerable = from p in element.RelateFlexBusinessInfo.GetFieldList() - orderby p.Tabindex - select p; - JSONArray jSONArray = new JSONArray(); - foreach (Field item in orderedEnumerable) - { - element.GetBindSinleValue(item.Key, data as DynamicObject, jSONArray, 0); - } - - return element.GetDisplayName(jSONArray, "."); - } - - public void GetImageByte(object value, ref object ret) - { - //IL_009a: Unknown result type (might be due to invalid IL or missing references) - //IL_009f: Unknown result type (might be due to invalid IL or missing references) - //IL_00ac: Unknown result type (might be due to invalid IL or missing references) - //IL_00c0: Expected O, but got Unknown - //IL_00c1: Unknown result type (might be due to invalid IL or missing references) - Guid result = Guid.Empty; - if (!Guid.TryParse(value.ToString(), out result)) - { - string text = ObjectUtils.Object2String(value); - if (string.IsNullOrWhiteSpace(text)) - { - return; - } - - text = text.Replace("nail=1", "nail=0"); - UriBuilder uriBuilder = new UriBuilder(); - Uri uri = uriBuilder.Uri; - WebClient webClient = new WebClient(); - try - { - byte[] array = webClient.DownloadData(uri); - ret = array; - return; - } - catch (Exception ex) - { - ex.StackTrace.ToString(); - return; - } - } - - try - { - TFileInfo val = new TFileInfo - { - FileId = value.ToString(), - CTX = base.View.Context - }; - ret = new UpDownloadService().GetFileData(val); - } - catch (Exception ex2) - { - ex2.StackTrace.ToString(); - } - } - - private void RepackData(DynamicObject tempObj) - { - try - { - string strSQL = "SELECT FUSEORGID,FCREATEORGID FROM T_BD_MATERIAL WHERE FMATERIALID=@materilId AND FNUMBER=@number"; - SqlParam sqlParam = new SqlParam("@materilId", KDDbType.Int64, Convert.ToInt64(tempObj["Id"])); - SqlParam sqlParam2 = new SqlParam("@number", KDDbType.String, Convert.ToString(tempObj["Number"])); - DynamicObject dynamicObject = DBUtils.ExecuteDynamicObject(base.Context, strSQL, null, null, CommandType.Text, sqlParam, sqlParam2).FirstOrDefault(); - if (dynamicObject != null && Convert.ToInt64(dynamicObject["FUSEORGID"]) != Convert.ToInt64(dynamicObject["FCREATEORGID"])) - { - string strSQL2 = "SELECT FIMAGE FROM T_BD_MATERIAL WHERE FCREATEORGID=FUSEORGID AND FNUMBER=@number"; - SqlParam sqlParam3 = new SqlParam("@number", KDDbType.String, Convert.ToString(tempObj["Number"])); - DynamicObject dynamicObject2 = DBUtils.ExecuteDynamicObject(base.Context, strSQL2, null, null, CommandType.Text, sqlParam3).FirstOrDefault(); - if (dynamicObject2 != null) - { - tempObj["Image"] = dynamicObject2["FIMAGE"]; - } - } - } - catch (Exception ex) - { - throw new Exception(ex.Message); - } - } - - private object GetBaseDataPropByBaseData(string formId, string fieldProp, DynamicObject itemValue) - { - try - { - FormMetadata formMetadata = (FormMetadata)MetaDataServiceHelper.Load(base.View.Context, Convert.ToString(formId)); - BusinessInfo businessInfo = formMetadata.BusinessInfo; - Field field = businessInfo.GetField(fieldProp); - object oriValue = BarCodeCommonService.GetItemValueFromBaseData(field, itemValue); - if (field is ComboField) - { - ComboField comboField = field as ComboField; - EnumObject enumObject = comboField.EnumObject; - EnumItem enumItem = enumObject.Items.FirstOrDefault((EnumItem p) => p.Value.Equals(oriValue)); - if (enumItem != null && enumItem.Caption != null) - { - oriValue = enumItem.Caption.ToString(base.Context.UserLocale); - } - } - else if (field is GroupField) - { - GroupField groupField = field as GroupField; - } - else if (oriValue == null) - { - itemValue = BusinessDataServiceHelper.Load(base.Context, businessInfo.GetDynamicObjectType(), null).FirstOrDefault(); - oriValue = BarCodeCommonService.GetItemValueFromBaseData(field, itemValue); - } - - return oriValue; - } - catch (Exception ex) - { - //UNWLogger.Error(base.Context, "BarCode OnPrepareNotePrintData", "error:" + ex.Message + ex.StackTrace, ex); - return null; - } - } - - private void SetComboValue() - { - int entryRowCount = base.View.Model.GetEntryRowCount("FEntityToBar"); - string model = Convert.ToString(base.View.Model.GetValue("FBarCodeModel")); - string boxmodel = Convert.ToString(base.View.Model.GetValue("FBarCodeBoxModel")); - string cboxmodel = Convert.ToString(base.View.Model.GetValue("FCenterBoxModel")); - string bboxmodel = Convert.ToString(base.View.Model.GetValue("FBigBoxModel")); - if (_noteTemplates.Count() > 0) - { - EnumItem enumItem = _noteTemplates.FirstOrDefault(); - if (enumItem != null) - { - string enumId = enumItem.EnumId; - if (_noteTemplates.Where((EnumItem p) => p.EnumId.EqualsIgnoreCase(model)).ToList().Count() == 0) - { - base.View.Model.SetValue("FBarCodeModel", enumId); - } - - if (_noteTemplates.Where((EnumItem p) => p.EnumId.EqualsIgnoreCase(boxmodel)).ToList().Count() == 0) - { - base.View.Model.SetValue("FBarCodeBoxModel", enumId); - } - - if (_noteTemplates.Where((EnumItem p) => p.EnumId.EqualsIgnoreCase(cboxmodel)).ToList().Count() == 0) - { - base.View.Model.SetValue("FCenterBoxModel", enumId); - } - - if (_noteTemplates.Where((EnumItem p) => p.EnumId.EqualsIgnoreCase(bboxmodel)).ToList().Count() == 0) - { - base.View.Model.SetValue("FBigBoxModel", enumId); - } - } - } - - if (entryRowCount <= 0) - { - return; - } - - for (int i = 0; i < entryRowCount; i++) - { - string modeltobar = Convert.ToString(base.View.Model.GetValue("FBarCodeModelToBar", i)); - if (_noteTemplates.Where((EnumItem p) => p.EnumId.EqualsIgnoreCase(modeltobar)).ToList().Count() == 0) - { - base.View.Model.SetValue("FBarCodeModelToBar", model, i); - } - } - } - - public override void DataChanged(DataChangedEventArgs e) - { - try - { - int entryRowCount = base.View.Model.GetEntryRowCount("FEntityToBill"); - int entryRowCount2 = base.View.Model.GetEntryRowCount("FEntityToBar"); - switch (e.Field.Key.ToUpperInvariant()) - { - case "FCUSTOMER": - { - string text2 = Model.GetValue("FTempRadioGroup").ToString(); - if (text2.Equals("1")) - { - long num10 = ((e.NewValue == null) ? 0 : Convert.ToInt64(e.NewValue)); - _noteTemplates = BarCodeCommonServiceHelper.GetValidNoteTemplatesByBillId_Customer(base.Context, "UHIK_BAR_BarCodePrint", num10); - if (_noteTemplates == null || _noteTemplates.Count == 0) - { - _noteTemplates = BarCodeCommonServiceHelper.GetValidNoteTemplatesByBillId(base.View.Context, "UHIK_BAR_BarCodePrint"); - } - - SetComboField(); - SetComboItems(); - SetComboValue(); - } - - break; - } - case "FASSISTANT": - { - string text2 = Model.GetValue("FTempRadioGroup").ToString(); - if (text2.Equals("2")) - { - string text3 = ((e.NewValue == null) ? "" : Convert.ToString(e.NewValue)); - _noteTemplates = BarCodeCommonServiceHelper.GetValidNoteTemplatesByBillId_Assist(base.Context, "UHIK_BAR_BarCodePrint", text3); - if (_noteTemplates == null || _noteTemplates.Count == 0) - { - _noteTemplates = BarCodeCommonServiceHelper.GetValidNoteTemplatesByBillId(base.View.Context, "UHIK_BAR_BarCodePrint"); - } - - SetComboField(); - SetComboItems(); - SetComboValue(); - } - - break; - } - case "FTEMPRADIOGROUP": - ControlTempRadio(); - _noteTemplates = BarCodeCommonServiceHelper.GetValidNoteTemplatesByBillId(base.View.Context, "UHIK_BAR_BarCodePrint"); - SetComboField(); - SetComboItems(); - SetComboValue(); - break; - case "FBILLID": - _sFormId = ((e.NewValue == null) ? "" : e.NewValue.ToString()); - SetDefRuleId(); - IsAutoPacking(); - base.View.Model.DeleteEntryData("FEntityToBill"); - base.View.Model.DeleteEntryData("FEntityToBar"); - break; - case "FBARCODEBOXRULE": - _sBoxRuleId = ((e.NewValue == null) ? 0 : Convert.ToInt64(e.NewValue)); - base.View.Model.DeleteEntryData("FEntityToBill"); - base.View.Model.DeleteEntryData("FEntityToBar"); - break; - case "FBARCODEFIELDRULE": - _sFieldRuleId = ((e.NewValue == null) ? 0 : Convert.ToInt64(e.NewValue)); - base.View.Model.DeleteEntryData("FEntityToBill"); - base.View.Model.DeleteEntryData("FEntityToBar"); - break; - case "FBIGBOXRULE": - _sBigBoxRuleId = ((e.NewValue == null) ? 0 : Convert.ToInt64(e.NewValue)); - base.View.Model.DeleteEntryData("FEntityToBill"); - base.View.Model.DeleteEntryData("FEntityToBar"); - break; - case "FCENTREBOXRULE": - _sCenterBoxRuleId = ((e.NewValue == null) ? 0 : Convert.ToInt64(e.NewValue)); - base.View.Model.DeleteEntryData("FEntityToBill"); - base.View.Model.DeleteEntryData("FEntityToBar"); - break; - case "FBARCODERULE": - _sRuleId = ((e.NewValue == null) ? 0 : Convert.ToInt64(e.NewValue)); - base.View.Model.DeleteEntryData("FEntityToBill"); - base.View.Model.DeleteEntryData("FEntityToBar"); - break; - case "FBARCODEMODEL": - { - if (entryRowCount > 0) - { - for (int i = 0; i < entryRowCount; i++) - { - base.View.Model.SetValue("FBARCODEMODELToBill", e.NewValue, i); - } - } - - if (entryRowCount2 <= 0) - { - break; - } - - for (int j = 0; j < entryRowCount2; j++) - { - if (base.View.Model.GetValue("FBarCodeModelToBar", j).IsNullOrEmptyOrWhiteSpace()) - { - base.View.Model.SetValue("FBarCodeModelToBar", e.NewValue, j); - } - } - - break; - } - case "FBARCODERULETOBILL": - { - long num11 = ((e.NewValue == null) ? 0 : Convert.ToInt64(e.NewValue)); - DynamicObject dynamicObject6 = base.View.Model.GetValue("FBARCODEFIELDRULEToBill", e.Row) as DynamicObject; - if (num11 > 0 && num11 != _sRuleId) - { - SetBillData(num11, (dynamicObject6 != null) ? Convert.ToInt64(dynamicObject6["Id"]) : 0, e.Row); - } - - break; - } - case "FBARCODEFIELDRULETOBILL": - { - long num9 = ((e.NewValue == null) ? 0 : Convert.ToInt64(e.NewValue)); - if (base.View.Model.GetValue("FBARCODERULEToBill", e.Row) is DynamicObject dynamicObject5 && num9 > 0 && num9 != _sFieldRuleId) - { - SetBillData(Convert.ToInt64(dynamicObject5["Id"]), num9, e.Row); - } - - break; - } - case "FMATERIALID": - { - decimal num4 = Convert.ToDecimal(base.View.Model.GetValue("FQty", e.Row)); - decimal num5 = Convert.ToDecimal(base.View.Model.GetValue("FMinPackCount", e.Row)); - if (num5 <= 0m && base.View.Model.GetValue("FMaterialId", e.Row) is DynamicObject dynamicObject3 && dynamicObject3["MaterialPurchase"] is DynamicObjectCollection dynamicObjectCollection2 && dynamicObjectCollection2.Count > 0) - { - DynamicObject dynamicObject4 = dynamicObjectCollection2[0]; - if (dynamicObject4 != null) - { - num5 = ((dynamicObject4["MinPackCount"] != null) ? Convert.ToDecimal(dynamicObject4["MinPackCount"]) : 1m); - } - } - - if (num4 > 0m && num5 > 0m) - { - decimal num6 = num4 / num5; - int num7 = 0; - int num8 = Convert.ToInt32(num6); - num7 = ((!((decimal)num8 < num6)) ? num8 : (num8 + 1)); - base.View.Model.SetValue("FCreateNumber", num7, e.Row); - base.View.Model.SetValue("FCreateNumber", 1, e.Row); - } - - CalcCreateNumber2(e.Row); - CenterCalcCreateNumber(e.Row); - BigCalcCreateNumber(e.Row); - break; - } - case "FPRINTADDRESS": - { - string text = Convert.ToString(e.NewValue); - if (!string.IsNullOrEmpty(text)) - { - SavePrintAddress(text); - } - - break; - } - case "FQTYTOBAR": - case "FMATERIALIDTOBAR": - { - decimal num = Convert.ToDecimal(base.View.Model.GetValue("FQtyToBar", e.Row)); - DynamicObject dynamicObject = base.View.Model.GetValue("FMaterialIdToBar", e.Row) as DynamicObject; - if (!(num > 0m) || dynamicObject == null || !(dynamicObject["MaterialPurchase"] is DynamicObjectCollection dynamicObjectCollection) || dynamicObjectCollection.Count <= 0) - { - break; - } - - DynamicObject dynamicObject2 = dynamicObjectCollection[0]; - if (dynamicObject2 != null) - { - int num2 = ((dynamicObject2["MinPackCount"] == null) ? 1 : Convert.ToInt32(dynamicObject2["MinPackCount"])); - int num3 = ((dynamicObject2["PrintCount"] == null) ? 1 : Convert.ToInt32(dynamicObject2["PrintCount"])); - if (num2 > 0 && num3 > 0) - { - base.View.Model.SetValue("FPrintNumber", num3, e.Row); - } - } - - break; - } - case "FQTY": - case "FBOXQTY": - case "FMINPACKCOUNT": - CalcCreateNumber2(e.Row); - CenterCalcCreateNumber(e.Row); - BigCalcCreateNumber(e.Row); - break; - case "FCREATENUMBER": - if (!_isEditQty) - { - CalcPackCount(e.Row); - } - - _isEditQty = false; - CenterCalcCreateNumber(e.Row); - BigCalcCreateNumber(e.Row); - break; - case "FCENTERBOXQTY": - CenterCalcCreateNumber(e.Row); - BigCalcCreateNumber(e.Row); - break; - case "FBIGBOXQTY": - BigCalcCreateNumber(e.Row); - break; - } - - base.DataChanged(e); - } - catch (Exception ex) - { - //UNWLogger.Error(base.Context, "BarCodePrintEdit", "DataChanged error:" + ex.Message + ex.StackTrace, ex); - throw ex; - } - } - - public override void BeforeF7Select(BeforeF7SelectEventArgs e) - { - try - { - switch (e.FieldKey.ToUpper()) - { - case "FBARCODERULE": - case "FBARCODEBOXRULE": - { - if (GetBarCodeFilter(out var filter)) - { - if (string.IsNullOrEmpty(e.ListFilterParameter.Filter)) - { - e.ListFilterParameter.Filter = filter; - break; - } - - IRegularFilterParameter listFilterParameter = e.ListFilterParameter; - listFilterParameter.Filter = listFilterParameter.Filter + " AND " + filter; - } - - break; - } - } - - base.BeforeF7Select(e); - } - catch (Exception ex) - { - //UNWLogger.Error(base.Context, "BarCodePrintEdit", "BeforeF7Select error:" + ex.Message + ex.StackTrace, ex); - throw ex; - } - } - - public override void BeforeSetItemValueByNumber(BeforeSetItemValueByNumberArgs e) - { - try - { - string text = e.BaseDataFieldKey.ToUpper(); - if (text == "FBARCODERULE" && GetBarCodeFilter(out var filter)) - { - if (string.IsNullOrEmpty(e.Filter)) - { - e.Filter = filter; - } - else - { - e.Filter = e.Filter + " AND " + filter; - } - } - } - catch (Exception ex) - { - //UNWLogger.Error(base.Context, "BarCodePrintEdit", "BeforeSetItemValueByNumber error:" + ex.Message + ex.StackTrace, ex); - throw ex; - } - } - - public override void AfterSave(AfterSaveEventArgs e) - { - try - { - base.View.UpdateView("FBILLCODEHEAD"); - base.AfterSave(e); - } - catch (Exception ex) - { - //UNWLogger.Error(base.Context, "BarCodePrintEdit", "AfterSave error:" + ex.Message + ex.StackTrace, ex); - throw ex; - } - } - - public override void ButtonClick(ButtonClickEventArgs e) - { - try - { - base.ButtonClick(e); - string text = e.Key.ToUpperInvariant(); - if (text == "FBTNSELECTPRINTER") - { - JSONArray jSONArray = new JSONArray(); - jSONArray.Add(0); - base.View.AddAction("SelectPrinterExt", jSONArray); - } - } - catch (Exception ex) - { - //UNWLogger.Error(base.Context, "BarCodePrintEdit", "ButtonClick error:" + ex.Message + ex.StackTrace, ex); - throw ex; - } - } - - public override void CustomEvents(CustomEventsArgs e) - { - try - { - base.CustomEvents(e); - BarCodeSysParamsModel barCodeBillSystemParameters = BarCodeCommonServiceHelper.GetBarCodeBillSystemParameters(base.Context, base.Context.CurrentOrganizationInfo.ID, _sFormId); - if (barCodeBillSystemParameters.FOpenBarPrintChainReq && e.EventName == "Custom.SetClientParams.SeqReqEnabled") - { - JSONObject jSONObject = new JSONObject(); - jSONObject["SeqReqEnabled"] = true; - JSONArray jSONArray = new JSONArray(); - jSONArray.Add(jSONObject); - base.View.AddAction("SetClientParams", jSONArray); - } - - switch (e.EventName.ToUpper()) - { - case "RETURNANDCLEARDATACOLLECTION": - case "TBRETURNANDCLEAR": - GetReturnDataFromSession(clearSessionData: true); - ((IListView)base.View.GetView(billPageId)).Close(); - break; - case "RETURNDETAILDATA": - GetReturnData(); - ((IListView)base.View.GetView(billPageId)).Close(); - break; - case "CLOSEDATACOLLECTIONANDRETURN": - GetReturnDataFrom(clear: false); - ((IListView)base.View.GetView(billPageId)).Close(); - break; - case "CLOSEWINDOWBYDETAIL": - ((IListView)base.View.GetView(billPageId)).Close(); - break; - case "SELECTPRINTER": - { - JSONObject jSONObject2 = JSONObject.Parse(e.EventArgs); - if (jSONObject2 == null) - { - break; - } - - string value = jSONObject2.GetValue("Data", "{}"); - if (!(value != "{}")) - { - break; - } - - JSONObject jSONObject3 = JSONObject.Parse(value); - if (jSONObject3 == null) - { - break; - } - - if (jSONObject3.GetValue("Selected", defaultValue: false)) - { - string value2 = jSONObject3.GetValue("PrinterName", ""); - base.View.Model.SetValue("FPrintAddress", value2); - break; - } - - string value3 = jSONObject3.GetValue("Message", ""); - if (!string.IsNullOrWhiteSpace(value3)) - { - base.View.ShowErrMessage(value3); - } - - break; - } - } - } - catch (Exception ex) - { - //UNWLogger.Error(base.Context, "BarCodePrintEdit", "CustomEvents error:" + ex.Message + ex.StackTrace, ex); - throw ex; - } - } - - private void GetReturnData() - { - ApplyReturnData(((IListView)base.View.GetView(billPageId)).SelectedRowsInfo); - } - - private void GetReturnDataFromSession(bool clearSessionData) - { - bool flag = false; - if (_sFormId == "STK_Inventory") - { - flag = true; - } - - List list = new List(); - IListView listView = (IListView)base.View.GetView(billPageId); - if (listView.Session == null || !listView.Session.ContainsKey("Data_Collection")) - { - return; - } - - if (listView.Session["Data_Collection"] is Dictionary dictionary && dictionary.Count > 0) - { - foreach (string key in dictionary.Keys) - { - ListSelectedRow listSelectedRow = dictionary[key]; - if (listSelectedRow.Selected && listSelectedRow.PrimaryKeyValue != null && !string.IsNullOrWhiteSpace(listSelectedRow.PrimaryKeyValue)) - { - list.Add(listSelectedRow.PrimaryKeyValue); - if (flag) - { - listData.Add(listSelectedRow); - } - } - } - } - - if (clearSessionData) - { - listView.Session["Data_Collection"] = null; - } - - if (list.Count >= 1) - { - _sourceId = string.Join(",", list); - _isFromBill = 1; - _billFormMetaData = (FormMetadata)MetaDataServiceHelper.Load(base.Context, _sFormId); - BindBillData(); - } - } - - private void GetReturnDataFrom(bool clear) - { - bool flag = false; - if (_sFormId == "STK_Inventory") - { - flag = true; - } - - List list = new List(); - IListView listView = (IListView)base.View.GetView(billPageId); - if (listView.Session == null || !listView.Session.ContainsKey("Data_Collection")) - { - return; - } - - if ((listView.Session["returnData"] as Dictionary)["ReturnData"] is Dictionary dictionary && dictionary.Count > 0) - { - foreach (string key in dictionary.Keys) - { - ListSelectedRow listSelectedRow = dictionary[key]; - if (listSelectedRow.Selected && listSelectedRow.PrimaryKeyValue != null && !string.IsNullOrWhiteSpace(listSelectedRow.PrimaryKeyValue)) - { - list.Add(listSelectedRow.PrimaryKeyValue); - if (flag) - { - listData.Add(listSelectedRow); - } - } - } - } - - if (clear) - { - listView.Session["Data_Collection"] = null; - } - - if (list.Count >= 1) - { - _sourceId = string.Join(",", list); - _isFromBill = 1; - _billFormMetaData = (FormMetadata)MetaDataServiceHelper.Load(base.Context, _sFormId); - BindBillData(); - } - } - - private void LockPrintInfo() - { - base.View.GetMainBarItem("tbNew").Enabled = true; - base.View.GetMainBarItem("tbSave").Enabled = true; - base.View.GetMainBarItem("tbChooseBill").Enabled = false; - base.View.GetMainBarItem("tbExit").Enabled = true; - base.View.GetBarItem("FEntityToBill", "tbButton").Enabled = false; - base.View.GetBarItem("FEntityToBill", "tbDeleteRow").Enabled = false; - base.View.GetBarItem("FEntityToBill", "tbBatchFill").Enabled = false; - base.View.GetBarItem("FEntityToBill", "tbCreBarCodeSum").Enabled = false; - base.View.GetBarItem("FEntityToBill", "tbCreBarCodeRow").Enabled = false; - base.View.GetBarItem("FEntityToBill", "tbGetNewData").Enabled = false; - base.View.GetBarItem("FEntityToBill", "tbDeleteList").Enabled = false; - Entity entity = base.View.BusinessInfo.GetEntity("FEntityToBill"); - base.View.StyleManager.SetEnabled(entity, "", value: false); - base.View.StyleManager.SetEnabled("FBillId", "FBillId", value: false); - base.View.StyleManager.SetEnabled("FBarCodeRule", "FBarCodeRule", value: false); - base.View.StyleManager.SetEnabled("FBILLCODEHEAD", "FBILLCODEHEAD", value: false); - base.View.GetControl("FCustomer").Enabled = false; - base.View.GetControl("FAssistantType").Enabled = false; - base.View.GetControl("FAssistant").Enabled = false; - } - - private bool GetBarCodeFilter(out string filter) - { - filter = $"\r\n FID IN (SELECT DISTINCT FID from T_BD_BARCODERULETOBILL\r\n WHERE FBILLID = '{_sFormId}'\r\n )"; - return !string.IsNullOrWhiteSpace(filter); - } - - private void SetBillRowLocked(List lSeq) - { - EntryEntity entryEntity = base.View.BusinessInfo.GetEntryEntity("FEntityToBill"); - foreach (int item in lSeq) - { - foreach (Field item2 in entryEntity.Fields.ToList()) - { - base.View.GetFieldEditor(item2.Key, item - 1).Enabled = false; - base.View.Model.SetValue("FBillCheckBox", 0, item - 1); - } - } - } - - private void SetDefData() - { - if (_isFromPrintList == 1) - { - return; - } - - if (_isFromBill == 1) - { - base.View.Model.SetValue("FBillId", _sFormId); - } - - Field field = base.View.BusinessInfo.GetField("FBarCodeModel"); - List modelFieldKeys = new List { "FBarCodeModel", "FBarCodeBoxModel", "FCenterBoxModel", "FBigBoxModel" }; - List list = (from p in base.View.BusinessInfo.GetFieldList() - where modelFieldKeys.Contains(p.Key) - select p).ToList(); - DynamicObject dataObject = base.View.Model.DataObject; - if (dataObject == null) - { - return; - } - - DynamicObject lastPrintTemplates = BarCodePrintServiceHelper.GetLastPrintTemplates(base.Context); - string text = Convert.ToString(dataObject[field.PropertyName]).Replace(" ", ""); - if (text == "" && _noteTemplates.Count > 0) - { - EnumItem enumItem = _noteTemplates.FirstOrDefault(); - foreach (Field item in list) - { - string empty = string.Empty; - if (enumItem == null) - { - continue; - } - - empty = enumItem.Value; - if (lastPrintTemplates != null) - { - string lastModelId = Convert.ToString(lastPrintTemplates[item.FieldName]); - EnumItem enumItem2 = _noteTemplates.FirstOrDefault((EnumItem p) => p.Value.Equals(lastModelId)); - if (enumItem2 != null) - { - empty = enumItem2.Value; - } - } - - base.View.Model.SetValue(item.Key, empty); - } - } - - bool flag = lastPrintTemplates != null && Convert.ToBoolean(Convert.ToInt32(lastPrintTemplates["FMERGEBILLDATA"].ToString())); - base.View.Model.SetValue("FMergeBillData", flag); - if (_isFromBill != 1 && lastPrintTemplates != null && !lastPrintTemplates["FBILLID"].IsNullOrEmptyOrWhiteSpace()) - { - base.View.Model.SetValue("FBILLID", Convert.ToString(lastPrintTemplates["FBILLID"])); - } - - if (_isFromBill != 1 && lastPrintTemplates != null && !lastPrintTemplates["FBARCODERULE"].IsNullOrEmptyOrWhiteSpace()) - { - base.View.Model.SetValue("FBARCODERULE", Convert.ToString(lastPrintTemplates["FBARCODERULE"])); - } - - if (lastPrintTemplates != null && !lastPrintTemplates["FCENTREBOXRULE"].IsNullOrEmptyOrWhiteSpace()) - { - base.View.Model.SetValue("FCENTREBOXRULE", Convert.ToString(lastPrintTemplates["FCENTREBOXRULE"])); - } - - if (lastPrintTemplates != null && !lastPrintTemplates["FBIGBOXRULE"].IsNullOrEmptyOrWhiteSpace()) - { - base.View.Model.SetValue("FBIGBOXRULE", Convert.ToString(lastPrintTemplates["FBIGBOXRULE"])); - } - - if (_isAutoPacking && lastPrintTemplates != null && !lastPrintTemplates["FBARCODEBOXRULE"].IsNullOrEmptyOrWhiteSpace()) - { - base.View.Model.SetValue("FBARCODEBOXRULE", Convert.ToString(lastPrintTemplates["FBARCODEBOXRULE"])); - } - } - - private string GetDefaultPrinter() - { - long userId = base.Context.UserId; - long iD = base.Context.CurrentOrganizationInfo.ID; - string text = base.Context.IpAddress; - if (!string.IsNullOrWhiteSpace(text)) - { - Regex regex = new Regex("\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}"); - text = Convert.ToString(regex.Match(text)); - } - - return BarCodePrintServiceHelper.GetDefaultPrinter(base.View.Context, userId, iD, text, (string)null); - } - - private void BindBillData() - { - if (_isFromBill != 1) - { - return; - } - - if (string.IsNullOrEmpty(_sFormId) || _sRuleId == 0L || string.IsNullOrEmpty(_sourceId)) - { - if (string.IsNullOrEmpty(_sFormId)) - { - base.View.ShowWarnningMessage(ResManager.LoadKDString("请先录入源单单据名称!", "0011019000003164", SubSystemType.BASE)); - } - else if (_sRuleId == 0) - { - base.View.ShowWarnningMessage(ResManager.LoadKDString("请先录入默认条码规则!", "0011019000003092", SubSystemType.BASE)); - } - else if (string.IsNullOrEmpty(_sourceId)) - { - base.View.ShowWarnningMessage(ResManager.LoadKDString("请先选择源单数据!", "0011019000003165", SubSystemType.BASE)); - } - } - else if (_isAutoPacking && _sBoxRuleId == 0) - { - base.View.ShowWarnningMessage(ResManager.LoadKDString("请先录入默认包装条码规则!", "58d194b2aae944ca", "APP_ISVPAAC2016062210550")); - } - else if (_isThreePacking && _sCenterBoxRuleId == 0) - { - base.View.ShowWarnningMessage(ResManager.LoadKDString("当前为三层装箱,请先录入中包条码规则!", "821ceb6207164fb8", "APP_ISVPAAC2016062210550")); - } - else - { - SetBillData(_sRuleId, _sFieldRuleId, -1); - DynamicObject dynamicObject = base.View.Model.GetValue("FBarCodeRule") as DynamicObject; - if (Convert.ToBoolean(dynamicObject["FIsAutoGenerateLot"])) - { - GetFlotBill(base.Context, base.View, "FLOT"); - } - } - } - - protected virtual void SetBillData(long eRuleId, long eFieldRuleId, int row) - { - string text = string.Empty; - string text2 = string.Empty; - FormMetadata formMetadata = (FormMetadata)MetaDataServiceHelper.Load(base.Context, _sFormId); - if (_isFromBill == 1 && formMetadata.BusinessInfo.GetEntity(_sEntityKey) != null) - { - text = formMetadata.BusinessInfo.GetEntity(_sEntityKey).EntryName; - } - - if (listData != null && listData.Count > 0) - { - string entryEntityKey = listData[0].EntryEntityKey; - if (!string.IsNullOrWhiteSpace(entryEntityKey) && formMetadata.BusinessInfo.GetEntity(entryEntityKey) != null) - { - text = formMetadata.BusinessInfo.GetEntity(entryEntityKey).EntryName; - } - } - - Dictionary DicFieldStrMap = BarCodeCommonServiceHelper.GetBarCodeItemFieldDic(base.Context, _sFormId, eRuleId); - if (eFieldRuleId > 0) - { - Dictionary fieldRules = BarCodeCommonServiceHelper.GetFieldRules(base.Context, Convert.ToInt64(eFieldRuleId)); - foreach (KeyValuePair item in fieldRules) - { - Dictionary barCodeItemFieldDic = BarCodeCommonServiceHelper.GetBarCodeItemFieldDic(base.Context, _sFormId, (long)Convert.ToInt32(item.Value)); - DicFieldStrMap = DicFieldStrMap.Union(barCodeItemFieldDic).ToDictionary((KeyValuePair p) => p.Key, (KeyValuePair p) => p.Value); - } - } - - Dictionary dictionary = new Dictionary(); - List list = new List(); - List list2 = new List(); - Field field = null; - Field field2 = null; - Entity entity = base.View.BillBusinessInfo.GetEntity("FEntityToBill"); - foreach (string sbarcodefield in DicFieldStrMap.Keys.ToList()) - { - field = entity.Fields.FirstOrDefault((Field p) => string.Equals(p.Key, sbarcodefield, StringComparison.OrdinalIgnoreCase)); - if (field.IsNullOrEmpty()) - { - continue; - } - - string text3 = DicFieldStrMap[sbarcodefield]; - string billBaseDataFieldKey = GetBillBaseDataFieldKey(text3); - string baseDataSubFieldKey = GetBaseDataSubFieldKey(text3); - bool flag = IsSubField(text3); - bool isBaseDataPropFieldInBill = false; - if (flag) - { - field2 = _billFormMetaData.BusinessInfo.GetField(billBaseDataFieldKey); - } - else - { - field2 = _billFormMetaData.BusinessInfo.GetField(text3); - if (field is BasePropertyField && field2 is BasePropertyField) - { - isBaseDataPropFieldInBill = true; - Field controlField = field.ControlField; - Field controlField2 = field2.ControlField; - if (!DicFieldStrMap.Keys.Contains(controlField.Key) && controlField != null && controlField2 != null) - { - DicFieldStrMap.Add(controlField.Key, controlField2.Key); - if (!dictionary.ContainsKey(controlField.Key)) - { - BarCodeBillCorrespondInfo barCodeBillCorrespondInfo = new BarCodeBillCorrespondInfo(); - barCodeBillCorrespondInfo.BarCodeFieldKey = controlField.Key; - barCodeBillCorrespondInfo.BarCodeField = controlField; - barCodeBillCorrespondInfo.CorrespondFieldKey = controlField2.Key; - barCodeBillCorrespondInfo.BillFieldKey = controlField2.Key; - barCodeBillCorrespondInfo.BaseDataSubFieldKey = ""; - barCodeBillCorrespondInfo.BillField = controlField2; - barCodeBillCorrespondInfo.IsBaseDataSubField = false; - barCodeBillCorrespondInfo.IsBaseDataPropFieldInBill = false; - dictionary.Add(sbarcodefield, barCodeBillCorrespondInfo); - } - } - - if (!list.Contains(controlField2.Key)) - { - list.Add(controlField2.Key); - } - } - } - - if (!dictionary.ContainsKey(sbarcodefield) && field2 != null) - { - BarCodeBillCorrespondInfo barCodeBillCorrespondInfo2 = new BarCodeBillCorrespondInfo(); - barCodeBillCorrespondInfo2.BarCodeFieldKey = sbarcodefield; - barCodeBillCorrespondInfo2.BarCodeField = field; - barCodeBillCorrespondInfo2.CorrespondFieldKey = text3; - barCodeBillCorrespondInfo2.BillFieldKey = billBaseDataFieldKey; - barCodeBillCorrespondInfo2.BaseDataSubFieldKey = baseDataSubFieldKey; - barCodeBillCorrespondInfo2.BillField = field2; - barCodeBillCorrespondInfo2.IsBaseDataSubField = flag; - barCodeBillCorrespondInfo2.IsBaseDataPropFieldInBill = isBaseDataPropFieldInBill; - dictionary.Add(sbarcodefield, barCodeBillCorrespondInfo2); - } - - if (!list.Contains(billBaseDataFieldKey)) - { - list.Add(billBaseDataFieldKey); - } - - if (field2 != null && !list2.Contains(field2.Entity.EntryName)) - { - list2.Add(field2.Entity.EntryName); - if (field2.Entity is SubEntryEntity && !list2.Contains((field2.Entity as SubEntryEntity).ParentEntity.EntryName)) - { - list2.Add((field2.Entity as SubEntryEntity).ParentEntity.EntryName); - } - } - } - - string primaryField = string.Empty; - if (_sFormId.EqualsIgnoreCase("FA_CARD")) - { - if (list2.Contains("CardDetail")) - { - list2.Remove("CardDetail"); - list2.Insert(0, "CardDetail"); - } - - if (list2.Contains("Allocation")) - { - list2.Remove("Allocation"); - list2.Insert(1, "Allocation"); - } - - primaryField = "FWtAssetNumber"; - if (!list.Contains("FAllocAssetNO")) - { - list.Add("FAllocAssetNO"); - } - - if (!list.Contains("FAllocRatio")) - { - list.Add("FAllocRatio"); - } - } - else if (_sFormId.EqualsIgnoreCase("STK_Inventory")) - { - if (!list.Contains("FLot")) - { - list.Add("FLot"); - } - - if (!list.Contains("FBaseQty")) - { - list.Add("FBaseQty"); - } - - if (!list.Contains("FBaseAVBQty")) - { - list.Add("FBaseAVBQty"); - } - } - - if (barcodeSysParm != null && barcodeSysParm.FTemplatePolicyType.Equals("3")) - { - text2 = GetField(); - if (!list.Contains(text2) && !text2.IsNullOrEmptyOrWhiteSpace()) - { - list.Add(text2); - } - } - - string sSeq = "FBILLSEQ"; - if (DicFieldStrMap.Keys.Contains(sSeq)) - { - field = base.View.BillBusinessInfo.GetField(sSeq); - if (!dictionary.ContainsKey(sSeq)) - { - List source = _billFormMetaData.BusinessInfo.Entrys.Select((Entity p) => p.EntryName).ToList(); - string sEntitykey = string.Empty; - if (_sFormId == "SFC_OperationPlanning") - { - string key = DicFieldStrMap[sSeq].Split('F')[0]; - List source2 = source.Where((string p) => DicFieldStrMap[sSeq].IndexOf(p + "F") > -1).ToList(); - sEntitykey = source2.Where((string p) => p.Equals(key)).FirstOrDefault(); - } - else - { - sEntitykey = source.Where((string p) => DicFieldStrMap[sSeq].IndexOf(p + "F") > -1).FirstOrDefault(); - } - - if (!string.IsNullOrEmpty(sEntitykey)) - { - field2 = new Field - { - EntityKey = sEntitykey, - FieldName = DicFieldStrMap[sSeq].Replace(sEntitykey, ""), - PropertyName = "Seq" - }; - string text4 = DicFieldStrMap[sSeq]; - BarCodeBillCorrespondInfo barCodeBillCorrespondInfo3 = new BarCodeBillCorrespondInfo(); - barCodeBillCorrespondInfo3.BarCodeFieldKey = sSeq; - barCodeBillCorrespondInfo3.BarCodeField = field; - barCodeBillCorrespondInfo3.CorrespondFieldKey = text4; - barCodeBillCorrespondInfo3.BillFieldKey = text4; - barCodeBillCorrespondInfo3.BaseDataSubFieldKey = ""; - if (_sFormId == "SFC_OperationPlanning") - { - field2.Entity = _billFormMetaData.BusinessInfo.Entrys.Where((Entity p) => p.EntryName.Equals(sEntitykey)).FirstOrDefault(); - } - - barCodeBillCorrespondInfo3.BillField = field2; - barCodeBillCorrespondInfo3.IsBaseDataSubField = false; - barCodeBillCorrespondInfo3.IsBaseDataPropFieldInBill = false; - dictionary.Add(sSeq, barCodeBillCorrespondInfo3); - if (field2 != null && !list2.Contains(sEntitykey)) - { - list2.Add(sEntitykey); - } - } - } - } - - string pkFieldName = _billFormMetaData.BusinessInfo.GetForm().PkFieldName; - DynamicObject dynamicObject = base.View.Model.GetValue("FBillId") as DynamicObject; - if (dynamicObject == null && string.IsNullOrWhiteSpace(_sFormId)) - { - return; - } - - if (dynamicObject != null && dynamicObject.DynamicObjectType.Properties.Contains("MODELTYPEID") && Convert.ToInt32(dynamicObject["MODELTYPEID"]) == 400) - { - string text5 = "FBASEDATAID"; - field = base.View.BillBusinessInfo.GetField(text5); - if (!dictionary.ContainsKey(text5)) - { - string text6 = text5; - if (DicFieldStrMap.ContainsKey(text5)) - { - text6 = DicFieldStrMap[text5]; - } - - field2 = new Field - { - FieldName = pkFieldName, - PropertyName = "Id" - }; - BarCodeBillCorrespondInfo barCodeBillCorrespondInfo4 = new BarCodeBillCorrespondInfo(); - barCodeBillCorrespondInfo4.BarCodeFieldKey = text5; - barCodeBillCorrespondInfo4.BarCodeField = field; - barCodeBillCorrespondInfo4.CorrespondFieldKey = text6; - barCodeBillCorrespondInfo4.BillFieldKey = text6; - barCodeBillCorrespondInfo4.BaseDataSubFieldKey = ""; - barCodeBillCorrespondInfo4.BillField = field2; - barCodeBillCorrespondInfo4.IsBaseDataSubField = false; - barCodeBillCorrespondInfo4.IsBaseDataPropFieldInBill = false; - dictionary.Add(text5, barCodeBillCorrespondInfo4); - } - } - - DynamicObject[] array = null; - array = GetSourceBillData(_billFormMetaData, list, _sourceId, _sourceEntryId); - Field seqField = (dictionary.ContainsKey(sSeq) ? dictionary[sSeq].BillField : null); - if (seqField != null && !seqField.EntityKey.IsNullOrEmptyOrWhiteSpace()) - { - DynamicObject[] array2 = array; - foreach (DynamicObject dynamicObject2 in array2) - { - DynamicObjectCollection dynamicObjectCollection = (dynamicObject2.DynamicObjectType.Properties.ContainsKey(seqField.EntityKey) ? (dynamicObject2[seqField.EntityKey] as DynamicObjectCollection) : null); - if (dynamicObjectCollection != null && dynamicObjectCollection.Count > 0) - { - dynamicObjectCollection.Sort((DynamicObject it) => Convert.ToInt32(it[seqField.PropertyName])); - } - } - } - - Dictionary dictionary2 = new Dictionary(); - if ((listData == null || listData.Count() <= 0) && !_sourceEntryId.IsNullOrEmptyOrWhiteSpace()) - { - List list3 = _sourceEntryId.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList(); - if (list3 == null || list3.Count == 0) - { - list3 = _sourceId.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList(); - } - - int num = 0; - foreach (string item2 in list3) - { - dictionary2.Add(num, item2); - num++; - } - } - else if (listData != null && listData.Count() > 0) - { - for (int j = 0; j < listData.Count; j++) - { - string value = (listData[j].EntryPrimaryKeyValue.IsNullOrEmptyOrWhiteSpace() ? "" : listData[j].EntryPrimaryKeyValue); - if (_sFormId.Equals("SFC_OperationPlanning") && listData[j].FieldValues.ContainsKey("FSubEntity")) - { - value = listData[j].FieldValues["FSubEntity"]; - } - - dictionary2.Add(j, value); - } - } - - if (!string.IsNullOrWhiteSpace(text) && array.Count() > 0 && array[0].DynamicObjectType.Properties.Contains(text)) - { - DynamicObject[] array3 = array; - foreach (DynamicObject dynamicObject3 in array3) - { - DynamicObjectCollection dynamicObjectCollection2 = dynamicObject3[text] as DynamicObjectCollection; - List list4 = new List(); - if (_isFromBill == 1 && (listData == null || listData.Count() <= 0) && !_sourceEntryId.IsNullOrEmptyOrWhiteSpace()) - { - List list5 = _sourceEntryId.Split(',').ToList(); - foreach (string item3 in list5) - { - int num2 = 0; - foreach (DynamicObject item4 in dynamicObjectCollection2) - { - string text7 = Convert.ToString(item4["Id"]); - if (text7 == item3) - { - list4.Add(num2); - break; - } - - num2++; - } - } - } - else - { - for (int l = 0; l < listData.Count; l++) - { - string entryPrimaryKeyValue = listData[l].EntryPrimaryKeyValue; - int num3 = 0; - foreach (DynamicObject item5 in dynamicObjectCollection2) - { - string text8 = Convert.ToString(item5["Id"]); - if (text8 == entryPrimaryKeyValue) - { - list4.Add(num3); - break; - } - - num3++; - } - } - } - - foreach (DynamicObject item6 in dynamicObjectCollection2) - { - foreach (string item7 in list2) - { - if (!(item7 != text) || !item6.DynamicObjectType.Properties.Contains(item7)) - { - continue; - } - - DynamicObjectCollection dynamicObjectCollection3 = item6[item7] as DynamicObjectCollection; - foreach (DynamicObject item8 in dynamicObjectCollection3) - { - if (!dictionary2.Values.Contains(Convert.ToString(item8["Id"]))) - { - dictionary2.Add(dictionary2.Count(), Convert.ToString(item8["Id"])); - } - } - } - } - - List list6 = new List(); - foreach (int item9 in list4) - { - list6.Add(dynamicObjectCollection2[item9]); - } - - dynamicObjectCollection2.Clear(); - for (int m = 0; m < list6.Count; m++) - { - dynamicObjectCollection2.Add(list6[m]); - } - } - } - - Entity entity2 = base.View.BusinessInfo.GetEntity("FEntityToBill"); - EntryEntity entryEntity = base.View.BusinessInfo.GetEntryEntity("FEntityToBar"); - DynamicObjectType dynamicObjectType = entity2.DynamicObjectType; - DynamicObject dybill = new DynamicObject(dynamicObjectType); - DynamicObjectCollection dybillCol = new DynamicObjectCollection(dynamicObjectType); - dybillCol = GetDynamicRows(array, null, dybillCol, dictionary, list2, dynamicObjectType, dybill, 0, 0, primaryField); - if (base.View.Model.GetValue("FBarCodeRule") is DynamicObject dynamicObject4 && dynamicObject4.Contains("FPrintSummaryEntry") && Convert.ToBoolean(dynamicObject4["FPrintSummaryEntry"])) - { - dybillCol = MergeSourceBill(dynamicObjectType, dybillCol.ToArray(), dictionary); - } - - if (dybillCol != null && dybillCol.Count() > 0 && dictionary2 != null && dictionary2.Count() > 0) - { - List list7 = new List(); - foreach (string entryId in dictionary2.Values) - { - DynamicObject dynamicObject5 = dybillCol.Where((DynamicObject p) => Convert.ToString(p["SrcEntryId"]).Equals(entryId)).FirstOrDefault(); - if (dynamicObject5 != null) - { - list7.Add(dynamicObject5); - } - } - - if (list7 != null && list7.Count() > 0 && _sFormId != "BD_SerialMainFile" && _sFormId != "BD_MATERIAL") - { - dybillCol.Clear(); - for (int n = 0; n < list7.Count; n++) - { - dybillCol.Add(list7[n]); - } - } - } - - bool flag2 = Convert.ToBoolean(base.View.Model.GetValue("FMergeBillData")); - if (row == -1) - { - if (flag2) - { - dybillCol = MergeEntries(dynamicObjectType, dybillCol, dictionary); - } - - EntryEntity entity3 = (EntryEntity)base.View.BillBusinessInfo.GetEntity("FEntityToBill"); - CreateBillRows(dybillCol, entity3, dictionary); - } - else - { - int index = Convert.ToInt32(base.View.Model.GetValue("FSrcIndex", row)); - DynamicObject detil = dybillCol[index]; - ModifyBillRow(detil, dictionary, row); - } - - OQLFilter ofilter = OQLFilter.CreateHeadEntityFilter($"FID = '{eRuleId}'"); - DynamicObject dynamicObject6 = BusinessDataServiceHelper.Load(base.Context, "BD_BarCodeRule", null, ofilter).FirstOrDefault(); - if (dynamicObject6 != null) - { - DynamicObjectCollection source3 = dynamicObject6["BD_BARCODERULEENTRY"] as DynamicObjectCollection; - List list8 = source3.Select((DynamicObject s) => Convert.ToString((s["BarCodePropertyId"] as DynamicObject)["BARCODEFIELDKEY"])).ToList(); - if (list8 != null && list8.Count > 0 && list8.Contains("FBILLCODE") && list8.Contains("FOPBILLNO")) - { - int entryRowCount = Model.GetEntryRowCount("FEntityToBill"); - for (int num4 = 0; num4 < entryRowCount; num4++) - { - Model.SetValue("FOPBILLNO", Model.GetValue("FBILLCODE", num4), num4); - } - } - } - - if (barcodeSysParm != null && barcodeSysParm.FTemplatePolicyType.Equals("3") && !text2.IsNullOrEmptyOrWhiteSpace()) - { - SetCustmerToBarcodePrint(text2, array); - } - } - - private string GetField() - { - string result = string.Empty; - string text = $"SELECT FFIELDKEY FROM T_BD_BARCODEITEM t1\r\n INNER JOIN T_BD_BARCODEITEMENTRY t2 ON t1.FID = t2.FID\r\n AND t1.FBARCODEFIELDKEY = 'FCUSTID'\r\n AND FBILLFORMID = '{_sFormId}' "; - DynamicObject dynamicObject = DBServiceHelper.ExecuteDynamicObject(base.Context, text).FirstOrDefault(); - if (dynamicObject != null) - { - result = Convert.ToString(dynamicObject["FFIELDKEY"]); - } - - return result; - } - - private void SetCustmerToBarcodePrint(string keyCustomer, DynamicObject[] dySoruceObjsColl) - { - Field field = _billFormMetaData.BusinessInfo.GetField(keyCustomer); - if (field == null) - { - return; - } - - DynamicObject dynamicObject = dySoruceObjsColl[dySoruceObjsColl.Count() - 1]; - Entity entity = field.Entity; - if (entity is EntryEntity) - { - string propertyName = Convert.ToString(entity.DynamicObjectType); - if (dynamicObject[propertyName] is DynamicObjectCollection dynamicObjectCollection && dynamicObjectCollection.Count > 0 && dynamicObjectCollection[0].DynamicObjectType.Properties.Contains(field.PropertyName)) - { - Model.SetValue("FCustomer", dynamicObjectCollection[0][field.PropertyName]); - } - } - else if (dynamicObject.DynamicObjectType.Properties.Contains(field.PropertyName)) - { - Model.SetValue("FCustomer", dynamicObject[field.PropertyName]); - } - } - - protected virtual DynamicObjectCollection MergeEntries(DynamicObjectType dotype, DynamicObjectCollection dybillCol, Dictionary DicFieldCorresMap) - { - DynamicObjectCollection dynamicObjectCollection = new DynamicObjectCollection(dotype); - Dictionary> dictionary = new Dictionary>(); - Dictionary dictionary2 = new Dictionary(); - int num = 0; - foreach (DynamicObject item in dybillCol) - { - Dictionary dictionary3 = new Dictionary(); - string text = ""; - Dictionary dictionary4 = new Dictionary(); - foreach (BarCodeBillCorrespondInfo value7 in DicFieldCorresMap.Values) - { - Field barCodeField = value7.BarCodeField; - if (barCodeField.DynamicProperty == null || !item.DynamicObjectType.Properties.Contains(barCodeField.PropertyName)) - { - continue; - } - - if (barCodeField is QtyField) - { - decimal value = (item[barCodeField.PropertyName].IsNullOrEmptyOrWhiteSpace() ? 0m : Convert.ToDecimal(item[barCodeField.PropertyName])); - dictionary4.Add(barCodeField, value); - } - else if (barCodeField is BaseDataField || barCodeField is RelatedFlexGroupField) - { - if (barCodeField is LotField) - { - if (Convert.ToString(item[barCodeField.PropertyName + "_Text"]).IsNullOrEmptyOrWhiteSpace()) - { - if (item[barCodeField.PropertyName] != null) - { - DynamicObject dynamicObject = item[barCodeField.PropertyName] as DynamicObject; - text += Convert.ToString(dynamicObject["Number"]).Trim(); - } - else - { - text += ""; - } - } - else - { - text += Convert.ToString(item[barCodeField.PropertyName + "_Text"]).Trim(); - } - - continue; - } - - if (barCodeField is RelatedFlexGroupField) - { - DynamicObject dynamicObject2 = item[barCodeField.PropertyName] as DynamicObject; - string text2 = ""; - if (dynamicObject2 != null) - { - long num2 = Convert.ToInt64(dynamicObject2["Id"]); - string text3 = Convert.ToString(((RelatedFlexGroupField)barCodeField).RefFormDynamicObjectType); - string text4 = ""; - if ("BD_FLEXVALUESDETAIL".EqualsIgnoreCase(text3)) - { - text2 = BarCodeBaseInfoServiceHelper.GetFlexValues(base.Context, num2, text3, out text4); - } - else if ("BD_FLEXSITEMDETAILV".EqualsIgnoreCase(text3)) - { - text2 = BarCodeBaseInfoServiceHelper.GetFlexValues(base.Context, num2, text3, out text4); - } - } - - text += text2; - continue; - } - - string text5 = Convert.ToString(item[barCodeField.PropertyName + "_Id"]); - EnumPkFieldType pkFieldType = ((BaseDataField)barCodeField).LookUpObject.PkFieldType; - if (!text5.IsNullOrEmptyOrWhiteSpace()) - { - if (barCodeField is AssistantField) - { - string propertyName = ((AssistantField)barCodeField).NumberProperty.PropertyName; - DynamicObject dynamicObject3 = BusinessDataServiceHelper.LoadSingle(base.Context, text5, ((BaseDataField)barCodeField).RefFormDynamicObjectType); - string text6 = string.Empty; - if (dynamicObject3 != null && dynamicObject3.Contains(propertyName)) - { - text6 = Convert.ToString(dynamicObject3[propertyName]); - } - - text += text6; - } - else if (barCodeField is BaseDataField) - { - if (!pkFieldType.Equals(EnumPkFieldType.STRING) && Convert.ToInt64(text5) <= 0) - { - text += ""; - continue; - } - - LookUpObject lookUpObject = null; - if (barCodeField is ItemClassField) - { - ItemClassTypeField itemClassTypeField = ((ItemClassField)barCodeField).ControlField as ItemClassTypeField; - string text7 = Convert.ToString(item[itemClassTypeField.PropertyName]); - if (text7.IsNullOrEmptyOrWhiteSpace() && !text5.IsNullOrEmptyOrWhiteSpace()) - { - throw new Exception(string.Format(ResManager.LoadKDString("{0}字段不可以为空!", "f0e7cc43f9c54a52", "APP_ISVPAAC2016062210550"), itemClassTypeField.Name.ToString(base.Context.UserLocale))); - } - - lookUpObject = itemClassTypeField.GetLookUpObject(text7); - } - else - { - lookUpObject = ((BaseDataField)barCodeField).LookUpObject; - } - - string propertyName2 = ((BaseDataField)barCodeField).NumberProperty.PropertyName; - DynamicObject dynamicObject4 = BusinessDataServiceHelper.LoadSingle(base.Context, text5, ((BaseDataField)barCodeField).RefFormDynamicObjectType); - string text8 = string.Empty; - if (dynamicObject4.Contains(propertyName2)) - { - text8 = Convert.ToString(dynamicObject4[propertyName2]); - } - - text += text8; - } - else - { - text += ""; - } - } - else - { - text += ""; - } - } - else - { - string text9 = Convert.ToString(item[barCodeField.PropertyName]); - if (barCodeField is DecimalField) - { - DecimalField decimalField = barCodeField as DecimalField; - int fieldScale = decimalField.FieldScale; - decimal d = Convert.ToDecimal(item[barCodeField.PropertyName]); - text9 = decimal.Round(d, fieldScale).ToString(); - } - - text += text9; - } - } - - if (dictionary2.ContainsKey(text)) - { - string value2 = ""; - dictionary2.TryGetValue(text, out value2); - Dictionary value3 = new Dictionary(); - dictionary.TryGetValue(text, out value3); - if (!value2.IsNullOrEmptyOrWhiteSpace()) - { - foreach (KeyValuePair item2 in dictionary4) - { - Field key = item2.Key; - decimal value4 = item2.Value; - decimal num3 = default(decimal); - decimal num4 = default(decimal); - num3 = value3[key]; - num4 = value4 + num3; - value3[key] = num4; - } - - dictionary2[text] = dictionary2[text] + "," + num; - } - } - else - { - dictionary.Add(text, dictionary4); - dictionary2.Add(text, num.ToString()); - } - - num++; - } - - foreach (KeyValuePair item3 in dictionary2) - { - string key2 = item3.Key; - string value5 = item3.Value.Split(',').ToArray().FirstOrDefault(); - int index = Convert.ToInt32(value5); - Dictionary value6 = new Dictionary(); - dictionary.TryGetValue(key2, out value6); - foreach (KeyValuePair item4 in value6) - { - dybillCol[index][item4.Key.PropertyName] = item4.Value; - } - - dynamicObjectCollection.Add(dybillCol[index]); - } - - return dynamicObjectCollection; - } - - protected virtual DynamicObjectCollection MergeSourceBill(DynamicObjectType dotype, DynamicObject[] dybillCol, Dictionary DicFieldCorresMap) - { - DynamicObjectCollection dynamicObjectCollection = new DynamicObjectCollection(dotype); - Dictionary> dictionary = new Dictionary>(); - Dictionary dictionary2 = new Dictionary(); - if (MergeID.Count > 0) - { - MergeID.Clear(); - } - - int num = 0; - foreach (DynamicObject dynamicObject in dybillCol) - { - Dictionary dictionary3 = new Dictionary(); - string text = ""; - Dictionary dictionary4 = new Dictionary(); - foreach (BarCodeBillCorrespondInfo value7 in DicFieldCorresMap.Values) - { - Field barCodeField = value7.BarCodeField; - if (barCodeField.DynamicProperty == null || !dynamicObject.DynamicObjectType.Properties.Contains(barCodeField.PropertyName)) - { - continue; - } - - if (barCodeField is QtyField) - { - decimal value = (dynamicObject[barCodeField.PropertyName].IsNullOrEmptyOrWhiteSpace() ? 0m : Convert.ToDecimal(dynamicObject[barCodeField.PropertyName])); - dictionary4.Add(barCodeField, value); - continue; - } - - if (barCodeField is BaseDataField || barCodeField is RelatedFlexGroupField) - { - if (barCodeField is LotField) - { - if (Convert.ToString(dynamicObject[barCodeField.PropertyName + "_Text"]).IsNullOrEmptyOrWhiteSpace()) - { - if (dynamicObject[barCodeField.PropertyName] != null) - { - DynamicObject dynamicObject2 = dynamicObject[barCodeField.PropertyName] as DynamicObject; - text += Convert.ToString(dynamicObject2["Number"]).Trim(); - } - else - { - text += ""; - } - } - else - { - text += Convert.ToString(dynamicObject[barCodeField.PropertyName + "_Text"]).Trim(); - } - - continue; - } - - if (barCodeField is RelatedFlexGroupField) - { - DynamicObject dynamicObject3 = dynamicObject[barCodeField.PropertyName] as DynamicObject; - string text2 = ""; - if (dynamicObject3 != null) - { - long num2 = Convert.ToInt64(dynamicObject3["Id"]); - string text3 = Convert.ToString(((RelatedFlexGroupField)barCodeField).RefFormDynamicObjectType); - string text4 = ""; - if ("BD_FLEXVALUESDETAIL".EqualsIgnoreCase(text3)) - { - text2 = BarCodeBaseInfoServiceHelper.GetFlexValues(base.Context, num2, text3, out text4); - } - else if ("BD_FLEXSITEMDETAILV".EqualsIgnoreCase(text3)) - { - text2 = BarCodeBaseInfoServiceHelper.GetFlexValues(base.Context, num2, text3, out text4); - } - } - - text += text2; - continue; - } - - string text5 = Convert.ToString(dynamicObject[barCodeField.PropertyName + "_Id"]); - EnumPkFieldType pkFieldType = ((BaseDataField)barCodeField).LookUpObject.PkFieldType; - if (!text5.IsNullOrEmptyOrWhiteSpace()) - { - if (barCodeField is AssistantField) - { - string propertyName = ((AssistantField)barCodeField).NumberProperty.PropertyName; - DynamicObject dynamicObject4 = BusinessDataServiceHelper.LoadSingle(base.Context, text5, ((BaseDataField)barCodeField).RefFormDynamicObjectType); - string text6 = string.Empty; - if (dynamicObject4 != null && dynamicObject4.Contains(propertyName)) - { - text6 = Convert.ToString(dynamicObject4[propertyName]); - } - - text += text6; - } - else if (barCodeField is BaseDataField) - { - if (!pkFieldType.Equals(EnumPkFieldType.STRING) && Convert.ToInt64(text5) <= 0) - { - text += ""; - continue; - } - - LookUpObject lookUpObject = null; - if (barCodeField is ItemClassField) - { - ItemClassTypeField itemClassTypeField = ((ItemClassField)barCodeField).ControlField as ItemClassTypeField; - string text7 = Convert.ToString(dynamicObject[itemClassTypeField.PropertyName]); - if (text7.IsNullOrEmptyOrWhiteSpace() && !text5.IsNullOrEmptyOrWhiteSpace()) - { - throw new Exception(string.Format(ResManager.LoadKDString("{0}字段不可以为空!", "f0e7cc43f9c54a52", "APP_ISVPAAC2016062210550"), itemClassTypeField.Name.ToString(base.Context.UserLocale))); - } - - lookUpObject = itemClassTypeField.GetLookUpObject(text7); - } - else - { - lookUpObject = ((BaseDataField)barCodeField).LookUpObject; - } - - string propertyName2 = ((BaseDataField)barCodeField).NumberProperty.PropertyName; - DynamicObject dynamicObject5 = BusinessDataServiceHelper.LoadSingle(base.Context, text5, ((BaseDataField)barCodeField).RefFormDynamicObjectType); - string text8 = string.Empty; - if (dynamicObject5.Contains(propertyName2)) - { - text8 = Convert.ToString(dynamicObject5[propertyName2]); - } - - text += text8; - } - else - { - text += ""; - } - } - else - { - text += ""; - } - - continue; - } - - string text9 = Convert.ToString(dynamicObject[barCodeField.PropertyName]); - if (barCodeField.PropertyName.EqualsIgnoreCase("BILLSEQ")) - { - int result = 0; - if (int.TryParse(text9, out result)) - { - dictionary4.Add(barCodeField, result); - } - - continue; - } - - if (barCodeField is DecimalField) - { - DecimalField decimalField = barCodeField as DecimalField; - int fieldScale = decimalField.FieldScale; - decimal d = Convert.ToDecimal(dynamicObject[barCodeField.PropertyName]); - text9 = decimal.Round(d, fieldScale).ToString(); - } - - text += text9; - } - - if (dictionary2.ContainsKey(text)) - { - string value2 = ""; - dictionary2.TryGetValue(text, out value2); - Dictionary value3 = new Dictionary(); - dictionary.TryGetValue(text, out value3); - if (!value2.IsNullOrEmptyOrWhiteSpace()) - { - foreach (KeyValuePair item in dictionary4) - { - Field key = item.Key; - if (!key.FieldName.EqualsIgnoreCase("FBILLSEQ")) - { - decimal value4 = item.Value; - decimal num3 = default(decimal); - decimal num4 = default(decimal); - num3 = value3[key]; - num4 = value4 + num3; - value3[key] = num4; - } - } - - dictionary2[text] = dictionary2[text] + "," + num; - } - } - else - { - dictionary.Add(text, dictionary4); - dictionary2.Add(text, num.ToString()); - } - - num++; - } - - foreach (KeyValuePair item2 in dictionary2) - { - string key2 = item2.Key; - string value5 = item2.Value.Split(',').ToArray().FirstOrDefault(); - int num5 = Convert.ToInt32(value5); - Dictionary value6 = new Dictionary(); - dictionary.TryGetValue(key2, out value6); - foreach (KeyValuePair item3 in value6) - { - dybillCol[num5][item3.Key.PropertyName] = item3.Value; - } - - dynamicObjectCollection.Add(dybillCol[num5]); - if (Convert.ToInt64(dybillCol[num5]["Id"]) > 0) - { - MergeID.Add(dybillCol[num5]["SrcEntryId"]); - } - } - - if (_sFormId == "STK_Inventory") - { - DynamicObjectCollection dynamicObjectCollection2 = KUtil.Clone(dynamicObjectCollection); - dynamicObjectCollection2.Clear(); - for (int j = 0; j < listData.Count(); j++) - { - string text10 = Convert.ToString(listData[j].PrimaryKeyValue); - foreach (DynamicObject item4 in dynamicObjectCollection) - { - string text11 = item4["SrcEntryId"].ToString(); - if (text10 == text11) - { - dynamicObjectCollection2.Add(item4); - } - } - } - - dynamicObjectCollection = dynamicObjectCollection2; - } - - return dynamicObjectCollection; - } - - protected virtual DynamicObject[] GetSourceBillData(FormMetadata _billFormMetaData, List lstFieldKey, string sourceId, string sourceEntryId) - { - DynamicObject[] array = null; - if (_sFormId.EqualsIgnoreCase("STK_Inventory")) - { - object[] pkArray = ((IEnumerable)sourceId.Split(',')).ToArray(); - DynamicObject[] array2 = BusinessDataServiceHelper.Load(base.Context, pkArray, _billFormMetaData.BusinessInfo.GetDynamicObjectType()); - return BarCodeCommonServiceHelper.GetInventoryDatas(base.Context, array2); - } - - string pkFieldName = _billFormMetaData.BusinessInfo.GetForm().PkFieldName; - EnumPkFieldType pkFieldType = _billFormMetaData.BusinessInfo.GetForm().PkFieldType; - List list = new List(); - foreach (string item in lstFieldKey) - { - list.Add(new SelectorItemInfo(item)); - } - - string text = ""; - text = ((!pkFieldType.Equals(EnumPkFieldType.STRING)) ? $"{pkFieldName} IN ( {sourceId} )" : string.Format("{0} IN ( '{1}' )", pkFieldName, string.Join("','", sourceId.Split(',').ToList()))); - OQLFilter ofilter = OQLFilter.CreateHeadEntityFilter(text); - if (list.Count > 0) - { - return BusinessDataServiceHelper.Load(base.Context, _sFormId, list, ofilter); - } - - return BusinessDataServiceHelper.Load(base.Context, _sFormId, null, ofilter); - } - - private bool IsSubField(string fieldKey) - { - int num = fieldKey.IndexOf("^"); - if (num > 0) - { - return true; - } - - return false; - } - - private string GetBillBaseDataFieldKey(string fieldKey) - { - int num = fieldKey.IndexOf("^"); - if (num > 0) - { - return fieldKey.Substring(0, num); - } - - return fieldKey; - } - - private string GetBaseDataSubFieldKey(string fieldKey) - { - int num = fieldKey.IndexOf("^"); - if (num > 0) - { - return fieldKey.Substring(num + 1, fieldKey.Length - num - 1); - } - - return ""; - } - - private BusinessInfo GetFormBusinessInfo(string formId) - { - if (!_baseBusinessInfo.ContainsKey(formId)) - { - BusinessInfo businessInfo = (MetaDataServiceHelper.Load(base.View.Context, formId) as FormMetadata).BusinessInfo; - _baseBusinessInfo.Add(formId, businessInfo); - return businessInfo; - } - - return _baseBusinessInfo[formId]; - } - - private DynamicObject GetBaseDataDynamicObject(string formId, string pkId) - { - string key = $"{formId}#{pkId}"; - if (!_baseDataInfo.ContainsKey(key)) - { - BusinessInfo formBusinessInfo = GetFormBusinessInfo(formId); - DynamicObject dynamicObject = BusinessDataServiceHelper.LoadSingle(base.View.Context, pkId, formBusinessInfo, null); - _baseDataInfo.Add(key, dynamicObject); - return dynamicObject; - } - - return _baseDataInfo[key]; - } - - private object GetBaseDataSubFieldValue(DynamicObject dy, BusinessInfo info, string key) - { - object result = null; - Field field = info.GetField(key); - string entryName = field.Entity.EntryName; - if (dy.DynamicObjectType.Name == entryName) - { - result = field.DynamicProperty.GetValue(dy); - } - else if (dy.DynamicObjectType.Properties.Contains(entryName)) - { - DynamicObjectCollection dynamicObjectCollection = dy[entryName] as DynamicObjectCollection; - if (!dynamicObjectCollection.IsNullOrEmpty() && dynamicObjectCollection.Count > 0) - { - result = field.DynamicProperty.GetValue(dynamicObjectCollection[0]); - } - } - - return result; - } - - public DynamicObjectCollection GetDynamicRows(DynamicObject[] dySoruceObjsColl, DynamicObject dyRootSoruceObj, DynamicObjectCollection dybillCol, Dictionary DicFieldCorresMap, List lEntryNames, DynamicObjectType dotype, DynamicObject dybill, int iCurLevel, int iMaxLevel, string primaryField) - { - List list = new List(lEntryNames); - Dictionary dictionary = new Dictionary(DicFieldCorresMap); - DynamicObjectCollection dynamicObjectCollection = new DynamicObjectCollection(dotype); - bool flag = dyRootSoruceObj.IsNullOrEmptyOrWhiteSpace(); - decimal num = Convert.ToDecimal(dybill["Qty"]); - dynamicObjectCollection = dybillCol; - string text = string.Empty; - if (dySoruceObjsColl != null && dySoruceObjsColl.Count() > 0) - { - foreach (DynamicObject dynamicObject in dySoruceObjsColl) - { - DynamicObject newDynamicObject = GetNewDynamicObject(dybill); - if (flag) - { - dyRootSoruceObj = dynamicObject; - } - - object primaryValue = null; - int num2 = 0; - foreach (string lEntryName in lEntryNames) - { - if (!primaryField.IsNullOrEmptyOrWhiteSpace()) - { - if (dyRootSoruceObj.DynamicObjectType.Properties.Contains(lEntryName)) - { - num2++; - text = lEntryName; - list.Remove(lEntryName); - break; - } - } - else if (dynamicObject.DynamicObjectType.Properties.Contains(lEntryName)) - { - num2++; - text = lEntryName; - list.Remove(lEntryName); - } - } - - if (!primaryField.IsNullOrEmptyOrWhiteSpace() && (!new string[3] { "", "CardDetail", "Allocation" }.Contains(text) || list.Count() > 2)) - { - num2 = 2; - } - - if (num2 >= 2) - { - base.View.ShowWarnningMessage(ResManager.LoadKDString("在同一个条码规则中的条码属性字段,需要符合一定的规则才能生成条码打印数据:\r\n1、各属性字段都在同一个单据头,如单据头上的所有字段;\r\n2、各属性字段都在同一个单据体,例如物料明细上的所有字段;\r\n3、各属性字段虽然处于不同的单据头或单据体,但它们之间具有关联关系,例如 单据头+物料、单据头+物料+序列号、物料+序列号等。", "0011019000003272", SubSystemType.BASE)); - break; - } - - if (num2 == 1) - { - foreach (BarCodeBillCorrespondInfo item in DicFieldCorresMap.Values.ToList()) - { - string barCodeFieldKey = item.BarCodeFieldKey; - Field barCodeField = item.BarCodeField; - bool isBaseDataSubField = item.IsBaseDataSubField; - Field billField = item.BillField; - if (billField is MulBaseDataField || billField is MulAssistantField) - { - throw new Exception(string.Format(ResManager.LoadKDString("不支持多选资料字段({0})!", "4c6c1dcb8e6e4ea5", "APP_ISVPAAC2016062210550"), billField)); - } - - if (isBaseDataSubField) - { - if ((billField.Entity.IsNullOrEmpty() || dynamicObject.DynamicObjectType.Name.Equals(billField.Entity.EntryName) || dynamicObject.DynamicObjectType.Name.Equals(billField.Entity.DynamicObjectType.Name)) && dynamicObject.DynamicObjectType.Properties.Contains(billField.PropertyName) && !string.IsNullOrWhiteSpace(barCodeField.FieldName)) - { - string baseDataSubFieldKey = item.BaseDataSubFieldKey; - string formId = (billField as BaseDataField).LookUpObject.FormId; - BusinessInfo formBusinessInfo = GetFormBusinessInfo(formId); - DynamicObject dynamicObject2 = dynamicObject[billField.PropertyName] as DynamicObject; - string pkId = Convert.ToString(dynamicObject2["Id"]); - DynamicObject baseDataDynamicObject = GetBaseDataDynamicObject(formId, pkId); - object baseDataSubFieldValue = GetBaseDataSubFieldValue(dynamicObject2, formBusinessInfo, baseDataSubFieldKey); - newDynamicObject[barCodeField.PropertyName] = baseDataSubFieldValue; - dictionary.Remove(barCodeFieldKey); - if (baseDataSubFieldValue != null && dynamicObject.DynamicObjectType.Properties.Contains(billField.PropertyName + "_Id") && newDynamicObject.DynamicObjectType.Properties.Contains(barCodeField.PropertyName + "_Id")) - { - newDynamicObject[barCodeField.PropertyName + "_Id"] = (baseDataSubFieldValue as DynamicObject)["Id"]; - } - } - } - else - { - if ((!billField.Entity.IsNullOrEmpty() && !dynamicObject.DynamicObjectType.Name.Equals(billField.Entity.EntryName) && !dynamicObject.DynamicObjectType.Name.Equals(billField.Entity.DynamicObjectType.Name)) || !dynamicObject.DynamicObjectType.Properties.Contains(billField.PropertyName) || string.IsNullOrWhiteSpace(barCodeField.FieldName)) - { - continue; - } - - if (barCodeFieldKey.EqualsIgnoreCase(primaryField)) - { - primaryValue = dynamicObject[billField.PropertyName]; - } - - if (dynamicObject[billField.PropertyName] != null && dynamicObject[billField.PropertyName].GetType().Name.EqualsIgnoreCase("OrmLocaleValue")) - { - newDynamicObject[barCodeField.PropertyName] = dynamicObject[billField.PropertyName].ToString(); - } - else if (dynamicObject[billField.PropertyName] is DynamicObjectCollection) - { - DynamicObjectCollection dynamicObjectCollection2 = dynamicObject[billField.PropertyName] as DynamicObjectCollection; - DynamicObjectCollection dynamicObjectCollection3 = newDynamicObject[barCodeField.PropertyName] as DynamicObjectCollection; - if (dynamicObjectCollection3 == null) - { - dynamicObjectCollection3 = new DynamicObjectCollection(dynamicObjectCollection2.DynamicCollectionItemPropertyType); - newDynamicObject[barCodeField.PropertyName] = dynamicObjectCollection3; - } - - foreach (DynamicObject item2 in dynamicObjectCollection2) - { - dynamicObjectCollection3.Add(item2); - } - } - else - { - newDynamicObject[barCodeField.PropertyName] = dynamicObject[billField.PropertyName]; - } - - dictionary.Remove(barCodeFieldKey); - if (dynamicObject.DynamicObjectType.Properties.Contains(billField.PropertyName + "_Id") && newDynamicObject.DynamicObjectType.Properties.Contains(barCodeField.PropertyName + "_Id")) - { - newDynamicObject[barCodeField.PropertyName + "_Id"] = dynamicObject[billField.PropertyName + "_Id"]; - } - } - } - - if (!flag && newDynamicObject.DynamicObjectType.Properties.Contains("SrcEntryId") && dynamicObject.DynamicObjectType.Properties.Contains("Id") && !_sFormId.IsNullOrEmptyOrWhiteSpace() && (_sFormId != "SFC_OperationPlanning" || (dynamicObject.GetDataEntityType().Name.Equals("SubEntity") && _sFormId == "SFC_OperationPlanning")) && !string.Equals(_sFormId, "FA_CARD", StringComparison.OrdinalIgnoreCase)) - { - newDynamicObject["SrcEntryId"] = Convert.ToString(dynamicObject["Id"]); - } - - iCurLevel++; - if (iCurLevel > iMaxLevel) - { - iMaxLevel = iCurLevel; - } - - DynamicObjectCollection dynamicObjectCollection4 = null; - if (!primaryField.IsNullOrEmptyOrWhiteSpace()) - { - dynamicObjectCollection4 = (DynamicObjectCollection)dyRootSoruceObj[text]; - } - else - { - dynamicObjectCollection4 = (DynamicObjectCollection)dynamicObject[text]; - if (text == "SubEntity" && _sFormId == "SFC_OperationPlanning" && IsCheck == 1) - { - DynamicObject dynamicObject3 = dynamicObjectCollection4[0].Clone() as DynamicObject; - DynamicObjectCollection dynamicObjectCollection5 = new DynamicObjectCollection(dynamicObject3.DynamicObjectType); - int num3 = 0; - foreach (DynamicObject item3 in dynamicObjectCollection4) - { - string value = Convert.ToString(item3["id"]); - if (SelectRowId.Keys.Contains(value)) - { - dynamicObjectCollection5.Add(item3); - } - } - - dynamicObjectCollection4 = dynamicObjectCollection5; - } - } - - List list2 = dynamicObjectCollection4.ToList(); - if (!primaryValue.IsNullOrEmptyOrWhiteSpace()) - { - list2 = list2.Where((DynamicObject p) => p["AllocAssetNO"].ToString().EqualsIgnoreCase(primaryValue.ToString())).ToList(); - } - - GetDynamicRows(list2.ToArray(), dyRootSoruceObj, dynamicObjectCollection, dictionary, list, dotype, newDynamicObject, iCurLevel, iMaxLevel, primaryField); - iCurLevel--; - continue; - } - - foreach (BarCodeBillCorrespondInfo item4 in DicFieldCorresMap.Values.ToList()) - { - string barCodeFieldKey2 = item4.BarCodeFieldKey; - Field barCodeField2 = item4.BarCodeField; - bool isBaseDataSubField2 = item4.IsBaseDataSubField; - Field billField2 = item4.BillField; - if (billField2 is MulBaseDataField || billField2 is MulAssistantField) - { - throw new Exception(string.Format(ResManager.LoadKDString("不支持多选资料字段({0})!", "4c6c1dcb8e6e4ea5", "APP_ISVPAAC2016062210550"), billField2)); - } - - if (isBaseDataSubField2) - { - if ((billField2.Entity.IsNullOrEmpty() || dynamicObject.DynamicObjectType.Name.Equals(billField2.Entity.EntryName) || dynamicObject.DynamicObjectType.Name.Equals(billField2.Entity.DynamicObjectType.Name)) && dynamicObject.DynamicObjectType.Properties.Contains(billField2.PropertyName) && !string.IsNullOrWhiteSpace(barCodeField2.FieldName)) - { - string baseDataSubFieldKey2 = item4.BaseDataSubFieldKey; - string formId2 = (billField2 as BaseDataField).LookUpObject.FormId; - BusinessInfo formBusinessInfo2 = GetFormBusinessInfo(formId2); - DynamicObject dynamicObject4 = dynamicObject[billField2.PropertyName] as DynamicObject; - object baseDataSubFieldValue2; - if (dynamicObject4.DynamicObjectType.Properties.Contains(formBusinessInfo2.GetField(baseDataSubFieldKey2).PropertyName)) - { - baseDataSubFieldValue2 = GetBaseDataSubFieldValue(dynamicObject4, formBusinessInfo2, baseDataSubFieldKey2); - } - else - { - string pkId2 = Convert.ToString(dynamicObject4["Id"]); - DynamicObject baseDataDynamicObject2 = GetBaseDataDynamicObject(formId2, pkId2); - baseDataSubFieldValue2 = GetBaseDataSubFieldValue(baseDataDynamicObject2, formBusinessInfo2, baseDataSubFieldKey2); - } - - newDynamicObject[barCodeField2.PropertyName] = baseDataSubFieldValue2; - dictionary.Remove(barCodeFieldKey2); - if (dynamicObject.DynamicObjectType.Properties.Contains(billField2.PropertyName + "_Id") && newDynamicObject.DynamicObjectType.Properties.Contains(barCodeField2.PropertyName + "_Id") && baseDataSubFieldValue2 != null) - { - newDynamicObject[barCodeField2.PropertyName + "_Id"] = (baseDataSubFieldValue2 as DynamicObject)["Id"]; - } - } - } - else if ((billField2.Entity.IsNullOrEmpty() || dynamicObject.DynamicObjectType.Name.Equals(billField2.Entity.EntryName) || dynamicObject.DynamicObjectType.Name.Equals(billField2.Entity.DynamicObjectType.Name)) && dynamicObject.DynamicObjectType.Properties.Contains(billField2.PropertyName) && !string.IsNullOrWhiteSpace(barCodeField2.FieldName)) - { - if (dynamicObject[billField2.PropertyName] != null && dynamicObject[billField2.PropertyName].GetType().Name.EqualsIgnoreCase("OrmLocaleValue")) - { - newDynamicObject[barCodeField2.PropertyName] = dynamicObject[billField2.PropertyName].ToString(); - } - else - { - newDynamicObject[barCodeField2.PropertyName] = dynamicObject[billField2.PropertyName]; - } - - if (billField2 is LotField && barCodeField2 is LotField) - { - newDynamicObject[barCodeField2.PropertyName + "_Text"] = dynamicObject[billField2.PropertyName + "_Text"]; - } - - dictionary.Remove(barCodeFieldKey2); - if (dynamicObject.DynamicObjectType.Properties.Contains(billField2.PropertyName + "_Id") && newDynamicObject.DynamicObjectType.Properties.Contains(barCodeField2.PropertyName + "_Id")) - { - newDynamicObject[barCodeField2.PropertyName + "_Id"] = dynamicObject[billField2.PropertyName + "_Id"]; - } - } - } - - if (newDynamicObject.DynamicObjectType.Properties.Contains("SrcEntryId") && dynamicObject.DynamicObjectType.Properties.Contains("Id") && !_sFormId.IsNullOrEmptyOrWhiteSpace() && (_sFormId != "SFC_OperationPlanning" || (dynamicObject.GetDataEntityType().Name.Equals("SubEntity") && _sFormId == "SFC_OperationPlanning")) && _sFormId != "FA_CARD") - { - newDynamicObject["SrcEntryId"] = Convert.ToString(dynamicObject["Id"]); - } - - if (!primaryField.IsNullOrEmptyOrWhiteSpace() && dynamicObject.DynamicObjectType.Name.EqualsIgnoreCase("Allocation")) - { - newDynamicObject["Qty"] = num * Convert.ToDecimal(dynamicObject["AllocRatio"]) / 100m; - } - - SetBillEntryValueExtend(dynamicObject, newDynamicObject); - if (iCurLevel == iMaxLevel) - { - dynamicObjectCollection.Add(GetNewDynamicObject(newDynamicObject)); - } - } - } - else if (iCurLevel == iMaxLevel) - { - dynamicObjectCollection.Add(GetNewDynamicObject(dybill)); - } - - return dynamicObjectCollection; - } - - private void setInventoryField(DynamicObject dybill, DynamicObject dySoruceObjs, Field barcodeField, Field billField) - { - //IL_015b: Unknown result type (might be due to invalid IL or missing references) - //IL_0160: Unknown result type (might be due to invalid IL or missing references) - //IL_0169: Unknown result type (might be due to invalid IL or missing references) - //IL_0181: Unknown result type (might be due to invalid IL or missing references) - //IL_0199: Unknown result type (might be due to invalid IL or missing references) - //IL_01b3: Expected O, but got Unknown - if (billField is DateTimeField) - { - object value = dySoruceObjs[billField.PropertyName]; - if (value.IsNullOrEmptyOrWhiteSpace() && (barcodeField.FieldName.Equals("FPRODUCTIONDATE") || barcodeField.FieldName.Equals("FEXPIRATIONDATE")) && dySoruceObjs["Lot"] is DynamicObject dynamicObject) - { - if (barcodeField.FieldName.Equals("FPRODUCTIONDATE")) - { - dybill[barcodeField.PropertyName] = dynamicObject["HProduceDate"]; - } - - if (barcodeField.FieldName.Equals("FEXPIRATIONDATE")) - { - dybill[barcodeField.PropertyName] = dynamicObject["HExpiryDate"]; - } - } - } - else - { - if (!(billField is QtyField) || !(dySoruceObjs["MaterialID"] is DynamicObject dynamicObject2)) - { - return; - } - - DynamicObject dynamicObject3 = (dynamicObject2["MaterialStock"] as DynamicObjectCollection)[0]["StoreUnitID"] as DynamicObject; - DynamicObject dynamicObject4 = (dynamicObject2["MaterialBase"] as DynamicObjectCollection)[0]["BaseUnitId"] as DynamicObject; - GetUnitConvertRateArgs val = new GetUnitConvertRateArgs - { - PrimaryKey = 1L, - MasterId = Convert.ToInt64(dynamicObject2["msterID"]), - SourceUnitId = Convert.ToInt64(dynamicObject4["Id"]), - DestUnitId = Convert.ToInt64(dynamicObject3["Id"]) - }; - UnitConvert unitConvertRate = UnitConvertServiceHelper.GetUnitConvertRate(base.Context, val); - if (billField.Key.EqualsIgnoreCase("FQty")) - { - decimal num = decimal.Parse(dySoruceObjs["FBaseQty"].ToString()); - decimal num2 = unitConvertRate.ConvertQty(num, ""); - dybill[barcodeField.PropertyName] = num2; - } - else if (billField.Key.EqualsIgnoreCase("FAVBQty")) - { - decimal num3 = default(decimal); - InvQueryRetRecord val2 = StockServiceHelper.GetInventoryDatas(base.Context, dySoruceObjs["Id"].ToString(), base.Context.CurrentOrganizationInfo.ID).FirstOrDefault(); - if (val2 != null) - { - decimal num4 = val2.BaseQty - val2.BaseLockQty; - num3 = unitConvertRate.ConvertQty(num4, ""); - } - - dybill[barcodeField.PropertyName] = num3; - } - else if (billField.Key.EqualsIgnoreCase("FBaseAVBQty")) - { - decimal num5 = default(decimal); - InvQueryRetRecord val3 = StockServiceHelper.GetInventoryDatas(base.Context, dySoruceObjs["Id"].ToString(), base.Context.CurrentOrganizationInfo.ID).FirstOrDefault(); - if (val3 != null) - { - decimal num6 = val3.BaseQty - val3.BaseLockQty; - } - - dybill[barcodeField.PropertyName] = num5; - } - } - } - - public DynamicObject GetNewDynamicObject(DynamicObject dybill) - { - DynamicObject dynamicObject = new DynamicObject(dybill.DynamicObjectType); - foreach (DynamicProperty property in dybill.DynamicObjectType.Properties) - { - if (dybill[property] is DynamicObjectCollection) - { - DynamicObjectCollection dynamicObjectCollection = dybill[property] as DynamicObjectCollection; - DynamicObjectCollection dynamicObjectCollection2 = dynamicObject[property] as DynamicObjectCollection; - if (dynamicObjectCollection2 == null) - { - dynamicObjectCollection2 = (DynamicObjectCollection)(dynamicObject[property] = new DynamicObjectCollection(dynamicObjectCollection.DynamicCollectionItemPropertyType)); - } - - foreach (DynamicObject item in dynamicObjectCollection) - { - dynamicObjectCollection2.Add(item); - } - } - else - { - dynamicObject[property] = dybill[property]; - } - } - - return dynamicObject; - } - - protected virtual bool GetEnabled(string name) - { - bool result = false; - string strSQL = "SELECT FVALUE FROM T_BAS_SYSTEMPROFILE WHERE FCATEGORY = 'UNSN' AND FKEY = @name"; - List list = new List(); - list.Add(new SqlParam("@name", KDDbType.String, name)); - DynamicObjectCollection source = DBUtils.ExecuteDynamicObject(base.Context, strSQL, null, null, CommandType.Text, list.ToArray()); - if (source.Count() > 0) - { - result = true; - } - - return result; - } - - private Dictionary GetMaterialParamsfilednull(List materialIdlist) - { - Dictionary dictionary = new Dictionary(); - if (materialIdlist.Count() == 0) - { - materialIdlist.Add(0); - } - - string strSQL = string.Format("SELECT T1.FIsSNManage,T1.FISBATCHMANAGE,T1.FISKFPERIOD ,T1.FMATERIALID FROM \r\n (SELECT {0} FID FROM TABLE(fn_StrSplit(@list,',',1))SS) T0 INNER JOIN T_BD_MATERIALSTOCK T1 ON T1.FMATERIALID = T0.FID;", SCMCommonUtil.GetCardinalityString(base.Context, "SS", (long)materialIdlist.Count())); - SqlParam sqlParam = new SqlParam("@list", KDDbType.udt_inttable, materialIdlist.ToArray()); - DynamicObjectCollection dynamicObjectCollection = DBUtils.ExecuteDynamicObject(base.Context, strSQL, null, null, CommandType.Text, sqlParam); - foreach (DynamicObject item in dynamicObjectCollection) - { - int num = Convert.ToInt32(item["FMATERIALID"]); - if (!dictionary.Keys.Contains(num)) - { - dictionary.Add(num, item); - } - } - - return dictionary; - } - - private Dictionary GetMaterialParams(List materialIdlist) - { - Dictionary dictionary = new Dictionary(); - if (materialIdlist.Count() == 0) - { - materialIdlist.Add(0); - } - - string text = ""; - string arg = string.Join(",", materialIdlist); - text = $" SELECT S.FMATERIALID,S.FISSNMANAGE,S.FISBATCHMANAGE,S.FISKFPERIOD,P.FBOXQTY FROM T_BD_MATERIALSTOCK S\r\n INNER JOIN T_BD_MATERIALPURCHASE P ON S.FMATERIALID=P.FMATERIALID\r\n WHERE S.FMATERIALID in ({arg}) "; - DynamicObjectCollection dynamicObjectCollection = DBUtils.ExecuteDynamicObject(base.Context, text, null, null, CommandType.Text); - foreach (DynamicObject item in dynamicObjectCollection) - { - int num = Convert.ToInt32(item["FMATERIALID"]); - if (!dictionary.Keys.Contains(num)) - { - dictionary.Add(num, item); - } - } - - return dictionary; - } - - private void CreateBillRows(DynamicObjectCollection billDetils, EntryEntity entity, Dictionary DicFieldCorresMap) - { - bool flag = GetEnabled("BARCODE_PRINT_QUICKBIND"); - try - { - BarCodeSysParamsModel barCodeBillSystemParameters = BarCodeCommonServiceHelper.GetBarCodeBillSystemParameters(base.Context, base.Context.CurrentOrganizationInfo.ID, _sFormId); - FormMetadata formMetadata = (FormMetadata)MetaDataServiceHelper.Load(base.Context, "BD_MATERIAL"); - int num = Model.GetEntryRowCount("FEntityToBill"); - string value = base.View.Model.GetValue("FBARCODEMODEL").ToString(); - DynamicObject dynamicObject = base.View.Model.GetValue("FBarCodeRule") as DynamicObject; - DynamicObject dynamicObject2 = base.View.Model.GetValue("FBarCodeBoxRule") as DynamicObject; - DynamicObject dynamicObject3 = base.View.Model.GetValue("FBarCodeFieldRule") as DynamicObject; - DynamicObject dynamicObject4 = base.View.Model.GetValue("FCentreBoxRule") as DynamicObject; - DynamicObject dynamicObject5 = base.View.Model.GetValue("FBigBoxRule") as DynamicObject; - DynamicObject dObject = base.View.Model.GetValue("FBillId") as DynamicObject; - bool flag2 = false; - List source = null; - if (dObject != null && dObject.DynamicObjectType.Properties.Contains("MODELTYPEID") && dObject.DynamicObjectType.Properties.Contains("Id")) - { - flag2 = Convert.ToInt32(dObject["MODELTYPEID"]) == 400; - if (flag2) - { - source = (from p in base.View.BusinessInfo.GetEntity("FEntityToBill").Fields - select p as BaseDataField into p - where p != null - select p).ToList(); - } - } - - BarCodeLog.Info("CreateBillRows", "BatchCreateNewEntryRow"); - base.View.Model.BatchCreateNewEntryRow("FEntityToBill", billDetils.Count()); - BarCodeLog.Info("CreateBillRows", "BatchCreateNewEntryRow"); - Field field = formMetadata.BusinessInfo.GetField("FBoxQty"); - string value2 = ""; - bool flag3 = false; - object[] array = null; - List materialIdlist = new List(); - BarCodeBillCorrespondInfo barCodeBillCorrespondInfo = DicFieldCorresMap.Values.FirstOrDefault((BarCodeBillCorrespondInfo p) => p.BarCodeField.Key.EqualsIgnoreCase("FMaterialId")); - if (barCodeBillCorrespondInfo != null) - { - string fname = barCodeBillCorrespondInfo.BarCodeField.PropertyName + "_Id"; - array = billDetils.Select((DynamicObject p) => p[fname]).Distinct().ToArray(); - materialIdlist = billDetils.Select((DynamicObject p) => Convert.ToInt32(p[fname])).Distinct().ToList(); - } - - Dictionary dictionary = ((field == null) ? GetMaterialParamsfilednull(materialIdlist) : GetMaterialParams(materialIdlist)); - BaseDataField baseDataField = base.View.BusinessInfo.GetField("FMaterialId") as BaseDataField; - DynamicObject[] array2 = ((array == null) ? null : BusinessDataServiceHelper.Load(base.Context, array, baseDataField.RefFormDynamicObjectType)); - if (array2 == null || dictionary.Count() <= 0) - { - flag = false; - } - - List list = billDetils.ToList(); - if (_sFormId == "STK_Inventory") - { - DynamicObjectCollection dynamicObjectCollection = KUtil.Clone(billDetils); - dynamicObjectCollection.Clear(); - for (int i = 0; i < listData.Count(); i++) - { - string text = Convert.ToString(listData[i].PrimaryKeyValue); - foreach (DynamicObject item in list) - { - string text2 = item["SrcEntryId"].ToString(); - if (text2 == text) - { - dynamicObjectCollection.Add(item); - } - } - } - - list = dynamicObjectCollection.ToList(); - } - - foreach (DynamicObject item2 in list) - { - DynamicObject entityDataObject = base.View.Model.GetEntityDataObject(entity, num); - foreach (BarCodeBillCorrespondInfo value7 in DicFieldCorresMap.Values) - { - Field barCodeField = value7.BarCodeField; - if (barCodeField.DynamicProperty == null || !item2.DynamicObjectType.Properties.Contains(barCodeField.PropertyName)) - { - continue; - } - - try - { - if (barCodeField is LotField) - { - if ((barCodeField as LotField).InputModel != 0) - { - DynamicObject dynamicObject6 = null; - string value3 = string.Empty; - if (barCodeField.DynamicProperty.GetValue(item2) is DynamicObject) - { - dynamicObject6 = (DynamicObject)barCodeField.DynamicProperty.GetValue(item2); - } - - if (dynamicObject6 != null) - { - value3 = Convert.ToString(dynamicObject6["number"]); - } - - if (value3.IsNullOrEmptyOrWhiteSpace()) - { - value3 = Convert.ToString(item2[barCodeField.PropertyName + "_Text"]); - } - - if (dynamicObject != null && Convert.ToBoolean(dynamicObject["IsAutoFillFlot"]) && value3.IsNullOrEmptyOrWhiteSpace() && flag3) - { - value3 = DateTime.Now.ToString("yyyyMMdd"); - } - - base.View.Model.SetValue(barCodeField.Key, value3, num); - ((LotField)barCodeField).DynamicProperty.SetValue(entityDataObject, dynamicObject6); - ((LotField)barCodeField).RefIDDynamicProperty.SetValue(entityDataObject, item2[barCodeField.PropertyName + "_Id"]); - } - else if (item2.DynamicObjectType.Properties.Contains(barCodeField.PropertyName + "_Id")) - { - base.View.Model.SetItemValueByID(barCodeField.Key, item2[barCodeField.PropertyName + "_Id"], num); - } - } - else if (barCodeField is RelatedFlexGroupField) - { - DynamicObject dynamicObject7 = barCodeField.DynamicProperty.GetValue(item2) as DynamicObject; - if (flag) - { - if (Regex.IsMatch(item2[barCodeField.PropertyName + "_Id"].ToString(), "^[+-]?\\d*$")) - { - entityDataObject[barCodeField.PropertyName + "_Id"] = (dynamicObject7.IsNullOrEmptyOrWhiteSpace() ? ((object)0) : dynamicObject7["Id"]); - } - else - { - entityDataObject[barCodeField.PropertyName + "_Id"] = (dynamicObject7.IsNullOrEmptyOrWhiteSpace() ? "" : dynamicObject7["Id"]); - } - - entityDataObject[barCodeField.PropertyName] = dynamicObject7; - } - else if (Regex.IsMatch(item2[barCodeField.PropertyName + "_Id"].ToString(), "^[+-]?\\d*$")) - { - base.View.Model.SetItemValueByID(barCodeField.Key, dynamicObject7.IsNullOrEmptyOrWhiteSpace() ? ((object)0) : dynamicObject7["Id"], num); - } - else - { - base.View.Model.SetItemValueByID(barCodeField.Key, dynamicObject7.IsNullOrEmptyOrWhiteSpace() ? "" : dynamicObject7["Id"], num); - } - } - else - { - if (!barCodeField.Key.EqualsIgnoreCase("FMaterialId")) - { - base.View.Model.SetValue(barCodeField.Key, barCodeField.DynamicProperty.GetValue(item2), num); - } - - if (item2.DynamicObjectType.Properties.Contains(barCodeField.PropertyName + "_Id")) - { - DynamicObject dynamicObject8 = item2[barCodeField.PropertyName] as DynamicObject; - object baseDataId = item2[barCodeField.PropertyName + "_Id"]; - if (barCodeField.Key.EqualsIgnoreCase("FMaterialId") && Convert.ToInt32(baseDataId) > 0) - { - DynamicObject dynamicObject9 = (flag ? dictionary[Convert.ToInt32(baseDataId)] : GetMaterialParams(Convert.ToInt64(baseDataId), field)); - flag3 = Convert.ToBoolean(dynamicObject9["FISBATCHMANAGE"].Equals("1")); - if (field != null) - { - value2 = Convert.ToString(dynamicObject9["FBOXQTY"]); - } - } - - DynamicObject dynamicObject10 = null; - if (dynamicObject8 != null) - { - string name = ((BaseDataField)barCodeField).LookUpObject.Name; - string propertyName = ((BaseDataField)barCodeField).NumberProperty.PropertyName; - if (flag) - { - if (barCodeField.Key == "FMaterialId") - { - DynamicObject value4 = array2.Where((DynamicObject p) => Convert.ToInt32(p["Id"]) == Convert.ToInt32(baseDataId)).FirstOrDefault(); - entityDataObject["MaterialId"] = value4; - entityDataObject["MaterialId_Id"] = Convert.ToString(baseDataId); - } - else - { - base.View.Model.SetValue(barCodeField.Key, baseDataId, num); - } - } - else - { - base.View.Model.SetValue(barCodeField.Key, baseDataId, num); - } - } - else - { - base.View.Model.SetValue(barCodeField.Key, baseDataId, num); - } - } - } - - if (!flag2 || !barCodeField.Key.EqualsIgnoreCase("FBASEDATAID")) - { - continue; - } - - base.View.Model.SetValue("FBASEDATATYPE", dObject["Id"], num); - if (_sFormId == "BD_SerialMainFile" && dObject["Id"].ToString() == "BD_SerialMainFile") - { - DynamicObject value5 = BusinessDataServiceHelper.LoadSingle(base.View.Context, barCodeField.DynamicProperty.GetValue(item2), _billFormMetaData.BusinessInfo.GetDynamicObjectType()); - base.View.Model.SetValue("FSerialNo", value5, num); - } - - BaseDataField baseDataField2 = source.Where((BaseDataField p) => p.LookUpObject != null && p.LookUpObject.FormId.EqualsIgnoreCase(dObject["Id"].ToString())).FirstOrDefault(); - if (baseDataField2 == null) - { - continue; - } - - base.View.Model.SetValue(baseDataField2.Key, barCodeField.DynamicProperty.GetValue(item2), num); - DynamicObject dynamicObject11 = BusinessDataServiceHelper.LoadSingle(base.View.Context, barCodeField.DynamicProperty.GetValue(item2), _billFormMetaData.BusinessInfo.GetDynamicObjectType()); - if (dynamicObject11 == null) - { - continue; - } - - if (baseDataField2 is LotField) - { - if ((baseDataField2 as LotField).InputModel != 0) - { - string value6 = Convert.ToString(dynamicObject11["number"]); - base.View.Model.SetValue(baseDataField2.Key, value6, num); - ((LotField)baseDataField2).DynamicProperty.SetValue(entityDataObject, dynamicObject11); - ((LotField)baseDataField2).RefIDDynamicProperty.SetValue(entityDataObject, dynamicObject11["Id"]); - } - else - { - base.View.Model.SetItemValueByID(baseDataField2.Key, dynamicObject11["Id"], num); - } - } - else - { - base.View.Model.SetValue(baseDataField2.Key, dynamicObject11, num); - } - } - catch (Exception ex) - { - //UNWLogger.Error(base.Context, "BarCodePrint", barCodeField.Key + " error:" + ex.Message + ex.StackTrace, ex); - throw ex; - } - } - - CalcCreateNumber(num); - base.View.Model.SetValue("FBARCODEMODELToBill", value, num); - base.View.Model.SetValue("FSrcIndex", num, num); - if (dynamicObject != null) - { - base.View.Model.SetValue("FBARCODERULEToBill", dynamicObject, num); - } - - if (dynamicObject2 != null) - { - base.View.Model.SetValue("FBARCODEBOXRULEToBill", dynamicObject2, num); - } - - if (dynamicObject3 != null) - { - base.View.Model.SetValue("FBARCODEFIELDRULEToBill", dynamicObject3, num); - } - - if (dynamicObject4 != null) - { - base.View.Model.SetValue("FCentreBoxRuleTOBILL", dynamicObject4, num); - } - - if (dynamicObject5 != null) - { - base.View.Model.SetValue("FBigBoxRuleToBill", dynamicObject5, num); - } - - CalcCanCreateQty(num, barCodeBillSystemParameters); - if (field != null) - { - base.View.Model.SetValue("FBoxQty", value2, num); - } - - CalcCreateNumberExtend(num, item2); - num++; - } - - int entryRowCount = Model.GetEntryRowCount("FEntityToBill"); - for (int j = 0; j < entryRowCount; j++) - { - base.View.InvokeFieldUpdateService("FMaterialId", j); - } - } - catch (Exception ex2) - { - base.View.Model.DeleteEntryData("FEntityToBill"); - base.View.Model.DeleteEntryData("FEntityToBar"); - throw ex2; - } - - if (flag) - { - base.View.UpdateView("FEntityToBill"); - } - } - - private DynamicObject GetMaterialParams(long materialId, Field boxQtyValue) - { - string text = ""; - text = ((boxQtyValue != null) ? "SELECT S.FMATERIALID, S.FISSNMANAGE,S.FISBATCHMANAGE,S.FISKFPERIOD,P.FBOXQTY FROM T_BD_MATERIALSTOCK S\r\n INNER JOIN T_BD_MATERIALPURCHASE P ON S.FMATERIALID=P.FMATERIALID\r\n WHERE S.FMATERIALID=@materialId " : "select FIsSNManage,FISBATCHMANAGE,FISKFPERIOD from T_BD_MATERIALSTOCK where FMATERIALID=@materialId "); - List list = new List(); - list.Add(new SqlParam("@materialId", KDDbType.Int64, materialId)); - return DBUtils.ExecuteDynamicObject(base.Context, text, null, null, CommandType.Text, list.ToArray()).FirstOrDefault(); - } - - private void ModifyBillRow(DynamicObject detil, Dictionary DicFieldCorresMap, int RowIndex) - { - DynamicObject dObject = base.View.Model.GetValue("FBillId") as DynamicObject; - bool flag = false; - List source = null; - if (dObject != null && dObject.DynamicObjectType.Properties.Contains("MODELTYPEID") && dObject.DynamicObjectType.Properties.Contains("Id")) - { - flag = Convert.ToInt32(dObject["MODELTYPEID"]) == 400; - if (flag) - { - source = (from p in base.View.BusinessInfo.GetEntity("FEntityToBill").Fields - select p as BaseDataField into p - where p != null - select p).ToList(); - } - } - - foreach (BarCodeBillCorrespondInfo value in DicFieldCorresMap.Values) - { - Field barCodeField = value.BarCodeField; - if (barCodeField.DynamicProperty == null || !detil.DynamicObjectType.Properties.Contains(barCodeField.PropertyName)) - { - continue; - } - - try - { - if (barCodeField.Key.EqualsIgnoreCase("FMaterialId")) - { - if (detil.DynamicObjectType.Properties.Contains(barCodeField.PropertyName + "_Id")) - { - base.View.Model.SetValue(barCodeField.Key, detil[barCodeField.PropertyName + "_Id"], RowIndex); - } - else - { - base.View.Model.SetValue(barCodeField.Key, barCodeField.DynamicProperty.GetValue(detil), RowIndex); - } - } - else if (barCodeField is LotField) - { - if ((barCodeField as LotField).InputModel != 0) - { - DynamicObject dynamicObject = null; - string empty = string.Empty; - if (barCodeField.DynamicProperty.GetValue(detil) is DynamicObject) - { - dynamicObject = (DynamicObject)barCodeField.DynamicProperty.GetValue(detil); - } - - empty = ((dynamicObject == null) ? (detil.DynamicObjectType.Properties.Contains(barCodeField.PropertyName + "_Text") ? Convert.ToString(detil[barCodeField.PropertyName + "_Text"]) : " ") : Convert.ToString(dynamicObject["number"])); - base.View.Model.SetValue(barCodeField.Key, empty, RowIndex); - } - else if (detil.DynamicObjectType.Properties.Contains(barCodeField.PropertyName + "_Id")) - { - base.View.Model.SetValue(barCodeField.Key, detil[barCodeField.PropertyName + "_Id"], RowIndex); - } - } - else - { - base.View.Model.SetValue(barCodeField.Key, barCodeField.DynamicProperty.GetValue(detil), RowIndex); - if (detil.DynamicObjectType.Properties.Contains(barCodeField.PropertyName + "_Id")) - { - base.View.Model.SetValue(barCodeField.Key, detil[barCodeField.PropertyName + "_Id"], RowIndex); - } - } - - if (!flag || !barCodeField.Key.EqualsIgnoreCase("FBASEDATAID")) - { - continue; - } - - base.View.Model.SetValue("FBASEDATATYPE", dObject["Id"], RowIndex); - BaseDataField baseDataField = source.Where((BaseDataField p) => p.LookUpObject.FormId.EqualsIgnoreCase(dObject["Id"].ToString())).FirstOrDefault(); - if (baseDataField != null) - { - base.View.Model.SetValue(baseDataField.Key, barCodeField.DynamicProperty.GetValue(detil), RowIndex); - DynamicObject dynamicObject2 = BusinessDataServiceHelper.LoadSingle(base.View.Context, barCodeField.DynamicProperty.GetValue(detil), _billFormMetaData.BusinessInfo.GetDynamicObjectType()); - if (dynamicObject2 != null) - { - base.View.Model.SetValue(baseDataField.Key, dynamicObject2, RowIndex); - } - } - } - catch (Exception ex) - { - ex.StackTrace.ToString(); - } - } - } - - private void InitCustParam(InitializeEventArgs e) - { - int.TryParse((e.Paramter.GetCustomParameter("isFromBill") == null) ? string.Empty : e.Paramter.GetCustomParameter("isFromBill").ToString(), out _isFromBill); - int.TryParse((e.Paramter.GetCustomParameter("isFromPrintList") == null) ? string.Empty : e.Paramter.GetCustomParameter("isFromPrintList").ToString(), out _isFromPrintList); - if (_isFromBill == 1) - { - var ruleId = e.Paramter.GetCustomParameter("RuleId"); - _sFormId = ((e.Paramter.GetCustomParameter("SourceFormId") == null) ? "" : e.Paramter.GetCustomParameter("SourceFormId").ToString()); - _sourceId = ((e.Paramter.GetCustomParameter("SourceId") == null) ? "" : e.Paramter.GetCustomParameter("SourceId").ToString()); - _sRuleId = ((e.Paramter.GetCustomParameter("RuleId") != null) ? Convert.ToInt32(ruleId) : 0); - _billFormMetaData = (FormMetadata)MetaDataServiceHelper.Load(base.Context, _sFormId); - _sourceEntryId = ((e.Paramter.GetCustomParameter("SourceEntryId") == null) ? "" : e.Paramter.GetCustomParameter("SourceEntryId").ToString()); - _sEntityKey = ((e.Paramter.GetCustomParameter("EntityKey") == null) ? "" : e.Paramter.GetCustomParameter("EntityKey").ToString()); - listData = e.Paramter.GetCustomParameter("SelectedRows") as ListSelectedRowCollection; - base.View.Model.SetValue("FBillId", _sFormId); - base.View.Model.SetValue("FBarCodeRule", _sRuleId); - } - } - - public void SetComboField() - { - ComboFieldEditor comboFieldEditor = null; - comboFieldEditor = base.View.GetFieldEditor("FBarCodeModel", 0); - comboFieldEditor.SetComboItems(_noteTemplates); - comboFieldEditor = base.View.GetFieldEditor("FBarCodeBoxModel", 0); - comboFieldEditor.SetComboItems(_noteTemplates); - comboFieldEditor = base.View.GetFieldEditor("FCenterBoxModel", 0); - comboFieldEditor.SetComboItems(_noteTemplates); - comboFieldEditor = base.View.GetFieldEditor("FBigBoxModel", 0); - comboFieldEditor.SetComboItems(_noteTemplates); - } - - public void OpenBarCodeGetBill() - { - if (string.IsNullOrEmpty(_sFormId)) - { - base.View.ShowWarnningMessage(ResManager.LoadKDString("请先录入源业务对象!", "0011019000003167", SubSystemType.BASE)); - return; - } - - string text = _sFormId; - if (text.EqualsIgnoreCase("BD_OverASerialView")) - { - text = "BD_SerialMainFile"; - } - - //List permissionOrg = PermissionServiceHelper.GetPermissionOrg(base.View.Context, new BusinessObject - //{ - // Id = text - //}, "6e44119a58cb4a8e86f6c385e14a17ad"); - //if (!permissionOrg.Contains(base.Context.CurrentOrganizationInfo.ID)) - //{ - // base.View.ShowWarnningMessage(ResManager.LoadKDString("当前组织下没有源业务对象的查看权限,不允许选单!", "0011019000003231", SubSystemType.BASE)); - // return; - //} - - if (_sRuleId == 0) - { - base.View.ShowWarnningMessage(ResManager.LoadKDString("请先录入默认条码规则!", "0011019000003092", SubSystemType.BASE)); - return; - } - - if (_isAutoPacking && _sBoxRuleId == 0) - { - base.View.ShowWarnningMessage(ResManager.LoadKDString("请先录入默认包装条码规则!", "58d194b2aae944ca", "APP_ISVPAAC2016062210550")); - return; - } - - if (_isThreePacking && _sCenterBoxRuleId == 0) - { - base.View.ShowWarnningMessage(ResManager.LoadKDString("当前为三层装箱,请先录入中包条码规则!", "821ceb6207164fb8", "APP_ISVPAAC2016062210550")); - return; - } - - ListShowParameter listShowParameter = new ListShowParameter(); - billPageId = SequentialGuid.NewGuid().ToString(); - listShowParameter.IsLookUp = true; - listShowParameter.ParentPageId = base.View.PageId; - listShowParameter.FormId = _sFormId; - listShowParameter.MultiSelect = true; - listShowParameter.PageId = billPageId; - listShowParameter.IsIsolationOrg = true; - listShowParameter.UseOrgId = base.Context.CurrentOrganizationInfo.ID; - if (_sFormId.EqualsIgnoreCase("BD_MATERIAL")) - { - listShowParameter.ListType = Convert.ToInt32(BOSEnums.Enu_ListType.BaseList); - } - - if (_sFormId.EqualsIgnoreCase("ENG_WorkCenter")) - { - listShowParameter.CustomParams.Add("WorkCenterType", "D"); - } - - if (_sFormId.EqualsIgnoreCase("STK_Inventory")) - { - listShowParameter.CustomParams.Add("NeedReturnData", "1"); - listShowParameter.CustomParams.Add("IsFromStockQuery", "True"); - listShowParameter.CustomParams.Add("QueryMode", "1"); - listShowParameter.CustomParams.Add("IsShowExit", "True"); - listShowParameter.CustomParams.Add("IsFromQuery", "True"); - } - - - string text2 = string.Empty; - List list = new List(); - list.Add("PUR_PurchaseOrder"); - list.Add("SAL_SaleOrder"); - list.Add("SAL_DELIVERYNOTICE"); - if (list.Contains(_sFormId)) - { - text2 = " t0.FCLOSESTATUS='A' "; - } - - if (_sFormId == "PRD_MO") - { - text2 = " t1_A.FSTATUS!=6 "; - } - - if (_sFormId == "SUB_SUBREQORDER") - { - text2 = " t1.FSTATUS!=6 "; - } - - if (_sFormId == "STK_LOTADJUST") - { - text2 += (text2.IsNullOrEmptyOrWhiteSpace() ? " FConvertType='B' " : " AND FConvertType='B' "); - } - - if (_sFormId == "FA_CARD") - { - text2 = "FISNEWREC=2"; - } - - if (_sFormId.EqualsIgnoreCase("UHIK_PRD_PACKAGE_INSTOCK")) - { - text2 = @" -FDocumentStatus = 'C' And FProductType = '1' - AND ( Exists ( - SELECT 1 FROM T_PLN_FORECAST et0 - INNER JOIN T_PLN_FORECASTENTRY et0e on et0.FID = et0e.FID - INNER JOIN T_PRD_MOENTRY et1e on et1e.FSALEORDERENTRYSEQ = et0e.FSEQ AND et1e.FSALEORDERNO = et0.FBILLNO - WHERE et0e.FPARENTROWID = t1.FROWID - )) -"; - } - if (!string.IsNullOrWhiteSpace(text2)) - { - if (string.IsNullOrEmpty(listShowParameter.ListFilterParameter.Filter)) - { - listShowParameter.ListFilterParameter.Filter = text2; - } - else - { - IRegularFilterParameter listFilterParameter = listShowParameter.ListFilterParameter; - listFilterParameter.Filter = listFilterParameter.Filter + " AND " + text2; - } - } - - base.View.ShowForm(listShowParameter, delegate (FormResult result) - { - if (result != null) - { - ApplyReturnData(result.ReturnData); - } - }); - } - - protected virtual bool ChooseBillCtrl(string formId) - { - return false; - } - - private void ApplyReturnData(object ret) - { - if (ret == null) - { - return; - } - - if (!(ret is ListSelectedRowCollection)) - { - return; - } - - SelectRowId = new Dictionary(); - listData = ret as ListSelectedRowCollection; - List list = new List(); - foreach (ListSelectedRow listDatum in listData) - { - if (listDatum.Selected && listDatum.PrimaryKeyValue != null && !string.IsNullOrWhiteSpace(listDatum.PrimaryKeyValue)) - { - list.Add(listDatum.PrimaryKeyValue); - } - - if (_sFormId == "SFC_OperationPlanning" && listDatum.DataRow != null) - { - IsCheck = 1; - DynamicObject dynamicObject = ((DynamicObjectDataRow)listDatum.DataRow).DynamicObject; - if (!SelectRowId.Keys.Contains(Convert.ToString(dynamicObject["t2_FDETAILID"]))) - { - SelectRowId.Add(Convert.ToString(dynamicObject["t2_FDETAILID"]), "t2_FDETAILID"); - } - } - } - - if (list != null && list.Count() >= 1) - { - _sourceId = string.Join(",", list); - _isFromBill = 1; - _billFormMetaData = (FormMetadata)MetaDataServiceHelper.Load(base.Context, _sFormId); - BindBillData(); - } - //拓展功能--返回源单单号-2025-4-8 - DynamicObject billtype = base.View.Model.GetValue("FBillId") as DynamicObject; - string formid = billtype["Id"].ToString(); - if (formid == "PUR_ReceiveBill") - { - int j = 1; - DynamicObject dobject = this.View.Model.DataObject; - DynamicObjectCollection entityObjs = dobject["BD_BARCODEPRINTENTRYBILL"] as DynamicObjectCollection; - foreach (dynamic obj in entityObjs) - { - string strSQL = string.Format(@"select FBILLNO,FSEQ,FSRCBILLNO from T_PUR_ReceiveEntry t1 -left join T_PUR_Receive t2 on t1.FID = t2.FID -join T_PUR_RECEIVEENTRY_L t3 on t1.FENTRYID = t3.FENTRYID -where FBILLNO = '{0}' and FSEQ = '{1}'", obj["BILLCODE"].ToString(), obj["BILLSEQ"].ToString()); - DynamicObjectCollection res = DBUtils.ExecuteDynamicObject(base.Context, strSQL, null, null, CommandType.Text); - if (res.Count > 0) - { - DynamicObject srcObject = res.FirstOrDefault(); - string text = Convert.ToString(srcObject["FSRCBILLNO"]); - this.View.Model.SetValue("FSRCBillNo", text, j - 1); - j++; - } - } - } - if (formid == "PRD_MORPT") - { - int j = 1; - DynamicObject dobject = this.View.Model.DataObject; - DynamicObjectCollection entityObjs = dobject["BD_BARCODEPRINTENTRYBILL"] as DynamicObjectCollection; - foreach (dynamic obj in entityObjs) - { - string strSQL = string.Format(@"select FBILLNO,FSEQ,FMOBILLNO,F_VHUB_TEXT from T_PRD_MORPTENTRY t1 -left join T_PRD_MORPT t2 on t1.FID = t2.FID -where FBILLNO = '{0}' and FSEQ = '{1}'", obj["BILLCODE"].ToString(), obj["BILLSEQ"].ToString()); - DynamicObjectCollection res = DBUtils.ExecuteDynamicObject(base.Context, strSQL, null, null, CommandType.Text); - if (res.Count > 0) - { - DynamicObject srcObject = res.FirstOrDefault(); - string mo = Convert.ToString(srcObject["FMOBILLNO"]); - string sn = Convert.ToString(srcObject["F_VHUB_TEXT"]); - this.View.Model.SetValue("FSRCBillNo", mo, j - 1); - this.View.Model.SetValue("FFSerialNoText", sn, j - 1); - j++; - } - } - } - ////拓展功能--返回源单单号 - } - - private bool CheckSelectRows() - { - EntryEntity entity = (EntryEntity)base.View.BusinessInfo.GetEntity("FEntityToBill"); - DynamicObjectCollection source = (from p in base.View.Model.GetEntityDataObject(entity) - where p["BillCheckBox"].ToString().EqualsIgnoreCase("True") - select p) as DynamicObjectCollection; - if (source.Count() > 1) - { - return true; - } - - return false; - } - - private void WriteBackBarcodeToBill() - { - string empty = string.Empty; - Entity entity = base.View.BusinessInfo.GetEntity("FEntityToBar"); - DynamicObjectCollection entityDataObject = base.View.Model.GetEntityDataObject(entity); - IEnumerable> enumerable = from b in entityDataObject - group b by b["BILLCODEToBar"]; - if (_billFormMetaData == null) - { - _billFormMetaData = (FormMetadata)MetaDataServiceHelper.Load(base.Context, Convert.ToString(_sFormId)); - BindBillData(); - } - - Field billNoField = _billFormMetaData.BusinessInfo.GetBillNoField(); - if (billNoField.IsNullOrEmptyOrWhiteSpace()) - { - return; - } - - foreach (IGrouping item in enumerable) - { - DynamicObject dynamicObject = null; - foreach (DynamicObject item2 in item.ToList()) - { - DynamicObject doRule = item2["BarCodeRule"] as DynamicObject; - string barcodeWriteBackKey = GetBarcodeWriteBackKey(doRule); - if (barcodeWriteBackKey.IsNullOrEmptyOrWhiteSpace()) - { - continue; - } - - Field field = _billFormMetaData.BusinessInfo.GetField(barcodeWriteBackKey); - string text = string.Empty; - string text2 = string.Empty; - if (field != null) - { - text = field.PropertyName; - text2 = field.Entity.EntryName; - } - - string text3 = string.Empty; - string operNum = string.Empty; - if (_sFormId.EqualsIgnoreCase("SFC_OperationPlanning") && field.Entity is SubEntryEntity) - { - text3 = (field.Entity as SubEntryEntity).ParentEntity.EntryName; - operNum = Convert.ToString(item2["OperNumberToBar"]); - } - - if (text.IsNullOrEmptyOrWhiteSpace()) - { - continue; - } - - string arg = Convert.ToString(item2["BILLCODEToBar"]); - int seq = Convert.ToInt32(item2["BillSeqToBar"]); - string value = Convert.ToString(item2["BarCode"]); - if (dynamicObject == null) - { - string empty2 = string.Empty; - empty2 = ((!_sFormId.Equals("FA_CARD")) ? $"{billNoField.Key} = '{arg}' " : $"{billNoField.Key} = '{arg}' AND FISNEWREC= '2' "); - OQLFilter ofilter = OQLFilter.CreateHeadEntityFilter(empty2); - dynamicObject = BusinessDataServiceHelper.Load(base.Context, _sFormId, null, ofilter).FirstOrDefault(); - } - - if (seq > 0) - { - if (text2.IsNullOrEmptyOrWhiteSpace()) - { - continue; - } - - if (dynamicObject.Contains(text2) && dynamicObject[text2] != null && (dynamicObject[text2] as DynamicObjectCollection).FirstOrDefault() != null && (dynamicObject[text2] as DynamicObjectCollection)[seq - 1].Contains(text) && (dynamicObject[text2] as DynamicObjectCollection).FirstOrDefault().Contains("Seq")) - { - List source = (dynamicObject[text2] as DynamicObjectCollection).ToList(); - DynamicObject dynamicObject2 = source.Where((DynamicObject u) => Convert.ToString(u["Seq"]) == seq.ToString()).FirstOrDefault(); - dynamicObject2[text] = value; - } - else if (dynamicObject.Contains(text2) && dynamicObject[text2] != null && (dynamicObject[text2] as DynamicObjectCollection)[seq - 1] != null && (dynamicObject[text2] as DynamicObjectCollection)[seq - 1].Contains(text)) - { - (dynamicObject[text2] as DynamicObjectCollection)[seq - 1][text] = value; - } - else - { - if (!_sFormId.EqualsIgnoreCase("SFC_OperationPlanning") || !(field.Entity is SubEntryEntity) || !dynamicObject.Contains(text3) || operNum.IsNullOrEmptyOrWhiteSpace() || (dynamicObject[text3] as DynamicObjectCollection).Count() < seq - 1 || (dynamicObject[text3] as DynamicObjectCollection)[seq - 1] == null || !(dynamicObject[text3] as DynamicObjectCollection)[seq - 1].Contains(text2)) - { - continue; - } - - DynamicObjectCollection source2 = (dynamicObject[text3] as DynamicObjectCollection)[seq - 1][text2] as DynamicObjectCollection; - DynamicObject dynamicObject3 = source2.Where((DynamicObject p) => Convert.ToString(p["OperNumber"]).Equals(operNum)).FirstOrDefault(); - int num = 0; - if (dynamicObject3 != null && dynamicObject3.Contains("Seq")) - { - num = Convert.ToInt32(dynamicObject3["Seq"]); - if (num > 0) - { - ((dynamicObject[text3] as DynamicObjectCollection)[seq - 1][text2] as DynamicObjectCollection)[num - 1][text] = value; - } - } - } - } - else if (dynamicObject.Contains(text)) - { - dynamicObject[text] = value; - } - } - - if (dynamicObject != null) - { - BusinessDataServiceHelper.Save(base.Context, dynamicObject); - } - } - } - - private string GetBarcodeWriteBackKey(DynamicObject doRule) - { - string result = string.Empty; - if (doRule != null) - { - DynamicObjectCollection dynamicObjectCollection = doRule["BD_BARCODERULEENTRYToBill"] as DynamicObjectCollection; - foreach (DynamicObject item in dynamicObjectCollection) - { - string str = Convert.ToString(item["BillId_Id"]); - if (str.EqualsIgnoreCase(_sFormId)) - { - string text = Convert.ToString(item["FieldKey"]); - if (!text.IsNullOrEmptyOrWhiteSpace()) - { - result = text; - } - - break; - } - } - } - - return result; - } - - public void SetBarCodeValue(List>>> AllBoxContrastNumbers, List>> securityCodes, string sType, List>>> fieldCodes, Dictionary qtyDic, List>> BarCodeCorrespondings, List existedNumbers = null) - { - SetBarCodeValue(AllBoxContrastNumbers, securityCodes, sType, fieldCodes, qtyDic, BarCodeCorrespondings, 0, existedNumbers); - } - - public void SetBarCodeValue(List>>> AllBoxContrastNumbers, List>> securityCodes, string sType, List>>> fieldCodes, Dictionary qtyDic, List>> BarCodeCorrespondings, int billIndex, List existedNumbers = null) - { - BarCodeSysParamsModel barCodeBillSystemParameters = BarCodeCommonServiceHelper.GetBarCodeBillSystemParameters(base.Context, base.Context.CurrentOrganizationInfo.ID, _sFormId); - //UNWLogger.Info(base.Context, "SetBarCodeValue", string.Format(ResManager.LoadKDString("生成条码分录数据开始", "c40bc32ce96a4219", "APP_ISVPAAC2016062210550"))); - EntryEntity entryEntity = (EntryEntity)base.View.BusinessInfo.GetEntity("FEntityToBill"); - DynamicObject[] array = (from p in base.View.Model.GetEntityDataObject(entryEntity) - where p["BillCheckBox"].ToString().EqualsIgnoreCase("True") - select p).ToArray(); - List fields = entryEntity.Fields; - string strFilter = $" FID='{_sRuleId}' "; - OQLFilter ofilter = OQLFilter.CreateHeadEntityFilter(strFilter); - DynamicObject dynamicObject = BusinessDataServiceHelper.Load(base.Context, "BD_BarCodeRule", null, ofilter).FirstOrDefault(); - DynamicObjectCollection source = dynamicObject["BD_BARCODERULEENTRY"] as DynamicObjectCollection; - List list = source.OrderBy((DynamicObject p) => p["Seq"]).ToList(); - EntryEntity entryEntity2 = (EntryEntity)base.View.BusinessInfo.GetEntity("FEntityToBar"); - List fields2 = entryEntity2.Fields; - Dictionary dictionary = new Dictionary(); - foreach (DynamicObject item in list) - { - string barcodeFieldkey = (item["BarCodePropertyId"] as DynamicObject)["BARCODEFIELDKEY"].ToString(); - Field field = fields2.FirstOrDefault((Field p) => p.FieldName.EqualsIgnoreCase(barcodeFieldkey)); - if (field != null && (!dictionary.Keys.Contains(field) || field.Key.EqualsIgnoreCase("FBarCodeRuleToBar") || field.Key.EqualsIgnoreCase("FBarCodeModelToBar") || field.Key.EqualsIgnoreCase("FDetailBillCodeToBar"))) - { - dictionary.Add(field, fields.Where((Field p) => p.FieldName.EqualsIgnoreCase(field.FieldName)).FirstOrDefault()); - } - } - - int num = 0; - List list2 = null; - List list3 = new List(); - StringBuilder stringBuilder = new StringBuilder(); - List list4 = new List(); - List list5 = new List(); - int num2 = 0; - decimal num3 = default(decimal); - int num4 = 0; - int num5 = _proIncrement; - int num6 = 1; - if (AllBoxContrastNumbers.Count() > 0) - { - num5 = _proIncrement / AllBoxContrastNumbers.Count(); - } - - if (num5 <= 0) - { - num5 = 1; - num6 = AllBoxContrastNumbers.Count() / _proIncrement; - } - - int num7 = 0; - int barRowCount = 0; - if (sType.Equals("TBCREBARCODEROW")) - { - AllBoxContrastNumbers.ForEach(delegate (KeyValuePair>> p) - { - p.Value.ToList().ForEach(delegate (KeyValuePair> k) - { - barRowCount += k.Value.Where((string j) => !j.IsNullOrEmptyOrWhiteSpace()).Count() + ((!k.Key.IsNullOrEmptyOrWhiteSpace()) ? 1 : 0); - }); - }); - } - else - { - AllBoxContrastNumbers.ForEach(delegate (KeyValuePair>> p) - { - p.Value.Distinct().ToList().ForEach(delegate (KeyValuePair> k) - { - barRowCount += (from j in k.Value.Distinct() - where !j.IsNullOrEmptyOrWhiteSpace() - select j).Count() + ((!k.Key.IsNullOrEmptyOrWhiteSpace()) ? 1 : 0); - }); - }); - } - - base.View.Model.BatchCreateNewEntryRow("FEntityToBar", barRowCount); - bool enabled = GetEnabled("BARCODE_PRINT_QUICKGENER"); - DynamicObjectCollection dynamicObjectCollection = (DynamicObjectCollection)Model.DataObject["BD_BARCODEPRINTENTRYBAR"]; - num = Model.GetEntryCurrentRowIndex("FEntityToBar"); - //尾行数量处理--2025-04-18 - decimal qtyCount = 0; - - foreach (KeyValuePair>> AllBoxContrastNumber in AllBoxContrastNumbers) - { - Dictionary> value = AllBoxContrastNumber.Value; - int num8 = value.Where((KeyValuePair> p) => !p.Key.IsNullOrEmptyOrWhiteSpace()).ToList().Count(); - Dictionary value2 = securityCodes[AllBoxContrastNumber.Key].Value; - List value3 = BarCodeCorrespondings[AllBoxContrastNumber.Key].Value; - Dictionary> dictionary2 = null; - if (fieldCodes != null && fieldCodes.Count() > AllBoxContrastNumber.Key) - { - dictionary2 = fieldCodes[AllBoxContrastNumber.Key].Value; - } - - int num9 = num5; - int num10 = 1; - if (num8 > 0) - { - num9 = num5 / num8; - } - - if (num9 <= 0) - { - num9 = 1; - num10 = num8 / num5; - } - - int num11 = 0; - int num12 = 0; - foreach (KeyValuePair> item2 in value) - { - DynamicObject dynamicObject2 = null; - int num13 = -1; - decimal num14 = default(decimal); - if (billIndex >= array.Count()) - { - break; - } - - dynamicObject2 = array[billIndex]; - if (billIndex == AllBoxContrastNumber.Key) - { - List value4 = item2.Value; - int num15 = value4.Distinct().Count(); - if ((num15 <= 1 || num15 != value4.Count) && sType.Equals("TBCREBARCODEROW") && num15 != 1) - { - } - } - - if (item2.Value != null) - { - list2 = ((!sType.Equals("TBCREBARCODEROW")) ? (from p in item2.Value.Distinct() - where !p.IsNullOrEmptyOrWhiteSpace() - select p).ToList() : item2.Value.Where((string p) => !p.IsNullOrEmptyOrWhiteSpace()).ToList()); - bool flag = false; - if (!item2.Key.IsNullOrEmptyOrWhiteSpace()) - { - list2.Insert(0, item2.Key); - flag = true; - } - - int num16 = list2.Where((string p) => !p.IsNullOrEmptyOrWhiteSpace()).ToList().Count(); - int num17 = num9; - int num18 = 1; - if (num16 > 0) - { - num17 = num9 / num16; - } - - if (num17 <= 0) - { - num17 = 1; - num18 = num16 / num9; - } - - int num19 = 0; - List list6 = new List(); - //if (!flag && !barCodeBillSystemParameters.FThreeLevelPacking && !barCodeBillSystemParameters.FBarcodeOrderType.Equals("1")) - //{ - // list2.Sort(); - //} - if (!flag && !barCodeBillSystemParameters.FThreeLevelPacking) - { - list2.Sort(); - } - - foreach (string barcode in list2) - { - if (barcode.IsNullOrEmptyOrWhiteSpace()) - { - continue; - } - - string value5 = (value2.IsNullOrEmptyOrWhiteSpace() ? "" : (from q in value2 - where q.Key == barcode - select q.Value).FirstOrDefault()); - BarCodeCorrespondingValue val = value3?.Where((BarCodeCorrespondingValue p) => p.BarCode == barcode).FirstOrDefault(); - num2++; - Dictionary dictionary3 = new Dictionary(); - if (dictionary2 != null && dictionary2.ContainsKey(barcode)) - { - dictionary3 = dictionary2[barcode]; - } - - if (list3 == null || (list3 != null && !list3.Contains(barcode))) - { - foreach (KeyValuePair item3 in dictionary) - { - Field key = item3.Key; - Field field2 = dictionary[key]; - if (field2 == null || field2.DynamicProperty == null) - { - continue; - } - - if (field2 is LotField) - { - if ((field2 as LotField).InputModel != 0) - { - DynamicObject dynamicObject3 = null; - string value6 = string.Empty; - if (field2.DynamicProperty.GetValue(dynamicObject2) is DynamicObject) - { - dynamicObject3 = (DynamicObject)field2.DynamicProperty.GetValue(dynamicObject2); - } - - if (dynamicObject3 != null) - { - value6 = Convert.ToString(dynamicObject3["number"]); - } - else if (dynamicObject2.DynamicObjectType.Properties.Contains(field2.PropertyName + "_Text")) - { - value6 = Convert.ToString(dynamicObject2[field2.PropertyName + "_Text"]); - } - - if (dynamicObject3 != null) - { - (base.View.Model.DataObject["BD_BARCODEPRINTENTRYBAR"] as DynamicObjectCollection)[num]["LotToBar"] = dynamicObject3; - (base.View.Model.DataObject["BD_BARCODEPRINTENTRYBAR"] as DynamicObjectCollection)[num]["LotToBar_Id"] = dynamicObject3["Id"]; - (base.View.Model.DataObject["BD_BARCODEPRINTENTRYBAR"] as DynamicObjectCollection)[num]["LotToBar_Text"] = dynamicObject3["Number"]; - } - else - { - base.View.Model.SetValue(key.Key, value6, num); - } - } - else if (dynamicObject2.DynamicObjectType.Properties.Contains(field2.PropertyName + "_Id")) - { - base.View.Model.SetValue(key.Key, dynamicObject2[field2.PropertyName + "_Id"], num); - } - } - else if (field2 is RelatedFlexGroupField) - { - if (Regex.IsMatch(dynamicObject2[field2.PropertyName + "_Id"].ToString(), "^[+-]?\\d*$")) - { - DynamicObject dynamicObject4 = field2.DynamicProperty.GetValue(dynamicObject2) as DynamicObject; - dynamicObjectCollection[num][key.PropertyName] = dynamicObject4; - if (dynamicObject4 != null) - { - dynamicObjectCollection[num][key.PropertyName + "_Id"] = dynamicObject4["Id"]; - } - - base.View.InvokeFieldUpdateService(key.Key, num); - continue; - } - - DynamicObject dynamicObject5 = field2.DynamicProperty.GetValue(dynamicObject2) as DynamicObject; - if (enabled) - { - dynamicObjectCollection[num][key.PropertyName] = dynamicObject5; - if (dynamicObject5 != null) - { - dynamicObjectCollection[num][key.PropertyName + "_Id"] = dynamicObject5["Id"]; - } - } - else - { - base.View.Model.SetItemValueByID(key.Key, dynamicObject5.IsNullOrEmptyOrWhiteSpace() ? "" : dynamicObject5["Id"], num); - } - } - else if (enabled) - { - dynamicObjectCollection[num][key.PropertyName] = dynamicObject2[field2.PropertyName]; - if (dynamicObject2.DynamicObjectType.Properties.Contains(field2.PropertyName + "_Id") && !dynamicObject2[field2.PropertyName + "_Id"].IsNullOrEmptyOrWhiteSpace()) - { - dynamicObjectCollection[num][key.PropertyName + "_Id"] = dynamicObject2[field2.PropertyName + "_Id"]; - } - } - else - { - base.View.Model.SetValue(key.Key, field2.DynamicProperty.GetValue(dynamicObject2), num); - if (dynamicObject2.DynamicObjectType.Properties.Contains(field2.PropertyName + "_Id") && !dynamicObject2[field2.PropertyName + "_Id"].IsNullOrEmptyOrWhiteSpace()) - { - base.View.Model.SetItemValueByID(key.Key, dynamicObject2[field2.PropertyName + "_Id"], num); - } - } - } - - foreach (KeyValuePair fieldCodeKV in dictionary3) - { - Field field3 = fields2.FirstOrDefault((Field p) => p.FieldName.EqualsIgnoreCase(fieldCodeKV.Key)); - if (field3 != null) - { - base.View.Model.SetValue(field3.Key, fieldCodeKV.Value, num); - } - } - - if (enabled) - { - dynamicObjectCollection[num]["BarCode"] = barcode; - dynamicObjectCollection[num]["SecurityCode"] = value5; - } - else - { - base.View.Model.SetValue("FBARCODE", barcode, num); - base.View.Model.SetValue("FDOCUMENTSTATUS", "", num); - base.View.Model.SetValue("FSecurityCode", value5, num); - } - - if (val != null) - { - if (enabled) - { - dynamicObjectCollection[num]["RandomCode"] = val.RandomCode; - dynamicObjectCollection[num]["FLowNo"] = val.FlowNo; - dynamicObjectCollection[num]["FShortFlowNo"] = val.ShortFlowNo; - dynamicObjectCollection[num]["FGuidCode"] = val.GuidCode; - } - else - { - base.View.Model.SetValue("FRandomCode", val.RandomCode, num); - base.View.Model.SetValue("FLowNo", val.FlowNo, num); - base.View.Model.SetValue("FShortFlowNo", val.ShortFlowNo, num); - base.View.Model.SetValue("FGuidCode", val.GuidCode, num); - } - } - - if (enabled) - { - dynamicObjectCollection[num]["BarCodeRule"] = dynamicObject; - dynamicObjectCollection[num]["BarCodeRule_Id"] = Convert.ToString(dynamicObject["Id"]); - object value7 = base.View.Model.GetValue("FBarCodeModel"); - dynamicObjectCollection[num]["BARCODEMODEL"] = value7; - } - else - { - base.View.Model.SetValue("FBarCodeRuleToBar", dynamicObject, num); - object value8 = base.View.Model.GetValue("FBarCodeModel"); - base.View.Model.SetValue("FBarCodeModelToBar", value8, num); - } - - if (barCodeBillSystemParameters.FThreeLevelPacking) - { - string strFilter2 = $" FBARCODE=N'{barcode}' "; - OQLFilter ofilter2 = OQLFilter.CreateHeadEntityFilter(strFilter2); - DynamicObject dynamicObject6 = BusinessDataServiceHelper.Load(base.Context, "BD_BarCodeMainFile", null, ofilter2).FirstOrDefault(); - if (!dynamicObject6.IsNullOrEmptyOrWhiteSpace() && dynamicObject6.Contains("BOXCAPACITY") && !dynamicObject6["BOXCAPACITY"].ToString().Equals("0")) - { - if (enabled) - { - dynamicObjectCollection[num]["QtyToBar"] = dynamicObject6["Qty"]; - } - else - { - base.View.Model.SetValue("FQtyToBar", dynamicObject6["Qty"], num); - } - - DynamicObject dynamicObject7 = dynamicObject2["FBigBoxRuleToBill"] as DynamicObject; - DynamicObject dynamicObject8 = dynamicObject2["FCentreBoxRuleToBill"] as DynamicObject; - DynamicObject dynamicObject9 = dynamicObject6["BarCodeRule"] as DynamicObject; - if (!dynamicObject7.IsNullOrEmptyOrWhiteSpace() && !dynamicObject9.IsNullOrEmptyOrWhiteSpace() && Convert.ToInt64(dynamicObject7["Id"]) == Convert.ToInt64(dynamicObject9["Id"])) - { - if (enabled) - { - dynamicObjectCollection[num]["BarCodeRule"] = dynamicObject7; - dynamicObjectCollection[num]["BarCodeRule_Id"] = Convert.ToString(dynamicObject7["Id"]); - object value9 = base.View.Model.GetValue("FBigBoxModel"); - dynamicObjectCollection[num]["BARCODEMODEL"] = value9; - } - else - { - base.View.Model.SetValue("FBarCodeRuleToBar", dynamicObject7, num); - object value10 = base.View.Model.GetValue("FBigBoxModel"); - base.View.Model.SetValue("FBarCodeModelToBar", value10, num); - } - } - - if (!dynamicObject8.IsNullOrEmptyOrWhiteSpace() && !dynamicObject9.IsNullOrEmptyOrWhiteSpace() && Convert.ToInt64(dynamicObject8["Id"]) == Convert.ToInt64(dynamicObject9["Id"])) - { - base.View.Model.SetValue("FBarCodeRuleToBar", dynamicObject8, num); - object value11 = base.View.Model.GetValue("FCenterBoxModel"); - if (enabled) - { - dynamicObjectCollection[num]["BARCODEMODEL"] = value11; - } - else - { - base.View.Model.SetValue("FBarCodeModelToBar", value11, num); - } - } - - num13 = num; - } - else - { - num4++; - decimal num20 = ((dynamicObject2["Qty"] != null) ? Convert.ToDecimal(dynamicObject2["Qty"]) : 0m); - decimal num21 = ((dynamicObject2["MinPackCount"] != null) ? Convert.ToDecimal(dynamicObject2["MinPackCount"]) : 1m); - if (num20 > 0m && num21 > 0m) - { - decimal num22 = qtyDic[barcode]; - if (enabled) - { - if (num22 < num21) - { - dynamicObjectCollection[num]["FIsLastBox"] = true; - } - - dynamicObjectCollection[num]["QtyToBar"] = num22; - } - else - { - if (num22 < num21) - { - base.View.Model.SetValue("FIsLastBox", true, num); - } - - base.View.Model.SetValue("FQtyToBar", num22, num); - } - - num14 += num22; - } - } - - if (enabled) - { - dynamicObjectCollection[num]["FIsLastBox"] = Convert.ToBoolean(dynamicObject6["IsLastBox"]); - } - else - { - base.View.Model.SetValue("FIsLastBox", Convert.ToBoolean(dynamicObject6["IsLastBox"]), num); - } - } - else if (flag) - { - decimal num23 = ((dynamicObject2["CreateNumber"] != null) ? Convert.ToDecimal(dynamicObject2["CreateNumber"]) : 0m); - decimal num24 = ((dynamicObject2["BoxQty"] != null) ? Convert.ToDecimal(dynamicObject2["BoxQty"]) : 0m); - decimal num25 = ((dynamicObject2["Qty"] != null) ? Convert.ToDecimal(dynamicObject2["Qty"]) : 0m); - decimal num26 = qtyDic[barcode]; - if (enabled) - { - dynamicObjectCollection[num]["QtyToBar"] = num26; - if (num26 > (decimal)(list2.Count() - 1)) - { - dynamicObjectCollection[num]["FIsLastBox"] = true; - } - - DynamicObject dynamicObject10 = dynamicObject2["BARCODEBOXRULE"] as DynamicObject; - dynamicObjectCollection[num]["BarCodeRule"] = dynamicObject10; - dynamicObjectCollection[num]["BarCodeRule_Id"] = Convert.ToString(dynamicObject10["Id"]); - object value12 = base.View.Model.GetValue("FBarCodeBoxModel"); - dynamicObjectCollection[num]["BARCODEMODEL"] = value12; - } - else - { - base.View.Model.SetValue("FQtyToBar", num26, num); - if (num26 > (decimal)(list2.Count() - 1)) - { - base.View.Model.SetValue("FIsLastBox", true, num); - } - - DynamicObject value13 = dynamicObject2["BARCODEBOXRULE"] as DynamicObject; - base.View.Model.SetValue("FBarCodeRuleToBar", value13, num); - object value14 = base.View.Model.GetValue("FBarCodeBoxModel"); - base.View.Model.SetValue("FBarCodeModelToBar", value14, num); - } - - flag = false; - num13 = num; - } - else - { - num4++; - decimal num27 = ((dynamicObject2["Qty"] != null) ? Convert.ToDecimal(dynamicObject2["Qty"]) : 0m); - decimal num28 = ((dynamicObject2["MinPackCount"] != null) ? Convert.ToDecimal(dynamicObject2["MinPackCount"]) : 1m); - if (num27 > 0m && num28 > 0m) - { - decimal num29 = qtyDic[barcode]; - if (enabled) - { - if (num29 < num28) - { - dynamicObjectCollection[num]["FIsLastBox"] = true; - } - - dynamicObjectCollection[num]["QtyToBar"] = num29; - } - else - { - if (num29 < num28) - { - base.View.Model.SetValue("FIsLastBox", true, num); - } - - //base.View.Model.SetValue("FQtyToBar", num29, num); - //尾行数量处理--2025-04018 - if (qtyCount + num29 > num27) - { - base.View.Model.SetValue("FQtyToBar", num27 % num28, num); - qtyCount = 0; - } - else if (qtyCount + num29 == num27) - { - base.View.Model.SetValue("FQtyToBar", num29, num); - qtyCount = 0; - } - else - { - base.View.Model.SetValue("FQtyToBar", num29, num); - qtyCount += num29; - } - - - } - - num14 += num29; - } - } - - base.View.Model.SetValue("FBILLNAME", _sFormId, num); - base.View.InvokeFieldUpdateService("FQtyToBar", num); - base.View.InvokeFieldUpdateService("FBillCodeToBar", num); - if (sType.Equals("TBCREBARCODESUM")) - { - list3?.Add(barcode); - } - - if (existedNumbers != null && existedNumbers.Contains(barcode)) - { - EntryGrid control = base.View.GetControl("FEntityToBar"); - control.SetForecolor("FBarCode", "#FF0000", num); - list6.Add(barcode); - } - - num++; - } - else - { - base.View.Model.DeleteEntryRow("FEntityToBar", num); - } - - num19++; - if (num19 % num18 == 0) - { - base.View.Session["ProcessRateValue"] = num12 + num19 % num18 * num17; - } - } - } - - if (num13 != -1) - { - decimal num30 = ((dynamicObject2["BoxQty"] != null) ? Convert.ToDecimal(dynamicObject2["BoxQty"]) : 0m); - if (enabled) - { - dynamicObjectCollection[num13]["QtyToBar"] = num14; - if (num30 > num14) - { - dynamicObjectCollection[num13]["FIsLastBox"] = true; - } - } - else - { - base.View.Model.SetValue("FBoxQtyToBar", num14, num13); - if (num30 > num14) - { - base.View.Model.SetValue("FIsLastBox", true, num13); - } - } - - num2++; - } - - num11++; - if (num11 % num10 == 0) - { - num12 = num7 + num11 % num10 * num9; - base.View.Session["ProcessRateValue"] = num12; - } - } - - billIndex++; - if (billIndex % num6 == 0) - { - num7 = billIndex % num6 * num5; - base.View.Session["ProcessRateValue"] = num7; - } - - //UNWLogger.Info(base.Context, "SetBarCodeValue", string.Format(ResManager.LoadKDString("源单分录{0}行 全部生成分录数据完成", "2fb244890b1043ab", "APP_ISVPAAC2016062210550"), billIndex)); - } - - if (enabled) - { - base.View.UpdateView("FEntityToBar"); - } - - setCaculate(); - // TODO 同步条码主档 - SynchronizeCodeMain(); - } - - public void SetDefRuleId() - { - if (!string.IsNullOrEmpty(_sFormId)) - { - _sRuleId = BarCodeCommonServiceHelper.GetDefRuleIdbyFormId(base.View.Context, _sFormId, (string)null); - base.View.Model.SetValue("FBARCODERULE", _sRuleId); - } - else - { - base.View.Model.SetValue("FBARCODERULE", 0); - } - } - - private void SavingPrintBarCode() - { - string text = DateTime.Now.ToString("yyyyMMddhhmmssfff"); - string text2 = string.Concat(base.View.Model.GetPKValue(), text); - if (CreateSavingPrintBarCode(text2)) - { - ListShowParameter listShowParameter = new ListShowParameter(); - ListRegularFilterParameter listRegularFilterParameter = new ListRegularFilterParameter(); - listRegularFilterParameter.Filter = $"FPRINTID='{text2}'"; - listRegularFilterParameter.OrderBy = " FPRINTSEQ "; - listShowParameter.ListFilterParameter = listRegularFilterParameter; - listShowParameter.IsLookUp = false; - listShowParameter.ListType = Convert.ToInt32(BOSEnums.Enu_ListType.BaseList); - listShowParameter.IsShowUsed = false; - listShowParameter.IsShowApproved = false; - listShowParameter.ParentPageId = base.View.PageId; - listShowParameter.MultiSelect = true; - listShowParameter.FormId = "BD_BarCodePool"; - base.View.ShowForm(listShowParameter); - } - } - - private bool CreateSavingPrintBarCode(string key) - { - //IL_0003: Unknown result type (might be due to invalid IL or missing references) - //IL_0009: Expected O, but got Unknown - bool result = false; - BarCoder val = new BarCoder(); - DynamicObjectCollection source = base.View.Model.DataObject["BD_BARCODEPRINTENTRYBAR"] as DynamicObjectCollection; - DynamicObject[] array = source.Where((DynamicObject p) => p["BarCodeCheck"].ToString().EqualsIgnoreCase("True")).ToArray(); - if (array.Count() < 1) - { - base.View.ShowWarnningMessage(ResManager.LoadKDString("请先选择打印数据行!", "0011019000003158", SubSystemType.BASE)); - return false; - } - - EntryEntity entryEntity = (EntryEntity)base.View.BusinessInfo.GetEntity("FEntityToBar"); - List fields = entryEntity.Fields; - val.DeleteBarCodePoolAtRegularTime(base.Context); - val.DeleteBarCodePool(base.Context, base.View.Model.GetPKValue()); - if (array.Count() > 0) - { - result = true; - } - - FormMetadata formMetadata = (FormMetadata)MetaDataServiceHelper.Load(base.Context, "BD_BarCodePool"); - DynamicObjectType dynamicObjectType = formMetadata.BusinessInfo.GetDynamicObjectType(); - Entity entity = formMetadata.BusinessInfo.GetEntity(0); - List fields2 = entity.Fields; - List list = new List(); - foreach (Field item in fields2) - { - if (!string.IsNullOrWhiteSpace(item.FieldName) && !list.Contains(item.FieldName) && !"FPRINTID".EqualsIgnoreCase(item.FieldName) && "T_BD_BARCODEPOOL".Equals(item.TableName) && !(item is MultiLangTextField) && !"FPRINTSEQ".EqualsIgnoreCase(item.FieldName)) - { - list.Add(item.FieldName); - } - - if (item.FieldName.ToUpper() == "FLOT") - { - list.Add("FLOT_Text"); - } - } - - string text = string.Join(",", list); - val.CreateBarCodePool(base.Context, (object)key, array, fields, formMetadata, dynamicObjectType, fields2, text); - return result; - } - - private void PrintBarCode(string printType) - { - try - { - printDatas = new List(); - newPrintDatas = new List(); - string defaultBarCodeModel = Convert.ToString(base.View.Model.GetValue("FBarCodeModel")); - BarCodePrintOperation printOperation = new BarCodePrintOperation(); - if (printType == "print") - { - string printAddress = Convert.ToString(base.View.Model.GetValue("FPrintAddress")).Trim().ToLowerInvariant(); - if (string.IsNullOrWhiteSpace(printAddress)) - { - base.View.ShowNotificationMessage(ResManager.LoadKDString("请填写打印机名称!", "0011019000003156", SubSystemType.BASE)); - } - else - { - if (!CheckPrintData() || printDatas == null || printDatas.Count <= 0) - { - return; - } - - BarCodeSysParamsModel barCodeBillSystemParameters = BarCodeCommonServiceHelper.GetBarCodeBillSystemParameters(base.Context, base.Context.CurrentOrganizationInfo.ID, _sFormId); - if (barCodeBillSystemParameters.IsBarcodePrintConfirm) - { - base.View.ShowMessage(ResManager.LoadKDString("当前共选择" + printDatas.Count + ResManager.LoadKDString("个条码,确认发送打印?", "0dfe9ea5f48f4a2f", "APP_ISVPAAC2016062210550"), "16be439445c94dea", "APP_ISVPAAC2016062210550"), MessageBoxOptions.YesNo, delegate (MessageBoxResult results) - { - if (results == MessageBoxResult.Yes) - { - List list7 = new List(); - List list8 = new List(); - List list9 = new List(); - int num4 = 0; - foreach (DynamicObject printData in printDatas) - { - if (printData != null) - { - int num5 = Convert.ToInt32(printData["PrintNumber"]); - for (int j = 0; j < num5; j++) - { - newPrintDatas.Add(printData); - string item3 = Convert.ToString(printData["BarCode"]); - string text3 = Convert.ToString(printData["BARCODEMODEL"]); - text3 = (string.IsNullOrWhiteSpace(text3) ? defaultBarCodeModel : text3); - text3 = text3.Replace(" ", ""); - list9.Add(text3); - list7.Add(item3); - list8.Add(num4.ToString()); - num4++; - } - } - } - - //UNWLogger.Info(base.Context, "PrintBarCode:", "printDataId=" + string.Join(",", list8)); - //UNWLogger.Info(base.Context, "PrintBarCode:", ResManager.LoadKDString("总数量:", "14512b12f13e4f85", "APP_ISVPAAC2016062210550") + list7.Count() + "," + printType + ",BarCode=" + string.Join(",", list7)); - printOperation.BarCodePrintDoAction(this, null, list8, list9, printType, printAddress); - printOperationType = printType; - } - }); - return; - } - - List list = new List(); - List list2 = new List(); - List list3 = new List(); - int num = 0; - foreach (DynamicObject printData2 in printDatas) - { - if (printData2 != null) - { - int num2 = Convert.ToInt32(printData2["PrintNumber"]); - for (int i = 0; i < num2; i++) - { - newPrintDatas.Add(printData2); - string item = Convert.ToString(printData2["BarCode"]); - string text = Convert.ToString(printData2["BARCODEMODEL"]); - text = (string.IsNullOrWhiteSpace(text) ? defaultBarCodeModel : text); - text = text.Replace(" ", ""); - list2.Add(text); - list3.Add(item); - list.Add(num.ToString()); - num++; - } - } - } - - //UNWLogger.Info(base.Context, "PrintBarCode:", "printDataId=" + string.Join(",", list)); - //UNWLogger.Info(base.Context, "PrintBarCode:", ResManager.LoadKDString("总数量:", "14512b12f13e4f85", "APP_ISVPAAC2016062210550") + list3.Count() + "," + printType + ",BarCode=" + string.Join(",", list3)); - printOperation.BarCodePrintDoAction(this, null, list, list2, printType, printAddress); - printOperationType = printType; - } - } - else - { - if (!(printType == "preview") || !CheckPrintData() || printDatas == null || printDatas.Count <= 0) - { - return; - } - - List list4 = new List(); - List list5 = new List(); - List list6 = new List(); - int num3 = 0; - foreach (DynamicObject printData3 in printDatas) - { - if (printData3 != null) - { - newPrintDatas.Add(printData3); - string item2 = Convert.ToString(printData3["BarCode"]); - string text2 = Convert.ToString(printData3["BARCODEMODEL"]); - text2 = (string.IsNullOrWhiteSpace(text2) ? defaultBarCodeModel : text2); - text2 = text2.Replace(" ", ""); - list5.Add(text2); - list6.Add(item2); - list4.Add(num3.ToString()); - num3++; - } - } - - //UNWLogger.Info(base.Context, "PrintBarCode:", "printDataId=" + string.Join(",", list4)); - //UNWLogger.Info(base.Context, "PrintBarCode:", ResManager.LoadKDString("总数量:", "14512b12f13e4f85", "APP_ISVPAAC2016062210550") + list6.Count() + "," + printType + ",BarCode=" + string.Join(",", list6)); - printOperation.BarCodePrintDoAction(this, null, list4, list5, printType, ""); - printOperationType = printType; - } - } - catch (Exception ex) - { - ex.StackTrace.ToString(); - } - } - - public void OpenPrintProcessForm() - { - _pPageId = Guid.NewGuid().ToString(); - DynamicFormShowParameter dynamicFormShowParameter = new DynamicFormShowParameter(); - dynamicFormShowParameter.FormId = "UN_BarcodePrintProcess"; - dynamicFormShowParameter.LayoutId = Guid.NewGuid().ToString(); - dynamicFormShowParameter.ParentPageId = base.View.PageId; - dynamicFormShowParameter.PageId = _pPageId; - dynamicFormShowParameter.OpenStyle.ShowType = ShowType.Modal; - dynamicFormShowParameter.OpenStyle.OpenType = OpenType.DefaultOpen; - dynamicFormShowParameter.CustomParams.Add("$Task", "1"); - base.View.ShowForm(dynamicFormShowParameter); - } - - public void ClosePrintProcessForm() - { - IDynamicFormView view = base.View.GetView(_pPageId); - view.Close(); - base.View.SendDynamicFormAction(view); - } - - private bool CheckPrintData() - { - bool flag = true; - ExtendedDataEntitySet extendedDataEntitySet = new ExtendedDataEntitySet(); - extendedDataEntitySet.Parse(new DynamicObject[1] { base.View.Model.DataObject }, base.View.Model.BusinessInfo); - ExtendedDataEntity[] array = (from p in extendedDataEntitySet.FindByEntityKey("FEntityToBar") - where p.DataEntity["BarCodeCheck"].ToString().EqualsIgnoreCase("True") - select p).ToArray(); - if (array.Count() < 1) - { - base.View.ShowWarnningMessage(ResManager.LoadKDString("请先选择打印数据行!", "0011019000003158", SubSystemType.BASE)); - flag = false; - } - - string text = Convert.ToString(base.View.Model.GetValue("FBarCodeModel")); - List list = new List(); - List list2 = new List(); - for (int i = 0; i < array.Count(); i++) - { - DynamicObject dataEntity = array[i].DataEntity; - printDatas.Add(dataEntity); - string text2 = Convert.ToString(dataEntity["BARCODEMODEL"]); - text2 = (string.IsNullOrWhiteSpace(text2) ? text : text2); - text2 = text2.Replace(" ", ""); - string value = Convert.ToString(dataEntity["BarCode"]); - int item = Convert.ToInt32(dataEntity["Seq"]); - if (string.IsNullOrWhiteSpace(value)) - { - list.Add(item); - flag = false; - } - - if (string.IsNullOrWhiteSpace(text2)) - { - list2.Add(item); - flag = false; - } - } - - string text3 = ""; - if (list.Count > 0) - { - for (int j = 0; j < list.Count; j++) - { - text3 = ((j < list.Count - 1) ? (list[j] + "、") : list[j].ToString()); - } - } - - text3 = (string.IsNullOrWhiteSpace(text3) ? "" : string.Format(ResManager.LoadKDString(ResManager.LoadKDString("第", "5e2976b208924f20", "APP_ISVPAAC2016062210550"), "0011019000003159", SubSystemType.BASE) + text3 + ResManager.LoadKDString("行条形码尚未生成!", "0011019000003160", SubSystemType.BASE))); - string text4 = ""; - if (list2.Count > 0) - { - for (int k = 0; k < list2.Count; k++) - { - text4 = ((k < list2.Count - 1) ? (list2[k] + "、") : list2[k].ToString()); - } - } - - text4 = (string.IsNullOrWhiteSpace(text4) ? "" : string.Format(ResManager.LoadKDString(ResManager.LoadKDString("第", "5e2976b208924f20", "APP_ISVPAAC2016062210550"), "0011019000003159", SubSystemType.BASE) + text4 + ResManager.LoadKDString("行条形码未设置条码模板!", "0011019000003161", SubSystemType.BASE))); - if (!string.IsNullOrWhiteSpace(text3 + text4)) - { - base.View.ShowNotificationMessage(text3 + text4); - } - - if (!flag) - { - printDatas = new List(); - } - - return flag; - } - - private void SavePrintAddress(string printAddress) - { - long userId = base.Context.UserId; - long iD = base.Context.CurrentOrganizationInfo.ID; - string text = base.Context.IpAddress; - if (!string.IsNullOrWhiteSpace(text)) - { - Regex regex = new Regex("\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}"); - text = Convert.ToString(regex.Match(text)); - } - - if (!string.IsNullOrWhiteSpace(printAddress)) - { - BarCodePrintServiceHelper.SavePrintAddress(base.Context, printAddress, userId, iD, text, (string)null); - } - } - - private void UpdatePrintCountAfterPrintOP() - { - long userId = base.View.Context.UserId; - DateTime now = DateTime.Now; - for (int i = 0; i < printDatas.Count; i++) - { - DynamicObject dynamicObject = printDatas[i]; - string text = Convert.ToString(dynamicObject["BarCode"]); - int num = Convert.ToInt32(dynamicObject["PrintNumber"]); - long num2 = ((!(dynamicObject["BarCodeRule"] is DynamicObject dynamicObject2)) ? 0 : Convert.ToInt64(dynamicObject2["Id"])); - BarCodePrintServiceHelper.UpdatePrintCountToMain(base.View.Context, text, userId, now, num2, num, 1); - } - - BarCodeSysParamsModel barCodeBillSystemParameters = BarCodeCommonServiceHelper.GetBarCodeBillSystemParameters(base.Context, base.Context.CurrentOrganizationInfo.ID, _sFormId); - if (!barCodeBillSystemParameters.IsPrintNoCanPrint) - { - return; - } - - Entity entity = base.View.BusinessInfo.GetEntity("FEntityToBar"); - DynamicObjectCollection entityDataObject = base.View.Model.GetEntityDataObject(entity); - for (int j = 0; j < entityDataObject.Count(); j++) - { - if (Convert.ToBoolean(entityDataObject[j]["BarCodeCheck"])) - { - entityDataObject[j]["BarCodeCheck"] = false; - entityDataObject[j]["IsPrinted"] = true; - } - } - - base.View.UpdateView("FEntityToBar"); - } - - private void WirteBackBarcodeSign(Context ctx) - { - BarCodeLog.Debug("BarcodePrintEdit", "Call WirteBackBarcodeSign"); - string mainFieldKey = GetMainFieldKey(ctx, _sFormId); - if (mainFieldKey.IsNullOrEmptyOrWhiteSpace()) - { - return; - } - - FormMetadata formMetadata = (FormMetadata)MetaDataServiceHelper.Load(ctx, _sFormId); - Entity entity = ((formMetadata != null && formMetadata.BusinessInfo.GetField(mainFieldKey) != null) ? formMetadata.BusinessInfo.GetField(mainFieldKey).Entity : null); - if (entity == null || !IsContainField(ctx, entity.TableName.ToUpper(), "FISCREBARCODE")) - { - return; - } - - Entity entity2 = base.View.BusinessInfo.GetEntity("FEntityToBill"); - DynamicObjectCollection entityDataObject = base.View.Model.GetEntityDataObject(entity2); - Dictionary> dictionary = new Dictionary>(); - if (entityDataObject != null && entityDataObject.Count() > 0) - { - foreach (DynamicObject item2 in entityDataObject) - { - if (item2["BARCODERULE"] is DynamicObject dynamicObject && dynamicObject.DynamicObjectType.Properties.Contains("FWirteBackBarcodeSign") && Convert.ToBoolean(dynamicObject["FWirteBackBarcodeSign"]) && item2.DynamicObjectType.Properties.Contains("BILLCODE") && !item2["BILLCODE"].IsNullOrEmptyOrWhiteSpace() && item2.DynamicObjectType.Properties.Contains("BILLSEQ") && !item2["BILLSEQ"].IsNullOrEmptyOrWhiteSpace()) - { - string key = Convert.ToString(item2["BILLCODE"]); - string item = Convert.ToString(item2["BILLSEQ"]); - if (dictionary.ContainsKey(key)) - { - dictionary[key].Add(item); - continue; - } - - dictionary.Add(key, new List { item }); - } - } - } - - if (dictionary != null && dictionary.Count() > 0) - { - string fieldName = formMetadata.BusinessInfo.GetBillNoField().FieldName; - string seqFieldKey = entity.SeqFieldKey; - Entity entity3 = formMetadata.BusinessInfo.Entrys.Where((Entity P) => P.EntityType == 0).FirstOrDefault(); - UpdateIsCreBarcode(ctx, entity3.TableName, entity.TableName, fieldName, seqFieldKey, dictionary); - } - } - - private string GetMainFieldKey(Context ctx, string billFormId) - { - string strSql = (BarCodeConst.FORMIDTOENTRYMAINFIELD.ContainsKey(billFormId) ? "SELECT T0.FFIELDKEY FROM T_BD_BARCODEITEMENTRY T0\r\n INNER JOIN T_BD_BARCODEITEM T1 ON T0.FID=T1.FID\r\n WHERE (T1.FBARCODEFIELDKEY=@FBARCODEFIELDKEY OR T1.FBARCODEFIELDKEY=@FBARCODEFIELDKEYTWO) AND T0.FBILLFORMID=@billFormId;" : "SELECT T0.FFIELDKEY FROM T_BD_BARCODEITEMENTRY T0 where t0.FID=@MaterialId and t0.FBILLFORMID=@billFormId;"); - List list = new List(); - if (BarCodeConst.FORMIDTOENTRYMAINFIELD.ContainsKey(billFormId)) - { - list.Add(new SqlParam("@FBARCODEFIELDKEY", KDDbType.String, BarCodeConst.FORMIDTOENTRYMAINFIELD[billFormId])); - list.Add(new SqlParam("@FBARCODEFIELDKEYTWO", KDDbType.String, BarCodeConst.FORMIDTOENTRYMAINFIELD2[billFormId])); - } - else - { - list.Add(new SqlParam("@MaterialId", KDDbType.Int32, 4)); - } - - list.Add(new SqlParam("@billFormId", KDDbType.String, billFormId)); - return DBUtils.ExecuteScalar(ctx, strSql, "", list.ToArray()); - } - - private bool IsContainField(Context ctx, string tableName, string fieldName) - { - bool result = false; - string strSql = $" SELECT count(1) FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME =@tbName AND KSQL_COL_NAME IN ('{fieldName}') "; - List list = new List(); - list.Add(new SqlParam("@tbName", KDDbType.String, tableName)); - int num = DBUtils.ExecuteScalar(base.Context, strSql, 0, list.ToArray()); - BarCodeLog.Info("Barcode IsCreBarcode ", string.Format(ResManager.LoadKDString("单据体中是否包含自定义字段【FISCREBARCODE】字段{0}", "d7acf135203349b7", "APP_ISVPAAC2016062210550"), num)); - if (num > 0) - { - result = true; - } - - return result; - } - - private void UpdateIsCreBarcode(Context ctx, string headTableName, string entryTableName, string billNoFieldName, string seqFieldName, Dictionary> billCodeToSeqDic) - { - StringBuilder stringBuilder = new StringBuilder(); - foreach (KeyValuePair> item in billCodeToSeqDic) - { - if (!stringBuilder.IsNullOrEmptyOrWhiteSpace()) - { - stringBuilder.Append(" OR "); - } - - stringBuilder.AppendFormat(" (T0.{0}='{1}' AND T1.{2} IN ({3})) ", billNoFieldName, item.Key, seqFieldName, string.Join(",", item.Value)); - } - - if (!stringBuilder.IsNullOrEmptyOrWhiteSpace()) - { - string empty = string.Empty; - empty = ((!headTableName.Equals("T_SFC_OPERPLANNING")) ? string.Format("MERGE INTO {0} TA\r\n USING (\r\n\t SELECT T1.FID, T1.FENTRYID FROM {1} T0\r\n\t INNER JOIN {0} T1 ON T0.FID=T1.FID\r\n WHERE {2}\r\n ) TB ON (TA.FID=TB.FID AND TA.FENTRYID=TB.FENTRYID)\r\n WHEN MATCHED THEN \r\n UPDATE SET TA.FISCREBARCODE='1'", entryTableName, headTableName, stringBuilder.ToString()) : string.Format("MERGE INTO {0} TA\r\n USING (\r\n\t SELECT FDETAILID FROM {1} T0\r\n INNER JOIN T_SFC_OPERPLANNINGSEQ T2 ON T0.FID = T2.FID\r\n\t INNER JOIN {0} T1 ON T1.FENTRYID = t2.FENTRYID\r\n WHERE {2}\r\n ) TB ON (TA.FDETAILID=TB.FDETAILID)\r\n WHEN MATCHED THEN \r\n UPDATE SET TA.FISCREBARCODE='1'", entryTableName, headTableName, stringBuilder.ToString())); - DBUtils.Execute(ctx, empty); - } - } - - private void CalcCanCreateQty(int RowIndex, BarCodeSysParamsModel barcodecreatesysparam) - { - if (barcodecreatesysparam.FControlCreateNumber) - { - decimal num = Convert.ToDecimal(base.View.Model.GetValue("FQty", RowIndex)); - string text = Convert.ToString(base.View.Model.GetValue("FBILLCODE", RowIndex)); - string text2 = Convert.ToString(base.View.Model.GetValue("FBILLSEQ", RowIndex)); - DynamicObject dynamicObject = base.View.Model.GetValue("FBARCODERULEToBill", RowIndex) as DynamicObject; - long ruleId = 0L; - if (dynamicObject != null) - { - ruleId = Convert.ToInt64(dynamicObject["Id"]); - } - - if (text.IsNullOrEmptyOrWhiteSpace()) - { - throw new Exception(ResManager.LoadKDString("条码生成规则中必须添加【单据编号】字段!", "cee4617af5b84c12", "APP_ISVPAAC2016062210550")); - } - - if (text2.IsNullOrEmptyOrWhiteSpace() || text2.Equals("0")) - { - throw new Exception(ResManager.LoadKDString("条码生成规则中必须添加【单据行号】字段!", "19fbc253a64640f5", "APP_ISVPAAC2016062210550")); - } - - decimal num2 = default(decimal); - //num2 = ((!barcodecreatesysparam.FCreateIsolation.Equals("1") && !barcodecreatesysparam.FCreateIsolation.IsNullOrEmptyOrWhiteSpace()) ? GetCreatedQtyByRule(text, text2, ruleId, barcodecreatesysparam.FGeneratorType) : GetCreatedQty(text, text2, barcodecreatesysparam.FGeneratorType)); - num2 = 0m; - decimal num3 = num - num2; - base.View.Model.SetValue("FCanCreateQty", num3, RowIndex); - base.View.Model.SetValue("FQty", num3, RowIndex); - base.View.Model.SetValue("FSourceQty", num, RowIndex); - } - } - - public void CheckCreateQty(int RowIndex, BarCodeSysParamsModel barcodecreatesysparam = null) - { - if (barcodecreatesysparam == null) - { - barcodecreatesysparam = BarCodeCommonServiceHelper.GetBarCodeBillSystemParameters(base.Context, base.Context.CurrentOrganizationInfo.ID, _sFormId); - } - - if (barcodecreatesysparam.FControlCreateNumber) - { - string billNo = base.View.Model.GetValue("FBILLCODE", RowIndex).ToString(); - string entrySeq = base.View.Model.GetValue("FBILLSEQ", RowIndex).ToString(); - decimal num = Convert.ToDecimal(base.View.Model.GetValue("FQty", RowIndex)); - decimal num2 = Convert.ToDecimal(base.View.Model.GetValue("FSourceQty", RowIndex)); - DynamicObject dynamicObject = base.View.Model.GetValue("FBARCODERULEToBill", RowIndex) as DynamicObject; - long ruleId = 0L; - if (dynamicObject != null) - { - ruleId = Convert.ToInt64(dynamicObject["Id"]); - } - - decimal num3 = default(decimal); - //num3 = ((!barcodecreatesysparam.FCreateIsolation.Equals("1") && !barcodecreatesysparam.FCreateIsolation.IsNullOrEmptyOrWhiteSpace()) ? GetCreatedQtyByRule(billNo, entrySeq, ruleId, barcodecreatesysparam.FGeneratorType) : GetCreatedQty(billNo, entrySeq, barcodecreatesysparam.FGeneratorType)); - num3 = 0m; - if (num <= 0m) - { - throw new Exception(string.Format(ResManager.LoadKDString("第【{0}】行,生成数量必须大于零!", "84111187b34f44be", "APP_ISVPAAC2016062210550"), RowIndex + 1)); - } - - if (num2 - num3 < num) - { - throw new Exception(string.Format(ResManager.LoadKDString("第【{0}】行,生成数量超过可生成数量!", "ca891099848e4078", "APP_ISVPAAC2016062210550"), RowIndex + 1)); - } - } - } - - public int GetBoxNumber(Dictionary keyValues, string key) - { - if (keyValues.ContainsKey(key)) - { - keyValues[key]++; - } - else - { - keyValues.Add(key, 1); - } - - return keyValues[key]; - } - - public decimal GetCreatedQty(string billNo, string entrySeq, string generatorType) - { - string strSql = string.Empty; - if (generatorType.IsNullOrEmptyOrWhiteSpace() || generatorType.Equals("1")) - { - strSql = "select sum(FQTY) from T_BD_BARCODEMAIN where FBILLCODE=@billNo and FBILLSEQ=@entrySeq"; - } - else if (!generatorType.IsNullOrEmptyOrWhiteSpace() && generatorType.Equals("2")) - { - strSql = "select sum(FQTY) from T_BD_BARCODEPRINTENTRYBILL where FBILLCODE=@billNo and FBILLSEQ=@entrySeq"; - } - - List list = new List(); - list.Add(new SqlParam("@billNo", KDDbType.String, billNo)); - list.Add(new SqlParam("@entrySeq", KDDbType.String, entrySeq)); - return DBUtils.ExecuteScalar(base.Context, strSql, 0m, list.ToArray()); - } - - public decimal GetCreatedQtyByRule(string billNo, string entrySeq, long ruleId, string generatorType) - { - string strSql = string.Empty; - if (generatorType.IsNullOrEmptyOrWhiteSpace() || generatorType.Equals("1")) - { - strSql = "select sum(FQTY) from T_BD_BARCODEMAIN where FBILLCODE=@billNo and FBILLSEQ=@entrySeq and FBARCODERULE=@ruleId"; - } - else if (!generatorType.IsNullOrEmptyOrWhiteSpace() && generatorType.Equals("2")) - { - strSql = "SELECT SUM(t2.FQTY) FROM T_BD_BARCODEPRINTENTRYBILL t1\r\n INNER JOIN T_BD_BARCODEPRINTENTRYBAR t2\r\n ON t1.FENTRYID=t2.FENTRYID\r\n WHERE t1.FBILLCODE=@billNo AND t2.FBARCODERULE=@ruleId"; - } - - List list = new List(); - list.Add(new SqlParam("@billNo", KDDbType.String, billNo)); - list.Add(new SqlParam("@entrySeq", KDDbType.String, entrySeq)); - list.Add(new SqlParam("@ruleId", KDDbType.String, ruleId)); - return DBUtils.ExecuteScalar(base.Context, strSql, 0m, list.ToArray()); - } - - private void CalcCreateNumber(int RowIndex) - { - decimal num = Convert.ToDecimal(base.View.Model.GetValue("FBoxQty", RowIndex)); - BarCodeSysParamsModel barCodeBillSystemParameters = BarCodeCommonServiceHelper.GetBarCodeBillSystemParameters(base.Context, base.Context.CurrentOrganizationInfo.ID, _sFormId); - if (barCodeBillSystemParameters.CreateCountRule.Equals("1")) - { - decimal num2 = Convert.ToDecimal(base.View.Model.GetValue("FQty", RowIndex)); - decimal num3 = default(decimal); - num2 = ((num2 <= 0m) ? 1m : num2); - if (num3 <= 0m && base.View.Model.GetValue("FMaterialId", RowIndex) is DynamicObject dynamicObject && dynamicObject["MaterialPurchase"] is DynamicObjectCollection dynamicObjectCollection && dynamicObjectCollection.Count > 0) - { - DynamicObject dynamicObject2 = dynamicObjectCollection[0]; - if (dynamicObject2 != null) - { - num3 = ((dynamicObject2["MinPackCount"] != null) ? Convert.ToDecimal(dynamicObject2["MinPackCount"]) : 1m); - } - } - - if (num3 <= 0m) - { - num3 = Convert.ToDecimal(base.View.Model.GetValue("FMinPackCount", RowIndex)); - } - - if (num3 > 0m) - { - decimal num4 = num2 / num3; - int num5 = 0; - int num6 = Convert.ToInt32(num4); - num5 = ((!((decimal)num6 < num4)) ? num6 : (num6 + 1)); - if (num > num3) - { - decimal num7 = Math.Ceiling(num2 / num); - base.View.Model.SetValue("FCreateBoxNumber", num7, RowIndex); - } - else - { - base.View.Model.SetValue("FCreateBoxNumber", 0, RowIndex); - } - //重算生成数--2025-4-18 - base.View.Model.SetValue("FCreateNumber", num5, RowIndex); - //base.View.Model.SetValue("FCreateNumber", 1, RowIndex); - base.View.Model.SetValue("FMinPackCount", num3, RowIndex); - } - } - else - { - decimal num8 = Convert.ToDecimal(base.View.Model.GetValue("FQty", RowIndex)); - decimal num9 = Convert.ToDecimal(base.View.Model.GetValue("FMinPackCount", RowIndex)); - if (num9 <= 0m) - { - num9 = num8; - } - - base.View.Model.SetValue("FMinPackCount", num9, RowIndex); - base.View.Model.SetValue("FCreateNumber", 1, RowIndex); - if (num > num8) - { - decimal num10 = Math.Ceiling(num8 / num); - base.View.Model.SetValue("FCreateBoxNumber", num10, RowIndex); - } - else - { - base.View.Model.SetValue("FCreateBoxNumber", 0, RowIndex); - } - } - } - - protected virtual void SetBillEntryValueExtend(DynamicObject souceBillDy, DynamicObject printBilEntry) - { - } - - protected virtual void CalcCreateNumberExtend(int RowIndex, DynamicObject detil) - { - } - - private void CalcPackCount(int RowIndex) - { - decimal num = Convert.ToDecimal(base.View.Model.GetValue("FQty", RowIndex)); - decimal num2 = Convert.ToDecimal(base.View.Model.GetValue("FBoxQty", RowIndex)); - int num3 = Convert.ToInt32(base.View.Model.GetValue("FCreateNumber", RowIndex)); - if (num3 > 0) - { - num = ((num <= 0m) ? 1m : num); - decimal num4 = num / (decimal)num3; - base.View.Model.SetValue("FMinPackCount", num4, RowIndex); - if (num2 > num4) - { - decimal num5 = Math.Ceiling(num / num2); - base.View.Model.SetValue("FCreateBoxNumber", num5, RowIndex); - } - else - { - base.View.Model.SetValue("FCreateBoxNumber", 0, RowIndex); - } - } - } - - private void CalcCreateNumber2(int RowIndex) - { - decimal num = Convert.ToDecimal(base.View.Model.GetValue("FQty", RowIndex)); - decimal num2 = Convert.ToDecimal(base.View.Model.GetValue("FMinPackCount", RowIndex)); - decimal num3 = Convert.ToDecimal(base.View.Model.GetValue("FBoxQty", RowIndex)); - if (num2 > 0m) - { - num = ((num <= 0m) ? 1m : num); - decimal num4 = num / num2; - long num5 = 0L; - long num6 = Convert.ToInt64(num4); - num5 = ((!((decimal)num6 < num4)) ? num6 : (num6 + 1)); - _isEditQty = true; - //重算生成数--2025-4-18 - base.View.Model.SetValue("FCreateNumber", num5, RowIndex); - //base.View.Model.SetValue("FCreateNumber", 1, RowIndex); - if (num3 > num2) - { - decimal num7 = Math.Ceiling(num / num3); - base.View.Model.SetValue("FCreateBoxNumber", num7, RowIndex); - } - else - { - base.View.Model.SetValue("FCreateBoxNumber", 0, RowIndex); - } - - } - } - - private void CenterCalcCreateNumber(int RowIndex) - { - decimal num = Convert.ToDecimal(base.View.Model.GetValue("FCenterBoxQty", RowIndex)); - if (num > 0m) - { - decimal num2 = default(decimal); - if (barcodeSysParm.FThreeLevelPacking && barcodeSysParm.FCreateOrder.Equals("1")) - { - decimal num3 = Convert.ToDecimal(base.View.Model.GetValue("FCreateNumber", RowIndex)); - num2 = num3 / num; - } - else - { - decimal num4 = Convert.ToDecimal(base.View.Model.GetValue("FQTY", RowIndex)); - num2 = num4 / num; - } - - int num5 = 0; - int num6 = Convert.ToInt32(num2); - num5 = ((!((decimal)num6 < num2)) ? num6 : (num6 + 1)); - base.View.Model.SetValue("FCenterCreateNumber", num5, RowIndex); - } - else - { - base.View.Model.SetValue("FCenterCreateNumber", 0, RowIndex); - base.View.Model.SetValue("FCenterBoxQty", 0, RowIndex); - base.View.Model.SetValue("FBigCreateNumber", 0, RowIndex); - } - } - - private void BigCalcCreateNumber(int RowIndex) - { - decimal num = default(decimal); - num = ((!barcodeSysParm.FThreeLevelPacking || !barcodeSysParm.FCreateOrder.Equals("1")) ? Convert.ToDecimal(base.View.Model.GetValue("FQTY", RowIndex)) : Convert.ToDecimal(base.View.Model.GetValue("FCenterCreateNumber", RowIndex))); - decimal num2 = Convert.ToDecimal(base.View.Model.GetValue("FBigBoxQty", RowIndex)); - if (num2 > 0m && !base.View.Model.GetValue("FBigBoxRule", RowIndex).IsNullOrEmptyOrWhiteSpace()) - { - if (num2 > 0m && num > 0m) - { - decimal num3 = num / num2; - int num4 = 0; - int num5 = Convert.ToInt32(num3); - num4 = ((!((decimal)num5 < num3)) ? num5 : (num5 + 1)); - base.View.Model.SetValue("FBigCreateNumber", num4, RowIndex); - } - else - { - base.View.Model.SetValue("FBigCreateNumber", 0, RowIndex); - } - } - } - - public void GetFlotBill(Context ctx, IDynamicFormView view, string flotkey) - { - string entryName = string.Empty; - if (!_billFormMetaData.BusinessInfo.ContainsKey(flotkey) || _sFormId == "STK_Inventory") - { - return; - } - - FormMetadata formMetadata = (FormMetadata)MetaDataServiceHelper.Load(base.Context, _sFormId); - if (_isFromBill == 1 && formMetadata.BusinessInfo.GetEntity(_sEntityKey) != null) - { - entryName = formMetadata.BusinessInfo.GetEntity(_sEntityKey).EntryName; - } - - if (listData != null && listData.Count > 0) - { - string entryEntityKey = listData[0].EntryEntityKey; - if (!string.IsNullOrWhiteSpace(entryEntityKey) && formMetadata.BusinessInfo.GetEntity(entryEntityKey) != null) - { - entryName = formMetadata.BusinessInfo.GetEntity(entryEntityKey).EntryName; - } - } - - LotField lotField = _billFormMetaData.BusinessInfo.GetField(flotkey) as LotField; - ExtendedDataEntitySet extendedDataEntitySet = new ExtendedDataEntitySet(); - DynamicObject[] sourceBillData = GetSourceBillData(_billFormMetaData, new List(), _sourceId, _sourceEntryId); - GetEnrtysfilterEntryIds(entryName, sourceBillData); - extendedDataEntitySet.Parse(sourceBillData, _billFormMetaData.BusinessInfo); - ExtendedDataEntity[] array = extendedDataEntitySet.FindByEntityKey(lotField.EntityKey); - ExtendedDataEntity[] array2; - if (base.View.Model.GetValue("FBarCodeRule") is DynamicObject dynamicObject && dynamicObject.Contains("FPrintSummaryEntry") && Convert.ToBoolean(dynamicObject["FPrintSummaryEntry"])) - { - array2 = new ExtendedDataEntity[MergeID.Count()]; - int num = 0; - ExtendedDataEntity[] array3 = array; - for (int i = 0; i < array3.Length; i++) - { - ExtendedDataEntity extendedDataEntity = array3[i]; - if (MergeID.Contains(Convert.ToString(extendedDataEntity.DataEntity["Id"]))) - { - array2[num++] = extendedDataEntity; - } - } - } - else - { - array2 = array; - } - - CodeAppResult val = StockServiceHelper.GenerateLotMasterByCodeRule(ctx, _billFormMetaData.BusinessInfo, lotField, array2); - if (!val.AllDataRight) - { - return; - } - - List> codeNumbers = val.CodeNumbers; - for (int j = 0; j < codeNumbers.Count; j++) - { - if (!codeNumbers[j].Value.IsNullOrEmptyOrWhiteSpace()) - { - DynamicObject dynamicObject2 = base.View.Model.GetValue(flotkey, j) as DynamicObject; - if (dynamicObject2 == null) - { - base.View.Model.SetItemValueByNumber(flotkey, codeNumbers[j].Value[0], j); - } - } - } - - view.UpdateView(flotkey); - } - - public void GetEnrtysfilterEntryIds(string entryName, DynamicObject[] dySoruceObjsColl) - { - if (string.IsNullOrWhiteSpace(entryName) || dySoruceObjsColl.Count() <= 0 || !dySoruceObjsColl[0].DynamicObjectType.Properties.Contains(entryName)) - { - return; - } - - foreach (DynamicObject dynamicObject in dySoruceObjsColl) - { - DynamicObjectCollection dynamicObjectCollection = dynamicObject[entryName] as DynamicObjectCollection; - List list = new List(); - if (_isFromBill == 1 && (listData == null || listData.Count() <= 0) && !_sourceEntryId.IsNullOrEmptyOrWhiteSpace()) - { - List list2 = _sourceEntryId.Split(',').ToList(); - foreach (string item in list2) - { - int num = 0; - foreach (DynamicObject item2 in dynamicObjectCollection) - { - string text = Convert.ToString(item2["Id"]); - if (text == item) - { - list.Add(num); - break; - } - - num++; - } - } - } - else - { - for (int j = 0; j < listData.Count; j++) - { - string entryPrimaryKeyValue = listData[j].EntryPrimaryKeyValue; - int num2 = 0; - foreach (DynamicObject item3 in dynamicObjectCollection) - { - string text2 = Convert.ToString(item3["Id"]); - if (text2 == entryPrimaryKeyValue) - { - list.Add(num2); - break; - } - - num2++; - } - } - } - - int num3 = 0; - List list3 = new List(); - foreach (DynamicObject item4 in dynamicObjectCollection) - { - if (!list.Contains(num3)) - { - list3.Add(item4); - } - - num3++; - } - - for (int k = 0; k < list3.Count; k++) - { - dynamicObjectCollection.Remove(list3[k]); - } - } - } - - /// - /// 同步条码主档 2025/6/30 - /// - private void SynchronizeCodeMain() - { - var sourceFormId = "UHIK_BD_BarCodeMainFile"; - var entity = this.View.BusinessInfo.GetEntity("FEntityToBar"); - var entityDataObject = this.View.Model.GetEntityDataObject(entity); - if (entityDataObject == null && entityDataObject.Count == 0) - { - this.View.ShowErrMessage("没有找到条码明细,请生成条码明细!!!"); - } - var billId = this.View.Model.GetValue("FBillId") as DynamicObject; // 获取业务对象 - var srcData = entityDataObject.ToList(); - var ObjList = new List(); - var meta = MetaDataServiceHelper.Load(this.Context, sourceFormId) as FormMetadata; - - foreach (var item in srcData) - { - var count = ObjList.Where(n => n["BarCode"].ToString() == item["BarCode"].ToString()).ToList().Count; - if (count > 0) - { - continue; - } - var objType = meta.BusinessInfo.GetDynamicObjectType(); - var queryParameter = new QueryBuilderParemeter(); - var barCode = item["BarCode"]; - queryParameter.FilterClauseWihtKey = string.Format(" FBarCode = '{0}' ", barCode); - queryParameter.FormId = sourceFormId; - var newObj = new DynamicObject(objType); - var loadObjs = BusinessDataServiceHelper.Load(this.Context, objType, queryParameter); - if (loadObjs.Count() > 0) - { - newObj = loadObjs[0]; - } - // 物料 - newObj["MaterialId_Id"] = item["MaterialIdToBar_Id"]; - newObj["MaterialId"] = item["MaterialIdToBar"]; - // 条码规则 - newObj["BarCodeRule_Id"] = item["BarCodeRule_Id"]; - newObj["BarCodeRule"] = item["BarCodeRule"]; - // 条形码 - newObj["BarCode"] = item["BarCode"]; - // 单位 - newObj["UnitId_Id"] = item["UnitIDToBar_Id"]; - newObj["UnitId"] = item["UnitIDToBar"]; - // 批号 - newObj["Lot_Id"] = item["LotToBar_Id"]; - newObj["Lot"] = item["LotToBar"]; - newObj["Lot_Text"] = item["LotToBar_Text"]; - newObj["FLotText"] = item["LotToBar_Text"]; - // 供应商批号 - newObj["SupplierLot"] = item["SUPPLIERLOTTOBAR"]; - // 数量 - newObj["Qty"] = item["QtyToBar"]; - // 行号 - newObj["BillSeq"] = item["BillSeqToBar"]; - // 仓库 - newObj["StockId_Id"] = item["StockIdToBar_Id"]; - newObj["StockId"] = item["StockIdToBar"]; - newObj["StockLocId_Id"] = item["FSTOCKLOCIDToBar_Id"]; - newObj["StockLocId"] = item["FSTOCKLOCIDToBar"]; - // 单据编码 - newObj["BillCode"] = item["BILLCODEToBar"]; - // 禁用状态 - newObj["ForbidStatus"] = "A"; - // 计数流水号 - newObj["FLowNo"] = item["FLowNo"]; - // 辅助属性 - newObj["AuxPropId_Id"] = item["AuxPropIdToBar_Id"]; - newObj["AuxPropId"] = item["AuxPropIdToBar"]; - - - - // 以下非标准字段 - //newObj["FMoEntryId_Id"] = item["FMOENTRYIDToBar_Id"]; - //newObj["FMoEntryId"] = item["FMOENTRYIDToBar"]; - //newObj["FBillId_Id"] = billId["Id"]; - //newObj["FBillId"] = billId; - //newObj["FMinPackCount"] = item["FMinPackCountToBar"]; - //newObj["FMUJU_Id"] = item["FMUJUToBar_Id"]; - //newObj["FMUJU"] = item["FMUJUToBar"]; - //newObj["F_JT_Id"] = item["F_JTToBar_Id"]; - //newObj["F_JT"] = item["F_JTToBar"]; - //newObj["F_BZFS"] = item["F_BZFSToBar"]; - - ObjList.Add(newObj); - } - if (ObjList.Count > 0) - { - OperateOption saveOption = OperateOption.Create(); - //saveOption.SetInteractionFlag(this.Option.GetInteractionFlag()); - saveOption.SetIgnoreWarning(true); - saveOption.SetIgnoreInteractionFlag(true); - var saveRslt = BusinessDataServiceHelper.Save(this.Context, meta.BusinessInfo, ObjList.ToArray(), saveOption, "Save"); - if (saveRslt.IsSuccess) - { - var resRows = saveRslt.Rows.ToList(); - foreach (var res in resRows) - { - var index = resRows.IndexOf(res); - this.View.Model.SetValue("FBarCodeMD5ToBar", res.DataEntity["Id"].ToString(), index); - } - this.View.UpdateView("FEntityToBar"); - this.View.ShowMessage("同步成功,可以在条码主档# 中查看生成的条码."); - } - else - { - this.View.ShowErrMessage(string.Join(",\r\n", saveRslt.OperateResult.Select(n => n.Message))); - } - } - } - } -} diff --git a/Gatedge.ScanCode.Basis.PlugIn/Bill/BAR_BarCodePrint/FormPlugIn/BarCodePrintEditRewriteV7.cs b/Gatedge.ScanCode.Basis.PlugIn/Bill/BAR_BarCodePrint/FormPlugIn/BarCodePrintEditRewriteV7.cs new file mode 100644 index 0000000..edd9258 --- /dev/null +++ b/Gatedge.ScanCode.Basis.PlugIn/Bill/BAR_BarCodePrint/FormPlugIn/BarCodePrintEditRewriteV7.cs @@ -0,0 +1,2961 @@ +using Kingdee.BOS; +using Kingdee.BOS.App.Data; +using Kingdee.BOS.Core; +using Kingdee.BOS.Core.Bill.PlugIn; +using Kingdee.BOS.Core.Bill.PlugIn.Args; +using Kingdee.BOS.Core.CommonFilter; +using Kingdee.BOS.Core.DynamicForm; +using Kingdee.BOS.Core.DynamicForm.PlugIn.Args; +using Kingdee.BOS.Core.DynamicForm.PlugIn.ControlModel; +using Kingdee.BOS.Core.Interaction; +using Kingdee.BOS.Core.List; +using Kingdee.BOS.Core.Metadata; +using Kingdee.BOS.Core.Metadata.EntityElement; +using Kingdee.BOS.Core.Metadata.FieldElement; +using Kingdee.BOS.Core.Permission; +using Kingdee.BOS.Core.SqlBuilder; +using Kingdee.BOS.JSON; +using Kingdee.BOS.KDThread; +using Kingdee.BOS.Log; +using Kingdee.BOS.Orm; +using Kingdee.BOS.Orm.DataEntity; +using Kingdee.BOS.Orm.Metadata.DataEntity; +using Kingdee.BOS.Resource; +using Kingdee.BOS.ServiceHelper; +using Kingdee.BOS.Util; +using Kingdee.K3.BD.BarCode.App.Core; +using Kingdee.K3.BD.BarCode.App.Core.BarCodeItem; +using Kingdee.K3.BD.BarCode.Business.PlugIn; +using Kingdee.K3.BD.BarCode.Core; +using Kingdee.K3.BD.BarCode.ServiceHelper; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Text.RegularExpressions; + +namespace Gatedge.ScanCode.Basis.PlugIn.Bill.BAR_BarCodePrint.FormPlugIn +{ + [Description("条码打印重写"), HotUpdate] + public class BarCodePrintEditRewriteV7 : AbstractBillPlugIn + { + private List _noteTemplates; + + private string barcodeToPrint = string.Empty; + + private List printDatas = new List(); + + private List newPrintDatas = new List(); + + private string printOperationType = string.Empty; + + private int currPrintIndex = -1; + + private int currPrintQty = 0; + + private string flagPrintType = string.Empty; + + private string _permissionConst = string.Empty; + + private int _sRuleId = 0; + + private int _sBoxRuleId = 0; + + private string _sFormId = string.Empty; + + private string _sourceId = string.Empty; + + private FormMetadata _billFormMetaData = null; + + private int _isFromBill = 0; + + private bool _isAutoPacking = false; + + private ListSelectedRowCollection listData = new ListSelectedRowCollection(); + + private int _isFromPrintList = 0; + + private string billPageId = string.Empty; + + private BarCodeSysParamsModel barcodeSysParm = null; + + private Dictionary _baseBusinessInfo = new Dictionary(); + + private Dictionary _baseDataInfo = new Dictionary(); + + private int _progressValue = 0; + + private int _proIncrement = 100; + + + public override void OnInitialize(InitializeEventArgs e) + { + base.OnInitialize(e); + this._permissionConst = ((base.View.OpenParameter.SubSystemId == "SCP") ? "SCP_BarCodePrint" : "BD_BarCodePrint"); + if (this._noteTemplates == null) + { + this._noteTemplates = BarCodeCommonServiceHelper.GetValidNoteTemplatesByBillId(base.View.Context, "BD_BarCodePrint"); + } + this.SetComboField(); + this.InitCustParam(e); + } + + public override void OnLoad(EventArgs e) + { + base.OnLoad(e); + if (this._isFromBill == 1) + { + base.View.Model.SetValue("FBillId", this._sFormId); + base.View.Model.SetValue("FBarCodeRule", this._sRuleId); + } + this.BindBillData(); + string defaultPrinter = this.GetDefaultPrinter(); + if (!string.IsNullOrWhiteSpace(defaultPrinter)) + { + base.View.Model.SetValue("FPrintAddress", defaultPrinter); + } + } + + private void IsAutoPacking() + { + this.barcodeSysParm = BarCodeCommonServiceHelper.GetBarCodeBillSystemParameters(base.Context, base.Context.CurrentOrganizationInfo.ID, this._sFormId); + base.View.Model.SetValue("FAutoPacking", this.barcodeSysParm.AutoCreatePaking); + this._isAutoPacking = this.barcodeSysParm.AutoCreatePaking; + base.View.InvokeFieldUpdateService("FAutoPacking", 0); + } + + public override void AfterBindData(EventArgs e) + { + base.AfterBindData(e); + this.SetDefData(); + this.SetComboItems(); + if (this._isFromPrintList == 1) + { + this.LockPrintInfo(); + } + else + { + this.IsAutoPacking(); + } + } + + public void SetComboItems() + { + Entity entity = base.View.BusinessInfo.GetEntity("FEntityToBar"); + DynamicObjectCollection entityDataObject = base.View.Model.GetEntityDataObject(entity); + ComboFieldEditor control = base.View.GetControl("FBarCodeModelToBar"); + control.SetComboItems(this._noteTemplates); + } + + public override void AfterCreateNewEntryRow(CreateNewEntryEventArgs e) + { + if (StringUtils.EqualsIgnoreCase(e.Entity.Key, "FEntityToBill")) + { + base.View.Model.SetValue("FBARCODEMODELToBill", base.View.Model.GetValue("FBarCodeModel"), e.Row); + } + base.AfterCreateNewEntryRow(e); + } + + public override void BarItemClick(BarItemClickEventArgs e) + { + string text = e.BarItemKey.ToUpperInvariant(); + if (text != null) + { + if (!(text == "TBNEW")) + { + if (!(text == "TBGETDATA")) + { + if (!(text == "TBSAVE")) + { + if (!(text == "TBPRINT")) + { + if (!(text == "TBVIEW")) + { + if (text == "TBCHOOSEBILL") + { + int entryRowCount = base.View.Model.GetEntryRowCount("FEntityToBill"); + if (entryRowCount > 0) + { + base.View.ShowWarnningMessage(ResManager.LoadKDString("暂不支持追加选单!", "0011019000003945", (SubSystemType)3, new object[0]), "", 0, null, (MessageBoxType)1); + return; + } + if (!BarCodeCommon.CheckPermission(base.Context, this._permissionConst, "5709b1a2a857e6")) + { + e.Cancel = true; + base.View.ShowWarnningMessage(ResManager.LoadKDString("没有该操作权限!", "0011019000003162", (SubSystemType)3, new object[0]), "", 0, null, (MessageBoxType)1); + return; + } + this.OpenBarCodeGetBill(); + } + } + } + } + } + } + else + { + this._isFromPrintList = 0; + this._isFromBill = 0; + this._sRuleId = 0; + this._sFormId = string.Empty; + this._sourceId = string.Empty; + } + } + base.BarItemClick(e); + } + + + public override void EntryBarItemClick(BarItemClickEventArgs e) + { + + string barItemKey = e.BarItemKey.ToUpperInvariant(); + switch (barItemKey) + { + case "TBCREBARCODESUM": + case "TBCREBARCODEROW": + { + if (!BarCodeCommon.CheckPermission(base.Context, this._permissionConst, "56e91e3b4348ec")) + { + e.Cancel = true; + base.View.ShowWarnningMessage(ResManager.LoadKDString("没有该操作权限!", "0011019000003162", (SubSystemType)3, new object[0]), "", 0, null, (MessageBoxType)1); + return; + } + if (this._isAutoPacking && this._sBoxRuleId == 0) + { + e.Cancel = true; + base.View.ShowWarnningMessage(ResManager.LoadKDString("请先录入默认包装条码规则!", "58d194b2aae944ca", (SubSystemType)16, new object[0]), "", 0, null, (MessageBoxType)1); + return; + } + ExtendedDataEntitySet extendedDataEntitySet = new ExtendedDataEntitySet(); + extendedDataEntitySet.Parse(new DynamicObject[] + { + base.View.Model.DataObject + }, base.View.Model.BusinessInfo); + ExtendedDataEntity[] entitys = (from p in extendedDataEntitySet.FindByEntityKey("FEntityToBill") + where StringUtils.EqualsIgnoreCase(p.DataEntity["BillCheckBox"].ToString(), "True") + select p).ToArray(); + if (entitys.Count() < 1) + { + base.View.ShowWarnningMessage(ResManager.LoadKDString("请先选择源单明细行!", "0011019000003163", (SubSystemType)3, new object[0]), "", 0, null, (MessageBoxType)1); + return; + } + int iCount = entitys.Count(); + int num2 = 0; + for (int i = 0; i < iCount; i++) + { + DynamicObject dataEntity = entitys[i].DataEntity; + int num3 = (dataEntity["CreateNumber"] != null) ? Convert.ToInt32(dataEntity["CreateNumber"]) : 0; + if (dataEntity["MinPackCount"] == null || Convert.ToInt32(dataEntity["MinPackCount"]) == 0) + { + base.View.ShowWarnningMessage(ResManager.LoadKDString("最小包装数不可为零!", "2b03fcaca96444e5", (SubSystemType)16, new object[0]), "", 0, null, (MessageBoxType)1); + return; + } + num2 += num3; + } + if (num2 > 10000) + { + base.View.ShowWarnningMessage(ResManager.LoadKDString("一次性生成条码数量过多可能会造成系统错误,建议一次生成条码总数不要超过10000!", "0011019000003983", (SubSystemType)3, new object[0]), "", 0, null, (MessageBoxType)1); + return; + } + BarCodeSysParamsModel barcodecreatesysparam = BarCodeCommonServiceHelper.GetBarCodeBillSystemParameters(base.Context, base.Context.CurrentOrganizationInfo.ID, this._sFormId); + Logger.Error("BarCode EntryBarItemClick", string.Concat(new object[] + { + "AllowScanCreate:", + barcodecreatesysparam.AllowScanCreate, + "OrgID", + base.Context.CurrentOrganizationInfo.ID, + "FormID", + this._sFormId + }), null); + if (!StringUtils.EqualsIgnoreCase(barcodecreatesysparam.AllowScanCreate, "1")) + { + string text2 = string.Empty; + string text3 = string.Empty; + Dictionary> dictionary = new Dictionary>(); + for (int j = 0; j < iCount; j++) + { + DynamicObject dataEntity = entitys[j].DataEntity; + text3 = ((dataEntity["BILLCODE"] != null) ? Convert.ToString(dataEntity["BILLCODE"]) : string.Empty); + long num4 = 0L; + if (dataEntity["MaterialId"] is DynamicObject) + { + DynamicObject dynamicObject = dataEntity["MaterialId"] as DynamicObject; + num4 = Convert.ToInt64(dynamicObject["Id"]); + } + if (!StringUtils.IsEmpty(text3)) + { + string key = text3 + "," + num4; + if (dictionary.ContainsKey(key)) + { + List list = dictionary[key]; + list.Add(j + 1); + } + else + { + dictionary.Add(key, new List + { + j + 1 + }); + } + } + } + if (dictionary.Count>>() > 0) + { + string text4 = string.Join("','", (from p in dictionary.Keys + select p.Split(new char[] + { + ',' + })[0]).ToArray()); + string text5 = string.Join(",", (from p in dictionary.Keys + select p.Split(new char[] + { + ',' + })[1]).ToArray()); + DynamicObjectCollection dynamicObjectCollection = BarCodePrintServiceHelper.IsPrintedBarCodes(base.Context, text3, text5, this._sFormId); + foreach (DynamicObject dynamicObject2 in dynamicObjectCollection) + { + string str = Convert.ToString(dynamicObject2["FBILLCODE"]); + string str2 = Convert.ToString(dynamicObject2["FMATERIALID"]); + string key2 = str + "," + str2; + if (dictionary.ContainsKey(key2)) + { + List values = dictionary[key2]; + text2 = text2 + "," + string.Join(",", values); + } + } + } + Logger.Error("BarCode EntryBarItemClick", "isCreateMsg1:" + text2, null); + if (!StringUtils.IsEmpty(text2) && text2.Length > 0) + { + Logger.Error("BarCode EntryBarItemClick", "isCreateMsg:" + text2, null); + if (StringUtils.EqualsIgnoreCase(barcodecreatesysparam.AllowScanCreate, "3")) + { + e.Cancel = true; + base.View.ShowMessage(ResManager.LoadKDString(string.Format(ResManager.LoadKDString("当前行【{0}】对应的单据和物料已经生成过条码!", "53a1b34d8ef2408f", (SubSystemType)16, new object[0]), text2.Substring(1)), "0011019000003983", (SubSystemType)3, new object[0]), 0); + return; + } + if (StringUtils.EqualsIgnoreCase(barcodecreatesysparam.AllowScanCreate, "2")) + { + base.View.ShowMessage(ResManager.LoadKDString(string.Format(ResManager.LoadKDString("当前行【{0}】对应的单据和物料已经生成过条码!", "53a1b34d8ef2408f", (SubSystemType)16, new object[0]), text2.Substring(1)), "0011019000003983", (SubSystemType)3, new object[0]), (MessageBoxOptions)4, delegate (MessageBoxResult result) + { + if (result == MessageBoxResult.Yes) + { + if (barcodecreatesysparam.AsyncCreateBarCode) + { + this.AsyncCreateBarCode(entitys, iCount, e.BarItemKey.ToUpperInvariant()); + } + else + { + this.CreateBarCode(entitys, iCount, e.BarItemKey.ToUpperInvariant()); + } + } + else if (result == MessageBoxResult.No) + { + e.Cancel = true; + } + }, "", 0); + } + } + else if (barcodecreatesysparam.AsyncCreateBarCode) + { + this.AsyncCreateBarCode(entitys, iCount, e.BarItemKey.ToUpperInvariant()); + } + else + { + this.CreateBarCode(entitys, iCount, e.BarItemKey.ToUpperInvariant()); + } + } + else if (barcodecreatesysparam.AsyncCreateBarCode) + { + this.AsyncCreateBarCode(entitys, iCount, e.BarItemKey.ToUpperInvariant()); + } + else + { + this.CreateBarCode(entitys, iCount, e.BarItemKey.ToUpperInvariant()); + } + break; + } + case "TBDELETELIST": + base.View.Model.DeleteEntryData("FEntityToBill"); + base.View.Model.DeleteEntryData("FEntityToBar"); + break; + case "TBGETNEWDATA": + base.View.Model.DeleteEntryData("FEntityToBill"); + base.View.Model.DeleteEntryData("FEntityToBar"); + this.BindBillData(); + base.View.UpdateView("FEntityToBill"); + break; + case "TBPRINTBARCODE": + if (!BarCodeCommon.CheckPermission(base.Context, this._permissionConst, "570756a559fbbd")) + { + e.Cancel = true; + base.View.ShowMessage(ResManager.LoadKDString("您没有打印条码权限!", "0011019000003088", (SubSystemType)3, new object[0]), 0); + return; + } + this.PrintBarCode("print"); + break; + case "TBVIEWBARCODE": + if (!BarCodeCommon.CheckPermission(base.Context, this._permissionConst, "570756a559fbbd")) + { + e.Cancel = true; + base.View.ShowMessage(ResManager.LoadKDString("您没有打印条码权限!", "0011019000003088", (SubSystemType)3, new object[0]), 0); + return; + } + this.PrintBarCode("preview"); + break; + case "TBBUTTONSAVING": + { + if (!BarCodeCommon.CheckPermission(base.Context, this._permissionConst, "570756a559fbbd")) + { + e.Cancel = true; + base.View.ShowMessage(ResManager.LoadKDString("您没有打印条码权限!", "0011019000003088", (SubSystemType)3, new object[0]), 0); + return; + } + IOperationResult operationResult = base.View.Model.Save(null); + this.SavingPrintBarCode(); + break; + } + } + base.EntryBarItemClick(e); + } + + private void CreateBarCode(ExtendedDataEntity[] entitys, int iCount, string sType) + { + Logger.Info("BarCodePrintEdit", "CreateBarCode Start"); + BarCodeCreateResult barCodeCreateResult = new BarCodeCreateResult(); + int num = (iCount - 1) / 1000; + ExtendedDataEntity[] array = new ExtendedDataEntity[1000]; + for (int i = 1; i <= num + 1; i++) + { + if (1000 * i < iCount) + { + Array.ConstrainedCopy(entitys, (i - 1) * 1000, array, 0, 1000); + barCodeCreateResult = BarCodeCreateServiceHelper.BarCodeCreateByRule(base.Context, base.View.BusinessInfo, (long)this._sRuleId, array); + if (!barCodeCreateResult.AllDataRight) + { + base.View.ShowErrMessage(barCodeCreateResult.ErrInfo, "", 0); + return; + } + this.SetBarCodeValue(barCodeCreateResult.BoxContrastNumbers, sType, barCodeCreateResult.ExistedNumbers); + } + else + { + array = new ExtendedDataEntity[iCount - (i - 1) * 1000]; + Array.ConstrainedCopy(entitys, (i - 1) * 1000, array, 0, iCount - (i - 1) * 1000); + barCodeCreateResult = BarCodeCreateServiceHelper.BarCodeCreateByRule(base.Context, base.View.BusinessInfo, (long)this._sRuleId, array); + if (!barCodeCreateResult.AllDataRight) + { + base.View.ShowErrMessage(barCodeCreateResult.ErrInfo, "", 0); + return; + } + this.SetBarCodeValue(barCodeCreateResult.BoxContrastNumbers, sType, barCodeCreateResult.ExistedNumbers); + } + } + base.View.GetControl("FTab").SelectedIndex = 1; + this.SetComboItems(); + this.barcodeSysParm = BarCodeCommonServiceHelper.GetBarCodeBillSystemParameters(base.Context, base.Context.CurrentOrganizationInfo.ID, this._sFormId); + if (this.barcodeSysParm.AutoSavePrintRecord) + { + OperateOption operateOption = OperateOption.Create(); + OperateOptionUtils.SetCacheMetadata(operateOption, false); + DynamicObject dataObject = this.Model.DataObject; + dataObject["FFormId"] = this.Model.BillBusinessInfo.GetForm().Id; + IOperationResult operationResult = BusinessDataServiceHelper.Save(base.Context, this.Model.BillBusinessInfo, dataObject, operateOption, ""); + base.View.UpdateView("FBILLCODEHEAD"); + this.Model.DataChanged = false; + } + List billRowLocked = (from p in entitys + select Convert.ToInt32(p.DataEntity["Seq"])).ToList(); + this.SetBillRowLocked(billRowLocked); + Logger.Info("BarCodePrintEdit", "CreateBarCode End"); + + // TODO 同步条码主档 + SynchronizeCodeMain(); + } + + private void AsyncCreateBarCode(ExtendedDataEntity[] entitys, int iCount, string sType) + { + DateTime currfirstTime = DateTime.Now; + DynamicFormShowParameter processForm = ViewUtils.ShowProcessForm(base.View, delegate (FormResult t) + { + }, true, ResManager.LoadKDString("正在加载界面", "cabf052101c44f41", (SubSystemType)16, new object[0])); + base.View.Session["ProcessRateValue"] = 0; + MainWorker.QuequeTask(delegate () + { + try + { + Logger.Info("BarCodePrintEdit", "AsyncCreateBarCode Start"); + BarCodeCreateResult barCodeCreateResult = new BarCodeCreateResult(); + int num = (iCount - 1) / 1000; + ExtendedDataEntity[] array = new ExtendedDataEntity[1000]; + this._proIncrement = ((num > 0) ? (99 / num) : 99); + for (int i = 1; i <= num + 1; i++) + { + if (1000 * i < iCount) + { + Array.ConstrainedCopy(entitys, (i - 1) * 1000, array, 0, 1000); + barCodeCreateResult = BarCodeCreateServiceHelper.BarCodeCreateByRule(this.Context, this.View.BusinessInfo, (long)this._sRuleId, array); + if (!barCodeCreateResult.AllDataRight) + { + this.View.ShowErrMessage(barCodeCreateResult.ErrInfo, "", 0); + break; + } + this.SetBarCodeValue(barCodeCreateResult.BoxContrastNumbers, sType, barCodeCreateResult.ExistedNumbers); + } + else + { + array = new ExtendedDataEntity[iCount - (i - 1) * 1000]; + Array.ConstrainedCopy(entitys, (i - 1) * 1000, array, 0, iCount - (i - 1) * 1000); + barCodeCreateResult = BarCodeCreateServiceHelper.BarCodeCreateByRule(this.Context, this.View.BusinessInfo, (long)this._sRuleId, array); + if (!barCodeCreateResult.AllDataRight) + { + this.View.ShowErrMessage(barCodeCreateResult.ErrInfo, "", 0); + break; + } + this.SetBarCodeValue(barCodeCreateResult.BoxContrastNumbers, sType, barCodeCreateResult.ExistedNumbers); + } + this.View.Session["ProcessRateValue"] = i * this._proIncrement; + } + } + catch (Exception ex) + { + Logger.Info("BarCodePrintEdit", string.Format(ResManager.LoadKDString("CreateBarCode错误:", "b0e764f5c3874f24", (SubSystemType)16, new object[0]), ex.Message)); + this.View.ShowErrMessage(ex.Message, "", 0); + } + }, + delegate (AsynResult result) + { + this.View.Session["ProcessRateValue"] = 99; + this.View.UpdateView("FEntityToBar"); + List billRowLocked = (from p in entitys + select Convert.ToInt32(p.DataEntity["Seq"])).ToList(); + this.SetBillRowLocked(billRowLocked); + this.View.GetControl("FTab").SelectedIndex = 1; + this.SetComboItems(); + this.barcodeSysParm = BarCodeCommonServiceHelper.GetBarCodeBillSystemParameters(this.Context, this.Context.CurrentOrganizationInfo.ID, this._sFormId); + if (this.barcodeSysParm.AutoSavePrintRecord) + { + OperateOption operateOption = OperateOption.Create(); + OperateOptionUtils.SetCacheMetadata(operateOption, false); + DynamicObject dataObject = this.Model.DataObject; + dataObject["FFormId"] = this.Model.BillBusinessInfo.GetForm().Id; + IOperationResult operationResult = BusinessDataServiceHelper.Save(this.Context, this.Model.BillBusinessInfo, dataObject, operateOption, ""); + this.View.UpdateView("FBILLCODEHEAD"); + this.Model.DataChanged = false; + } + IDynamicFormView view = this.View.GetView(processForm.PageId); + if (view != null) + { + view.Close(); + this.View.SendDynamicFormAction(view); + } + DateTime now = DateTime.Now; + TimeSpan timeSpan = now - currfirstTime; + Logger.Info("BarCodePrintEdit", ResManager.LoadKDString("AsyncCreateBarCode End 耗时:", "af1a7988425d4c2a", (SubSystemType)16, new object[0]) + timeSpan.ToString("g")); + + // TODO 同步条码主档 + SynchronizeCodeMain(); + }); + } + + + public override void OnAfterPrint(AfterPrintEventArgs e) + { + base.OnAfterPrint(e); + this.UpdatePrintCountAfterPrintOP(); + this.printOperationType = string.Empty; + this.printDatas = new List(); + this.newPrintDatas = new List(); + } + + public override void OnPrepareNotePrintData(PreparePrintDataEventArgs e) + { + if (e.DataSourceId.Equals("FEntityToBar", StringComparison.OrdinalIgnoreCase)) + { + List list = new List(); + string value = e.BillIds.FirstOrDefault(); + if (this.newPrintDatas != null && this.newPrintDatas.Count > 0) + { + DynamicObject dynamicObject = this.newPrintDatas[Convert.ToInt32(value)]; + if (dynamicObject != null) + { + DynamicObject dynamicObject2 = new DynamicObject(e.DynamicObjectType); + foreach (object obj in e.Fields) + { + string text = obj.ToString(); + if (!(text == "FExpPeriod")) + { + object obj2 = ""; + bool flag = false; + bool flag2 = false; + string text2 = string.Empty; + if (text.Contains(".")) + { + string[] array = text.Split(new char[] + { + '.' + }); + string text3 = array[0]; + string text4 = array[1]; + if (array.Count() > 2) + { + text2 = array[2]; + } + string propertyName = base.View.BusinessInfo.GetField(text3).PropertyName; + DynamicObject dynamicObject3 = dynamicObject[propertyName] as DynamicObject; + if (dynamicObject3 == null) + { + if (StringUtils.EqualsIgnoreCase(propertyName, "LotToBar") || StringUtils.EqualsIgnoreCase(text3, "FLotToBar")) + { + obj2 = dynamicObject[propertyName + "_Text"]; + text = string.Format("{0}_{1}", text3, text4); + dynamicObject2[text] = obj2; + } + continue; + } + if (dynamicObject3.DynamicObjectType.Name.ToUpperInvariant() == "BD_FLEXSITEMDETAILV") + { + flag = true; + } + if (dynamicObject3.DynamicObjectType.Name.ToUpperInvariant() == "BD_FLEXVALUESDETAIL") + { + flag2 = true; + } + text = string.Format("{0}_{1}{2}", text3, text4, ObjectUtils.IsNullOrEmptyOrWhiteSpace(text2) ? "" : ("_" + text2)); + if (dynamicObject3.DynamicObjectType.Properties.Contains(text4.Remove(0, 1))) + { + obj2 = dynamicObject3[text4.Remove(0, 1)]; + } + else if (dynamicObject3.DynamicObjectType.Properties.Contains(text4)) + { + obj2 = dynamicObject3[text4]; + } + if (ObjectUtils.IsNullOrEmptyOrWhiteSpace(obj2)) + { + if (base.View.BusinessInfo.GetField(text3) is BaseDataField) + { + string formId = ((BaseDataField)base.View.BusinessInfo.GetField(text3)).LookUpObject.FormId; + obj2 = this.GetBaseDataPropByBaseData(formId, text4, dynamicObject3); + } + } + } + else if (base.View.BusinessInfo.GetField(text) is BasePropertyField) + { + string controlFieldKey = base.View.BusinessInfo.GetField(text).ControlFieldKey; + string propertyName = base.View.BusinessInfo.GetField(text).PropertyName; + string text5 = base.View.BusinessInfo.GetField(text).ControlField.DynamicProperty.Name; + DynamicObject dynamicObject4 = dynamicObject[text5] as DynamicObject; + if (dynamicObject4 != null) + { + obj2 = Convert.ToString(dynamicObject4[propertyName]); + } + } + else if (base.View.BusinessInfo.GetField(text) != null) + { + string propertyName = base.View.BusinessInfo.GetField(text).PropertyName; + obj2 = dynamicObject[propertyName]; + } + if (obj2 is DynamicObject) + { + if (flag) + { + text2 = (ObjectUtils.IsNullOrEmptyOrWhiteSpace(text2) ? "FDataValue" : text2); + if ((obj2 as DynamicObject).DynamicObjectType.Properties.Contains(text2)) + { + dynamicObject2[text] = (obj2 as DynamicObject)[text2].ToString(); + string text6 = text.Split(new char[] + { + '_' + })[0]; + if (dynamicObject2.DynamicObjectType.Properties.Contains(text6)) + { + string text5 = base.View.BusinessInfo.GetField(text6).PropertyName; + if (dynamicObject.DynamicObjectType.Properties.Contains(text5 + "_Id")) + { + dynamicObject2[text6] = dynamicObject[text5 + "_Id"]; + } + } + if (dynamicObject2.DynamicObjectType.Properties.Contains("FMaterialIdToBar_Ref")) + { + string propertyName2 = base.View.BusinessInfo.GetField("FMaterialIdToBar").PropertyName; + if (dynamicObject.DynamicObjectType.Properties.Contains(propertyName2) && dynamicObject.DynamicObjectType.Properties.Contains(propertyName2 + "_Id")) + { + dynamicObject2["FMaterialIdToBar_Ref"] = dynamicObject[propertyName2]; + dynamicObject2["FMaterialIdToBar_Id"] = dynamicObject[propertyName2 + "_Id"]; + } + } + } + } + else if (flag2) + { + text2 = (ObjectUtils.IsNullOrEmptyOrWhiteSpace(text2) ? "Name" : text2); + if ((obj2 as DynamicObject).DynamicObjectType.Properties.Contains(text2)) + { + dynamicObject2[text] = (obj2 as DynamicObject)[text2].ToString(); + string text7 = text.Split(new char[] + { + '_' + })[0]; + if (dynamicObject2.DynamicObjectType.Properties.Contains(text7)) + { + string propertyName3 = base.View.BusinessInfo.GetField(text7).PropertyName; + if (dynamicObject.DynamicObjectType.Properties.Contains(propertyName3 + "_Id")) + { + dynamicObject2[text7] = dynamicObject[propertyName3 + "_Id"]; + } + } + if (dynamicObject2.DynamicObjectType.Properties.Contains("FStockIdToBar_Ref")) + { + string propertyName4 = base.View.BusinessInfo.GetField("FStockIdToBar").PropertyName; + if (dynamicObject.DynamicObjectType.Properties.Contains(propertyName4) && dynamicObject.DynamicObjectType.Properties.Contains(propertyName4 + "_Id")) + { + dynamicObject2["FStockIdToBar_Ref"] = dynamicObject[propertyName4]; + dynamicObject2["FStockIdToBar_Id"] = dynamicObject[propertyName4 + "_Id"]; + } + } + } + } + else + { + text2 = (ObjectUtils.IsNullOrEmptyOrWhiteSpace(text2) ? "Name" : text2); + if ((obj2 as DynamicObject).DynamicObjectType.Properties.Contains(text2)) + { + dynamicObject2[text] = (obj2 as DynamicObject)[text2].ToString(); + } + } + } + else if (dynamicObject2.DynamicObjectType.Properties.Contains(text)) + { + dynamicObject2[text] = obj2; + if (flag) + { + dynamicObject2[text] = obj2; + string text6 = text.Split(new char[] + { + '_' + })[0]; + if (dynamicObject2.DynamicObjectType.Properties.Contains(text6)) + { + string text5 = base.View.BusinessInfo.GetField(text6).PropertyName; + if (dynamicObject.DynamicObjectType.Properties.Contains(text5 + "_Id")) + { + dynamicObject2[text6] = dynamicObject[text5 + "_Id"]; + } + } + if (dynamicObject2.DynamicObjectType.Properties.Contains("FMaterialIdToBar_Ref")) + { + string propertyName2 = base.View.BusinessInfo.GetField("FMaterialIdToBar").PropertyName; + if (dynamicObject.DynamicObjectType.Properties.Contains(propertyName2) && dynamicObject.DynamicObjectType.Properties.Contains(propertyName2 + "_Id")) + { + dynamicObject2["FMaterialIdToBar_Ref"] = dynamicObject[propertyName2]; + dynamicObject2["FMaterialIdToBar_Id"] = dynamicObject[propertyName2 + "_Id"]; + } + } + } + } + } + } + list.Add(dynamicObject2); + } + } + e.DataObjects = list.ToArray(); + } + base.OnPrepareNotePrintData(e); + } + + private object GetBaseDataPropByBaseData(string formId, string fieldProp, DynamicObject itemValue) + { + FormMetadata formMetadata = (FormMetadata)MetaDataServiceHelper.Load(base.View.Context, Convert.ToString(formId), true); + BusinessInfo businessInfo = formMetadata.BusinessInfo; + Field field = businessInfo.GetField(fieldProp); + object oriValue = BarCodeCommonService.GetItemValueFromBaseData(field, itemValue); + if (field is ComboField) + { + ComboField comboField = field as ComboField; + EnumObject enumObject = comboField.EnumObject; + EnumItem enumItem = enumObject.Items.FirstOrDefault((EnumItem p) => p.Value.Equals(oriValue)); + oriValue = enumItem.Caption.ToString(); + } + else if (field is GroupField) + { + GroupField groupField = field as GroupField; + } + return oriValue; + } + + public override void DataChanged(DataChangedEventArgs e) + { + int entryRowCount = base.View.Model.GetEntryRowCount("FEntityToBill"); + int entryRowCount2 = base.View.Model.GetEntryRowCount("FEntityToBar"); + string text = e.Field.Key.ToUpperInvariant(); + switch (text) + { + case "FBILLID": + this._sFormId = ((e.NewValue == null) ? "" : e.NewValue.ToString()); + this.SetDefRuleId(); + this.IsAutoPacking(); + base.View.Model.DeleteEntryData("FEntityToBill"); + base.View.Model.DeleteEntryData("FEntityToBar"); + break; + case "FBARCODEBOXRULE": + this._sBoxRuleId = ((e.NewValue == null) ? 0 : Convert.ToInt32(e.NewValue)); + base.View.Model.DeleteEntryData("FEntityToBill"); + base.View.Model.DeleteEntryData("FEntityToBar"); + break; + case "FBARCODERULE": + this._sRuleId = ((e.NewValue == null) ? 0 : Convert.ToInt32(e.NewValue)); + base.View.Model.DeleteEntryData("FEntityToBill"); + base.View.Model.DeleteEntryData("FEntityToBar"); + break; + case "FBARCODEMODEL": + if (entryRowCount > 0) + { + for (int i = 0; i < entryRowCount; i++) + { + base.View.Model.SetValue("FBARCODEMODELToBill", e.NewValue, i); + } + } + if (entryRowCount2 > 0) + { + for (int i = 0; i < entryRowCount2; i++) + { + if (base.View.Model.GetValue("FBarCodeModelToBar", i) == null) + { + base.View.Model.SetValue("FBarCodeModelToBar", e.NewValue, i); + } + } + } + break; + case "FBARCODERULETOBILL": + { + int num2 = (e.NewValue == null) ? 0 : Convert.ToInt32(e.NewValue); + if (num2 > 0 && num2 != this._sRuleId) + { + this.SetBillData(num2, e.Row); + } + break; + } + case "FQTY": + case "FMATERIALID": + { + decimal d = Convert.ToDecimal(base.View.Model.GetValue("FQty", e.Row)); + DynamicObject dynamicObject = base.View.Model.GetValue("FMaterialId", e.Row) as DynamicObject; + if (d > 0m && dynamicObject != null) + { + DynamicObjectCollection dynamicObjectCollection = dynamicObject["MaterialPurchase"] as DynamicObjectCollection; + if (dynamicObjectCollection != null && dynamicObjectCollection.Count > 0) + { + DynamicObject dynamicObject2 = dynamicObjectCollection[0]; + if (dynamicObject2 != null) + { + int num3 = (dynamicObject2["MinPackCount"] != null) ? Convert.ToInt32(dynamicObject2["MinPackCount"]) : 1; + int num4 = 1; + if (num4 > 0) + { + decimal num5 = d / num4; + int num6 = Convert.ToInt32(num5); + int num7; + if (num6 < num5) + { + num7 = num6 + 1; + } + else + { + num7 = num6; + } + base.View.Model.SetValue("FCreateNumber", num7, e.Row); + } + } + } + } + this.CalcCreateNumber2(e.Row); + break; + } + case "FPRINTADDRESS": + { + string text2 = Convert.ToString(e.NewValue); + if (!string.IsNullOrEmpty(text2)) + { + this.SavePrintAddress(text2); + } + break; + } + case "FQTYTOBAR": + case "FMATERIALIDTOBAR": + { + decimal d2 = Convert.ToDecimal(base.View.Model.GetValue("FQtyToBar", e.Row)); + DynamicObject dynamicObject3 = base.View.Model.GetValue("FMaterialIdToBar", e.Row) as DynamicObject; + if (d2 > 0m && dynamicObject3 != null) + { + DynamicObjectCollection dynamicObjectCollection2 = dynamicObject3["MaterialPurchase"] as DynamicObjectCollection; + if (dynamicObjectCollection2 != null && dynamicObjectCollection2.Count > 0) + { + DynamicObject dynamicObject4 = dynamicObjectCollection2[0]; + if (dynamicObject4 != null) + { + int num8 = (dynamicObject4["MinPackCount"] != null) ? Convert.ToInt32(dynamicObject4["MinPackCount"]) : 1; + int num9 = (dynamicObject4["PrintCount"] != null) ? Convert.ToInt32(dynamicObject4["PrintCount"]) : 1; + if (num8 > 0 && num9 > 0) + { + base.View.Model.SetValue("FPrintNumber", num9, e.Row); + } + } + } + } + break; + } + case "FBOXQTY": + case "FMINPACKCOUNT": + this.CalcCreateNumber2(e.Row); + break; + } + base.DataChanged(e); + } + + public override void BeforeF7Select(BeforeF7SelectEventArgs e) + { + string text = e.FieldKey.ToUpper(); + if (text != null) + { + if (text == "FBARCODERULE" || text == "FBARCODEBOXRULE") + { + string text2; + if (this.GetBarCodeFilter(out text2)) + { + if (string.IsNullOrEmpty(e.ListFilterParameter.Filter)) + { + e.ListFilterParameter.Filter = text2; + } + else + { + IRegularFilterParameter listFilterParameter = e.ListFilterParameter; + listFilterParameter.Filter = listFilterParameter.Filter + " AND " + text2; + } + } + } + } + base.BeforeF7Select(e); + } + + public override void BeforeSetItemValueByNumber(BeforeSetItemValueByNumberArgs e) + { + string text = e.BaseDataFieldKey.ToUpper(); + if (text != null) + { + if (text == "FBARCODERULE") + { + string text2; + if (this.GetBarCodeFilter(out text2)) + { + if (string.IsNullOrEmpty(e.Filter)) + { + e.Filter = text2; + } + else + { + e.Filter = e.Filter + " AND " + text2; + } + } + } + } + } + + public override void AfterSave(AfterSaveEventArgs e) + { + base.View.UpdateView("FBILLCODEHEAD"); + base.AfterSave(e); + } + + public override void ButtonClick(ButtonClickEventArgs e) + { + base.ButtonClick(e); + string text = e.Key.ToUpperInvariant(); + if (text != null) + { + if (text == "FBTNSELECTPRINTER") + { + JSONArray jsonarray = new JSONArray(); + jsonarray.Add(0); + base.View.AddAction("SelectPrinterExt", jsonarray); + } + } + } + + public override void CustomEvents(CustomEventsArgs e) + { + base.CustomEvents(e); + List list = new List(); + string text = e.EventName.ToUpper(); + if (text != null) + { + if (!(text == "RETURNANDCLEARDATACOLLECTION")) + { + if (!(text == "RETURNDETAILDATA")) + { + if (!(text == "CLOSEWINDOWBYDETAIL")) + { + if (text == "SELECTPRINTER") + { + JSONObject jsonobject = JSONObject.Parse(e.EventArgs); + if (jsonobject != null) + { + string value = jsonobject.GetValue("Data", "{}"); + if (value != "{}") + { + JSONObject jsonobject2 = JSONObject.Parse(value); + if (jsonobject2 != null) + { + if (jsonobject2.GetValue("Selected", false)) + { + string value2 = jsonobject2.GetValue("PrinterName", ""); + base.View.Model.SetValue("FPrintAddress", value2); + } + else + { + string value3 = jsonobject2.GetValue("Message", ""); + if (!string.IsNullOrWhiteSpace(value3)) + { + base.View.ShowErrMessage(value3, "", 0); + } + } + } + } + } + } + } + else + { + ((IListView)base.View.GetView(this.billPageId)).Close(); + } + } + else + { + this.GetReturnData(); + ((IListView)base.View.GetView(this.billPageId)).Close(); + } + } + else + { + this.GetReturnDataFromSession(true); + ((IListView)base.View.GetView(this.billPageId)).Close(); + } + } + } + + private void GetReturnData() + { + List list = new List(); + foreach (ListSelectedRow listSelectedRow in ((IListView)base.View.GetView(this.billPageId)).SelectedRowsInfo) + { + if (listSelectedRow.Selected && listSelectedRow.PrimaryKeyValue != null && !string.IsNullOrWhiteSpace(listSelectedRow.PrimaryKeyValue)) + { + list.Add(listSelectedRow.PrimaryKeyValue); + } + } + if (list.Count >= 1) + { + this._sourceId = "'" + string.Join("','", list) + "'"; + this._isFromBill = 1; + this._billFormMetaData = (FormMetadata)MetaDataServiceHelper.Load(base.Context, this._sFormId, true); + this.BindBillData(); + } + } + + private void GetReturnDataFromSession(bool clearSessionData) + { + List list = new List(); + IListView listView = (IListView)base.View.GetView(this.billPageId); + if (listView.Session != null && listView.Session.ContainsKey("Data_Collection")) + { + Dictionary dictionary = listView.Session["Data_Collection"] as Dictionary; + if (dictionary != null && dictionary.Count > 0) + { + foreach (string key in dictionary.Keys) + { + ListSelectedRow listSelectedRow = dictionary[key]; + if (listSelectedRow.Selected && listSelectedRow.PrimaryKeyValue != null && !string.IsNullOrWhiteSpace(listSelectedRow.PrimaryKeyValue)) + { + list.Add(listSelectedRow.PrimaryKeyValue); + } + } + } + if (clearSessionData) + { + listView.Session["Data_Collection"] = null; + } + if (list.Count >= 1) + { + this._sourceId = "'" + string.Join("','", list) + "'"; + this._isFromBill = 1; + this._billFormMetaData = (FormMetadata)MetaDataServiceHelper.Load(base.Context, this._sFormId, true); + this.BindBillData(); + } + } + } + + private void LockPrintInfo() + { + base.View.GetMainBarItem("tbNew").Enabled = true; + base.View.GetMainBarItem("tbSave").Enabled = true; + base.View.GetMainBarItem("tbChooseBill").Enabled = false; + base.View.GetMainBarItem("tbExit").Enabled = true; + base.View.GetBarItem("FEntityToBill", "tbButton").Enabled = false; + base.View.GetBarItem("FEntityToBill", "tbDeleteRow").Enabled = false; + base.View.GetBarItem("FEntityToBill", "tbBatchFill").Enabled = false; + base.View.GetBarItem("FEntityToBill", "tbCreBarCodeSum").Enabled = false; + base.View.GetBarItem("FEntityToBill", "tbCreBarCodeRow").Enabled = false; + base.View.GetBarItem("FEntityToBill", "tbGetNewData").Enabled = false; + base.View.GetBarItem("FEntityToBill", "tbDeleteList").Enabled = false; + Entity entity = base.View.BusinessInfo.GetEntity("FEntityToBill"); + base.View.StyleManager.SetEnabled(entity, "", false); + base.View.StyleManager.SetEnabled("FBillId", "FBillId", false); + base.View.StyleManager.SetEnabled("FBarCodeRule", "FBarCodeRule", false); + base.View.StyleManager.SetEnabled("FBILLCODEHEAD", "FBILLCODEHEAD", false); + } + + private bool GetBarCodeFilter(out string filter) + { + filter = string.Format("\r\n FID IN (SELECT DISTINCT FID from T_BD_BARCODERULETOBILL\r\n WHERE FBILLID = '{0}'\r\n )", this._sFormId); + return !string.IsNullOrWhiteSpace(filter); + } + + private void SetBillRowLocked(List lSeq) + { + EntryEntity entryEntity = base.View.BusinessInfo.GetEntryEntity("FEntityToBill"); + foreach (int num in lSeq) + { + foreach (Field field in entryEntity.Fields.ToList()) + { + base.View.GetFieldEditor(field.Key, num - 1).Enabled = false; + base.View.Model.SetValue("FBillCheckBox", 0, num - 1); + } + } + } + + private void SetDefData() + { + if (this._isFromBill == 1) + { + base.View.Model.SetValue("FBillId", this._sFormId); + } + Field field = base.View.BusinessInfo.GetField("FBarCodeModel"); + DynamicObject dataObject = base.View.Model.DataObject; + if (dataObject != null) + { + string a = Convert.ToString(dataObject[field.PropertyName]).Replace(" ", ""); + if (a == "" && this._noteTemplates.Count > 0) + { + EnumItem enumItem = this._noteTemplates.FirstOrDefault(); + if (enumItem != null) + { + base.View.Model.SetValue("FBarCodeModel", enumItem.Value); + base.View.Model.SetValue("FBarCodeBoxModel", enumItem.Value); + } + } + } + } + + private string GetDefaultPrinter() + { + long userId = base.Context.UserId; + long id = base.Context.CurrentOrganizationInfo.ID; + string text = base.Context.IpAddress; + if (!string.IsNullOrWhiteSpace(text)) + { + Regex regex = new Regex("\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}"); + text = Convert.ToString(regex.Match(text)); + } + return BarCodePrintServiceHelper.GetDefaultPrinter(base.View.Context, userId, id, text); + } + + private void BindBillData() + { + if (this._isFromBill == 1) + { + if (string.IsNullOrEmpty(this._sFormId) || this._sRuleId == 0 || string.IsNullOrEmpty(this._sourceId)) + { + if (string.IsNullOrEmpty(this._sFormId)) + { + base.View.ShowWarnningMessage(ResManager.LoadKDString("请先录入源单单据名称!", "0011019000003164", (SubSystemType)3, new object[0]), "", 0, null, (MessageBoxType)1); + } + else if (this._sRuleId == 0) + { + base.View.ShowWarnningMessage(ResManager.LoadKDString("请先录入默认条码规则!", "0011019000003092", (SubSystemType)3, new object[0]), "", 0, null, (MessageBoxType)1); + } + else if (string.IsNullOrEmpty(this._sourceId)) + { + base.View.ShowWarnningMessage(ResManager.LoadKDString("请先选择源单数据!", "0011019000003165", (SubSystemType)3, new object[0]), "", 0, null, (MessageBoxType)1); + } + } + else if (this._isAutoPacking && this._sBoxRuleId == 0) + { + base.View.ShowWarnningMessage(ResManager.LoadKDString("请先录入默认包装条码规则!", "58d194b2aae944ca", (SubSystemType)16, new object[0]), "", 0, null, (MessageBoxType)1); + } + else + { + this.SetBillData(this._sRuleId, -1); + } + } + } + + private void SetBillData(int eRuleId, int row) + { + string text = string.Empty; + if (this.listData != null && this.listData.Count > 0) + { + string entryEntityKey = this.listData[0].EntryEntityKey; + if (!string.IsNullOrWhiteSpace(entryEntityKey)) + { + FormMetadata formMetadata = (FormMetadata)MetaDataServiceHelper.Load(base.Context, this._sFormId, true); + if (formMetadata.BusinessInfo.GetEntity(entryEntityKey) != null) + { + text = formMetadata.BusinessInfo.GetEntity(entryEntityKey).EntryName; + } + } + } + Dictionary DicFieldStrMap = BarCodeCommonServiceHelper.GetBarCodeItemFieldDic(base.Context, this._sFormId, eRuleId); + Dictionary dictionary = new Dictionary(); + List list = new List(); + List list2 = new List(); + foreach (string text2 in DicFieldStrMap.Keys.ToList()) + { + Field field = base.View.BillBusinessInfo.GetField(text2); + if (!ObjectUtils.IsNullOrEmpty(field)) + { + string text3 = DicFieldStrMap[text2]; + string text4 = this.GetBillBaseDataFieldKey(text3); + string baseDataSubFieldKey = this.GetBaseDataSubFieldKey(text3); + bool flag = this.IsSubField(text3); + bool isBaseDataPropFieldInBill = false; + Field field2; + if (flag) + { + field2 = this._billFormMetaData.BusinessInfo.GetField(text4); + } + else + { + field2 = this._billFormMetaData.BusinessInfo.GetField(text3); + if (field is BasePropertyField && field2 is BasePropertyField) + { + isBaseDataPropFieldInBill = true; + Field controlField = field.ControlField; + Field controlField2 = field2.ControlField; + if (!DicFieldStrMap.Keys.Contains(controlField.Key) && controlField != null && controlField2 != null) + { + DicFieldStrMap.Add(controlField.Key, controlField2.Key); + if (!dictionary.ContainsKey(controlField.Key)) + { + dictionary.Add(text2, new BarCodeBillCorrespondInfo + { + BarCodeFieldKey = controlField.Key, + BarCodeField = controlField, + CorrespondFieldKey = controlField2.Key, + BillFieldKey = controlField2.Key, + BaseDataSubFieldKey = "", + BillField = controlField2, + IsBaseDataSubField = false, + IsBaseDataPropFieldInBill = false + }); + } + } + if (!list.Contains(controlField2.Key)) + { + list.Add(controlField2.Key); + } + } + } + if (!dictionary.ContainsKey(text2) && field2 != null) + { + dictionary.Add(text2, new BarCodeBillCorrespondInfo + { + BarCodeFieldKey = text2, + BarCodeField = field, + CorrespondFieldKey = text3, + BillFieldKey = text4, + BaseDataSubFieldKey = baseDataSubFieldKey, + BillField = field2, + IsBaseDataSubField = flag, + IsBaseDataPropFieldInBill = isBaseDataPropFieldInBill + }); + } + if (!list.Contains(text4)) + { + list.Add(text4); + } + if (field2 != null && !list2.Contains(field2.Entity.EntryName)) + { + list2.Add(field2.Entity.EntryName); + if (field2.Entity is SubEntryEntity && !list2.Contains((field2.Entity as SubEntryEntity).ParentEntity.EntryName)) + { + list2.Add((field2.Entity as SubEntryEntity).ParentEntity.EntryName); + } + } + } + } + string primaryField = string.Empty; + if (StringUtils.EqualsIgnoreCase(this._sFormId, "FA_CARD")) + { + if (list2.Contains("CardDetail")) + { + list2.Remove("CardDetail"); + list2.Insert(1, "CardDetail"); + } + if (list2.Contains("Allocation")) + { + list2.Remove("Allocation"); + list2.Insert(2, "Allocation"); + } + primaryField = "FWtAssetNumber"; + if (!list.Contains("FAllocAssetNO")) + { + list.Add("FAllocAssetNO"); + } + if (!list.Contains("FAllocRatio")) + { + list.Add("FAllocRatio"); + } + } + string sSeq = "FBILLSEQ"; + if (DicFieldStrMap.Keys.Contains(sSeq)) + { + Field field = base.View.BillBusinessInfo.GetField(sSeq); + if (!dictionary.ContainsKey(sSeq)) + { + List source = (from p in this._billFormMetaData.BusinessInfo.Entrys + select p.EntryName).ToList(); + string text5 = (from p in source + where DicFieldStrMap[sSeq].IndexOf(p + "F") > -1 + select p).FirstOrDefault(); + if (!string.IsNullOrEmpty(text5)) + { + Field field2 = new Field + { + EntityKey = text5, + FieldName = DicFieldStrMap[sSeq].Replace(text5, ""), + PropertyName = "Seq" + }; + string text4 = DicFieldStrMap[sSeq]; + BarCodeBillCorrespondInfo barCodeBillCorrespondInfo = new BarCodeBillCorrespondInfo(); + barCodeBillCorrespondInfo.BarCodeFieldKey = sSeq; + barCodeBillCorrespondInfo.BarCodeField = field; + barCodeBillCorrespondInfo.CorrespondFieldKey = text4; + barCodeBillCorrespondInfo.BillFieldKey = text4; + barCodeBillCorrespondInfo.BaseDataSubFieldKey = ""; + barCodeBillCorrespondInfo.BillField = field2; + barCodeBillCorrespondInfo.IsBaseDataSubField = false; + barCodeBillCorrespondInfo.IsBaseDataPropFieldInBill = false; + dictionary.Add(sSeq, barCodeBillCorrespondInfo); + if (field2 != null && !list2.Contains(text5)) + { + list2.Add(text5); + } + } + } + } + string pkFieldName = this._billFormMetaData.BusinessInfo.GetForm().PkFieldName; + DynamicObject dynamicObject = base.View.Model.GetValue("FBillId") as DynamicObject; + if (dynamicObject != null || !string.IsNullOrWhiteSpace(this._sFormId)) + { + if (dynamicObject != null && dynamicObject.DynamicObjectType.Properties.Contains("MODELTYPEID") && Convert.ToInt32(dynamicObject["MODELTYPEID"]) == 400) + { + string text6 = "FBASEDATAID"; + Field field = base.View.BillBusinessInfo.GetField(text6); + if (!dictionary.ContainsKey(text6)) + { + string text4 = text6; + if (DicFieldStrMap.ContainsKey(text6)) + { + text4 = DicFieldStrMap[text6]; + } + Field field2 = new Field + { + FieldName = pkFieldName, + PropertyName = "Id" + }; + dictionary.Add(text6, new BarCodeBillCorrespondInfo + { + BarCodeFieldKey = text6, + BarCodeField = field, + CorrespondFieldKey = text4, + BillFieldKey = text4, + BaseDataSubFieldKey = "", + BillField = field2, + IsBaseDataSubField = false, + IsBaseDataPropFieldInBill = false + }); + } + } + List list3 = new List(); + foreach (string text7 in list) + { + list3.Add(new SelectorItemInfo(text7)); + } + string text8 = string.Format("{0} IN ( {1} )", pkFieldName, this._sourceId); + OQLFilter oqlfilter = OQLFilter.CreateHeadEntityFilter(text8); + DynamicObject[] array = BusinessDataServiceHelper.Load(base.Context, this._sFormId, list3, oqlfilter); + if (!string.IsNullOrWhiteSpace(text) && array.Count() > 0) + { + if (array[0].DynamicObjectType.Properties.Contains(text)) + { + foreach (DynamicObject dynamicObject2 in array) + { + DynamicObjectCollection dynamicObjectCollection = dynamicObject2[text] as DynamicObjectCollection; + List list4 = new List(); + for (int j = 0; j < this.listData.Count; j++) + { + string entryPrimaryKeyValue = this.listData[j].EntryPrimaryKeyValue; + int num = 0; + foreach (DynamicObject dynamicObject3 in dynamicObjectCollection) + { + string a = Convert.ToString(dynamicObject3["Id"]); + if (a == entryPrimaryKeyValue) + { + list4.Add(num); + break; + } + num++; + } + } + int num2 = 0; + List list5 = new List(); + foreach (DynamicObject dynamicObject3 in dynamicObjectCollection) + { + if (!list4.Contains(num2)) + { + list5.Add(dynamicObject3); + } + num2++; + } + for (int k = 0; k < list5.Count; k++) + { + dynamicObjectCollection.Remove(list5[k]); + } + } + } + } + Entity entity = base.View.BusinessInfo.GetEntity("FEntityToBill"); + EntryEntity entryEntity = base.View.BusinessInfo.GetEntryEntity("FEntityToBar"); + DynamicObjectType dynamicObjectType = entity.DynamicObjectType; + DynamicObject dybill = new DynamicObject(dynamicObjectType); + DynamicObjectCollection dynamicObjectCollection2 = new DynamicObjectCollection(dynamicObjectType, null); + dynamicObjectCollection2 = this.GetDynamicRows(array, null, dynamicObjectCollection2, dictionary, list2, dynamicObjectType, dybill, 0, 0, primaryField); + if (row == -1) + { + EntryEntity entity2 = (EntryEntity)base.View.BillBusinessInfo.GetEntity("FEntityToBill"); + this.CreateBillRows(dynamicObjectCollection2, entity2, dictionary); + } + else + { + DynamicObject detil = dynamicObjectCollection2[row]; + this.ModifyBillRow(detil, dictionary, row); + } + } + } + + private bool IsSubField(string fieldKey) + { + int num = fieldKey.IndexOf("^"); + return num > 0; + } + + private string GetBillBaseDataFieldKey(string fieldKey) + { + int num = fieldKey.IndexOf("^"); + string result; + if (num > 0) + { + result = fieldKey.Substring(0, num); + } + else + { + result = fieldKey; + } + return result; + } + + private string GetBaseDataSubFieldKey(string fieldKey) + { + int num = fieldKey.IndexOf("^"); + string result; + if (num > 0) + { + result = fieldKey.Substring(num + 1, fieldKey.Length - num - 1); + } + else + { + result = ""; + } + return result; + } + + private BusinessInfo GetFormBusinessInfo(string formId) + { + BusinessInfo result; + if (!this._baseBusinessInfo.ContainsKey(formId)) + { + BusinessInfo businessInfo = (MetaDataServiceHelper.Load(base.View.Context, formId, true) as FormMetadata).BusinessInfo; + this._baseBusinessInfo.Add(formId, businessInfo); + result = businessInfo; + } + else + { + result = this._baseBusinessInfo[formId]; + } + return result; + } + + private DynamicObject GetBaseDataDynamicObject(string formId, string pkId) + { + string key = string.Format("{0}#{1}", formId, pkId); + DynamicObject result; + if (!this._baseDataInfo.ContainsKey(key)) + { + BusinessInfo formBusinessInfo = this.GetFormBusinessInfo(formId); + DynamicObject dynamicObject = BusinessDataServiceHelper.LoadSingle(base.View.Context, pkId, formBusinessInfo, null); + this._baseDataInfo.Add(key, dynamicObject); + result = dynamicObject; + } + else + { + result = this._baseDataInfo[key]; + } + return result; + } + + private object GetBaseDataSubFieldValue(DynamicObject dy, BusinessInfo info, string key) + { + object result = null; + Field field = info.GetField(key); + string entryName = field.Entity.EntryName; + if (dy.DynamicObjectType.Name == entryName) + { + result = field.DynamicProperty.GetValue(dy); + } + else if (dy.DynamicObjectType.Properties.Contains(entryName)) + { + DynamicObjectCollection dynamicObjectCollection = dy[entryName] as DynamicObjectCollection; + if (!ObjectUtils.IsNullOrEmpty(dynamicObjectCollection) && dynamicObjectCollection.Count > 0) + { + result = field.DynamicProperty.GetValue(dynamicObjectCollection[0]); + } + } + return result; + } + + public DynamicObjectCollection GetDynamicRows(DynamicObject[] dySoruceObjsColl, DynamicObject dyRootSoruceObj, DynamicObjectCollection dybillCol, Dictionary DicFieldCorresMap, List lEntryNames, DynamicObjectType dotype, DynamicObject dybill, int iCurLevel, int iMaxLevel, string primaryField) + { + List list = new List(lEntryNames); + Dictionary dictionary = new Dictionary(DicFieldCorresMap); + DynamicObjectCollection dynamicObjectCollection = new DynamicObjectCollection(dotype, null); + bool flag = ObjectUtils.IsNullOrEmptyOrWhiteSpace(dyRootSoruceObj); + decimal d = Convert.ToDecimal(dybill["Qty"]); + dynamicObjectCollection = dybillCol; + string text = string.Empty; + if (dySoruceObjsColl != null && dySoruceObjsColl.Count() > 0) + { + for (int i = 0; i < dySoruceObjsColl.Length; i++) + { + DynamicObject dynamicObject = dySoruceObjsColl[i]; + if (flag) + { + dyRootSoruceObj = dynamicObject; + } + object primaryValue = null; + int num = 0; + foreach (string text2 in lEntryNames) + { + if (!ObjectUtils.IsNullOrEmptyOrWhiteSpace(primaryField)) + { + if (dyRootSoruceObj.DynamicObjectType.Properties.Contains(text2)) + { + num++; + text = text2; + list.Remove(text2); + break; + } + } + else if (dynamicObject.DynamicObjectType.Properties.Contains(text2)) + { + num++; + text = text2; + list.Remove(text2); + } + } + if (!ObjectUtils.IsNullOrEmptyOrWhiteSpace(primaryField)) + { + if (!new string[] + { + "", + "CardDetail", + "Allocation" + }.Contains(text) || list.Count() > 2) + { + num = 2; + } + } + if (num >= 2) + { + base.View.ShowWarnningMessage(ResManager.LoadKDString("在同一个条码规则中的条码属性字段,需要符合一定的规则才能生成条码打印数据:\r\n1、各属性字段都在同一个单据头,如单据头上的所有字段;\r\n2、各属性字段都在同一个单据体,例如物料明细上的所有字段;\r\n3、各属性字段虽然处于不同的单据头或单据体,但它们之间具有关联关系,例如 单据头+物料、单据头+物料+序列号、物料+序列号等。", "0011019000003272", (SubSystemType)3, new object[0]), "", 0, null, (MessageBoxType)1); + break; + } + if (num == 1) + { + foreach (BarCodeBillCorrespondInfo barCodeBillCorrespondInfo in DicFieldCorresMap.Values.ToList()) + { + string barCodeFieldKey = barCodeBillCorrespondInfo.BarCodeFieldKey; + Field barCodeField = barCodeBillCorrespondInfo.BarCodeField; + bool isBaseDataSubField = barCodeBillCorrespondInfo.IsBaseDataSubField; + Field billField = barCodeBillCorrespondInfo.BillField; + if (isBaseDataSubField) + { + if (dynamicObject.DynamicObjectType.Properties.Contains(billField.PropertyName) && !string.IsNullOrWhiteSpace(barCodeField.FieldName)) + { + string baseDataSubFieldKey = barCodeBillCorrespondInfo.BaseDataSubFieldKey; + string formId = (billField as BaseDataField).LookUpObject.FormId; + BusinessInfo formBusinessInfo = this.GetFormBusinessInfo(formId); + DynamicObject dynamicObject2 = dynamicObject[billField.PropertyName] as DynamicObject; + string pkId = Convert.ToString(dynamicObject2["Id"]); + DynamicObject baseDataDynamicObject = this.GetBaseDataDynamicObject(formId, pkId); + object baseDataSubFieldValue = this.GetBaseDataSubFieldValue(dynamicObject2, formBusinessInfo, baseDataSubFieldKey); + dybill[barCodeField.PropertyName] = baseDataSubFieldValue; + dictionary.Remove(barCodeFieldKey); + if (baseDataSubFieldValue != null && dynamicObject.DynamicObjectType.Properties.Contains(billField.PropertyName + "_Id") && dybill.DynamicObjectType.Properties.Contains(barCodeField.PropertyName + "_Id")) + { + dybill[barCodeField.PropertyName + "_Id"] = (baseDataSubFieldValue as DynamicObject)["Id"]; + } + } + } + else if (dynamicObject.DynamicObjectType.Properties.Contains(billField.PropertyName) && !string.IsNullOrWhiteSpace(barCodeField.FieldName)) + { + if (StringUtils.EqualsIgnoreCase(barCodeFieldKey, primaryField)) + { + primaryValue = dynamicObject[billField.PropertyName]; + } + if (dynamicObject[billField.PropertyName] != null && StringUtils.EqualsIgnoreCase(dynamicObject[billField.PropertyName].GetType().Name, "OrmLocaleValue")) + { + dybill[barCodeField.PropertyName] = dynamicObject[billField.PropertyName].ToString(); + } + else + { + dybill[barCodeField.PropertyName] = dynamicObject[billField.PropertyName]; + } + dictionary.Remove(barCodeFieldKey); + if (dynamicObject.DynamicObjectType.Properties.Contains(billField.PropertyName + "_Id") && dybill.DynamicObjectType.Properties.Contains(barCodeField.PropertyName + "_Id")) + { + dybill[barCodeField.PropertyName + "_Id"] = dynamicObject[billField.PropertyName + "_Id"]; + } + } + } + iCurLevel++; + if (iCurLevel > iMaxLevel) + { + iMaxLevel = iCurLevel; + } + DynamicObjectCollection dynamicObjectCollection2; + if (!ObjectUtils.IsNullOrEmptyOrWhiteSpace(primaryField)) + { + dynamicObjectCollection2 = (DynamicObjectCollection)dyRootSoruceObj[text]; + } + else + { + dynamicObjectCollection2 = (DynamicObjectCollection)dynamicObject[text]; + } + List list2 = dynamicObjectCollection2.ToList(); + if (dynamicObjectCollection2.DynamicCollectionItemPropertyType.Properties.Contains("Seq")) + { + list2 = (from a in dynamicObjectCollection2 + orderby Convert.ToInt32(a["Seq"]) + select a).ToList(); + } + if (!ObjectUtils.IsNullOrEmptyOrWhiteSpace(primaryValue)) + { + list2 = (from p in list2 + where StringUtils.EqualsIgnoreCase(p["AllocAssetNO"].ToString(), primaryValue.ToString()) + select p).ToList(); + } + this.GetDynamicRows(list2.ToArray(), dyRootSoruceObj, dynamicObjectCollection, dictionary, list, dotype, dybill, iCurLevel, iMaxLevel, primaryField); + iCurLevel--; + } + else + { + foreach (BarCodeBillCorrespondInfo barCodeBillCorrespondInfo in DicFieldCorresMap.Values.ToList()) + { + string barCodeFieldKey = barCodeBillCorrespondInfo.BarCodeFieldKey; + Field barCodeField = barCodeBillCorrespondInfo.BarCodeField; + bool isBaseDataSubField = barCodeBillCorrespondInfo.IsBaseDataSubField; + Field billField = barCodeBillCorrespondInfo.BillField; + if (isBaseDataSubField) + { + if (dynamicObject.DynamicObjectType.Properties.Contains(billField.PropertyName) && !string.IsNullOrWhiteSpace(barCodeField.FieldName)) + { + string baseDataSubFieldKey = barCodeBillCorrespondInfo.BaseDataSubFieldKey; + string formId = (billField as BaseDataField).LookUpObject.FormId; + BusinessInfo formBusinessInfo = this.GetFormBusinessInfo(formId); + DynamicObject dynamicObject2 = dynamicObject[billField.PropertyName] as DynamicObject; + object baseDataSubFieldValue; + if (dynamicObject2.DynamicObjectType.Properties.Contains(formBusinessInfo.GetField(baseDataSubFieldKey).PropertyName)) + { + baseDataSubFieldValue = this.GetBaseDataSubFieldValue(dynamicObject2, formBusinessInfo, baseDataSubFieldKey); + } + else + { + string pkId = Convert.ToString(dynamicObject2["Id"]); + DynamicObject baseDataDynamicObject = this.GetBaseDataDynamicObject(formId, pkId); + baseDataSubFieldValue = this.GetBaseDataSubFieldValue(baseDataDynamicObject, formBusinessInfo, baseDataSubFieldKey); + } + dybill[barCodeField.PropertyName] = baseDataSubFieldValue; + dictionary.Remove(barCodeFieldKey); + if (dynamicObject.DynamicObjectType.Properties.Contains(billField.PropertyName + "_Id") && dybill.DynamicObjectType.Properties.Contains(barCodeField.PropertyName + "_Id")) + { + if (baseDataSubFieldValue != null) + { + dybill[barCodeField.PropertyName + "_Id"] = (baseDataSubFieldValue as DynamicObject)["Id"]; + } + } + } + } + else if (dynamicObject.DynamicObjectType.Properties.Contains(billField.PropertyName) && !string.IsNullOrWhiteSpace(barCodeField.FieldName)) + { + if (dynamicObject[billField.PropertyName] != null && StringUtils.EqualsIgnoreCase(dynamicObject[billField.PropertyName].GetType().Name, "OrmLocaleValue")) + { + dybill[barCodeField.PropertyName] = dynamicObject[billField.PropertyName].ToString(); + } + else + { + dybill[barCodeField.PropertyName] = dynamicObject[billField.PropertyName]; + } + dictionary.Remove(barCodeFieldKey); + if (dynamicObject.DynamicObjectType.Properties.Contains(billField.PropertyName + "_Id") && dybill.DynamicObjectType.Properties.Contains(barCodeField.PropertyName + "_Id")) + { + dybill[barCodeField.PropertyName + "_Id"] = dynamicObject[billField.PropertyName + "_Id"]; + } + } + } + if (!ObjectUtils.IsNullOrEmptyOrWhiteSpace(primaryField) && StringUtils.EqualsIgnoreCase(dynamicObject.DynamicObjectType.Name, "Allocation")) + { + dybill["Qty"] = d * Convert.ToDecimal(dynamicObject["AllocRatio"]) / 100m; + } + if (iCurLevel == iMaxLevel) + { + dynamicObjectCollection.Add(this.GetNewDynamicObject(dybill)); + } + } + } + } + else if (iCurLevel == iMaxLevel) + { + dynamicObjectCollection.Add(this.GetNewDynamicObject(dybill)); + } + return dynamicObjectCollection; + } + + public DynamicObject GetNewDynamicObject(DynamicObject dybill) + { + DynamicObject dynamicObject = new DynamicObject(dybill.DynamicObjectType); + foreach (DynamicProperty dynamicProperty in dybill.DynamicObjectType.Properties) + { + dynamicObject[dynamicProperty] = dybill[dynamicProperty]; + } + return dynamicObject; + } + + private void CreateBillRows(DynamicObjectCollection billDetils, EntryEntity entity, Dictionary DicFieldCorresMap) + { + int num = this.Model.GetEntryRowCount("FEntityToBill"); + string text = base.View.Model.GetValue("FBARCODEMODEL").ToString(); + DynamicObject dynamicObject = base.View.Model.GetValue("FBarCodeRule") as DynamicObject; + DynamicObject dynamicObject2 = base.View.Model.GetValue("FBarCodeBoxRule") as DynamicObject; + DynamicObject dObject = base.View.Model.GetValue("FBillId") as DynamicObject; + bool flag = false; + List source = null; + if (dObject != null && dObject.DynamicObjectType.Properties.Contains("MODELTYPEID") && dObject.DynamicObjectType.Properties.Contains("Id")) + { + flag = (Convert.ToInt32(dObject["MODELTYPEID"]) == 400); + if (flag) + { + source = (from p in base.View.BusinessInfo.GetEntity("FEntityToBill").Fields + select p as BaseDataField into p + where p != null + select p).ToList(); + } + } + foreach (DynamicObject dynamicObject3 in billDetils) + { + base.View.Model.CreateNewEntryRow("FEntityToBill"); + DynamicObject entityDataObject = base.View.Model.GetEntityDataObject(entity, num); + foreach (BarCodeBillCorrespondInfo barCodeBillCorrespondInfo in DicFieldCorresMap.Values) + { + Field barCodeField = barCodeBillCorrespondInfo.BarCodeField; + if (barCodeField.DynamicProperty != null && dynamicObject3.DynamicObjectType.Properties.Contains(barCodeField.PropertyName)) + { + try + { + if (StringUtils.EqualsIgnoreCase(barCodeField.Key, "FMaterialId")) + { + if (dynamicObject3.DynamicObjectType.Properties.Contains(barCodeField.PropertyName + "_Id")) + { + base.View.Model.SetValue(barCodeField.Key, dynamicObject3[barCodeField.PropertyName + "_Id"], num); + } + else + { + base.View.Model.SetValue(barCodeField.Key, barCodeField.DynamicProperty.GetValue(dynamicObject3), num); + } + } + else if (barCodeField is LotField) + { + if ((barCodeField as LotField).InputModel != 0) + { + DynamicObject dynamicObject4 = null; + string text2 = string.Empty; + if (barCodeField.DynamicProperty.GetValue(dynamicObject3) is DynamicObject) + { + dynamicObject4 = (DynamicObject)barCodeField.DynamicProperty.GetValue(dynamicObject3); + } + if (dynamicObject4 != null) + { + text2 = Convert.ToString(dynamicObject4["number"]); + } + base.View.Model.SetValue(barCodeField.Key, text2, num); + ((LotField)barCodeField).DynamicProperty.SetValue(entityDataObject, dynamicObject4); + ((LotField)barCodeField).RefIDDynamicProperty.SetValue(entityDataObject, dynamicObject3[barCodeField.PropertyName + "_Id"]); + } + else if (dynamicObject3.DynamicObjectType.Properties.Contains(barCodeField.PropertyName + "_Id")) + { + base.View.Model.SetItemValueByID(barCodeField.Key, dynamicObject3[barCodeField.PropertyName + "_Id"], num); + } + } + else if (barCodeField is RelatedFlexGroupField) + { + if (Regex.IsMatch(dynamicObject3[barCodeField.PropertyName + "_Id"].ToString(), "^[+-]?\\d*$")) + { + DynamicObject dynamicObject5 = barCodeField.DynamicProperty.GetValue(dynamicObject3) as DynamicObject; + base.View.Model.SetItemValueByID(barCodeField.Key, ObjectUtils.IsNullOrEmptyOrWhiteSpace(dynamicObject5) ? 0 : dynamicObject5["Id"], num); + } + else + { + DynamicObject dynamicObject5 = barCodeField.DynamicProperty.GetValue(dynamicObject3) as DynamicObject; + base.View.Model.SetItemValueByID(barCodeField.Key, ObjectUtils.IsNullOrEmptyOrWhiteSpace(dynamicObject5) ? "" : dynamicObject5["Id"], num); + } + } + else + { + base.View.Model.SetValue(barCodeField.Key, barCodeField.DynamicProperty.GetValue(dynamicObject3), num); + if (dynamicObject3.DynamicObjectType.Properties.Contains(barCodeField.PropertyName + "_Id")) + { + base.View.Model.SetItemValueByID(barCodeField.Key, dynamicObject3[barCodeField.PropertyName + "_Id"], num); + } + } + if (flag && StringUtils.EqualsIgnoreCase(barCodeField.Key, "FBASEDATAID")) + { + base.View.Model.SetValue("FBASEDATATYPE", dObject["Id"], num); + BaseDataField baseDataField = (from p in source + where StringUtils.EqualsIgnoreCase(p.LookUpObject.FormId, dObject["Id"].ToString()) + select p).FirstOrDefault(); + if (baseDataField != null) + { + base.View.Model.SetValue(baseDataField.Key, barCodeField.DynamicProperty.GetValue(dynamicObject3), num); + DynamicObject dynamicObject6 = BusinessDataServiceHelper.LoadSingle(base.View.Context, barCodeField.DynamicProperty.GetValue(dynamicObject3), this._billFormMetaData.BusinessInfo.GetDynamicObjectType(), null); + if (dynamicObject6 != null) + { + base.View.Model.SetValue(baseDataField.Key, dynamicObject6, num); + } + } + } + } + catch + { + } + } + } + this.CalcCreateNumber(num); + base.View.Model.SetValue("FBARCODEMODELToBill", text, num); + if (dynamicObject != null) + { + base.View.Model.SetValue("FBARCODERULEToBill", dynamicObject["Id"], num); + } + if (dynamicObject2 != null) + { + base.View.Model.SetValue("FBARCODEBOXRULEToBill", dynamicObject2["Id"], num); + } + DynamicObject dynamicObject7 = base.View.Model.GetValue("FMaterialId", num) as DynamicObject; + if (dynamicObject7 != null) + { + string text3 = string.Format("FMATERIALID = {0} ", dynamicObject7["Id"]); + OQLFilter oqlfilter = OQLFilter.CreateHeadEntityFilter(text3); + dynamicObject7 = BusinessDataServiceHelper.Load(base.Context, "BD_MATERIAL", null, oqlfilter).FirstOrDefault(); + if (dynamicObject7 != null) + { + DynamicObject dynamicObject8 = (dynamicObject7["MaterialPurchase"] as DynamicObjectCollection).FirstOrDefault(); + if (dynamicObject8 != null && dynamicObject8.DynamicObjectType.Properties.Contains("BoxQty")) + { + decimal num2 = Convert.ToDecimal(dynamicObject8["BoxQty"]); + base.View.Model.SetValue("FBoxQty", num2, num); + } + } + } + num++; + } + int entryRowCount = this.Model.GetEntryRowCount("FEntityToBill"); + for (int i = 0; i < entryRowCount; i++) + { + base.View.InvokeFieldUpdateService("FMaterialId", i); + } + } + + private void ModifyBillRow(DynamicObject detil, Dictionary DicFieldCorresMap, int RowIndex) + { + DynamicObject dObject = base.View.Model.GetValue("FBillId") as DynamicObject; + bool flag = false; + List source = null; + if (dObject != null && dObject.DynamicObjectType.Properties.Contains("MODELTYPEID") && dObject.DynamicObjectType.Properties.Contains("Id")) + { + flag = (Convert.ToInt32(dObject["MODELTYPEID"]) == 400); + if (flag) + { + source = (from p in base.View.BusinessInfo.GetEntity("FEntityToBill").Fields + select p as BaseDataField into p + where p != null + select p).ToList(); + } + } + foreach (BarCodeBillCorrespondInfo barCodeBillCorrespondInfo in DicFieldCorresMap.Values) + { + Field barCodeField = barCodeBillCorrespondInfo.BarCodeField; + if (barCodeField.DynamicProperty != null && detil.DynamicObjectType.Properties.Contains(barCodeField.PropertyName)) + { + try + { + if (StringUtils.EqualsIgnoreCase(barCodeField.Key, "FMaterialId")) + { + if (detil.DynamicObjectType.Properties.Contains(barCodeField.PropertyName + "_Id")) + { + base.View.Model.SetValue(barCodeField.Key, detil[barCodeField.PropertyName + "_Id"], RowIndex); + } + else + { + base.View.Model.SetValue(barCodeField.Key, barCodeField.DynamicProperty.GetValue(detil), RowIndex); + } + } + else if (barCodeField is LotField) + { + if ((barCodeField as LotField).InputModel != 0) + { + DynamicObject dynamicObject = null; + string text = string.Empty; + if (barCodeField.DynamicProperty.GetValue(detil) is DynamicObject) + { + dynamicObject = (DynamicObject)barCodeField.DynamicProperty.GetValue(detil); + } + if (dynamicObject != null) + { + text = Convert.ToString(dynamicObject["number"]); + } + base.View.Model.SetValue(barCodeField.Key, text, RowIndex); + } + else if (detil.DynamicObjectType.Properties.Contains(barCodeField.PropertyName + "_Id")) + { + base.View.Model.SetValue(barCodeField.Key, detil[barCodeField.PropertyName + "_Id"], RowIndex); + } + } + else + { + base.View.Model.SetValue(barCodeField.Key, barCodeField.DynamicProperty.GetValue(detil), RowIndex); + if (detil.DynamicObjectType.Properties.Contains(barCodeField.PropertyName + "_Id")) + { + base.View.Model.SetValue(barCodeField.Key, detil[barCodeField.PropertyName + "_Id"], RowIndex); + } + } + if (flag && StringUtils.EqualsIgnoreCase(barCodeField.Key, "FBASEDATAID")) + { + base.View.Model.SetValue("FBASEDATATYPE", dObject["Id"], RowIndex); + BaseDataField baseDataField = (from p in source + where StringUtils.EqualsIgnoreCase(p.LookUpObject.FormId, dObject["Id"].ToString()) + select p).FirstOrDefault(); + if (baseDataField != null) + { + base.View.Model.SetValue(baseDataField.Key, barCodeField.DynamicProperty.GetValue(detil), RowIndex); + DynamicObject dynamicObject2 = BusinessDataServiceHelper.LoadSingle(base.View.Context, barCodeField.DynamicProperty.GetValue(detil), this._billFormMetaData.BusinessInfo.GetDynamicObjectType(), null); + if (dynamicObject2 != null) + { + base.View.Model.SetValue(baseDataField.Key, dynamicObject2, RowIndex); + } + } + } + } + catch + { + } + } + } + } + + private void InitCustParam(InitializeEventArgs e) + { + int.TryParse((e.Paramter.GetCustomParameter("isFromBill") == null) ? string.Empty : e.Paramter.GetCustomParameter("isFromBill").ToString(), out this._isFromBill); + int.TryParse((e.Paramter.GetCustomParameter("isFromPrintList") == null) ? string.Empty : e.Paramter.GetCustomParameter("isFromPrintList").ToString(), out this._isFromPrintList); + if (this._isFromBill == 1) + { + this._sFormId = ((e.Paramter.GetCustomParameter("SourceFormId") == null) ? "" : e.Paramter.GetCustomParameter("SourceFormId").ToString()); + this._sourceId = ((e.Paramter.GetCustomParameter("SourceId") == null) ? "" : e.Paramter.GetCustomParameter("SourceId").ToString()); + this._sRuleId = ((e.Paramter.GetCustomParameter("RuleId") == null) ? 0 : Convert.ToInt32(e.Paramter.GetCustomParameter("RuleId"))); + this._billFormMetaData = (FormMetadata)MetaDataServiceHelper.Load(base.Context, this._sFormId, true); + base.View.Model.SetValue("FBillId", this._sFormId); + base.View.Model.SetValue("FBarCodeRule", this._sRuleId); + } + } + + public void SetComboField() + { + ComboFieldEditor fieldEditor = base.View.GetFieldEditor("FBarCodeModel", 0); + fieldEditor.SetComboItems(this._noteTemplates); + fieldEditor = base.View.GetFieldEditor("FBarCodeBoxModel", 0); + fieldEditor.SetComboItems(this._noteTemplates); + } + + public void OpenBarCodeGetBill() + { + if (string.IsNullOrEmpty(this._sFormId)) + { + base.View.ShowWarnningMessage(ResManager.LoadKDString("请先录入源业务对象!", "0011019000003167", (SubSystemType)3, new object[0]), "", 0, null, (MessageBoxType)1); + } + else + { + string text = this._sFormId; + if (StringUtils.EqualsIgnoreCase(text, "BD_OverASerialView")) + { + text = "BD_SerialMainFile"; + } + List permissionOrg = PermissionServiceHelper.GetPermissionOrg(base.View.Context, new BusinessObject + { + Id = text + }, "6e44119a58cb4a8e86f6c385e14a17ad"); + if (!permissionOrg.Contains(base.Context.CurrentOrganizationInfo.ID)) + { + base.View.ShowWarnningMessage(ResManager.LoadKDString("当前组织下没有源业务对象的查看权限,不允许选单!", "0011019000003231", (SubSystemType)3, new object[0]), "", 0, null, (MessageBoxType)1); + } + else if (this._sRuleId == 0) + { + base.View.ShowWarnningMessage(ResManager.LoadKDString("请先录入默认条码规则!", "0011019000003092", (SubSystemType)3, new object[0]), "", 0, null, (MessageBoxType)1); + } + else if (this._isAutoPacking && this._sBoxRuleId == 0) + { + base.View.ShowWarnningMessage(ResManager.LoadKDString("请先录入默认包装条码规则!", "58d194b2aae944ca", (SubSystemType)16, new object[0]), "", 0, null, (MessageBoxType)1); + } + else + { + ListShowParameter listShowParameter = new ListShowParameter(); + this.billPageId = SequentialGuid.NewGuid().ToString(); + listShowParameter.IsLookUp = true; + listShowParameter.ParentPageId = base.View.PageId; + listShowParameter.FormId = this._sFormId; + listShowParameter.MultiSelect = true; + listShowParameter.PageId = this.billPageId; + listShowParameter.IsIsolationOrg = true; + listShowParameter.UseOrgId = base.Context.CurrentOrganizationInfo.ID; + if (StringUtils.EqualsIgnoreCase(this._sFormId, "ENG_WorkCenter")) + { + listShowParameter.CustomParams.Add("WorkCenterType", "D"); + } + if (StringUtils.EqualsIgnoreCase(this._sFormId, "STK_Inventory")) + { + listShowParameter.CustomParams.Add("NeedReturnData", "1"); + listShowParameter.CustomParams.Add("IsFromStockQuery", "True"); + listShowParameter.CustomParams.Add("QueryMode", "1"); + listShowParameter.CustomParams.Add("IsShowExit", "True"); + } + string text2 = string.Empty; + if (new List + { + "PUR_PurchaseOrder", + "SAL_SaleOrder", + "SAL_DELIVERYNOTICE" + }.Contains(this._sFormId)) + { + text2 = " t0.FCLOSESTATUS='A' "; + } + if (this._sFormId == "PRD_MO") + { + text2 = " t1_A.FSTATUS!=6 "; + } + if (this._sFormId == "SUB_SUBREQORDER") + { + text2 = " t1.FSTATUS!=6 "; + } + if (!string.IsNullOrWhiteSpace(text2)) + { + if (string.IsNullOrEmpty(listShowParameter.ListFilterParameter.Filter)) + { + listShowParameter.ListFilterParameter.Filter = text2; + } + else + { + IRegularFilterParameter listFilterParameter = listShowParameter.ListFilterParameter; + listFilterParameter.Filter = listFilterParameter.Filter + " AND " + text2; + } + } + base.View.ShowForm(listShowParameter, delegate (FormResult result) + { + this.ApplyReturnData(result); + }); + } + } + } + + private void ApplyReturnData(FormResult ret) + { + if (ret != null && ret.ReturnData != null && !string.IsNullOrWhiteSpace(ret.ReturnData.ToString())) + { + object returnData = ret.ReturnData; + if (returnData is ListSelectedRowCollection) + { + this.listData = (returnData as ListSelectedRowCollection); + List list = new List(); + foreach (ListSelectedRow listSelectedRow in this.listData) + { + if (listSelectedRow.Selected && listSelectedRow.PrimaryKeyValue != null && !string.IsNullOrWhiteSpace(listSelectedRow.PrimaryKeyValue)) + { + list.Add(listSelectedRow.PrimaryKeyValue); + } + } + if (list != null && list.Count() >= 1) + { + if (StringUtils.EqualsIgnoreCase(this._sFormId, "STK_Inventory")) + { + this._sourceId = "'" + string.Join("','", list) + "'"; + } + else + { + this._sourceId = string.Join(",", list); + } + this._isFromBill = 1; + this._billFormMetaData = (FormMetadata)MetaDataServiceHelper.Load(base.Context, this._sFormId, true); + this.BindBillData(); + } + } + } + } + + private bool CheckSelectRows() + { + EntryEntity entryEntity = (EntryEntity)base.View.BusinessInfo.GetEntity("FEntityToBill"); + DynamicObjectCollection source = (from p in base.View.Model.GetEntityDataObject(entryEntity) + where StringUtils.EqualsIgnoreCase(p["BillCheckBox"].ToString(), "True") + select p) as DynamicObjectCollection; + return source.Count() > 1; + } + + private string GetBarcodeWriteBackKey(DynamicObject doRule) + { + string result = string.Empty; + if (doRule != null) + { + DynamicObjectCollection dynamicObjectCollection = doRule["BD_BARCODERULEENTRYToBill"] as DynamicObjectCollection; + foreach (DynamicObject dynamicObject in dynamicObjectCollection) + { + string text = Convert.ToString(dynamicObject["BillId_Id"]); + if (StringUtils.EqualsIgnoreCase(text, this._sFormId)) + { + string text2 = Convert.ToString(dynamicObject["FieldKey"]); + if (!ObjectUtils.IsNullOrEmptyOrWhiteSpace(text2)) + { + result = text2; + } + break; + } + } + } + return result; + } + + public void SetBarCodeValue(List>>> AllBoxContrastNumbers, string sType, List existedNumbers = null) + { + Logger.Info("SetBarCodeValue", string.Format(ResManager.LoadKDString("生成条码分录数据开始", "c40bc32ce96a4219", (SubSystemType)16, new object[0]), new object[0])); + EntryEntity entryEntity = (EntryEntity)base.View.BusinessInfo.GetEntity("FEntityToBill"); + DynamicObject[] array = (from p in base.View.Model.GetEntityDataObject(entryEntity) + where StringUtils.EqualsIgnoreCase(p["BillCheckBox"].ToString(), "True") + select p).ToArray(); + List fields = entryEntity.Fields; + string text = string.Format(" FID='{0}' ", this._sRuleId); + OQLFilter oqlfilter = OQLFilter.CreateHeadEntityFilter(text); + DynamicObject dynamicObject = BusinessDataServiceHelper.Load(base.Context, "BD_BarCodeRule", null, oqlfilter).FirstOrDefault(); + DynamicObjectCollection source = dynamicObject["BD_BARCODERULEENTRY"] as DynamicObjectCollection; + EntryEntity entryEntity2 = (EntryEntity)base.View.BusinessInfo.GetEntity("FEntityToBar"); + List fields2 = entryEntity2.Fields; + Dictionary dictionary = new Dictionary(); + using (List.Enumerator enumerator = fields2.GetEnumerator()) + { + while (enumerator.MoveNext()) + { + Field field = enumerator.Current; + DynamicObject dynamicObject2 = source.FirstOrDefault((DynamicObject p) => StringUtils.EqualsIgnoreCase((p["BarCodePropertyId"] as DynamicObject)["BARCODEFIELDKEY"].ToString(), field.FieldName)); + if ((dynamicObject2 != null && !dictionary.Keys.Contains(field)) || StringUtils.EqualsIgnoreCase(field.Key, "FBarCodeRuleToBar") || StringUtils.EqualsIgnoreCase(field.Key, "FBarCodeModelToBar")) + { + dictionary.Add(field, (from p in fields + where StringUtils.EqualsIgnoreCase(p.FieldName, field.FieldName) + select p).FirstOrDefault()); + } + } + } + int num = 0; + int num2 = 0; + List list = null; + List list2 = new List(); + StringBuilder stringBuilder = new StringBuilder(); + List list3 = new List(); + int num3 = 0; + decimal num4 = 0m; + int num5 = 0; + int num6 = this._proIncrement; + int num7 = 1; + if (AllBoxContrastNumbers.Count>>>() > 0) + { + num6 = this._proIncrement / AllBoxContrastNumbers.Count>>>(); + } + if (num6 <= 0) + { + num6 = 1; + num7 = AllBoxContrastNumbers.Count>>>() / this._proIncrement; + } + int num8 = 0; + foreach (KeyValuePair>> keyValuePair in AllBoxContrastNumbers) + { + Dictionary> value = keyValuePair.Value; + int num9 = (from p in value + where !ObjectUtils.IsNullOrEmptyOrWhiteSpace(p.Key) + select p).ToList>>().Count>>(); + int num10 = num6; + int num11 = 1; + if (num9 > 0) + { + num10 = num6 / num9; + } + if (num10 <= 0) + { + num10 = 1; + num11 = num9 / num6; + } + int num12 = 0; + int num13 = 0; + foreach (KeyValuePair> keyValuePair2 in value) + { + DynamicObject dynamicObject3 = null; + int num14 = -1; + decimal num15 = 0m; + if (num2 >= array.Count()) + { + break; + } + dynamicObject3 = array[num2]; + if (num2 == keyValuePair.Key) + { + List value2 = keyValuePair2.Value; + int num16 = value2.Distinct().Count(); + if ((num16 > 1 && num16 == value2.Count) || (sType.Equals("TBCREBARCODEROW") && num16 == 1)) + { + } + } + if (keyValuePair2.Value != null) + { + if (sType.Equals("TBCREBARCODEROW")) + { + list = (from p in keyValuePair2.Value + where !ObjectUtils.IsNullOrEmptyOrWhiteSpace(p) + select p).ToList(); + } + else + { + list = (from p in keyValuePair2.Value.Distinct() + where !ObjectUtils.IsNullOrEmptyOrWhiteSpace(p) + select p).ToList(); + } + bool flag = false; + if (!ObjectUtils.IsNullOrEmptyOrWhiteSpace(keyValuePair2.Key)) + { + list.Insert(0, keyValuePair2.Key); + flag = true; + } + int num17 = (from p in list + where !ObjectUtils.IsNullOrEmptyOrWhiteSpace(p) + select p).ToList().Count(); + int num18 = num10; + int num19 = 1; + if (num17 > 0) + { + num18 = num10 / num17; + } + if (num18 <= 0) + { + num18 = 1; + num19 = num17 / num10; + } + int num20 = 0; + foreach (string text2 in list) + { + if (!ObjectUtils.IsNullOrEmptyOrWhiteSpace(text2)) + { + num3++; + if (list2 == null || (list2 != null && !list2.Contains(text2))) + { + base.View.Model.CreateNewEntryRow("FEntityToBar"); + num = this.Model.GetEntryCurrentRowIndex("FEntityToBar"); + DynamicObject entityDataObject = base.View.Model.GetEntityDataObject(entryEntity2, num); + foreach (Field field2 in fields2) + { + if (dictionary.ContainsKey(field2) && dictionary[field2] != null && dictionary[field2].DynamicProperty != null) + { + if (dictionary[field2] is LotField) + { + if ((dictionary[field2] as LotField).InputModel != 0) + { + DynamicObject dynamicObject4 = null; + string text3 = string.Empty; + if (dictionary[field2].DynamicProperty.GetValue(dynamicObject3) is DynamicObject) + { + dynamicObject4 = (DynamicObject)dictionary[field2].DynamicProperty.GetValue(dynamicObject3); + } + if (dynamicObject4 != null) + { + text3 = Convert.ToString(dynamicObject4["number"]); + } + else if (dynamicObject3.DynamicObjectType.Properties.Contains(dictionary[field2].PropertyName + "_Text")) + { + text3 = Convert.ToString(dynamicObject3[dictionary[field2].PropertyName + "_Text"]); + } + base.View.Model.SetValue(field2.Key, text3, num); + } + else if (dynamicObject3.DynamicObjectType.Properties.Contains(dictionary[field2].PropertyName + "_Id")) + { + base.View.Model.SetValue(field2.Key, dynamicObject3[dictionary[field2].PropertyName + "_Id"], num); + } + } + else if (dictionary[field2] is RelatedFlexGroupField) + { + if (Regex.IsMatch(dynamicObject3[dictionary[field2].PropertyName + "_Id"].ToString(), "^[+-]?\\d*$")) + { + DynamicObject dynamicObject5 = dictionary[field2].DynamicProperty.GetValue(dynamicObject3) as DynamicObject; + base.View.Model.SetItemValueByID(field2.Key, ObjectUtils.IsNullOrEmptyOrWhiteSpace(dynamicObject5) ? 0 : dynamicObject5["Id"], num); + } + else + { + DynamicObject dynamicObject5 = dictionary[field2].DynamicProperty.GetValue(dynamicObject3) as DynamicObject; + base.View.Model.SetItemValueByID(field2.Key, ObjectUtils.IsNullOrEmptyOrWhiteSpace(dynamicObject5) ? "" : dynamicObject5["Id"], num); + } + } + else + { + base.View.Model.SetValue(field2.Key, dictionary[field2].DynamicProperty.GetValue(dynamicObject3), num); + if (dynamicObject3.DynamicObjectType.Properties.Contains(dictionary[field2].PropertyName + "_Id") && !ObjectUtils.IsNullOrEmptyOrWhiteSpace(dynamicObject3[dictionary[field2].PropertyName + "_Id"])) + { + base.View.Model.SetItemValueByID(field2.Key, dynamicObject3[dictionary[field2].PropertyName + "_Id"], num); + } + } + } + } + base.View.Model.SetValue("FBARCODE", text2, num); + base.View.Model.SetValue("FDOCUMENTSTATUS", "", num); + if (flag) + { + decimal num21 = (dynamicObject3["CreateNumber"] != null) ? Convert.ToDecimal(dynamicObject3["CreateNumber"]) : 0m; + decimal d = (dynamicObject3["BoxQty"] != null) ? Convert.ToDecimal(dynamicObject3["BoxQty"]) : 0m; + decimal d2 = (dynamicObject3["Qty"] != null) ? Convert.ToDecimal(dynamicObject3["Qty"]) : 0m; + decimal num22 = 1m; + if (num21 != 0m && d2 != 0m) + { + num22 = Math.Floor(d / (d2 / num21)); + } + base.View.Model.SetValue("FQtyToBar", num22, num); + if (num22 > list.Count() - 1) + { + base.View.Model.SetValue("FIsLastBox", true, num); + } + DynamicObject dynamicObject6 = dynamicObject3["BARCODEBOXRULE"] as DynamicObject; + base.View.Model.SetValue("FBarCodeRuleToBar", dynamicObject6, num); + object value3 = base.View.Model.GetValue("FBarCodeBoxModel"); + base.View.Model.SetValue("FBarCodeModelToBar", value3, num); + flag = false; + num14 = num; + } + else + { + num5++; + decimal d2 = (dynamicObject3["Qty"] != null) ? Convert.ToDecimal(dynamicObject3["Qty"]) : 0m; + int num23 = (dynamicObject3["CreateNumber"] != null) ? Convert.ToInt32(dynamicObject3["CreateNumber"]) : 1; + decimal num24 = (dynamicObject3["MinPackCount"] != null) ? Convert.ToDecimal(dynamicObject3["MinPackCount"]) : 1m; + decimal num25 = 1m; + if (num24 != 0m && d2 != 0m) + { + num25 = d2 / num24; + } + int num26 = Convert.ToInt32(num25); + int num27; + if (num26 < num25) + { + num27 = num26 + 1; + } + else + { + num27 = num26; + } + if (d2 > 0m && num23 > 0 && num24 > 0m) + { + decimal num28; + if (num23 == num27) + { + num28 = num24; + } + else + { + num28 = d2 / num23; + } + if (num5 == num23) + { + num28 = d2 - num4; + num5 = 0; + num4 = 0m; + if (num28 < num24) + { + base.View.Model.SetValue("FIsLastBox", true, num); + } + } + else + { + num4 += num28; + } + base.View.Model.SetValue("FQtyToBar", num28, num); + num15 += num28; + } + } + base.View.Model.SetValue("FBILLNAME", this._sFormId, num); + base.View.InvokeFieldUpdateService("FQtyToBar", num); + decimal num29 = (base.View.Model.GetValue("FQtyToBar", num) == null) ? 0m : Convert.ToDecimal(base.View.Model.GetValue("FQtyToBar", num)); + list3.Add(string.Format(" Update T_BD_BARCODEMAIN SET FQTY={0} WHERE FBARCODE='{1}'; ", num29, text2)); + if (!ObjectUtils.IsNullOrEmptyOrWhiteSpace(keyValuePair2.Key)) + { + list3.Add(string.Format(" Update t_UN_PackagingEntry SET FQTY={0} WHERE FENTRYBARCODE='{1}'; ", num29, text2)); + } + num++; + if (sType.Equals("TBCREBARCODESUM") && list2 != null) + { + list2.Add(text2); + } + if (existedNumbers != null && existedNumbers.Contains(text2)) + { + EntryGrid control = base.View.GetControl("FEntityToBar"); + control.SetForecolor("FBarCode", "#FF0000", num); + } + } + num20++; + if (num20 % num19 == 0) + { + base.View.Session["ProcessRateValue"] = num13 + num20 % num19 * num18; + } + Logger.Info("SetBarCodeValue", string.Format(ResManager.LoadKDString("条码{0}生成分录数据完成", "1bc64827d77a47c5", (SubSystemType)16, new object[0]), text2)); + } + } + } + if (num14 != -1) + { + base.View.Model.SetValue("FBoxQtyToBar", num15, num14); + list3.Add(string.Format(" Update T_BD_BARCODEMAIN SET FBOXQTY={0} WHERE FBARCODE='{1}'; ", num15, keyValuePair2.Key)); + num3++; + } + if (!ObjectUtils.IsNullOrEmptyOrWhiteSpace(keyValuePair2.Key)) + { + list3.Add(string.Format("update t_UN_Packaging set FENTRYCOUNT=(select count(1) from t_UN_PackagingEntry where t_UN_PackagingEntry.FID=t_UN_Packaging.FID),\r\n FSUMQTY=(select sum(FQTY) from t_UN_PackagingEntry where t_UN_PackagingEntry.FID=t_UN_Packaging.FID) where FPACKAGING='{0}';", keyValuePair2.Key)); + } + num12++; + if (num12 % num11 == 0) + { + num13 = num8 + num12 % num11 * num10; + base.View.Session["ProcessRateValue"] = num13; + } + Logger.Info("SetBarCodeValue", string.Format(ResManager.LoadKDString("箱条码{0} 全部生成分录数据完成", "6bc38aa376e2469c", (SubSystemType)16, new object[0]), keyValuePair2.Key)); + } + num2++; + if (num2 % num7 == 0) + { + num8 = num2 % num7 * num6; + base.View.Session["ProcessRateValue"] = num8; + } + Logger.Info("SetBarCodeValue", string.Format(ResManager.LoadKDString("源单分录{0}行 全部生成分录数据完成", "2fb244890b1043ab", (SubSystemType)16, new object[0]), num2)); + } + DateTime now = DateTime.Now; + Logger.Info("SetBarCodeValue", string.Format(ResManager.LoadKDString("回填条码数量sql开始执行,数量:{0}", "dd5bc2f02a18436d", (SubSystemType)16, new object[0]), list3.Count())); + if (list3.Count() > 0) + { + DBUtils.ExecuteBatch(base.Context, list3, 500); + num3 = 0; + } + DateTime now2 = DateTime.Now; + TimeSpan timeSpan = now2 - now; + Logger.Info("SetBarCodeValue", string.Format(ResManager.LoadKDString("回填条码数量sql执行完成,执行时间:{0}", "3a0a11407d3f4caa", (SubSystemType)16, new object[0]), timeSpan.ToString("g"))); + } + + public void SetDefRuleId() + { + if (!string.IsNullOrEmpty(this._sFormId)) + { + this._sRuleId = BarCodeCommonServiceHelper.GetDefRuleIdbyFormId(base.View.Context, this._sFormId); + base.View.Model.SetValue("FBARCODERULE", this._sRuleId); + } + else + { + base.View.Model.SetValue("FBARCODERULE", 0); + } + } + + private void SavingPrintBarCode() + { + if (this.CreateSavingPrintBarCode()) + { + ListShowParameter listShowParameter = new ListShowParameter(); + listShowParameter.ListFilterParameter = new ListRegularFilterParameter + { + Filter = string.Format("FPRINTID='{0}'", base.View.Model.GetPKValue()) + }; + listShowParameter.IsLookUp = false; + listShowParameter.ListType = Convert.ToInt32(2); + listShowParameter.IsShowUsed = false; + listShowParameter.IsShowApproved = false; + listShowParameter.ParentPageId = base.View.PageId; + listShowParameter.MultiSelect = true; + listShowParameter.FormId = "BD_BarCodePool"; + base.View.ShowForm(listShowParameter); + } + } + + private bool CreateSavingPrintBarCode() + { + bool flag = false; + BarCoder barCoder = new BarCoder(); + DynamicObjectCollection source = base.View.Model.DataObject["BD_BARCODEPRINTENTRYBAR"] as DynamicObjectCollection; + DynamicObject[] array = (from p in source + where StringUtils.EqualsIgnoreCase(p["BarCodeCheck"].ToString(), "True") + select p).ToArray(); + bool result; + if (array.Count() < 1) + { + base.View.ShowWarnningMessage(ResManager.LoadKDString("请先选择打印数据行!", "0011019000003158", (SubSystemType)3, new object[0]), "", 0, null, (MessageBoxType)1); + result = false; + } + else + { + EntryEntity entryEntity = (EntryEntity)base.View.BusinessInfo.GetEntity("FEntityToBar"); + List fields = entryEntity.Fields; + barCoder.DeleteBarCodePool(base.Context, base.View.Model.GetPKValue()); + if (array.Count() > 0) + { + flag = true; + } + FormMetadata formMetadata = (FormMetadata)MetaDataServiceHelper.Load(base.Context, "BD_BarCodePool", true); + DynamicObjectType dynamicObjectType = formMetadata.BusinessInfo.GetDynamicObjectType(); + Entity entity = formMetadata.BusinessInfo.GetEntity(0); + List fields2 = entity.Fields; + string text = ""; + foreach (Field field in fields2) + { + if (!string.IsNullOrWhiteSpace(field.FieldName) && !StringUtils.EqualsIgnoreCase("FPRINTID", field.FieldName) && "T_BD_BARCODEPOOL".Equals(field.TableName) && !(field is MultiLangTextField)) + { + text = text + field.FieldName + ","; + } + } + text = text.Substring(0, text.Length - 1); + barCoder.CreateBarCodePool(base.Context, base.View.Model.GetPKValue(), array, fields, formMetadata, dynamicObjectType, fields2, text); + result = flag; + } + return result; + } + + private void PrintBarCode(string printType) + { + this.printDatas = new List(); + this.newPrintDatas = new List(); + string text = Convert.ToString(base.View.Model.GetValue("FBarCodeModel")); + BarCodePrintOperation barCodePrintOperation = new BarCodePrintOperation(); + if (printType == "print") + { + string text2 = Convert.ToString(base.View.Model.GetValue("FPrintAddress")).Trim().ToLowerInvariant(); + if (string.IsNullOrWhiteSpace(text2)) + { + base.View.ShowNotificationMessage(ResManager.LoadKDString("请填写打印机名称!", "0011019000003156", (SubSystemType)3, new object[0]), "", 0); + } + else + { + bool flag = this.CheckPrintData(); + if (flag) + { + if (this.printDatas != null && this.printDatas.Count > 0) + { + List list = new List(); + List list2 = new List(); + int num = 0; + foreach (DynamicObject dynamicObject in this.printDatas) + { + if (dynamicObject != null) + { + int num2 = Convert.ToInt32(dynamicObject["PrintNumber"]); + for (int i = 0; i < num2; i++) + { + this.newPrintDatas.Add(dynamicObject); + string text3 = Convert.ToString(dynamicObject["BARCODEMODEL"]); + text3 = (string.IsNullOrWhiteSpace(text3) ? text : text3); + text3 = text3.Replace(" ", ""); + list2.Add(text3); + list.Add(num.ToString()); + num++; + } + } + } + barCodePrintOperation.BarCodePrintDoAction(this, null, list, list2, printType, text2); + this.printOperationType = printType; + } + } + } + } + else if (printType == "preview") + { + bool flag = this.CheckPrintData(); + if (flag) + { + if (this.printDatas != null && this.printDatas.Count > 0) + { + List list = new List(); + List list2 = new List(); + int num = 0; + foreach (DynamicObject dynamicObject in this.printDatas) + { + if (dynamicObject != null) + { + this.newPrintDatas.Add(dynamicObject); + string text3 = Convert.ToString(dynamicObject["BARCODEMODEL"]); + text3 = (string.IsNullOrWhiteSpace(text3) ? text : text3); + text3 = text3.Replace(" ", ""); + list2.Add(text3); + list.Add(num.ToString()); + num++; + } + } + barCodePrintOperation.BarCodePrintDoAction(this, null, list, list2, printType, ""); + this.printOperationType = printType; + } + } + } + } + + private bool CheckPrintData() + { + bool flag = true; + ExtendedDataEntitySet extendedDataEntitySet = new ExtendedDataEntitySet(); + extendedDataEntitySet.Parse(new DynamicObject[] + { + base.View.Model.DataObject + }, base.View.Model.BusinessInfo); + ExtendedDataEntity[] array = (from p in extendedDataEntitySet.FindByEntityKey("FEntityToBar") + where StringUtils.EqualsIgnoreCase(p.DataEntity["BarCodeCheck"].ToString(), "True") + select p).ToArray(); + if (array.Count() < 1) + { + base.View.ShowWarnningMessage(ResManager.LoadKDString("请先选择打印数据行!", "0011019000003158", (SubSystemType)3, new object[0]), "", 0, null, (MessageBoxType)1); + flag = false; + } + string text = Convert.ToString(base.View.Model.GetValue("FBarCodeModel")); + List list = new List(); + List list2 = new List(); + for (int i = 0; i < array.Count(); i++) + { + DynamicObject dataEntity = array[i].DataEntity; + this.printDatas.Add(dataEntity); + string text2 = Convert.ToString(dataEntity["BARCODEMODEL"]); + text2 = (string.IsNullOrWhiteSpace(text2) ? text : text2); + text2 = text2.Replace(" ", ""); + string value = Convert.ToString(dataEntity["BarCode"]); + int item = Convert.ToInt32(dataEntity["Seq"]); + if (string.IsNullOrWhiteSpace(value)) + { + list.Add(item); + flag = false; + } + if (string.IsNullOrWhiteSpace(text2)) + { + list2.Add(item); + flag = false; + } + } + string text3 = ""; + if (list.Count > 0) + { + for (int j = 0; j < list.Count; j++) + { + text3 = ((j < list.Count - 1) ? (list[j].ToString() + "、") : list[j].ToString()); + } + } + text3 = (string.IsNullOrWhiteSpace(text3) ? "" : string.Format(ResManager.LoadKDString("第", "0011019000003159", (SubSystemType)3, new object[0]) + text3 + ResManager.LoadKDString("行条形码尚未生成!", "0011019000003160", (SubSystemType)3, new object[0]), new object[0])); + string text4 = ""; + if (list2.Count > 0) + { + for (int k = 0; k < list2.Count; k++) + { + text4 = ((k < list2.Count - 1) ? (list2[k].ToString() + "、") : list2[k].ToString()); + } + } + text4 = (string.IsNullOrWhiteSpace(text4) ? "" : string.Format(ResManager.LoadKDString("第", "0011019000003159", (SubSystemType)3, new object[0]) + text4 + ResManager.LoadKDString("行条形码未设置条码模板!", "0011019000003161", (SubSystemType)3, new object[0]), new object[0])); + if (!string.IsNullOrWhiteSpace(text3 + text4)) + { + base.View.ShowNotificationMessage(text3 + text4, "", 0); + } + if (!flag) + { + this.printDatas = new List(); + } + return flag; + } + + private void SavePrintAddress(string printAddress) + { + long userId = base.Context.UserId; + long id = base.Context.CurrentOrganizationInfo.ID; + string text = base.Context.IpAddress; + if (!string.IsNullOrWhiteSpace(text)) + { + Regex regex = new Regex("\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}"); + text = Convert.ToString(regex.Match(text)); + } + if (!string.IsNullOrWhiteSpace(printAddress)) + { + BarCodePrintServiceHelper.SavePrintAddress(base.Context, printAddress, userId, id, text); + } + } + + private void UpdatePrintCountAfterPrintOP() + { + long userId = base.View.Context.UserId; + DateTime now = DateTime.Now; + for (int i = 0; i < this.printDatas.Count; i++) + { + DynamicObject dynamicObject = this.printDatas[i]; + string text = Convert.ToString(dynamicObject["BarCode"]); + int num = Convert.ToInt32(dynamicObject["PrintNumber"]); + DynamicObject dynamicObject2 = dynamicObject["BarCodeRule"] as DynamicObject; + long num2 = (dynamicObject2 == null) ? 0L : Convert.ToInt64(dynamicObject2["Id"]); + BarCodePrintServiceHelper.UpdatePrintCountToMain(base.View.Context, text, userId, now, num2, num, num); + } + } + + private void CalcCreateNumber(int RowIndex) + { + decimal num = Convert.ToDecimal(base.View.Model.GetValue("FBoxQty", RowIndex)); + BarCodeSysParamsModel barCodeBillSystemParameters = BarCodeCommonServiceHelper.GetBarCodeBillSystemParameters(base.Context, base.Context.CurrentOrganizationInfo.ID, this._sFormId); + if (barCodeBillSystemParameters.CreateCountRule.Equals("1")) + { + decimal num2 = Convert.ToDecimal(base.View.Model.GetValue("FQty", RowIndex)); + DynamicObject dynamicObject = base.View.Model.GetValue("FMaterialId", RowIndex) as DynamicObject; + if (num2 > 0m && dynamicObject != null) + { + DynamicObjectCollection dynamicObjectCollection = dynamicObject["MaterialPurchase"] as DynamicObjectCollection; + if (dynamicObjectCollection != null && dynamicObjectCollection.Count > 0) + { + DynamicObject dynamicObject2 = dynamicObjectCollection[0]; + if (dynamicObject2 != null) + { + int num3 = (dynamicObject2["MinPackCount"] != null) ? Convert.ToInt32(dynamicObject2["MinPackCount"]) : 1; + if (num3 == 0) + { + num3 = 1; + } + if (num3 > 0) + { + decimal num4 = num2 / num3; + int num5 = Convert.ToInt32(num4); + int num6; + if (num5 < num4) + { + num6 = num5 + 1; + } + else + { + num6 = num5; + } + if (num > num3) + { + decimal num7 = Math.Ceiling(num2 / num); + base.View.Model.SetValue("FCreateBoxNumber", num7, RowIndex); + } + else + { + base.View.Model.SetValue("FCreateBoxNumber", 0, RowIndex); + } + base.View.Model.SetValue("FCreateNumber", num6, RowIndex); + base.View.Model.SetValue("FMinPackCount", num3, RowIndex); + } + } + } + } + } + else + { + decimal num2 = Convert.ToDecimal(base.View.Model.GetValue("FQty", RowIndex)); + base.View.Model.SetValue("FCreateNumber", 1, RowIndex); + base.View.Model.SetValue("FMinPackCount", num2, RowIndex); + if (num > num2) + { + decimal num7 = Math.Ceiling(num2 / num); + base.View.Model.SetValue("FCreateBoxNumber", num7, RowIndex); + } + else + { + base.View.Model.SetValue("FCreateBoxNumber", 0, RowIndex); + } + } + } + + private void CalcCreateNumber2(int RowIndex) + { + decimal d = Convert.ToDecimal(base.View.Model.GetValue("FQty", RowIndex)); + decimal num = Convert.ToDecimal(base.View.Model.GetValue("FMinPackCount", RowIndex)); + decimal num2 = Convert.ToDecimal(base.View.Model.GetValue("FBoxQty", RowIndex)); + if (num > 0m) + { + decimal num3 = d / num; + int num4 = Convert.ToInt32(num3); + int num5; + if (num4 < num3) + { + num5 = num4 + 1; + } + else + { + num5 = num4; + } + base.View.Model.SetValue("FCreateNumber", num5, RowIndex); + if (num2 > num) + { + decimal num6 = Math.Ceiling(d / num2); + base.View.Model.SetValue("FCreateBoxNumber", num6, RowIndex); + } + else + { + base.View.Model.SetValue("FCreateBoxNumber", 0, RowIndex); + } + } + } + + /// + /// 同步条码主档 2025/6/30 + /// + private void SynchronizeCodeMain() + { + var sourceFormId = "UHIK_BD_BarCodeMainFile"; + var entity = this.View.BusinessInfo.GetEntity("FEntityToBar"); + var entityDataObject = this.View.Model.GetEntityDataObject(entity); + if (entityDataObject == null && entityDataObject.Count == 0) + { + this.View.ShowErrMessage("没有找到条码明细,请生成条码明细!!!"); + } + var billId = this.View.Model.GetValue("FBillId") as DynamicObject; // 获取业务对象 + var srcData = entityDataObject.ToList(); + var ObjList = new List(); + var meta = MetaDataServiceHelper.Load(this.Context, sourceFormId) as FormMetadata; + + foreach (var item in srcData) + { + var count = ObjList.Where(n => n["BarCode"].ToString() == item["BarCode"].ToString()).ToList().Count; + if (count > 0) + { + continue; + } + var objType = meta.BusinessInfo.GetDynamicObjectType(); + var queryParameter = new QueryBuilderParemeter(); + var barCode = item["BarCode"]; + queryParameter.FilterClauseWihtKey = string.Format(" FBarCode = '{0}' ", barCode); + queryParameter.FormId = sourceFormId; + var newObj = new DynamicObject(objType); + var loadObjs = BusinessDataServiceHelper.Load(this.Context, objType, queryParameter); + if (loadObjs.Count() > 0) + { + newObj = loadObjs[0]; + } + // 物料 + newObj["MaterialId_Id"] = item["MaterialIdToBar_Id"]; + newObj["MaterialId"] = item["MaterialIdToBar"]; + // 条码规则 + newObj["BarCodeRule_Id"] = item["BarCodeRule_Id"]; + newObj["BarCodeRule"] = item["BarCodeRule"]; + // 条形码 + newObj["BarCode"] = item["BarCode"]; + // 单位 + newObj["UnitId_Id"] = item["UnitIDToBar_Id"]; + newObj["UnitId"] = item["UnitIDToBar"]; + // 批号 + newObj["Lot_Id"] = item["LotToBar_Id"]; + newObj["Lot"] = item["LotToBar"]; + newObj["Lot_Text"] = item["LotToBar_Text"]; + newObj["FLotText"] = item["LotToBar_Text"]; + // 供应商批号 + newObj["SupplierLot"] = item["SUPPLIERLOTTOBAR"]; + // 数量 + newObj["Qty"] = item["QtyToBar"]; + // 行号 + newObj["BillSeq"] = item["BillSeqToBar"]; + // 仓库 + newObj["StockId_Id"] = item["StockIdToBar_Id"]; + newObj["StockId"] = item["StockIdToBar"]; + newObj["StockLocId_Id"] = item["FSTOCKLOCIDToBar_Id"]; + newObj["StockLocId"] = item["FSTOCKLOCIDToBar"]; + // 单据编码 + newObj["BillCode"] = item["BILLCODEToBar"]; + // 禁用状态 + newObj["ForbidStatus"] = "A"; + // 计数流水号 + newObj["FLowNo"] = item["FLowNo"]; + // 辅助属性 + newObj["AuxPropId_Id"] = item["AuxPropIdToBar_Id"]; + newObj["AuxPropId"] = item["AuxPropIdToBar"]; + + //// 以下是非标准字段,且必要 + newObj["FBillId_Id"] = billId["Id"]; + newObj["FBillId"] = billId; + newObj["FMinPackCount"] = item["FMinPackCountToBar"]; + + + + //// 以下非标准字段 + //newObj["FMoEntryId_Id"] = item["FMOENTRYIDToBar_Id"]; + //newObj["FMoEntryId"] = item["FMOENTRYIDToBar"]; + + //newObj["FMUJU_Id"] = item["FMUJUToBar_Id"]; + //newObj["FMUJU"] = item["FMUJUToBar"]; + //newObj["F_JT_Id"] = item["F_JTToBar_Id"]; + //newObj["F_JT"] = item["F_JTToBar"]; + //newObj["F_BZFS"] = item["F_BZFSToBar"]; + + ObjList.Add(newObj); + } + if (ObjList.Count > 0) + { + OperateOption saveOption = OperateOption.Create(); + //saveOption.SetInteractionFlag(this.Option.GetInteractionFlag()); + saveOption.SetIgnoreWarning(true); + saveOption.SetIgnoreInteractionFlag(true); + var saveRslt = BusinessDataServiceHelper.Save(this.Context, meta.BusinessInfo, ObjList.ToArray(), saveOption, "Save"); + if (saveRslt.IsSuccess) + { + var resRows = saveRslt.Rows.ToList(); + foreach (var res in resRows) + { + var index = resRows.IndexOf(res); + this.View.Model.SetValue("FBarCodeMD5ToBar", res.DataEntity["Id"].ToString(), index); + } + this.View.UpdateView("FEntityToBar"); + this.View.ShowMessage("同步成功,可以在条码主档# 中查看生成的条码."); + } + else + { + this.View.ShowErrMessage(string.Join(",\r\n", saveRslt.OperateResult.Select(n => n.Message))); + } + } + } + + + } +} diff --git a/Gatedge.ScanCode.Basis.PlugIn/Bill/BAR_BarCodePrint/FormPlugIn/FileName.cs b/Gatedge.ScanCode.Basis.PlugIn/Bill/BAR_BarCodePrint/FormPlugIn/FileName.cs deleted file mode 100644 index e092345..0000000 --- a/Gatedge.ScanCode.Basis.PlugIn/Bill/BAR_BarCodePrint/FormPlugIn/FileName.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Gatedge.ScanCode.Basis.PlugIn.Bill.BAR_BarCodePrint.FormPlugIn -{ - internal class FileName - { - } -} diff --git a/Gatedge.ScanCode.Basis.PlugIn/Bill/BAR_Record/ServicePlugIn/Save.cs b/Gatedge.ScanCode.Basis.PlugIn/Bill/BAR_Record/ServicePlugIn/Save.cs index 9dd0807..7402b0a 100644 --- a/Gatedge.ScanCode.Basis.PlugIn/Bill/BAR_Record/ServicePlugIn/Save.cs +++ b/Gatedge.ScanCode.Basis.PlugIn/Bill/BAR_Record/ServicePlugIn/Save.cs @@ -25,10 +25,11 @@ namespace Gatedge.ScanCode.Basis.PlugIn.Bill.BAR_Record.ServicePlugIn e.FieldKeys.Add("FBarMoEntryId"); } - public override void BeforeDoSaveExecute(BeforeDoSaveExecuteEventArgs e) + + public override void BeginOperationTransaction(BeginOperationTransactionArgs e) { - base.BeforeDoSaveExecute(e); - foreach (var bill in e.DataEntities) + base.BeginOperationTransaction(e); + foreach (var bill in e.DataEntitys) { var barEntityList = bill["FBarEntity"] as DynamicObjectCollection; var resultEntityList = bill["FResultEntity"] as DynamicObjectCollection; diff --git a/Gatedge.ScanCode.Basis.PlugIn/Gatedge.ScanCode.Basis.PlugIn.csproj b/Gatedge.ScanCode.Basis.PlugIn/Gatedge.ScanCode.Basis.PlugIn.csproj index ec37569..a76bff9 100644 --- a/Gatedge.ScanCode.Basis.PlugIn/Gatedge.ScanCode.Basis.PlugIn.csproj +++ b/Gatedge.ScanCode.Basis.PlugIn/Gatedge.ScanCode.Basis.PlugIn.csproj @@ -31,151 +31,46 @@ 4 - + + False ..\Library\Kingdee.BOS.dll - + + False ..\Library\Kingdee.BOS.App.dll - - ..\Library\Kingdee.BOS.App.Core.dll - - - ..\Library\Kingdee.BOS.Business.Bill.dll - - - ..\Library\Kingdee.BOS.Contracts.dll - - + + False ..\Library\Kingdee.BOS.Core.dll - + + False ..\Library\Kingdee.BOS.DataEntity.dll - - ..\Library\Kingdee.BOS.Excel.dll + + ..\Library\Kingdee.BOS.OrmEngine.dll - - ..\Library\Kingdee.BOS.FileServer.Core.dll - - - ..\Library\Kingdee.BOS.FileServer.ProxyService.dll - - + + False ..\Library\Kingdee.BOS.ServiceHelper.dll - - ..\Library\Kingdee.BOS.VerificationHelper.dll - - - ..\Library\Kingdee.BOS.Web.dll - - - ..\Library\Kingdee.BOS.Web.HTML.dll - - - ..\Library\Kingdee.BOS.Web.HTML.Core.dll - - - ..\Library\Kingdee.BOS.WebApi.FormService.dll - - - ..\Library\Kingdee.CDP.WebApi.SDK.dll - - - ..\Library\Kingdee.K3.BD.BarCode.App.dll - - + + False ..\Library\Kingdee.K3.BD.BarCode.App.Core.dll - - ..\Library\Kingdee.K3.BD.BarCode.App.ServicePlugIn.dll - - - ..\Library\Kingdee.K3.BD.BarCode.Business.DynamicForm.dll - - + + False ..\Library\Kingdee.K3.BD.BarCode.Business.PlugIn.dll - - ..\Library\Kingdee.K3.BD.BarCode.Contracts.dll - - + + False ..\Library\Kingdee.K3.BD.BarCode.Core.dll - + + False ..\Library\Kingdee.K3.BD.BarCode.ServiceHelper.dll - - ..\Library\Kingdee.K3.BD.Contracts.dll - - - ..\Library\Kingdee.K3.BD.NewCode.Core.dll - - - ..\Library\Kingdee.K3.BD.NewCode.Extension.dll - - - ..\Library\Kingdee.K3.BD.ServiceHelper.dll - - - ..\Library\Kingdee.K3.Core.dll - - - ..\Library\Kingdee.K3.FIN.Business.PlugIn.dll - - - ..\Library\Kingdee.K3.FIN.Core.dll - - - ..\Library\Kingdee.K3.FIN.HS.Business.PlugIn.dll - - - ..\Library\Kingdee.K3.FIN.HS.Common.BusinessEntity.dll - - - ..\Library\Kingdee.K3.FIN.HS.Contracts.dll - - - ..\Library\Kingdee.K3.FIN.HS.ServiceHelper.dll - - - ..\Library\Kingdee.K3.FIN.ServiceHelper.dll - - - ..\Library\Kingdee.K3.MFG.App.dll - - - ..\Library\Kingdee.K3.MFG.BusinessCommon.dll - - - ..\Library\Kingdee.K3.MFG.Contracts.dll - - - ..\Library\Kingdee.K3.MFG.PLN.App.Core.dll - - - ..\Library\Kingdee.K3.MFG.PLN.App.MrpModel.dll - - - ..\Library\Kingdee.K3.MFG.PLN.Business.PlugIn.dll - - - ..\Library\Kingdee.K3.MFG.PLN.Report.PlugIn.dll - - - ..\Library\Kingdee.K3.MFG.ServiceHelper.dll - - - ..\Library\Kingdee.K3.SCM.App.Core.dll - - - ..\Library\Kingdee.K3.SCM.Common.BusinessEntity.dll - - - ..\Library\Kingdee.K3.SCM.ServiceHelper.dll - - + False ..\Library\Newtonsoft.Json.dll @@ -189,8 +84,7 @@ - - + diff --git a/Library/Kingdee.BOS.App.Core.dll b/Library/Kingdee.BOS.App.Core.dll deleted file mode 100644 index 8faa445..0000000 Binary files a/Library/Kingdee.BOS.App.Core.dll and /dev/null differ diff --git a/Library/Kingdee.BOS.App.dll b/Library/Kingdee.BOS.App.dll index b1467d2..3032643 100644 Binary files a/Library/Kingdee.BOS.App.dll and b/Library/Kingdee.BOS.App.dll differ diff --git a/Library/Kingdee.BOS.Business.Bill.dll b/Library/Kingdee.BOS.Business.Bill.dll deleted file mode 100644 index aaa3e24..0000000 Binary files a/Library/Kingdee.BOS.Business.Bill.dll and /dev/null differ diff --git a/Library/Kingdee.BOS.Contracts.dll b/Library/Kingdee.BOS.Contracts.dll deleted file mode 100644 index 2da2dc6..0000000 Binary files a/Library/Kingdee.BOS.Contracts.dll and /dev/null differ diff --git a/Library/Kingdee.BOS.Core.dll b/Library/Kingdee.BOS.Core.dll index cedd95a..0c45f1e 100644 Binary files a/Library/Kingdee.BOS.Core.dll and b/Library/Kingdee.BOS.Core.dll differ diff --git a/Library/Kingdee.BOS.DataEntity.dll b/Library/Kingdee.BOS.DataEntity.dll index d0baa93..274bd70 100644 Binary files a/Library/Kingdee.BOS.DataEntity.dll and b/Library/Kingdee.BOS.DataEntity.dll differ diff --git a/Library/Kingdee.BOS.Excel.dll b/Library/Kingdee.BOS.Excel.dll deleted file mode 100644 index fb162ce..0000000 Binary files a/Library/Kingdee.BOS.Excel.dll and /dev/null differ diff --git a/Library/Kingdee.BOS.FileServer.Core.dll b/Library/Kingdee.BOS.FileServer.Core.dll deleted file mode 100644 index e57dae0..0000000 Binary files a/Library/Kingdee.BOS.FileServer.Core.dll and /dev/null differ diff --git a/Library/Kingdee.BOS.FileServer.ProxyService.dll b/Library/Kingdee.BOS.FileServer.ProxyService.dll deleted file mode 100644 index 6e9e515..0000000 Binary files a/Library/Kingdee.BOS.FileServer.ProxyService.dll and /dev/null differ diff --git a/Library/Kingdee.BOS.OrmEngine.dll b/Library/Kingdee.BOS.OrmEngine.dll new file mode 100644 index 0000000..081ccd2 Binary files /dev/null and b/Library/Kingdee.BOS.OrmEngine.dll differ diff --git a/Library/Kingdee.BOS.ServiceHelper.dll b/Library/Kingdee.BOS.ServiceHelper.dll index 9240855..da44fed 100644 Binary files a/Library/Kingdee.BOS.ServiceHelper.dll and b/Library/Kingdee.BOS.ServiceHelper.dll differ diff --git a/Library/Kingdee.BOS.VerificationHelper.dll b/Library/Kingdee.BOS.VerificationHelper.dll deleted file mode 100644 index 4160c23..0000000 Binary files a/Library/Kingdee.BOS.VerificationHelper.dll and /dev/null differ diff --git a/Library/Kingdee.BOS.Web.HTML.Core.dll b/Library/Kingdee.BOS.Web.HTML.Core.dll deleted file mode 100644 index 1c37225..0000000 Binary files a/Library/Kingdee.BOS.Web.HTML.Core.dll and /dev/null differ diff --git a/Library/Kingdee.BOS.Web.HTML.dll b/Library/Kingdee.BOS.Web.HTML.dll deleted file mode 100644 index 37a8a8a..0000000 Binary files a/Library/Kingdee.BOS.Web.HTML.dll and /dev/null differ diff --git a/Library/Kingdee.BOS.Web.dll b/Library/Kingdee.BOS.Web.dll deleted file mode 100644 index ae56477..0000000 Binary files a/Library/Kingdee.BOS.Web.dll and /dev/null differ diff --git a/Library/Kingdee.BOS.WebApi.Client.dll b/Library/Kingdee.BOS.WebApi.Client.dll deleted file mode 100644 index cc90e07..0000000 Binary files a/Library/Kingdee.BOS.WebApi.Client.dll and /dev/null differ diff --git a/Library/Kingdee.BOS.WebApi.FormService.dll b/Library/Kingdee.BOS.WebApi.FormService.dll deleted file mode 100644 index 5789fd3..0000000 Binary files a/Library/Kingdee.BOS.WebApi.FormService.dll and /dev/null differ diff --git a/Library/Kingdee.BOS.dll b/Library/Kingdee.BOS.dll index 0b9ac56..8e6218a 100644 Binary files a/Library/Kingdee.BOS.dll and b/Library/Kingdee.BOS.dll differ diff --git a/Library/Kingdee.CDP.WebApi.SDK.dll b/Library/Kingdee.CDP.WebApi.SDK.dll deleted file mode 100644 index 4d68c10..0000000 Binary files a/Library/Kingdee.CDP.WebApi.SDK.dll and /dev/null differ diff --git a/Library/Kingdee.K3.BD.BarCode.App.Core.dll b/Library/Kingdee.K3.BD.BarCode.App.Core.dll index c139344..ff1c10a 100644 Binary files a/Library/Kingdee.K3.BD.BarCode.App.Core.dll and b/Library/Kingdee.K3.BD.BarCode.App.Core.dll differ diff --git a/Library/Kingdee.K3.BD.BarCode.App.ServicePlugIn.dll b/Library/Kingdee.K3.BD.BarCode.App.ServicePlugIn.dll deleted file mode 100644 index 7173a02..0000000 Binary files a/Library/Kingdee.K3.BD.BarCode.App.ServicePlugIn.dll and /dev/null differ diff --git a/Library/Kingdee.K3.BD.BarCode.App.dll b/Library/Kingdee.K3.BD.BarCode.App.dll deleted file mode 100644 index 60743b5..0000000 Binary files a/Library/Kingdee.K3.BD.BarCode.App.dll and /dev/null differ diff --git a/Library/Kingdee.K3.BD.BarCode.Business.DynamicForm.dll b/Library/Kingdee.K3.BD.BarCode.Business.DynamicForm.dll deleted file mode 100644 index 0b19699..0000000 Binary files a/Library/Kingdee.K3.BD.BarCode.Business.DynamicForm.dll and /dev/null differ diff --git a/Library/Kingdee.K3.BD.BarCode.Business.PlugIn.dll b/Library/Kingdee.K3.BD.BarCode.Business.PlugIn.dll index 389bf68..d91b1ad 100644 Binary files a/Library/Kingdee.K3.BD.BarCode.Business.PlugIn.dll and b/Library/Kingdee.K3.BD.BarCode.Business.PlugIn.dll differ diff --git a/Library/Kingdee.K3.BD.BarCode.Contracts.dll b/Library/Kingdee.K3.BD.BarCode.Contracts.dll deleted file mode 100644 index 082c47d..0000000 Binary files a/Library/Kingdee.K3.BD.BarCode.Contracts.dll and /dev/null differ diff --git a/Library/Kingdee.K3.BD.BarCode.Core.dll b/Library/Kingdee.K3.BD.BarCode.Core.dll index 3254234..1fbef3b 100644 Binary files a/Library/Kingdee.K3.BD.BarCode.Core.dll and b/Library/Kingdee.K3.BD.BarCode.Core.dll differ diff --git a/Library/Kingdee.K3.BD.BarCode.ServiceHelper.dll b/Library/Kingdee.K3.BD.BarCode.ServiceHelper.dll index 09f94a8..9990cba 100644 Binary files a/Library/Kingdee.K3.BD.BarCode.ServiceHelper.dll and b/Library/Kingdee.K3.BD.BarCode.ServiceHelper.dll differ diff --git a/Library/Kingdee.K3.BD.Contracts.dll b/Library/Kingdee.K3.BD.Contracts.dll deleted file mode 100644 index 89ab95f..0000000 Binary files a/Library/Kingdee.K3.BD.Contracts.dll and /dev/null differ diff --git a/Library/Kingdee.K3.BD.NewCode.Core.dll b/Library/Kingdee.K3.BD.NewCode.Core.dll deleted file mode 100644 index 47cedbe..0000000 Binary files a/Library/Kingdee.K3.BD.NewCode.Core.dll and /dev/null differ diff --git a/Library/Kingdee.K3.BD.NewCode.Extension.dll b/Library/Kingdee.K3.BD.NewCode.Extension.dll deleted file mode 100644 index e6196df..0000000 Binary files a/Library/Kingdee.K3.BD.NewCode.Extension.dll and /dev/null differ diff --git a/Library/Kingdee.K3.BD.ServiceHelper.dll b/Library/Kingdee.K3.BD.ServiceHelper.dll deleted file mode 100644 index 7bb294d..0000000 Binary files a/Library/Kingdee.K3.BD.ServiceHelper.dll and /dev/null differ diff --git a/Library/Kingdee.K3.Core.dll b/Library/Kingdee.K3.Core.dll deleted file mode 100644 index 4ec6a58..0000000 Binary files a/Library/Kingdee.K3.Core.dll and /dev/null differ diff --git a/Library/Kingdee.K3.FIN.Business.PlugIn.dll b/Library/Kingdee.K3.FIN.Business.PlugIn.dll deleted file mode 100644 index 475189f..0000000 Binary files a/Library/Kingdee.K3.FIN.Business.PlugIn.dll and /dev/null differ diff --git a/Library/Kingdee.K3.FIN.Core.dll b/Library/Kingdee.K3.FIN.Core.dll deleted file mode 100644 index ab998e9..0000000 Binary files a/Library/Kingdee.K3.FIN.Core.dll and /dev/null differ diff --git a/Library/Kingdee.K3.FIN.HS.Business.PlugIn.dll b/Library/Kingdee.K3.FIN.HS.Business.PlugIn.dll deleted file mode 100644 index 30800be..0000000 Binary files a/Library/Kingdee.K3.FIN.HS.Business.PlugIn.dll and /dev/null differ diff --git a/Library/Kingdee.K3.FIN.HS.Common.BusinessEntity.dll b/Library/Kingdee.K3.FIN.HS.Common.BusinessEntity.dll deleted file mode 100644 index 8c32801..0000000 Binary files a/Library/Kingdee.K3.FIN.HS.Common.BusinessEntity.dll and /dev/null differ diff --git a/Library/Kingdee.K3.FIN.HS.Contracts.dll b/Library/Kingdee.K3.FIN.HS.Contracts.dll deleted file mode 100644 index 0840184..0000000 Binary files a/Library/Kingdee.K3.FIN.HS.Contracts.dll and /dev/null differ diff --git a/Library/Kingdee.K3.FIN.HS.ServiceHelper.dll b/Library/Kingdee.K3.FIN.HS.ServiceHelper.dll deleted file mode 100644 index 913d2da..0000000 Binary files a/Library/Kingdee.K3.FIN.HS.ServiceHelper.dll and /dev/null differ diff --git a/Library/Kingdee.K3.FIN.ServiceHelper.dll b/Library/Kingdee.K3.FIN.ServiceHelper.dll deleted file mode 100644 index 804e923..0000000 Binary files a/Library/Kingdee.K3.FIN.ServiceHelper.dll and /dev/null differ diff --git a/Library/Kingdee.K3.MFG.App.dll b/Library/Kingdee.K3.MFG.App.dll deleted file mode 100644 index 5dbf7d2..0000000 Binary files a/Library/Kingdee.K3.MFG.App.dll and /dev/null differ diff --git a/Library/Kingdee.K3.MFG.BusinessCommon.dll b/Library/Kingdee.K3.MFG.BusinessCommon.dll deleted file mode 100644 index 34bb853..0000000 Binary files a/Library/Kingdee.K3.MFG.BusinessCommon.dll and /dev/null differ diff --git a/Library/Kingdee.K3.MFG.Contracts.dll b/Library/Kingdee.K3.MFG.Contracts.dll deleted file mode 100644 index ddfc290..0000000 Binary files a/Library/Kingdee.K3.MFG.Contracts.dll and /dev/null differ diff --git a/Library/Kingdee.K3.MFG.PLN.App.Core.dll b/Library/Kingdee.K3.MFG.PLN.App.Core.dll deleted file mode 100644 index 0d741aa..0000000 Binary files a/Library/Kingdee.K3.MFG.PLN.App.Core.dll and /dev/null differ diff --git a/Library/Kingdee.K3.MFG.PLN.App.MrpModel.dll b/Library/Kingdee.K3.MFG.PLN.App.MrpModel.dll deleted file mode 100644 index 54013da..0000000 Binary files a/Library/Kingdee.K3.MFG.PLN.App.MrpModel.dll and /dev/null differ diff --git a/Library/Kingdee.K3.MFG.PLN.Business.PlugIn.dll b/Library/Kingdee.K3.MFG.PLN.Business.PlugIn.dll deleted file mode 100644 index f5f5d9d..0000000 Binary files a/Library/Kingdee.K3.MFG.PLN.Business.PlugIn.dll and /dev/null differ diff --git a/Library/Kingdee.K3.MFG.PLN.Report.PlugIn.dll b/Library/Kingdee.K3.MFG.PLN.Report.PlugIn.dll deleted file mode 100644 index e9789eb..0000000 Binary files a/Library/Kingdee.K3.MFG.PLN.Report.PlugIn.dll and /dev/null differ diff --git a/Library/Kingdee.K3.MFG.ServiceHelper.dll b/Library/Kingdee.K3.MFG.ServiceHelper.dll deleted file mode 100644 index 75c9af8..0000000 Binary files a/Library/Kingdee.K3.MFG.ServiceHelper.dll and /dev/null differ diff --git a/Library/Kingdee.K3.SCM.App.Core.dll b/Library/Kingdee.K3.SCM.App.Core.dll deleted file mode 100644 index 05c1f4b..0000000 Binary files a/Library/Kingdee.K3.SCM.App.Core.dll and /dev/null differ diff --git a/Library/Kingdee.K3.SCM.Common.BusinessEntity.dll b/Library/Kingdee.K3.SCM.Common.BusinessEntity.dll deleted file mode 100644 index eff5194..0000000 Binary files a/Library/Kingdee.K3.SCM.Common.BusinessEntity.dll and /dev/null differ diff --git a/Library/Kingdee.K3.SCM.ServiceHelper.dll b/Library/Kingdee.K3.SCM.ServiceHelper.dll deleted file mode 100644 index a225bf9..0000000 Binary files a/Library/Kingdee.K3.SCM.ServiceHelper.dll and /dev/null differ diff --git a/Library/Newtonsoft.Json.dll b/Library/Newtonsoft.Json.dll index d593ed6..416bd37 100644 Binary files a/Library/Newtonsoft.Json.dll and b/Library/Newtonsoft.Json.dll differ