Ejemplo n.º 1
0
        private void OBackgroundWorker_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            this.Dispatcher.Invoke(() =>
            {
                EnterEmailPasswordWindow oEnterEmailPasswordWindow = e.Argument as EnterEmailPasswordWindow;

                var varList = (InstallmentPerLoanGridControl.ItemsSource as System.Collections.Generic.List <ViewModels.InstallmentViewModel>)
                              .Select(current => new
                {
                    current.AmountRialFormat,
                    current.PersianInstallmentDate,
                    current.PersianPaymentDate,
                    current.IsPayedDescription,
                })
                              .ToList();

                Stimulsoft.Report.StiReport oStiReport = new Stimulsoft.Report.StiReport();

                oStiReport.Load(Properties.Resources.InstallmentListReport);

                oStiReport.Dictionary.Variables.Add("Today", System.DateTime.Now.ToPersianDate());
                oStiReport.Dictionary.Variables.Add("FundName", Utility.CurrentFund.Name);
                oStiReport.Dictionary.Variables.Add("FundManagerName", Utility.CurrentFund.ManagerName);
                oStiReport.Dictionary.Variables.Add("MemberName", Utility.CurrentLoan.Member.FullName.ToString());
                oStiReport.Dictionary.Variables.Add("LoanAmount", (new ViewModels.LoanViewModel {
                    LoanAmount = Utility.CurrentLoan.LoanAmount
                }).LoanAmountRialFormat);
                oStiReport.Dictionary.Variables.Add("RefundAmount", (new ViewModels.LoanViewModel {
                    RefundAmount = Utility.CurrentLoan.RefundAmount
                }).RefundAmountRialFormat);

                oStiReport.RegBusinessObject("InstallmentsList", varList);
                oStiReport.Compile();
                oStiReport.RenderWithWpf();

                System.IO.MemoryStream oMemoryStream = new System.IO.MemoryStream();

                oStiReport.ExportDocument(Stimulsoft.Report.StiExportFormat.Pdf, oMemoryStream);
                oMemoryStream.Seek(0, System.IO.SeekOrigin.Begin);

                Utility.SendEmail
                (
                    senderEmail: Utility.CurrentUser.EmailAddress,
                    senderPassword: oEnterEmailPasswordWindow.EmailPassword,
                    displayName: Utility.CurrentUser.FullName.ToString(),
                    receiverEmail: Utility.CurrentMember.EmailAddress,
                    subject: Utility.CurrentFund.Name + " | " + "لیست اقساط " + Utility.CurrentMember.FullName.ToString(),
                    body: "لیست اقساط " + Utility.CurrentMember.FullName.ToString() +
                    System.Environment.NewLine +
                    new FarsiLibrary.Utils.PersianDate(System.DateTime.Now).ToString(),
                    attachment: oMemoryStream,
                    attachmentName: "لیست اقساط " + Utility.CurrentMember.FullName.ToString()
                );
            });
        }
        private void OBackgroundWorker_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            this.Dispatcher.Invoke(() =>
            {
                EnterEmailPasswordWindow oEnterEmailPasswordWindow = e.Argument as EnterEmailPasswordWindow;

                var varObject = new
                {
                    LoansCount              = LoansCountLabel.Content,
                    LoansAmount             = LoansAmountLabel.Content,
                    PayedLoansCount         = PayedLoansCountLabel.Content,
                    PayedLoansAmount        = PayedLoansAmountLabel.Content,
                    InstallmentsCount       = InstallmentsCountLabel.Content,
                    InstallmentsAmount      = InstallmentsAmountLabel.Content,
                    PayedInstallmentsCount  = PayedInstallmentsCountLabel.Content,
                    PayedInstallmentsAmount = PayedInstallmentsAmountLabel.Content,
                };

                Stimulsoft.Report.StiReport oStiReport = new Stimulsoft.Report.StiReport();

                oStiReport.Load(Properties.Resources.FundBalanceReport);

                oStiReport.Dictionary.Variables.Add("Today", System.DateTime.Now.ToPersianDate());
                oStiReport.Dictionary.Variables.Add("FundName", Utility.CurrentFund.Name);
                oStiReport.Dictionary.Variables.Add("FundManagerName", Utility.CurrentFund.ManagerName);
                oStiReport.Dictionary.Variables.Add("FundBalance", Utility.CurrentFund.Balance.ToRialStringFormat());

                oStiReport.RegBusinessObject("MemberBalance", varObject);
                oStiReport.Compile();
                oStiReport.RenderWithWpf();

                System.IO.MemoryStream oMemoryStream = new System.IO.MemoryStream();

                oStiReport.ExportDocument(Stimulsoft.Report.StiExportFormat.Pdf, oMemoryStream);
                oMemoryStream.Seek(0, System.IO.SeekOrigin.Begin);

                Utility.SendEmail
                (
                    senderEmail: Utility.CurrentUser.EmailAddress,
                    senderPassword: oEnterEmailPasswordWindow.EmailPassword,
                    displayName: Utility.CurrentUser.FullName.ToString(),
                    receiverEmail: Utility.CurrentMember.EmailAddress,
                    subject: Utility.CurrentFund.Name + " | " + "تراز مالی عضو  " + Utility.CurrentMember.FullName.ToString(),
                    body: "تراز مالی " + Utility.CurrentMember.FullName.ToString() +
                    System.Environment.NewLine +
                    new FarsiLibrary.Utils.PersianDate(System.DateTime.Now).ToString(),
                    attachment: oMemoryStream,
                    attachmentName: "تراز مالی " + Utility.CurrentMember.FullName.ToString()
                );
            });
        }
        private void SendEmailButton_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            bool internetConnected = Utility.CheckForInternetConnection();

            if (internetConnected == true)
            {
                EnterEmailPasswordWindow oEnterEmailPasswordWindow = new EnterEmailPasswordWindow();

                if (oEnterEmailPasswordWindow.ShowDialog() == true)
                {
                    Utility.MainWindow.MainProgressBar.IsIndeterminate = true;
                    Utility.MainWindow.MainProgressBar.Visibility      = System.Windows.Visibility.Visible;

                    System.ComponentModel.BackgroundWorker oBackgroundWorker = new System.ComponentModel.BackgroundWorker();

                    oBackgroundWorker.DoWork += OBackgroundWorker_DoWork;
                    oBackgroundWorker.RunWorkerAsync(oEnterEmailPasswordWindow);
                }
                else
                {
                    Utility.MainWindow.MainProgressBar.IsIndeterminate = false;
                    Utility.MainWindow.MainProgressBar.Visibility      = System.Windows.Visibility.Hidden;

                    return;
                }
            }
            else
            {
                Utility.MainWindow.MainProgressBar.IsIndeterminate = false;
                Utility.MainWindow.MainProgressBar.Visibility      = System.Windows.Visibility.Hidden;

                Infrastructure.MessageBox.Show
                (
                    caption: Infrastructure.MessageBox.Caption.Error,
                    text: "اتصال به اینترنت برقرار نمی‌باشد. از اتصال دستگاه خود با اینترنت اطمینان حاصل فرمایید."
                );

                return;
            }
        }
Ejemplo n.º 4
0
        private void OBackgroundWorker_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            this.Dispatcher.Invoke(() =>
            {
                EnterEmailPasswordWindow oEnterEmailPasswordWindow = e.Argument as EnterEmailPasswordWindow;

                var varList = (MembersLoanGridControl.ItemsSource as System.Collections.Generic.List <ViewModels.LoanViewModel>)
                              .OrderBy(current => current.StartDate)
                              .Select(current => new
                {
                    current.LoanAmountRialFormat,
                    current.RefundAmountRialFormat,
                    current.PersianEndDate,
                    current.PersianStartDate,
                    current.InstallmentsCount,
                    current.IsPayedDescrption,
                    current.Description,
                })
                              .ToList();

                if (varList.Count == 0)
                {
                    Infrastructure.MessageBox.Show
                    (
                        caption: Infrastructure.MessageBox.Caption.Error,
                        text: "اطلاعاتی برای ارسال توسط پست الکترونیکی موجود نمی‌باشد. "
                    );

                    return;
                }

                Stimulsoft.Report.StiReport oStiReport = new Stimulsoft.Report.StiReport();

                oStiReport.Load(Properties.Resources.MembersLoansListReport);

                oStiReport.Dictionary.Variables.Add("Today", System.DateTime.Now.ToPersianDate());
                oStiReport.Dictionary.Variables.Add("FundName", Utility.CurrentFund.Name);
                oStiReport.Dictionary.Variables.Add("FundManagerName", Utility.CurrentFund.ManagerName);
                oStiReport.Dictionary.Variables.Add("MemberName", Utility.CurrentMember.FullName.ToString());
                oStiReport.Dictionary.Variables.Add("LoanStatus", LoanStatusComboBox.Text);
                oStiReport.RegBusinessObject("Loans", varList);
                oStiReport.Compile();
                oStiReport.RenderWithWpf();

                string fileName = string.Format("گزارش {0} {1}", LoanStatusComboBox.Text, Utility.CurrentMember.FullName.ToString());

                System.IO.MemoryStream oMemoryStream = new System.IO.MemoryStream();

                oStiReport.ExportDocument(Stimulsoft.Report.StiExportFormat.Pdf, oMemoryStream);
                oMemoryStream.Seek(0, System.IO.SeekOrigin.Begin);

                Utility.SendEmail
                (
                    senderEmail: Utility.CurrentUser.EmailAddress,
                    senderPassword: oEnterEmailPasswordWindow.EmailPassword,
                    displayName: Utility.CurrentUser.FullName.ToString(),
                    receiverEmail: Utility.CurrentMember.EmailAddress,
                    subject: Utility.CurrentFund.Name + " | " + LoanStatusComboBox.Text + " " + Utility.CurrentMember.FullName.ToString(),
                    body: LoanStatusComboBox.Text + Utility.CurrentMember.FullName.ToString() +
                    System.Environment.NewLine +
                    new FarsiLibrary.Utils.PersianDate(System.DateTime.Now).ToString(),
                    attachment: oMemoryStream,
                    attachmentName: fileName
                );
            });
        }
Ejemplo n.º 5
0
        private void OEmailBackgroundWorker_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            this.Dispatcher.Invoke(() =>
            {
                DAL.UnitOfWork oUnitOfWork = new DAL.UnitOfWork();

                if (SendEmailToggleSwitch.IsChecked == true && IsConnectedToInternet == true)
                {

                    EnterEmailPasswordWindow oEnterEmailPasswordWindow = new EnterEmailPasswordWindow();

                    if (oEnterEmailPasswordWindow.ShowDialog() == true)
                    {
                        var varList = oUnitOfWork.InstallmentRepository
                        .Get()
                        .Where(current => current.LoanId == Utility.CurrentLoan.Id)
                        .Select(current => new ViewModels.InstallmentViewModel()
                        {
                            Id = current.Id,
                            Amount = current.PaymentAmount,
                            InstallmentDate = current.InstallmentDate,
                            PaymentDate = current.PaymentDate,
                            IsActive = !(current.IsPayed),
                            IsPayed = current.IsPayed,
                        })
                        .OrderBy(current => current.InstallmentDate)
                        .ToList()
                        .Select(current => new
                        {
                            current.AmountRialFormat,
                            current.PersianInstallmentDate,
                            current.PersianPaymentDate,
                            current.IsPayedDescription,
                        })
                        .ToList();

                        Stimulsoft.Report.StiReport oStiReport = new Stimulsoft.Report.StiReport();

                        oStiReport.Load(Properties.Resources.InstallmentListReport);

                        oStiReport.Dictionary.Variables.Add("Today", System.DateTime.Now.ToPersianDate());
                        oStiReport.Dictionary.Variables.Add("FundName", Utility.CurrentFund.Name);
                        oStiReport.Dictionary.Variables.Add("FundManagerName", Utility.CurrentFund.ManagerName);
                        oStiReport.Dictionary.Variables.Add("MemberName", Utility.CurrentMember.FullName.ToString());
                        oStiReport.Dictionary.Variables.Add("LoanAmount", (new ViewModels.LoanViewModel { LoanAmount = Utility.CurrentLoan.LoanAmount }).LoanAmountRialFormat);
                        oStiReport.Dictionary.Variables.Add("RefundAmount", (new ViewModels.LoanViewModel { RefundAmount = Utility.CurrentLoan.RefundAmount }).RefundAmountRialFormat);

                        oStiReport.RegBusinessObject("InstallmentsList", varList);
                        oStiReport.Compile();
                        oStiReport.RenderWithWpf();

                        System.IO.MemoryStream oMemoryStream = new System.IO.MemoryStream();

                        oStiReport.ExportDocument(Stimulsoft.Report.StiExportFormat.Pdf, oMemoryStream);
                        oMemoryStream.Seek(0, System.IO.SeekOrigin.Begin);

                        Utility.SendEmail
                        (
                            senderEmail: Utility.CurrentUser.EmailAddress,
                            senderPassword: oEnterEmailPasswordWindow.EmailPassword,
                            displayName: Utility.CurrentUser.FullName.ToString(),
                            receiverEmail: Utility.CurrentMember.EmailAddress,
                            subject: Utility.CurrentFund.Name + " | " + "پرداخت وام" + Utility.CurrentMember.FullName.ToString(),
                            body: "لیست اقساط وام پرداخت شده توسط صندوق به " + Utility.CurrentMember.FullName.ToString() +
                            System.Environment.NewLine +
                            new FarsiLibrary.Utils.PersianDate(System.DateTime.Now).ToString(),
                            attachment: oMemoryStream,
                            attachmentName: "لیست اقساط وام پرداخت شده"
                        );
                    }
                    else
                    {
                        Utility.MainWindow.MainProgressBar.IsIndeterminate = false;
                        Utility.MainWindow.MainProgressBar.Visibility = System.Windows.Visibility.Hidden;
                    }
                }
                else
                {
                    Utility.MainWindow.MainProgressBar.IsIndeterminate = false;
                    Utility.MainWindow.MainProgressBar.Visibility = System.Windows.Visibility.Hidden;
                }
            });
        }