public object NewExportJob(Store s) { var viewModel = new ExportViewModel(s); var exportView = new ExportView { DataContext = viewModel }; var tabItemModel = new TabItemViewModel(String.Format(Strings.ExportTabDefaultTitle, s.Location), exportView); TabItems.Add(tabItemModel); Messenger.Default.Send(new SelectTabMessage(tabItemModel)); return(null); }
private void Export(object obj) { if (_exportView == null) { _exportView = Container.Resolve <ExportView>(); _exportView.ShowDialog(); } else { _exportView.Focus(); } }
public async Task ShowExportView(string exportData) { CoreApplicationView exportWindow = null; bool init = false; lock (_lock) { if (_isWindowInitializing) { return; } if (_exportWindow == null) { init = true; _isWindowInitializing = true; _exportWindow = CoreApplication.CreateNewView(); } exportWindow = _exportWindow; } if (init) { await _exportWindow.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { _exportViewModel = new ExportViewModel(exportData); ExportView exportView = new ExportView(_exportViewModel); Window.Current.Content = exportView; Window.Current.Activate(); var viewId = ApplicationView.GetForCurrentView().Id; _ = ApplicationViewSwitcher.TryShowAsStandaloneAsync(viewId); }); lock (_lock) { _isWindowInitializing = false; } } else { await _exportWindow.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { _exportViewModel.ExportText = exportData; var w = Window.Current.Content; var viewId = ApplicationView.GetForCurrentView().Id; _ = ApplicationViewSwitcher.TryShowAsStandaloneAsync(viewId); }); } }
private void OnExportviewClosedMsg(ExportViewClosedMsg msg) { _exportView = null; }
private void InitCommand() { ShippingQueryCommand = new DelegateCommand((obj) => { GetShippingBills(); }); DirectorySelectCommand = new DelegateCommand((obj) => { // 导出目录选择 System.Windows.Forms.FolderBrowserDialog fbd = new System.Windows.Forms.FolderBrowserDialog(); if (fbd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { HostConfig.HostValue = fbd.SelectedPath; var result = _commonService.SaveHostConfig(HostConfig); if (result) { HostConfig = _commonService.GetHostConfig(4, _hostName, user.ID); } } }); ShippingBillExportCommand = new DelegateCommand((obj) => { if (Directory.Exists(HostConfig.HostValue)) { ExportView view = new ExportView(1, 1); (view.DataContext as ExportViewModel).Export((type, outputEntity, checkBoxValue, orderedColumns) => { view.Close(); if (type == 1) { DataTable datatable = new DataTable(); if (outputEntity == 1) { datatable = _shippingService.GetShippingBillExprotDataTable1(userDataId, GeneralParameter); new Helper.DataTableImportExportHelper().ExportDataTableToExcel(datatable, HostConfig.HostValue, HostConfig.TypeDesciption); MessageBox.Show("导出成功"); } else if (outputEntity == 2) { datatable = _shippingService.GetShippingBillExprotDataTable2(userDataId, GeneralParameter); new Helper.DataTableImportExportHelper().ExportDataTableToExcel(datatable, HostConfig.HostValue, HostConfig.TypeDesciption); MessageBox.Show("导出成功"); } else if (outputEntity == 3) { datatable = _shippingService.GetShippingBillExprotDataTable3(userDataId, string.Join(",", orderedColumns), GeneralParameter); new Helper.DataTableImportExportHelper().ExportDataTableToExcel(datatable, HostConfig.HostValue, HostConfig.TypeDesciption, checkBoxValue, 1, orderedColumns); MessageBox.Show("导出成功"); } } }); view.ShowDialog(); } else { MessageBox.Show("目录不存在,请先选择导出的目录"); DirectorySelectCommand.Execute(null); // MethodBase.GetCurrentMethod().Invoke(null,null); //递归调用 // StackFrame frame = new StackFrame(0); //frame.GetMethod().Invoke(0,null); } _commonService.WriteActionLog(new ActionOperationLogModel { ActionName = "ExportShippingData", ActionDesc = "导出托运单", UserId = user.ID, MainMenuId = 7, PKId = -1, HostName = _hostName }); }); }
private void InitCommand() { DirectorySelectBaseCommand = new DelegateCommand((obj) => { // 导出目录选择 System.Windows.Forms.FolderBrowserDialog fbd = new System.Windows.Forms.FolderBrowserDialog(); if (fbd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { HostConfig.HostValue = fbd.SelectedPath; var result = CommonService.SaveHostConfig(HostConfig); if (result) { HostConfig = CommonService.GetHostConfig(Menu.ID, HostName, User.ID); } } }); ExportBaseCommand = new DelegateCommand((obj) => { if (Directory.Exists(HostConfig.HostValue)) { ExportView view = new ExportView(Menu.ID, 3);// Menu.ID-SJExportViewTypedColumn中的ViewGroupId; 3 - 第几个radioButton被默认选中从1开始 //Export((type - 导出1 取消0, outputEntity 界面选中的radiobuttion 同上, checkBoxValue 选择分类导出的情况下,选择的类别和, orderedColumns 选择分类导出的情况下,选择类别的顺序列表) (view.DataContext as ExportViewModel).Export((type, outputEntity, checkBoxValue, orderedColumns) => { view.Close(); if (type == 1) { if (outputEntity == 3) { DataTable datatable = _service.GetSJBatchBomRequestDeliveryExportData(GeneralParameter.ParamBeginDate.Value, string.Join(",", orderedColumns)); if (datatable.Rows.Count > 0) { ExportHelper.ExportDeliveryDataToExcel(GeneralParameter.ParamBeginDate.Value, datatable, HostConfig.HostValue, HostConfig.TypeDesciption + CommonService.GetQueryParameterValueString(GeneralParameter) , outputEntity, orderedColumns, true, "$$$发料单", true); MessageBox.Show("导出成功"); } else { MessageBox.Show($"【{GeneralParameter.ParamBeginDate.Value}】 没有可导出的数据"); } } else { DataTable datatable = _service.GeSJBatchBOMSummaryExportData(GeneralParameter.ParamBeginDate.Value); if (datatable.Rows.Count > 0) { ExportHelper.ExportDataTableToExcel(datatable, HostConfig.HostValue, "物料需求" + CommonService.GetQueryParameterValueString(GeneralParameter), outputEntity, null, false, "物料需求", false); MessageBox.Show("导出成功"); } else { MessageBox.Show($"【{GeneralParameter.ParamBeginDate.Value}】 没有可导出的数据"); } } } }); view.ShowDialog(); } else { MessageBox.Show("目录不存在,请先选择导出的目录"); DirectorySelectBaseCommand.Execute(null); } CommonService.WriteActionLog(new ActionOperationLogModel { ActionName = "ExportBaseCommand", ActionDesc = HostConfig.TypeDesciption + HostConfig.TypeId.ToString(), UserId = User.ID, MainMenuId = Menu.ID, PKId = -1, HostName = HostName }); }); MaterialRequestGenerateCommand = new DelegateCommand((obj) => { _service.SplitBatchBomRequest(GeneralParameter.ParamBeginDate.Value); QueryBaseCommand.Execute(null); CommonService.WriteActionLog(new ActionOperationLogModel { ActionName = "MaterialRequestGenerateCommand", ActionDesc = "生成物料需求", UserId = User.ID, MainMenuId = Menu.ID, PKId = -1, HostName = HostName }); }); WorkshopInventoryRefreshCommand = new DelegateCommand((obj) => { BatchBomRequestSummaryLists.Clear(); _service.RefreshWorkshopInventoryQty(CommonService.GetSqlWhereString(Filter)); QueryBaseCommand.Execute(null); CommonService.WriteActionLog(new ActionOperationLogModel { ActionName = "WorkshopInventoryRefreshCommand", ActionDesc = "获取现场库存", UserId = User.ID, MainMenuId = Menu.ID, PKId = -1, HostName = HostName }); }); QueryBaseCommand = new DelegateCommand((obj) => { BatchBomRequestSummaryLists.Clear(); InventoryLists.Clear(); DeliverTransferLists.Clear(); _service.GetBatchBomRequestDetailSummaryLists(CommonService.GetSqlWhereString(Filter)).ForEach(x => BatchBomRequestSummaryLists.Add(x)); }); DeliverCommand = new DelegateCommand((obj) => { if (BatchBomRequestSummarySelectedItem != null) { if (InventorySelectedItem != null && InventorySelectedItem.TransferingWeight > 0 && InventorySelectedItem.TransferingWeight <= InventorySelectedItem.TotalWeight) { if (_service.InsertDeliverTransfer(InventorySelectedItem)) { DeliverTransferLists.Clear(); _service.GetDeliverTransferLists(BatchBomRequestSummarySelectedItem).ForEach(x => DeliverTransferLists.Add(x)); BatchBomRequestSummarySelectedItem.QtyTransfering = DeliverTransferLists.Where(x => string.IsNullOrEmpty(x.TransferedBillNo)).Sum(x => x.TransferingWeight).Value; } } else { MessageBox.Show("发料数量必须大于0且小于总重量"); } } else { MessageBox.Show("先选择主表行数据"); } CommonService.WriteActionLog(new ActionOperationLogModel { ActionName = "DeliverCommand", ActionDesc = "发料", UserId = User.ID, MainMenuId = Menu.ID, PKId = -1, HostName = HostName }); }); DeliveryDeleteCommand = new DelegateCommand((obj) => { int id = -1; if (BatchBomRequestSummarySelectedItem != null) { var selectedLists = ((obj as DataGrid).SelectedItems).Cast <MaterialTimelyInventoryModel>().ToList(); if (selectedLists.Count == 1) { var model = selectedLists.First(); if (_service.DeleteDeliverTransfer(model.Id)) { id = model.Id; DeliverTransferLists.Clear(); _service.GetDeliverTransferLists(BatchBomRequestSummarySelectedItem).ForEach(x => DeliverTransferLists.Add(x)); BatchBomRequestSummarySelectedItem.QtyTransfering = DeliverTransferLists.Sum(x => x.TransferingWeight).Value; } } else { MessageBox.Show("每次必须选中且删除一行记录"); } } else { MessageBox.Show("先选择主表行数据"); } CommonService.WriteActionLog(new ActionOperationLogModel { ActionName = "DeliveryDeleteCommand", ActionDesc = "删除发料", UserId = User.ID, MainMenuId = Menu.ID, PKId = id, HostName = HostName }); }); TransferDeleteCommand = new DelegateCommand((obj) => { if (BatchBomRequestSummarySelectedItem != null) { var selectedLists = ((obj as DataGrid).SelectedItems).Cast <MaterialTimelyInventoryModel>().ToList(); if (selectedLists.Count == 1) { var model = selectedLists.First(); if (!_service.ExistsK3Bill(model.TransferedBillNo)) { if (_service.DeleteDeliverTransfer(model.TransferedBillNo)) { //重新加载主表格 QueryBaseCommand.Execute(null); } } else { MessageBox.Show("请先将选择的调拨单号,在K3里面删除"); } } else { MessageBox.Show("每次必须选中且删除一行记录"); } } else { MessageBox.Show("先选择主表行数据"); } CommonService.WriteActionLog(new ActionOperationLogModel { ActionName = "TransferDeleteCommand", ActionDesc = "删除调拨单", UserId = User.ID, MainMenuId = Menu.ID, PKId = -1, HostName = HostName }); }); SelectionChangedCommand = new DelegateCommand((obj) => { if (BatchBomRequestSummarySelectedItem == null) { return; } InventoryLists.Clear(); _service.GetGetMaterialTimelyInventoryLists(BatchBomRequestSummarySelectedItem.MaterialId, BatchBomRequestSummarySelectedItem.ProductionDate, BatchBomRequestSummarySelectedItem.BatchTypeId, BatchBomRequestSummarySelectedItem.StockId).ForEach(x => InventoryLists.Add(x)); DeliverTransferLists.Clear(); _service.GetDeliverTransferLists(BatchBomRequestSummarySelectedItem).ForEach(x => DeliverTransferLists.Add(x)); }); BatchNoQtyK3InsertCommand = new DelegateCommand((obj) => { // 获取当天所有已发料未调拨数据 var selectedLists = ((obj as DataGrid).SelectedItems).Cast<MaterialTimelyInventoryModel>().ToList(); var selectedLists = _service.GetK3InsertData(GeneralParameter.ParamBeginDate.Value); if (selectedLists.Count > 0) { var emp = K3ApiFKService.GetEmployeeByUserName(User.UserName); if (emp != null) { TransferMainModel main = new TransferMainModel { FBillerID = new BaseNumberNameModelX { FNumber = emp.FName, FName = emp.FName }, FFManagerID = emp, // BaseNumberNameModelX { FNumber = "111", FName = "吴强" }, FSManagerID = emp, // new BaseNumberNameModelX { FNumber = "111", FName = "吴强" }, FRefType = new BaseNumberNameModelX { FNumber = "01", FName = "成本调拨" }, FClassTypeID = 41, FDate = DateTime.Now.Date.ToString("yyyy-MM-dd") }; List <TransferSonModel> sons = new List <TransferSonModel>(); foreach (MaterialTimelyInventoryModel item in selectedLists) { sons.Add(new TransferSonModel { FItemID = new BaseNumberNameModelX { FNumber = item.MaterialNumber, FName = item.MaterialName }, // K3ApiFKService.GetMaterialById FChkPassItem = new BaseNumberNameModelX { FNumber = "Y", FName = "是" }, FPlanMode = new BaseNumberNameModelX { FNumber = "MTS", FName = "MTS计划模式" }, FDCStockID1 = new BaseNumberNameModelX { FNumber = item.ParentStockNumber, FName = item.ParentStockName }, //K3ApiFKService.GetStockById(item.ParentStockId), FSCStockID1 = new BaseNumberNameModelX { FNumber = item.StockNumber, FName = item.StockName }, FUnitID = new BaseNumberNameModelX { FNumber = "kg", FName = "kg" }, FAuxQty = item.TransferingWeight.Value, FQty = item.TransferingWeight.Value, FBatchNo = item.BatchNo, }); } var requestModel = new K3ApiInsertRequestModel <TransferMainModel, TransferSonModel>() { Data = new K3ApiInsertDataRequestModel <TransferMainModel, TransferSonModel>() { Page1 = new List <TransferMainModel> { main }, Page2 = sons } }; string postJson = JsonHelper.ObjectToJson(requestModel); K3ApiInsertResponseModel response = K3ApiService.Insert("Transfer", postJson); if (response.StatusCode == 200) { //double totalQty = selectedLists.Sum(x => x.TransferingWeight).Value; string ids = string.Join(",", selectedLists.Select(x => x.Id)); if (_service.UpdateBillNo(ids, response.Data.BillNo)) { QueryBaseCommand.Execute(null); } else { MessageBox.Show($"插入K3调拨单,更新发料表失败,请联系管理员"); } } else { MessageBox.Show($"{response.Message}"); } } else { MessageBox.Show($"【{User.UserName}】 在K3里面不存在,或不一致"); } } else { MessageBox.Show($"【{GeneralParameter.ParamBeginDate.Value}】 没有已发料且未调拨的数据"); } CommonService.WriteActionLog(new ActionOperationLogModel { ActionName = "BatchNoQtyK3InsertCommand", ActionDesc = "生成调拨单", UserId = User.ID, MainMenuId = Menu.ID, PKId = -1, HostName = HostName }); }); }
public ExportViewModel(MainView Parent) { ExportWindow = new ExportView(this); ExportWindow.ShowDialog(Parent); }
/// <inheritdoc/> public override DM.IDock CreateLayout() { // Documents var pageDocument = new PageDocument { Id = nameof(PageDocument), Title = "Page" }; // Tools var projectTool = new ProjectTool { Id = nameof(ProjectTool), Title = "Project" }; var optionsTool = new OptionsTool { Id = nameof(OptionsTool), Title = "Options" }; var imagesTool = new ImagesTool { Id = nameof(ImagesTool), Title = "Images" }; var groupsTool = new GroupsTool { Id = nameof(GroupsTool), Title = "Groups" }; var databasesTool = new DatabasesTool { Id = nameof(DatabasesTool), Title = "Databases" }; var scriptTool = new ScriptTool { Id = nameof(ScriptTool), Title = "Script" }; var exportTool = new ExportTool { Id = nameof(ExportTool), Title = "Export" }; var browserTool = new BrowserTool { Id = nameof(BrowserTool), Title = "Browser" }; var documentTool = new DocumentTool { Id = nameof(DocumentTool), Title = "Document" }; var stylesTool = new StylesTool { Id = nameof(StylesTool), Title = "Styles" }; var templatesTool = new TemplatesTool { Id = nameof(TemplatesTool), Title = "Templates" }; var containerTool = new ContainerTool { Id = nameof(ContainerTool), Title = "Container" }; var zoomTool = new ZoomTool { Id = nameof(ZoomTool), Title = "Zoom" }; var shapeTool = new ShapeTool { Id = nameof(ShapeTool), Title = "Shape" }; var toolsTool = new ToolsTool { Id = nameof(ToolsTool), Title = "Tools" }; var dataTool = new DataTool { Id = nameof(DataTool), Title = "Data" }; var styleTool = new StyleTool { Id = nameof(StyleTool), Title = "Style" }; var templateTool = new TemplateTool { Id = nameof(TemplateTool), Title = "Template" }; // Panes var leftPane = new DMC.ProportionalDock { Id = nameof(DMC.IProportionalDock), Title = "EditorLeft", Orientation = DM.Orientation.Vertical, Proportion = 0.17, ActiveDockable = null, VisibleDockables = CreateList <DM.IDockable> ( new DMC.ToolDock { Id = nameof(DMC.IToolDock), Title = "EditorLeftTop", Proportion = double.NaN, ActiveDockable = projectTool, VisibleDockables = CreateList <DM.IDockable> ( projectTool, optionsTool, imagesTool ) }, new DMC.SplitterDock() { Id = nameof(DMC.ISplitterDock), Title = "LeftTopSplitter" }, new DMC.ToolDock { Id = nameof(DMC.IToolDock), Title = "EditorLeftBottom", Proportion = double.NaN, ActiveDockable = groupsTool, VisibleDockables = CreateList <DM.IDockable> ( groupsTool, databasesTool, toolsTool ) } ) }; var rightPane = new DMC.ProportionalDock { Id = nameof(DMC.IProportionalDock), Title = "EditorRight", Orientation = DM.Orientation.Vertical, Proportion = 0.17, ActiveDockable = null, VisibleDockables = CreateList <DM.IDockable> ( new DMC.ToolDock { Id = nameof(DMC.IToolDock), Title = "EditorRightTop", Proportion = double.NaN, ActiveDockable = stylesTool, VisibleDockables = CreateList <DM.IDockable> ( stylesTool, templatesTool, containerTool, zoomTool ) }, new DMC.SplitterDock() { Id = nameof(DMC.ISplitterDock), Title = "RightTopSplitter" }, new DMC.ToolDock { Id = nameof(DMC.IToolDock), Title = "EditorRightBottom", Proportion = double.NaN, ActiveDockable = shapeTool, VisibleDockables = CreateList <DM.IDockable> ( shapeTool, dataTool, styleTool, templateTool ) } ) }; var documentsPane = new DMC.DocumentDock { Id = nameof(DMC.IDocumentDock), Title = "DocumentsPane", IsCollapsable = false, Proportion = double.NaN, ActiveDockable = pageDocument, VisibleDockables = CreateList <DM.IDockable> ( pageDocument, documentTool, scriptTool, exportTool, browserTool ) }; // Editor var editorLayout = new DMC.ProportionalDock { Id = nameof(DMC.IProportionalDock), Title = "EditorLayout", Orientation = DM.Orientation.Horizontal, Proportion = double.NaN, ActiveDockable = null, VisibleDockables = CreateList <DM.IDockable> ( leftPane, new DMC.SplitterDock() { Id = nameof(DMC.ISplitterDock), Title = "LeftSplitter" }, documentsPane, new DMC.SplitterDock() { Id = nameof(DMC.ISplitterDock), Title = "RightSplitter" }, rightPane ) }; // Views var editorView = new EditorView { Id = nameof(EditorView), Title = "Editor", ActiveDockable = editorLayout, VisibleDockables = CreateList <DM.IDockable> ( editorLayout ) }; var aboutView = new AboutView { Id = nameof(AboutView), Title = "About" }; var browserView = new BrowserView { Id = nameof(BrowserView), Title = "Browser" }; var scriptView = new ScriptView { Id = nameof(ScriptView), Title = "Script" }; var exportView = new ExportView { Id = nameof(ExportView), Title = "Export" }; var documentView = new DocumentView { Id = nameof(DocumentView), Title = "Document" }; var dashboardView = new DashboardView { Id = nameof(DashboardView), Title = "Dashboard" }; // Root var root = new DMC.RootDock { Id = nameof(DMC.IRootDock), Title = "Root", IsCollapsable = false, ActiveDockable = dashboardView, DefaultDockable = dashboardView, VisibleDockables = CreateList <DM.IDockable> ( dashboardView, editorView, aboutView, browserView, scriptView, exportView, documentView ) }; root.Top = CreatePinDock(); root.Top.Alignment = DM.Alignment.Top; root.Bottom = CreatePinDock(); root.Bottom.Alignment = DM.Alignment.Bottom; root.Left = CreatePinDock(); root.Left.Alignment = DM.Alignment.Left; root.Right = CreatePinDock(); root.Right.Alignment = DM.Alignment.Right; return(root); }
private void InitCommand() { QueryBaseCommand = new DelegateCommand((obj) => { SalesRebateSummaryLists.Clear(); ListsCount = 0; ListsSum = 0; SalesRebateLists.Clear(); RebatePctValueString = string.Empty; _salesRebateService.GetSalesRebateSummaryLists(UserDataId, CommonService.GetSqlWhereString(QueryParameter)).ForEach(x => { SalesRebateSummaryLists.Add(x); ListsSum += x.OrgAmount; ListsCount++; }); }); DirectorySelectBaseCommand = new DelegateCommand((obj) => { // 导出目录选择 System.Windows.Forms.FolderBrowserDialog fbd = new System.Windows.Forms.FolderBrowserDialog(); if (fbd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { HostConfig.HostValue = fbd.SelectedPath; var result = CommonService.SaveHostConfig(HostConfig); if (result) { HostConfig = CommonService.GetHostConfig(DataGridId, HostName, User.ID); } } }); ExportBaseCommand = new DelegateCommand((obj) => { if (Directory.Exists(HostConfig.HostValue)) { ExportView view = new ExportView(DataGridId, 1); (view.DataContext as ExportViewModel).Export((type, outputEntity, checkBoxValue, orderedColumns) => { view.Close(); if (type == 1) { DataTable datatable = new DataTable(); if (outputEntity == 1) { // 获取导出数据名称 string viewName = CommonService.GetExportViewName(DataGridId, 1); if (!string.IsNullOrEmpty(viewName)) { datatable = viewName.EndsWith("Proc")? _salesRebateService.GetExportDataProc(viewName, ReportQueryParameter): CommonService.GetExportDataView(viewName, CommonService.GetSqlWhereString(ReportQueryParameter)); ExportHelper.ExportDataTableToExcel(datatable, HostConfig.HostValue, HostConfig.TypeDesciption + CommonService.GetQueryParameterValueString(ReportQueryParameter)); MessageBox.Show("导出成功"); } } else if (outputEntity == 2) { // 获取导出数据名称 string viewName = CommonService.GetExportViewName(DataGridId, 2); if (!string.IsNullOrEmpty(viewName)) { datatable = viewName.EndsWith("Proc") ? _salesRebateService.GetExportDataProc(viewName, ReportQueryParameter) : CommonService.GetExportDataView(viewName, CommonService.GetSqlWhereString(ReportQueryParameter)); ExportHelper.ExportDataTableToExcel(datatable, HostConfig.HostValue, HostConfig.TypeDesciption + CommonService.GetQueryParameterValueString(ReportQueryParameter)); MessageBox.Show("导出成功"); } } else if (outputEntity == 3) { // 获取导出数据名称 string procName = CommonService.GetExportViewName(DataGridId, 3); if (!string.IsNullOrEmpty(procName)) { datatable = CommonService.GetExportDataProcedure(procName, UserDataId, string.Join(",", orderedColumns), CommonService.GetSqlWhereString(ReportQueryParameter)); ExportHelper.ExportDataTableToExcel(datatable, HostConfig.HostValue, HostConfig.TypeDesciption + CommonService.GetQueryParameterValueString(ReportQueryParameter), checkBoxValue, orderedColumns, false, "", false); MessageBox.Show("导出成功"); } } } }); view.ShowDialog(); } else { MessageBox.Show("目录不存在,请先选择导出的目录"); DirectorySelectBaseCommand.Execute(null); } CommonService.WriteActionLog(new ActionOperationLogModel { ActionName = "ExportBaseCommand", ActionDesc = HostConfig.TypeDesciption + CommonService.GetQueryParameterValueString(QueryParameter), UserId = User.ID, MainMenuId = Menu.ID, PKId = -1, HostName = HostName }); }); SalesRebateRecentParameterConfigCommand = new DelegateCommand((obj) => { if (BatchParameter.OrganizationSearchedItem != null && BatchParameter.RebateClassSeletedItem != null) { if (BatchParameterVerification(out DateTime maxDate)) { if (_salesRebateService.IfExistsOrgICSaleBill(BatchParameter)) { SalesRebateRecentParameterView view = new SalesRebateRecentParameterView(BatchParameter); (view.DataContext as SalesRebateRecentParameterViewModel).WithParam(null, (type, outputEntity, isChanged) => { view.Close(); if (isChanged) { // 计算刚才配置的参数 _salesRebateService.CalculateAmount(BatchParameter, User.ID, true); // 查询出刚生成的数据 QueryBaseCommand.Execute(null); } }); view.Show(); CommonService.WriteActionLog(new ActionOperationLogModel { ActionName = "SalesRebateRecentParameterConfigCommand", ActionDesc = CommonService.GetSqlWhereString(BatchParameter), UserId = User.ID, MainMenuId = Menu.ID, PKId = -1, HostName = HostName }); } else { MessageBox.Show($"【{BatchParameter.SettleDateBegin}】至【{BatchParameter.SettleDateEnd}】 ,客户【{BatchParameter.OrganizationSearchedItem.Name}】 没有K3销售单据"); } } else { MessageBox.Show($"【{maxDate}】 该类型【{BatchParameter.RebateClassSeletedItem.ItemValue} 】已经返利,同时间点不能多次返利"); } } else { MessageBox.Show("请先输入客户和返利类别"); } }); SalesRebateK3ApiInsertCommand = new DelegateCommand((obj) => { StringBuilder stringBuilder = new StringBuilder(); if (SalesRebateSummarySelectedItem != null && string.IsNullOrEmpty(SalesRebateSummarySelectedItem.K3BillNo) && SalesRebateLists.Count > 0) { var maxDate = _salesRebateService.GetMaxSettleDateByOrgId(BatchParameter.OrganizationSearchedItem.Id, BatchParameter.RebateClassSeletedItem.ItemSeq); if (SalesRebateSummarySelectedItem.SettleDateBegin > maxDate && SalesRebateSummarySelectedItem.SettleDateEnd > maxDate) { SalesInvoiceVATMainModel main = new SalesInvoiceVATMainModel { Fdate = SalesRebateSummarySelectedItem.SettleDateEnd.AddDays(5).ToString("yyyy-MM-dd"), FCustID = K3ApiFKService.GetOrganizationById(SalesRebateSummarySelectedItem.OrgId), FBillerID = new BaseNumberNameModelX { FNumber = User.UserName, FName = User.UserName }, FNote = "结算日期:" + SalesRebateSummarySelectedItem.SettleDateBegin.Date.ToString("yyyy-MM-dd") + "至" + SalesRebateSummarySelectedItem.SettleDateEnd.Date.ToString("yyyy-MM-dd") }; var son = new SalesInvoiceVATSonModel { Fauxprice = SalesRebateSummarySelectedItem.OrgAmount, Famount = SalesRebateSummarySelectedItem.OrgAmount * main.FROB, FStdAmount = SalesRebateSummarySelectedItem.OrgAmount * main.FROB, FTaxRate = SalesRebateSummarySelectedItem.OrgAmount * 0.13, FTaxAmount = SalesRebateSummarySelectedItem.OrgAmount * 0.13 * main.FROB, FStdTaxAmount = SalesRebateSummarySelectedItem.OrgAmount * 0.13 * main.FROB, FAllAmount = SalesRebateSummarySelectedItem.OrgAmount * (1 + 0.13), FAuxTaxPrice = SalesRebateSummarySelectedItem.OrgAmount * (1 + 0.13), FAuxPriceDiscount = SalesRebateSummarySelectedItem.OrgAmount * (1 + 0.13), FAmountincludetax = SalesRebateSummarySelectedItem.OrgAmount * (1 + 0.13) * main.FROB, FStdAmountincludetax = SalesRebateSummarySelectedItem.OrgAmount * (1 + 0.13) * main.FROB, FRemainAmount = SalesRebateSummarySelectedItem.OrgAmount * (1 + 0.13) * main.FROB, FRemainAmountFor = SalesRebateSummarySelectedItem.OrgAmount * (1 + 0.13) * main.FROB, }; var requestModel = new K3ApiInsertRequestModel <SalesInvoiceVATMainModel, SalesInvoiceVATSonModel>() { Data = new K3ApiInsertDataRequestModel <SalesInvoiceVATMainModel, SalesInvoiceVATSonModel>() { Page1 = new List <SalesInvoiceVATMainModel> { main }, Page2 = new List <SalesInvoiceVATSonModel> { son } } }; string postJson = JsonHelper.ObjectToJson(requestModel); K3ApiInsertResponseModel response = K3ApiXService.Insert(Token, "Sales_Invoice_VAT", postJson); if (response.StatusCode == 200) { // 更新后台数据 _salesRebateService.UpdateK3BillNo(SalesRebateSummarySelectedItem.Id, response.Data.BillNo, SalesRebateSummarySelectedItem.SettleDateEnd.AddDays(5)); stringBuilder.Append($"成功 BillNo:{response.Data.BillNo}, SettleDateBegin:{SalesRebateSummarySelectedItem.SettleDateBegin}, SettleDateEnd:{SalesRebateSummarySelectedItem.SettleDateEnd},OrgId: {SalesRebateSummarySelectedItem.OrgId}, RebateClass:{SalesRebateSummarySelectedItem.RebateClass}"); } else { MessageBox.Show(response.Message); stringBuilder.Append($"{response.Message}"); CommonService.WriteActionLog(new ActionOperationLogModel { ActionName = "SalesRebateRecentParameterConfigCommand", ActionDesc = stringBuilder.ToString(), UserId = User.ID, MainMenuId = Menu.ID, PKId = -1, HostName = HostName }); return; } } else { MessageBox.Show($"【{maxDate}】 该类型【{BatchParameter.RebateClassSeletedItem.ItemValue} 】已经返利,同时间点不能多次返利"); } } //重新加载数据 QueryBaseCommand.Execute(null); CommonService.WriteActionLog(new ActionOperationLogModel { ActionName = "SalesRebateK3ApiInsertCommand", ActionDesc = stringBuilder.ToString(), UserId = User.ID, MainMenuId = Menu.ID, PKId = -1, HostName = HostName }); }); SalesRebateK3ApiRemoveCommand = new DelegateCommand((obj) => { // 弹出删除提示 if (MessageBox.Show($"此操作会将K3单据和本条记录同时删除", "温馨提示", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { if (SalesRebateSummarySelectedItem != null && !string.IsNullOrEmpty(SalesRebateSummarySelectedItem.K3BillNo)) { string k3BillNo = SalesRebateSummarySelectedItem.K3BillNo; // 可选参数FInterID,当FBillNo重复时传入,【只删除明细行】 string postJson = @"{""Data"": {""FBillNo"":""" + k3BillNo + @"""}}"; var response = K3ApiXService.Delete(Token, "Sales_Invoice_VAT", postJson); // 如果Token过期则重新加载 if (response.StatusCode == 200) { if (_salesRebateService.SummaryDelete(SalesRebateSummarySelectedItem.Id, SalesRebateSummarySelectedItem.Guid)) { MessageBox.Show("删除K3单据成功"); } else { MessageBox.Show("后台删除失败,单据不存在"); } } else if (response.Message.IndexOf("token", StringComparison.OrdinalIgnoreCase) > 0) { Token = K3ApiXService.GetToken(); response = K3ApiXService.Delete(Token, "Sales_Invoice_VAT", postJson); MessageBox.Show(response.Message); } else { MessageBox.Show(response.Message); } CommonService.WriteActionLog(new ActionOperationLogModel { ActionName = "SalesRebateK3ApiRemoveCommand", ActionDesc = k3BillNo, UserId = User.ID, MainMenuId = Menu.ID, PKId = -1, HostName = HostName }); QueryBaseCommand.Execute(null); } else { MessageBox.Show("一次只能选择一个K3单据且已经生成过K3单据"); } } }); DetailSelectionChangedCommand = new DelegateCommand((obj) => { if (SalesRebateSelectedItem != null) { var lists = _salesRebateAmountRangeService.GetSalesRebateAmountRangeRecentParameterLists(SalesRebateSelectedItem.PGuid); if (lists.Count > 0) { StringBuilder result = new StringBuilder(); foreach (var item in lists) { result.Append($"金额区间:{item.AmountLower}-{item.AmountUpper} 万元 比例:{item.SalesRebatePctValue}% \t\t"); } RebatePctValueString = result.ToString(); } else { RebatePctValueString = string.Empty; } } }); SummarySelectionChangedCommand = new DelegateCommand((obj) => { if (SalesRebateSummarySelectedItem != null) { RebatePctValueString = string.Empty; SalesRebateLists.Clear(); _salesRebateService.GetSalesRebateListsByGuid(SalesRebateSummarySelectedItem.Guid).ForEach(x => SalesRebateLists.Add(x)); } }); SalesRebateSummaryDeleteCommand = new DelegateCommand((obj) => { if (SalesRebateSummarySelectedItem != null && string.IsNullOrEmpty(SalesRebateSummarySelectedItem.K3BillNo)) { _salesRebateService.SummaryDelete(SalesRebateSummarySelectedItem.Id, SalesRebateSummarySelectedItem.Guid); QueryBaseCommand.Execute(null); } }); ReportQueryCommand = new DelegateCommand((obj) => { ReportLists.Clear(); _salesRebateService.GetCaseAmountReport(ReportQueryParameter).ForEach(x => ReportLists.Add(x)); }); AmountCalculateCommand = new DelegateCommand((obj) => { if (BatchParameterVerification(out DateTime maxDate)) { // 计算刚才配置的参数 _salesRebateService.CalculateAmount(BatchParameter, User.ID, false); // 查询出刚生成的数据 QueryBaseCommand.Execute(null); } else { MessageBox.Show($"【{maxDate}】 该类型【{BatchParameter.RebateClassSeletedItem.ItemValue} 】已经返利,同时间点不能多次返利"); } }); }
private void InitCommand() { PrintConfigurationSaveBaseCommand = new DelegateCommand((obj) => { string msg = PrintHelper.VerifyPrintConfiguration(PrintConfiguration); if (string.IsNullOrEmpty(msg)) { int id = CommonService.SaveBarTenderPrintConfigXX(PrintConfiguration); if (id > 0) { PrintConfiguration.Id = id; MessageBox.Show("保存成功"); } else { MessageBox.Show("保存失败,请联系管理员"); } } else { MessageBox.Show(msg); } }); TemplateSelectBaseCommand = new DelegateCommand((obj) => { System.Windows.Forms.FolderBrowserDialog fbd = new System.Windows.Forms.FolderBrowserDialog(); if (fbd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { PirntTemplates = PrintHelper.GetTenderPrintA4Templates(fbd.SelectedPath); } }); DirectorySelectBaseCommand = new DelegateCommand((obj) => { // 导出目录选择 System.Windows.Forms.FolderBrowserDialog fbd = new System.Windows.Forms.FolderBrowserDialog(); if (fbd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { HostConfig.HostValue = fbd.SelectedPath; var result = CommonService.SaveHostConfig(HostConfig); if (result) { HostConfig = CommonService.GetHostConfig(DataGridId, HostName, User.ID); } } }); ExportBaseCommand = new DelegateCommand((obj) => { if (Directory.Exists(HostConfig.HostValue)) { ExportView view = new ExportView(DataGridId, 1); (view.DataContext as ExportViewModel).Export((type, outputEntity, checkBoxValue, orderedColumns) => { view.Close(); if (type == 1) { DataTable datatable = new DataTable(); if (outputEntity == 1) { datatable = _service.GetExportData1("DGPrintA4", User.ID, CommonService.GetSqlWhereString(QueryParameter)); ExportHelper.ExportDataTableToExcel(datatable, HostConfig.HostValue, HostConfig.TypeDesciption + CommonService.GetQueryParameterValueString(QueryParameter)); MessageBox.Show("导出成功"); } //else if (outputEntity == 2) //{ // datatable = _shippingService.GetShippingBillExprotDataTable2(UserDataId); // new Helper.DataTableImportExportHelper().ExportDataTableToExcel(datatable, HostConfig.HostValue, HostConfig.TypeDesciption); // MessageBox.Show("导出成功"); //} //else if (outputEntity == 3) //{ // datatable = _shippingService.GetShippingBillExprotDataTable3(UserDataId, string.Join(",", orderedColumns)); // new Helper.DataTableImportExportHelper().ExportDataTableToExcel(datatable, HostConfig.HostValue, HostConfig.TypeDesciption, checkBoxValue, 1, orderedColumns); // MessageBox.Show("导出成功"); //} } }); view.ShowDialog(); } else { MessageBox.Show("目录不存在,请先选择导出的目录"); DirectorySelectBaseCommand.Execute(null); } CommonService.WriteActionLog(new ActionOperationLogModel { ActionName = "ExportBaseCommand", ActionDesc = HostConfig.TypeDesciption + HostConfig.TypeId.ToString(), UserId = User.ID, MainMenuId = Menu.ID, PKId = -1, HostName = HostName }); }); DataGridSaveCommand = new DelegateCommand((obj) => { DataGridManagementService.SaveColumnConfigurationInUserInterface(obj as DataGrid, User.ID); MessageBox.Show("参数保存成功"); }); PrintBaseCommand = new DelegateCommand((obj) => { string msg = PrintHelper.VerifyPrintConfiguration(PrintConfiguration); if (string.IsNullOrEmpty(msg)) { var selectedLists = ((obj as DataGrid).SelectedItems).Cast <LabelPrintHistoryModel>().ToList(); if (selectedLists.Count > 0) { string result = _print.BarTenderPrintA4(selectedLists, PrintConfiguration, selectedLists.Sum(x => x.PrintCount)); MessageBox.Show(result); QueryCommand.Execute(null); } else { MessageBox.Show("先选择行数据,【CTRL】或【SHFIT】 多选行"); } } else { MessageBox.Show(msg); } }); QueryCommand = new DelegateCommand((obj) => { PrintHistoryLists.Clear(); _service.GetHistoryLists(CommonService.GetSqlWhereString(QueryParameter)).ForEach(x => PrintHistoryLists.Add(x)); }); DataGridManageCommand = new DelegateCommand((obj) => { var grid = obj as DataGrid; UserDataGridFormatConfigurationView view = new UserDataGridFormatConfigurationView("DGPrintA4"); (view.DataContext as UserDataGridFormatConfigurationViewModel).WithParam(null, (type, outputEntity) => { view.Close(); if (type == 1) { // 重新加载DataGrid格式 grid.Columns.Clear(); CommonService.GetUserDataGridColumn(User.ID, grid, 0); } }); view.ShowDialog(); }); }