Esempio n. 1
0
        /// <summary>
        /// Prints the preview report by report.
        /// </summary>
        /// <param name="frmParent">The FRM parent.</param>
        /// <param name="param">The e parameter.</param>
        /// <param name="isPrint">if set to <c>true</c> [is print].</param>
        public void PrintPreviewReportByReport(XtraForm frmParent, DrilldownReportParam param, bool isPrint)
        {
            try
            {
                Cursor.Current   = Cursors.WaitCursor;
                _reportListModel = ReportLists.Find(item => item.ReportID == param.ArgParameter[0].ToString());
                if (_reportListModel == null)
                {
                    return;
                }
                _frmParentForm = frmParent;

                var reportListSource = GetDrillDownDataSource(frmParent, _reportListModel, param.ArgParameter);
                if (reportListSource == null || reportListSource.Count <= 0)
                {
                    return;
                }
                if (reportListSource.Count > 0)
                {
                    if (!string.IsNullOrEmpty(_reportListModel.TableName))
                    {
                        DataMember = _reportListModel.TableName.Trim();
                    }
                    DisplayReport(ref reportListSource, _reportListModel, false, frmParent, false, isPrint, DateTime.MinValue);
                }
                else
                {
                    XtraMessageBox.Show("Không có bản ghi nào", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.ToString(), "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Prints the preview report.
        /// </summary>
        /// <param name="frmParent">The FRM parent.</param>
        /// <param name="reportId">The s report identifier.</param>
        /// <param name="isPint">if set to <c>true</c> [is pint].</param>
        public void PrintPreviewReport(XtraForm frmParent, string reportId, bool isPint)
        {
            try
            {
                Cursor.Current = Cursors.WaitCursor;

                _reportListModel = ReportLists.Find(item => item.ReportID == reportId);
                if (_reportListModel == null)
                {
                    return;
                }
                _frmParentForm = frmParent;
                var reportListSource = GetDataSource(frmParent, _reportListModel);
                if (reportListSource == null)
                {
                    return;
                }
                if (reportListSource.Count <= 0)
                {
                    XtraMessageBox.Show("Dữ liệu lấy lên báo cáo Không có bản ghi nào.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                if (!string.IsNullOrEmpty(_reportListModel.TableName))
                {
                    DataMember = _reportListModel.TableName.Trim();
                }
                DisplayReport(ref reportListSource, _reportListModel, false, frmParent, false, isPint, DateTime.MinValue);
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.ToString(), "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Esempio n. 3
0
 public void ExtractXMLKhoBac(string reportId)
 {
     _reportListModel = ReportLists.Find(item => item.ReportId == reportId);
     if (!string.IsNullOrEmpty(_reportListModel.InputTypeName))
     {
         var type   = Assembly.GetExecutingAssembly().GetType(GetType().Namespace + "." + "ExportXML");
         var target = (BaseReport)Activator.CreateInstance(type);
         if (!string.IsNullOrEmpty(_reportListModel.ProcedureName))
         {
             var args       = new object[] { ReportParameter, _rsTool, null, false };
             var dataSource = (IList)(type.InvokeMember(_reportListModel.FunctionReportName + "XML", BindingFlags.InvokeMethod, null, target, args));
         }
     }
 }
Esempio n. 4
0
        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} 】已经返利,同时间点不能多次返利");
                }
            });
        }