/// <summary> /// 初始化车辆品牌、车系、车型描述 /// </summary> public static void InitVehicleBrand() { var funcName = "InitVehicleBrand"; LogHelper.WriteBussLogStart(BussID, LoginInfoDAX.UserName, funcName, "", "", null); //查询所有有效的车辆品牌车系 List <MDLBS_VehicleBrandInspireSumma> resultVehicleBrandAndInspireList = new List <MDLBS_VehicleBrandInspireSumma>(); _baseDax.QueryForList(new MDLBS_VehicleBrandInspireSumma() { WHERE_VBIS_IsValid = true, }, resultVehicleBrandAndInspireList); //品牌 List <MDLBS_VehicleBrandInspireSumma> resultVehicleBrandList = new List <MDLBS_VehicleBrandInspireSumma>(); _baseDax.CopyModelList(resultVehicleBrandAndInspireList, resultVehicleBrandList); //车系 List <MDLBS_VehicleBrandInspireSumma> resultVehicleInspireList = new List <MDLBS_VehicleBrandInspireSumma>(); _baseDax.CopyModelList(resultVehicleBrandAndInspireList, resultVehicleInspireList); //车型描述 List <MDLBS_VehicleBrandInspireSumma> resultVehicleModelDescList = new List <MDLBS_VehicleBrandInspireSumma>(); _baseDax.CopyModelList(resultVehicleBrandAndInspireList, resultVehicleModelDescList); if (resultVehicleBrandList.Count > 0) { resultVehicleBrandList = resultVehicleBrandList.GroupBy(p => new { p.VBIS_Brand, p.VBIS_BrandSpellCode }) .Select(g => g.First()).OrderBy(x => x.VBIS_Brand).ToList(); //将车辆品牌保存到缓存 CacheDAX.Add(CacheDAX.ConfigDataKey.VehicleBrand, resultVehicleBrandList, true); } if (resultVehicleInspireList.Count > 0) { resultVehicleInspireList = resultVehicleInspireList.GroupBy(p => new { p.VBIS_Brand, p.VBIS_Inspire, p.VBIS_InspireSpellCode }) .Select(g => g.First()).OrderBy(x => x.VBIS_Brand).ThenBy(x => x.VBIS_Inspire).ToList(); //将车辆车系保存到缓存 CacheDAX.Add(CacheDAX.ConfigDataKey.VehicleBrandInspire, resultVehicleInspireList, true); } if (resultVehicleModelDescList.Count > 0) { resultVehicleModelDescList = resultVehicleModelDescList.GroupBy(p => new { p.VBIS_Brand, p.VBIS_Inspire, p.VBIS_ModelDesc }) .Select(g => g.First()).OrderBy(x => x.VBIS_Brand).ThenBy(x => x.VBIS_Inspire).ThenBy(x => x.VBIS_ModelDesc).ToList(); //将车型描述保存到缓存 CacheDAX.Add(CacheDAX.ConfigDataKey.VehicleModelDesc, resultVehicleModelDescList, true); } LogHelper.WriteBussLogEndOK(Trans.COM, LoginInfoDAX.UserName, funcName, "", "", null); }
/// <summary> /// 删除 /// </summary> /// <param name="paramModelList">UIModel</param> /// <returns></returns> public bool DeleteDetailDS(List <AutoPartsShareInventoryManagerUIModel> paramModelList) { var funcName = "DeleteDetailDS"; LogHelper.WriteBussLogStart(Trans.IS, LoginInfoDAX.UserName, funcName, "", "", null); #region 准备数据 List <MDLPIS_ShareInventory> deleteShareInventoryList = new List <MDLPIS_ShareInventory>(); _bll.CopyModelList(paramModelList, deleteShareInventoryList); foreach (var loopDeleteInventory in deleteShareInventoryList) { loopDeleteInventory.WHERE_SI_ID = loopDeleteInventory.SI_ID; } deleteShareInventoryList = deleteShareInventoryList.Where(x => !string.IsNullOrEmpty(x.WHERE_SI_ID)).ToList(); #endregion #region 步到平台 if (!SynchronizeShareInventory(paramModelList)) { //同步到平台失败 ResultMsg = MsgHelp.GetMsg(MsgCode.E_0018, new object[] { SystemActionEnum.Name.DELETE + SystemTableEnums.Name.PIS_ShareInventory, "同步平台失败" }); return(false); } #endregion #region 除数据 try { DBManager.BeginTransaction(DBCONFIG.Coeus); #region 除共享库存 var deleteShareInventoryResult = _bll.DeleteByList <MDLPIS_ShareInventory, MDLPIS_ShareInventory>(deleteShareInventoryList); if (!deleteShareInventoryResult) { DBManager.RollBackTransaction(DBCONFIG.Coeus); #region 保存本地失败,还原同步到平台上已删除的共享库存 List <AutoPartsShareInventoryManagerUIModel> restoreSyncShareInventoryList = new List <AutoPartsShareInventoryManagerUIModel>(); foreach (var loopInsert in paramModelList) { loopInsert.OperateType = "Save"; } restoreSyncShareInventoryList.AddRange(paramModelList); SynchronizeShareInventory(restoreSyncShareInventoryList); #endregion //删除[共享库存]信息失败 ResultMsg = MsgHelp.GetMsg(MsgCode.E_0010, new object[] { SystemActionEnum.Name.DELETE + SystemTableEnums.Name.PIS_ShareInventory }); return(false); } #endregion DBManager.CommitTransaction(DBCONFIG.Coeus); } catch (Exception ex) { DBManager.RollBackTransaction(DBCONFIG.Coeus); #region 保存本地失败,还原同步到平台上已删除的共享库存 List <AutoPartsShareInventoryManagerUIModel> restoreSyncShareInventoryList = new List <AutoPartsShareInventoryManagerUIModel>(); foreach (var loopInsert in paramModelList) { loopInsert.OperateType = "Save"; } restoreSyncShareInventoryList.AddRange(paramModelList); SynchronizeShareInventory(restoreSyncShareInventoryList); #endregion ResultMsg = MsgHelp.GetMsg(MsgCode.E_0018, new object[] { SystemActionEnum.Name.DELETE, ex.Message }); LogHelper.WriteBussLogEndNG(BussID, LoginInfoDAX.UserName, MethodBase.GetCurrentMethod().ToString(), ex.Message, "", null); return(false); } #endregion return(true); }
/// <summary> /// 保存 /// </summary> /// <param name="paramHead">UIModel</param> /// <returns></returns> public bool SaveDetailDS(WarehouseManagerUIModel paramHead, SkyCarBindingList <WarehouseBinManagerUIModel, MDLPIS_WarehouseBin> paramWarehouseBinList) { //服务端检查 if (!ServerCheck(paramHead)) { return(false); } #region 准备数据 #region 仓库 //将UIModel转为TBModel var argsWarehouse = paramHead.ToTBModelForSaveAndDelete <MDLPIS_Warehouse>(); //判断主键是否被赋值 if (string.IsNullOrEmpty(paramHead.WH_ID)) { argsWarehouse.WH_ID = Guid.NewGuid().ToString(); argsWarehouse.WH_CreatedBy = LoginInfoDAX.UserName; argsWarehouse.WH_CreatedTime = BLLCom.GetCurStdDatetime(); } argsWarehouse.WH_UpdatedBy = LoginInfoDAX.UserName; argsWarehouse.WH_UpdatedTime = BLLCom.GetCurStdDatetime(); #endregion #region 仓位 //添加的仓位 if (paramWarehouseBinList != null && paramWarehouseBinList.InsertList != null && paramWarehouseBinList.InsertList.Count > 0) { foreach (var loopDetailItem in paramWarehouseBinList.InsertList) { loopDetailItem.WHB_WH_ID = argsWarehouse.WH_ID ?? argsWarehouse.WHERE_WH_ID; loopDetailItem.WHB_CreatedBy = LoginInfoDAX.UserName; loopDetailItem.WHB_CreatedTime = BLLCom.GetCurStdDatetime(); loopDetailItem.WHB_UpdatedBy = LoginInfoDAX.UserName; loopDetailItem.WHB_UpdatedTime = BLLCom.GetCurStdDatetime(); } } #endregion #endregion #region 带事务的保存 try { DBManager.BeginTransaction(DBCONFIG.Coeus); #region 保存仓库 var saveWarehouseResult = _bll.Save(argsWarehouse, argsWarehouse.WH_ID); if (!saveWarehouseResult) { DBManager.RollBackTransaction(DBCONFIG.Coeus); ResultMsg = MsgHelp.GetMsg(MsgCode.E_0010, new object[] { SystemActionEnum.Name.SAVE + SystemTableEnums.Name.PIS_Warehouse }); return(false); } #endregion #region 保存仓位 var saveWarehouseBinResult = _bll.UnitySave(paramWarehouseBinList); if (!saveWarehouseBinResult) { DBManager.RollBackTransaction(DBCONFIG.Coeus); ResultMsg = MsgHelp.GetMsg(MsgCode.E_0010, new object[] { SystemActionEnum.Name.SAVE + SystemTableEnums.Name.PIS_WarehouseBin }); return(false); } #endregion DBManager.CommitTransaction(DBCONFIG.Coeus); } catch (Exception ex) { DBManager.RollBackTransaction(DBCONFIG.Coeus); //保存[仓库]信息发生异常 ResultMsg = MsgHelp.GetMsg(MsgCode.E_0018, new object[] { SystemActionEnum.Name.SAVE, ex.Message }); LogHelper.WriteBussLogEndNG(BussID, LoginInfoDAX.UserName, MethodBase.GetCurrentMethod().ToString(), ex.Message, "", null); return(false); } //将最新数据回写给DetailDS CopyModel(argsWarehouse, paramHead); #endregion #region 刷新缓存 //刷新仓库缓存 var resultWarehouseList = CacheDAX.Get(CacheDAX.ConfigDataKey.Warehouse) as List <MDLPIS_Warehouse>; List <MDLPIS_Warehouse> newWarehouseList = new List <MDLPIS_Warehouse>(); if (resultWarehouseList != null) { newWarehouseList = resultWarehouseList; if (resultWarehouseList.All(x => x.WH_ID != argsWarehouse.WH_ID && x.WH_Name != argsWarehouse.WH_Name)) { newWarehouseList.Add(argsWarehouse); CacheDAX.Add(CacheDAX.ConfigDataKey.Warehouse, newWarehouseList, true); } } else { newWarehouseList.Add(argsWarehouse); CacheDAX.Add(CacheDAX.ConfigDataKey.Warehouse, newWarehouseList, true); } //刷新仓位缓存 if (paramWarehouseBinList == null) { return(true); } var resultWarehouseBinList = CacheDAX.Get(CacheDAX.ConfigDataKey.WarehouseBin) as List <MDLPIS_WarehouseBin>; List <MDLPIS_WarehouseBin> newWarehouseBinList = new List <MDLPIS_WarehouseBin>(); if (resultWarehouseBinList != null) { newWarehouseBinList = resultWarehouseBinList; if (paramWarehouseBinList.InsertList != null && paramWarehouseBinList.InsertList.Count > 0) { foreach (var loopInsertBin in paramWarehouseBinList.InsertList) { if (resultWarehouseBinList.All(x => x.WHB_ID != loopInsertBin.WHB_ID && x.WHB_Name != loopInsertBin.WHB_Name)) { var tempWarehouseBin = new MDLPIS_WarehouseBin(); _bll.CopyModel(loopInsertBin, tempWarehouseBin); newWarehouseBinList.Add(tempWarehouseBin); CacheDAX.Add(CacheDAX.ConfigDataKey.WarehouseBin, newWarehouseBinList, true); } } } if (paramWarehouseBinList.DeleteList != null && paramWarehouseBinList.DeleteList.Count > 0) { //待移除的仓位 List <MDLPIS_WarehouseBin> removeWarehouseBinList = new List <MDLPIS_WarehouseBin>(); foreach (var loopWarehouseBin in newWarehouseBinList) { var deleteWarehouseBin = paramWarehouseBinList.DeleteList.FirstOrDefault(x => x.WHB_ID == loopWarehouseBin.WHB_ID); if (deleteWarehouseBin != null) { removeWarehouseBinList.Add(loopWarehouseBin); } } foreach (var loopWarehouseBin in removeWarehouseBinList) { newWarehouseBinList.Remove(loopWarehouseBin); } } } else { var tempWarehouseBinList = new List <MDLPIS_WarehouseBin>(); _bll.CopyModelList(paramWarehouseBinList.InsertList, tempWarehouseBinList); newWarehouseBinList.AddRange(tempWarehouseBinList); CacheDAX.Add(CacheDAX.ConfigDataKey.WarehouseBin, newWarehouseBinList, true); } #endregion return(true); }
/// <summary> /// 审核 /// </summary> /// <param name="paramHead">UIModel</param> /// <param name="paramDetailList">明细UIModel</param> /// <returns></returns> public bool ApproveDetailDS(ReceiptBillManagerUIModel paramHead, SkyCarBindingList <ReceiptBillManagerDetailUIModel, MDLFM_ReceiptBillDetail> paramDetailList) { var funcName = "ApproveDetailDS"; LogHelper.WriteBussLogStart(BussID, LoginInfoDAX.UserName, funcName, "", "", null); if (paramHead == null || string.IsNullOrEmpty(paramHead.RB_ID) || string.IsNullOrEmpty(paramHead.RB_No)) { //没有获取到收款单,审核失败 ResultMsg = MsgHelp.GetMsg(MsgCode.W_0024, new object[] { SystemTableEnums.Name.FM_ReceiptBill, SystemActionEnum.Name.APPROVE }); return(false); } var receiptBillManagerDetailList = paramDetailList.Where(x => x.RBD_SourceTypeName == ReceiptBillDetailSourceTypeEnum.Name.SGSK); if (receiptBillManagerDetailList.Count() != paramDetailList.Count() || receiptBillManagerDetailList.Count() == 0) { //收款单不为手工收款,不能审核 ResultMsg = MsgHelp.GetMsg(MsgCode.E_0017, new object[] { SystemTableEnums.Name.FM_ReceiptBill + MsgParam.NO + MsgParam.BE + PayBillDetailSourceTypeEnum.Name.SGFK, SystemActionEnum.Name.APPROVE }); return(false); } #region 定义变量 //待更新的[收款单] MDLFM_ReceiptBill updateReceiptBill = paramHead.ToTBModelForSaveAndDelete <MDLFM_ReceiptBill>(); //待更新[收款单明细] List <MDLFM_ReceiptBillDetail> updateReceiptBillDetailList = new List <MDLFM_ReceiptBillDetail>(); //待新增对应的[应收单] List <MDLFM_AccountReceivableBill> addAccountReceivableBillList = new List <MDLFM_AccountReceivableBill>(); //待新增对应的[应收单明细] List <MDLFM_AccountReceivableBillDetail> addAccountReceivableBillDetailList = new List <MDLFM_AccountReceivableBillDetail>(); //待更新的[钱包] MDLEWM_Wallet updateWallet = new MDLEWM_Wallet(); //待新增的[钱包异动] MDLEWM_WalletTrans addWalletTrans = new MDLEWM_WalletTrans(); #endregion #region 准备数据 if (paramDetailList[0].RBD_SourceTypeName == ReceiptBillDetailSourceTypeEnum.Name.SGSK) { #region 新增[应收单]和[应收单明细] foreach (var loopDetail in paramDetailList) { #region 新增[应收单] MDLFM_AccountReceivableBill accountReceivableBill = new MDLFM_AccountReceivableBill { ARB_ID = System.Guid.NewGuid().ToString(), ARB_No = BLLCom.GetCoeusDocumentNo(DocumentTypeEnums.Code.ARB), ARB_BillDirectCode = BillDirectionEnum.Code.PLUS, ARB_BillDirectName = BillDirectionEnum.Name.PLUS, ARB_SourceTypeCode = AccountReceivableBillSourceTypeEnum.Code.SGCJ, ARB_SourceTypeName = AccountReceivableBillSourceTypeEnum.Name.SGCJ, ARB_Org_ID = LoginInfoDAX.OrgID, ARB_Org_Name = LoginInfoDAX.OrgShortName, ARB_PayObjectTypeCode = paramHead.RB_PayObjectTypeCode, ARB_PayObjectTypeName = paramHead.RB_PayObjectTypeName, ARB_PayObjectID = paramHead.RB_PayObjectID, ARB_PayObjectName = paramHead.RB_PayObjectName, ARB_AccountReceivableAmount = loopDetail.RBD_ReceiveAmount, ARB_ReceivedAmount = loopDetail.RBD_ReceiveAmount, ARB_UnReceiveAmount = 0, ARB_BusinessStatusName = AccountReceivableBillStatusEnum.Name.YWC, ARB_BusinessStatusCode = AccountReceivableBillStatusEnum.Code.YWC, ARB_ApprovalStatusName = ApprovalStatusEnum.Name.YSH, ARB_ApprovalStatusCode = ApprovalStatusEnum.Code.YSH, ARB_IsValid = true, ARB_CreatedBy = LoginInfoDAX.UserName, ARB_CreatedTime = BLLCom.GetCurStdDatetime(), ARB_UpdatedBy = LoginInfoDAX.UserName, ARB_UpdatedTime = BLLCom.GetCurStdDatetime(), }; addAccountReceivableBillList.Add(accountReceivableBill); //回写付款单的来源的单号 loopDetail.RBD_SrcBillNo = accountReceivableBill.ARB_No; #endregion #region 新增[应收单明细] MDLFM_AccountReceivableBillDetail accountPayableBillDetail = new MDLFM_AccountReceivableBillDetail { ARBD_ID = Guid.NewGuid().ToString(), ARBD_ARB_ID = accountReceivableBill.ARB_ID, ARBD_IsMinusDetail = false, ARBD_Org_ID = accountReceivableBill.ARB_Org_ID, ARBD_Org_Name = accountReceivableBill.ARB_Org_Name, ARBD_AccountReceivableAmount = loopDetail.RBD_ReceiveAmount, ARBD_ReceivedAmount = loopDetail.RBD_ReceiveAmount, ARBD_UnReceiveAmount = 0, ARBD_BusinessStatusName = accountReceivableBill.ARB_BusinessStatusName, ARBD_BusinessStatusCode = accountReceivableBill.ARB_BusinessStatusCode, ARBD_ApprovalStatusName = accountReceivableBill.ARB_ApprovalStatusName, ARBD_ApprovalStatusCode = accountReceivableBill.ARB_ApprovalStatusCode, ARBD_IsValid = true, ARBD_CreatedBy = LoginInfoDAX.UserName, ARBD_CreatedTime = BLLCom.GetCurStdDatetime(), ARBD_UpdatedBy = LoginInfoDAX.UserName, ARBD_UpdatedTime = BLLCom.GetCurStdDatetime(), }; addAccountReceivableBillDetailList.Add(accountPayableBillDetail); #endregion } #endregion } #region 收款单 //更新收款单[业务状态]为{已完成},[审核状态]为{已审核} updateReceiptBill.RB_ApprovalStatusName = ApprovalStatusEnum.Name.YSH; updateReceiptBill.RB_ApprovalStatusCode = ApprovalStatusEnum.Code.YSH; updateReceiptBill.RB_BusinessStatusName = ReceiptBillStatusEnum.Name.YWC; updateReceiptBill.RB_BusinessStatusCode = ReceiptBillStatusEnum.Code.YWC; updateReceiptBill.RB_UpdatedBy = LoginInfoDAX.UserName; updateReceiptBill.RB_UpdatedTime = BLLCom.GetCurStdDatetime(); #endregion #region 更新[付款单明细]数据 _bll.CopyModelList <ReceiptBillManagerDetailUIModel, MDLFM_ReceiptBillDetail>(paramDetailList, updateReceiptBillDetailList); foreach (var loopPayBillDetaill in updateReceiptBillDetailList) { loopPayBillDetaill.WHERE_RBD_ID = loopPayBillDetaill.RBD_ID; loopPayBillDetaill.WHERE_RBD_VersionNo = loopPayBillDetaill.RBD_VersionNo; loopPayBillDetaill.RBD_VersionNo++; } #endregion #region 更新[钱包余额]和新增[钱包异动] if (paramHead.RB_ReceiveTypeName == TradeTypeEnum.Name.WALLET) { #region 更新[钱包] updateWallet.WHERE_Wal_ID = paramHead.Wal_ID; updateWallet.WHERE_Wal_VersionNo = paramHead.Wal_VersionNo; updateWallet.Wal_AvailableBalance = paramHead.Wal_AvailableBalance - paramHead.RB_ReceiveTotalAmount; paramHead.Wal_AvailableBalance = updateWallet.Wal_AvailableBalance ?? 0; #endregion #region 新增[钱包异动] addWalletTrans.WalT_ID = System.Guid.NewGuid().ToString(); addWalletTrans.WalT_Org_ID = LoginInfoDAX.OrgID; addWalletTrans.WalT_Org_Name = LoginInfoDAX.OrgShortName; addWalletTrans.WalT_Wal_ID = paramHead.Wal_ID; addWalletTrans.WalT_Wal_No = paramHead.Wal_No; addWalletTrans.WalT_Time = BLLCom.GetCurStdDatetime(); addWalletTrans.WalT_TypeCode = WalTransTypeEnum.Code.XF; addWalletTrans.WalT_TypeName = WalTransTypeEnum.Name.XF; addWalletTrans.WalT_Amount = -paramHead.RB_ReceiveTotalAmount; addWalletTrans.WalT_BillNo = paramHead.RB_No; addWalletTrans.WalT_IsValid = true; addWalletTrans.WalT_CreatedBy = LoginInfoDAX.UserName; addWalletTrans.WalT_CreatedTime = BLLCom.GetCurStdDatetime(); addWalletTrans.WalT_UpdatedBy = LoginInfoDAX.UserName; addWalletTrans.WalT_UpdatedTime = BLLCom.GetCurStdDatetime(); #endregion } #endregion #endregion #region 带事务的保存 try { DBManager.BeginTransaction(DBCONFIG.Coeus); #region 更新[收款单] bool updateReceiptBillResult = _bll.Save(updateReceiptBill); if (!updateReceiptBillResult) { DBManager.RollBackTransaction(DBCONFIG.Coeus); ResultMsg = MsgHelp.GetMsg(MsgCode.E_0010, new object[] { SystemActionEnum.Name.SAVE + SystemTableEnums.Name.FM_ReceiptBill }); LogHelper.WriteBussLogEndNG(BussID, LoginInfoDAX.UserName, funcName, ResultMsg, "", null); return(false); } #endregion #region 更新[收款单明细] foreach (var loopReceiptBillDetail in updateReceiptBillDetailList) { bool updateDetailResult = _bll.Update(loopReceiptBillDetail); if (!updateDetailResult) { DBManager.RollBackTransaction(DBCONFIG.Coeus); ResultMsg = MsgHelp.GetMsg(MsgCode.E_0010, new object[] { SystemActionEnum.Name.APPROVE + SystemTableEnums.Name.FM_ReceiptBillDetail }); return(false); } } #endregion #region 新增[应收单] bool addAccountReceivableBillResult = _bll.InsertByList <MDLFM_AccountReceivableBill, MDLFM_AccountReceivableBill>(addAccountReceivableBillList); if (!addAccountReceivableBillResult) { DBManager.RollBackTransaction(DBCONFIG.Coeus); ResultMsg = MsgHelp.GetMsg(MsgCode.E_0010, new object[] { MsgParam.ADD + SystemTableEnums.Name.FM_AccountReceivableBill }); return(false); } #endregion #region 新增[应付单明细] bool addAccountReceivableBillDetailResult = _bll.InsertByList <MDLFM_AccountReceivableBillDetail, MDLFM_AccountReceivableBillDetail>(addAccountReceivableBillDetailList); if (!addAccountReceivableBillDetailResult) { DBManager.RollBackTransaction(DBCONFIG.Coeus); ResultMsg = MsgHelp.GetMsg(MsgCode.E_0010, new object[] { MsgParam.ADD + SystemTableEnums.Name.FM_AccountReceivableBillDetail }); return(false); } #endregion #region 更新[钱包余额]和新增[钱包异动] if (paramHead.RB_ReceiveTypeName == TradeTypeEnum.Name.WALLET) { #region 更新[钱包余额] bool updateWalletResult = _bll.Save(updateWallet); if (!updateWalletResult) { DBManager.RollBackTransaction(DBCONFIG.Coeus); ResultMsg = MsgHelp.GetMsg(MsgCode.E_0010, new object[] { MsgParam.UPDATE + SystemTableEnums.Name.EWM_Wallet }); LogHelper.WriteBussLogEndNG(BussID, LoginInfoDAX.UserName, funcName, ResultMsg, "", null); return(false); } #endregion #region 新增[钱包异动] bool addWalletTransResult = _bll.Insert <MDLEWM_WalletTrans>(addWalletTrans); if (!addWalletTransResult) { DBManager.RollBackTransaction(DBCONFIG.Coeus); ResultMsg = MsgHelp.GetMsg(MsgCode.E_0010, new object[] { MsgParam.ADD + SystemTableEnums.Name.EWM_WalletTrans }); return(false); } #endregion } #endregion DBManager.CommitTransaction(DBCONFIG.Coeus); } catch (Exception ex) { DBManager.RollBackTransaction(DBCONFIG.Coeus); ResultMsg = MsgHelp.GetMsg(MsgCode.E_0018, new object[] { SystemActionEnum.Name.APPROVE, ex.Message }); LogHelper.WriteBussLogEndNG(BussID, LoginInfoDAX.UserName, MethodBase.GetCurrentMethod().ToString(), ex.Message, "", null); return(false); } #endregion //将最新数据回写给DetailDS CopyModel(updateReceiptBill, paramHead); return(true); }
/// <summary> /// 查询 /// </summary> public void QueryAction() { if (cbWhere_CustomerType.Text == CustomerTypeEnum.Name.PTNQXSH && (string.IsNullOrEmpty(mcbWhere_AutoFactoryName.SelectedText) || string.IsNullOrEmpty(mcbWhere_AutoFactoryName.SelectedValue))) { //请选择汽修商户 MessageBoxs.Show(Trans.COM, this.ToString(), MsgHelp.GetMsg(MsgCode.E_0013, new object[] { MsgParam.AUTOFACTORY }), MessageBoxButtons.OK, MessageBoxIcon.Information); return; } List <CustomerQueryUIModel> resultCustomerList = new List <CustomerQueryUIModel>(); _bll.QueryForList(SQLID.COMM_SQL11, new CustomerQueryQCModel { PageSize = PageSize, PageIndex = PageIndex, //客户类型 WHERE_CustomerType = cbWhere_CustomerType.Text.Trim(), //客户名称 WHERE_CustomerName = txtWhere_CustomerName.Text.Trim(), //汽修商户名称 WHERE_AutoFactoryName = mcbWhere_AutoFactoryName.SelectedText, //组织ID WHERE_OrgID = LoginInfoDAX.UserID == SysConst.SUPER_ADMIN ? null : LoginInfoDAX.OrgID, }, resultCustomerList); if (cbWhere_CustomerType.Text == CustomerTypeEnum.Name.PTNQXSH) { ListGridDS = new List <CustomerQueryUIModel>(); //根据指定的汽修商户数据库信息获取Venus组织列表 List <MDLSM_Organization> tempVenusOrgList = new List <MDLSM_Organization>(); BLLCom.QueryAutoFactoryCustomerOrgList(mcbWhere_AutoFactoryName.SelectedValue, tempVenusOrgList); foreach (var loopVenusOrg in tempVenusOrgList) { foreach (var loopCustomer in resultCustomerList) { if (loopCustomer.AutoFactoryOrgCode == loopVenusOrg.Org_Code && loopCustomer.CustomerName == loopVenusOrg.Org_ShortName) { CustomerQueryUIModel authorityVenusOrg = new CustomerQueryUIModel() { CustomerType = loopCustomer.CustomerType, CustomerID = loopCustomer.CustomerID, CustomerName = loopCustomer.CustomerName, AutoFactoryCode = loopCustomer.AutoFactoryCode, AutoFactoryName = loopCustomer.AutoFactoryName, AutoFactoryOrgID = loopVenusOrg.Org_ID, AutoFactoryOrgCode = loopCustomer.AutoFactoryOrgCode, CustomerPhoneNo = loopCustomer.CustomerPhoneNo, CustomerAddress = loopCustomer.CustomerAddress, CreditAmount = loopCustomer.CreditAmount, DebtAmount = loopCustomer.DebtAmount, PaymentTypeCode = loopCustomer.PaymentTypeCode, PaymentTypeName = loopCustomer.PaymentTypeName, BillingTypeCode = loopCustomer.BillingTypeCode, BillingTypeName = loopCustomer.BillingTypeName, DeliveryTypeCode = loopCustomer.DeliveryTypeCode, DeliveryTypeName = loopCustomer.DeliveryTypeName, DeliveryByID = loopCustomer.DeliveryByID, DeliveryByName = loopCustomer.DeliveryByName, DeliveryByPhone = loopCustomer.DeliveryByPhone, IsEndSales = loopCustomer.IsEndSales, AutoPartsPriceType = loopCustomer.AutoPartsPriceType, Wal_ID = loopCustomer.Wal_ID, Wal_No = loopCustomer.Wal_No, Wal_Org_ID = loopCustomer.Wal_Org_ID, Wal_Org_Name = loopCustomer.Wal_Org_Name, Wal_AvailableBalance = loopCustomer.Wal_AvailableBalance, RowID = loopCustomer.RowID, RecordCount = loopCustomer.RecordCount, //汽修商户组织信息 AutoFactoryOrgInfo = loopCustomer.CustomerID + SysConst.Semicolon_DBC + loopVenusOrg.Org_ID + SysConst.Semicolon_DBC + loopCustomer.AutoFactoryOrgCode, }; ListGridDS.Add(authorityVenusOrg); } } } } else { _bll.CopyModelList(resultCustomerList, ListGridDS); } gdGrid.DataSource = ListGridDS; gdGrid.DataBind(); if (ListGridDS.Count > 0) { dynamic subObject = ListGridDS[0]; TotalRecordCount = subObject.RecordCount; } else { TotalRecordCount = 0; } //设置翻页控件 SetBarPaging(TotalRecordCount); //设置单元格是否可以编辑 SetPayConfirmWindowStyle(); }
/// <summary> /// 从平台同步组织信息到本地数据库 /// </summary> /// <returns></returns> public static bool SynchronizeOrgInfo() { var funcName = "SynchronizeOrgInfo"; LogHelper.WriteBussLogStart(Trans.COM, LoginInfoDAX.UserName, funcName, "", "", null); //根据商户编码和产品编码来查询组织信息 string argsPostData = string.Format(ApiParameter.BF0002, ConfigurationManager.AppSettings[AppSettingKey.MCT_CODE], SysConst.ProductCode); string strApiData = APIDataHelper.GetAPIData(ApiUrl.BF0002Url, argsPostData); var jsonResult = (JObject)JsonConvert.DeserializeObject(strApiData); if (jsonResult != null && jsonResult["ResultCode"].ToString().Equals("I0001")) { var argsSettingKeyMctCode1 = jsonResult["ListOrganization"]; var platformOrgJson = (JArray)JsonConvert.DeserializeObject(argsSettingKeyMctCode1.ToString()); var localOrgList = new List <MDLSM_Organization>(); _bllBase.QuerryForList(new MDLSM_Organization { WHERE_Org_IsValid = true }, localOrgList); var invalidOrgList = new List <MDLSM_Organization>(); _bllBase.CopyModelList(localOrgList, invalidOrgList); //从无效列表中移除在平台上有效的组织 foreach (var json in platformOrgJson) { var validOrgList = invalidOrgList.Where(p => p.Org_Code == json["Org_Code"].ToString()).ToList(); if (validOrgList.Count > 0) { invalidOrgList.Remove(validOrgList[0]); } } try { DBManager.BeginTransaction(DBCONFIG.Coeus); if (invalidOrgList.Count > 0) { foreach (var model in invalidOrgList) { model.WHERE_Org_ID = model.Org_ID; model.Org_IsValid = false; bool save = _bllBase.Save <MDLSM_Organization>(model); if (!save) { DBManager.RollBackTransaction(DBCONFIG.Coeus); LogHelper.WriteBussLogEndOK(Trans.COM, LoginInfoDAX.UserName, funcName, "同步组织失败!", "", null); return(false); } } } var orgList = new List <MDLSM_Organization>(); foreach (var json in platformOrgJson) { var argsorg = new MDLSM_Organization(); var sameOrgList = localOrgList.Where(p => p.Org_Code == json["Org_Code"].ToString()).ToList(); if (sameOrgList.Count > 0) { argsorg = sameOrgList[0]; } argsorg.WHERE_Org_ID = argsorg.Org_ID; argsorg.Org_Code = json["Org_Code"].ToString(); argsorg.Org_FullName = json["Org_FullName"].ToString(); argsorg.Org_ShortName = json["Org_ShortName"].ToString(); argsorg.Org_Contacter = json["Org_Contacter"].ToString(); argsorg.Org_TEL = json["Org_TEL"].ToString(); argsorg.Org_PhoneNo = json["Org_PhoneNo"].ToString(); argsorg.Org_Prov_Code = json["Org_Prov_Code"].ToString(); argsorg.Org_City_Code = json["Org_City_Code"].ToString(); argsorg.Org_Dist_Code = json["Org_Dist_Code"].ToString(); argsorg.Org_Addr = json["Org_Addr"].ToString(); argsorg.Org_Longitude = json["Org_Longitude"].ToString(); argsorg.Org_Latitude = json["Org_Latitude"].ToString(); argsorg.Org_MarkerTitle = json["Org_MarkerTitle"].ToString(); argsorg.Org_MarkerContent = json["Org_MarkerContent"].ToString(); argsorg.Org_Remark = json["Org_Remark"].ToString(); //Org_MCT_ID 作为MCT_Code来存放 argsorg.Org_MCT_ID = ConfigurationManager.AppSettings[AppSettingKey.MCT_CODE] ?? string.Empty; argsorg.Org_CreatedBy = argsorg.Org_UpdatedBy = "系统同步"; argsorg.Org_IsValid = true; bool save = _bllBase.Save <MDLSM_Organization>(argsorg); if (!save) { DBManager.RollBackTransaction(DBCONFIG.Coeus); LogHelper.WriteBussLogEndOK(Trans.COM, LoginInfoDAX.UserName, funcName, "同步组织失败!", "", null); return(false); } orgList.Add(argsorg); } DBManager.CommitTransaction(DBCONFIG.Coeus); LoginInfoDAX.OrgList = new List <MDLSM_Organization>(orgList); } catch (Exception ex) { DBManager.RollBackTransaction(DBCONFIG.Coeus); LogHelper.WriteErrorLog(Trans.COM, "ExecuteSyncCommand", ex.Message, null, ex); LogHelper.WriteBussLogEndOK(Trans.COM, LoginInfoDAX.UserName, funcName, ex.Message, "", null); return(false); } } else { var strErrorMessage = jsonResult == null ? "" : jsonResult["ResultMsg"].ToString(); LogHelper.WriteBussLogEndOK(Trans.COM, LoginInfoDAX.UserName, funcName, strErrorMessage, "", null); } LogHelper.WriteBussLogEndOK(Trans.COM, LoginInfoDAX.UserName, funcName, "", "", null); return(true); }