public void send(int a) { if (Ref == null) { bookingNo = txtBookingNo.Text.ToString(); } string viaStr = "**"; Gen_SubCompany objSubCompany = AppVars.objSubCompany; string connString = Application.StartupPath + @"\Reports\Report.exe"; // string connString =@"D:\Zeeshan\Cloud Despatch\Taxi_AppMain\bin\x86\Debug\Reports\Report.exe"; //D:\Zeeshan\Cloud Despatch\Taxi_AppMain\bin\x86\Debug // string connString = @"C:\Users\Muhammad Zeeshan\Documents\Visual Studio 2010\Projects\Report\Report\bin\Debug\Report.exe"; //C:\Users\Muhammad Zeeshan\Documents\Visual Studio 2010\Projects\Report\Report\bin\Debug //System.Diagnostics.Process proc = System.Diagnostics.Process.GetProcesses().FirstOrDefault(c => c.ProcessName.Contains("Report")); //if (proc != null) //{ // proc.Kill(); // proc.CloseMainWindow(); // proc.Close(); //} DateTime?fromDate = dtpFromDate.Value.ToDateorNull(); DateTime?toDate = dtpTillDate.Value.ToDateorNull(); string conn = System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"].ToStr(); Classes.JArguments j = new Classes.JArguments() {//Connectionstring = ConnectionString = conn, bookingid = bookingNo.ToString(), fromDate = fromDate.Value, toDate = toDate.Value, _Checkbox = chkRefNo.Checked , reportname = "rptfrmJobDetails" }; // Convert BlogSites object to JOSN string format string jsonData = JsonConvert.SerializeObject(j); jsonData = Cryptography.Encrypt(jsonData, "report", true); System.Diagnostics.Process.Start(connString, jsonData); }
public frmEmail(ReportViewer viewer, string attachmentTitle, string ComapnyEmail, Gen_SubCompany objEmailDetails) { InitializeComponent(); this.ReportViewer1 = viewer; objEmailDetails.IsTpCompany = (ReportViewer1.Tag.ToStr() == "invoice" && objEmailDetails != null && objEmailDetails.UseDifferentEmailForInvoices.ToBool())? true : false; attachmentTitle = attachmentTitle.Replace("/", "").Trim(); this.FileTitle = attachmentTitle; txtAttachment.Text = FileTitle; txtFrom.Text = (viewer.Tag.ToStr() == "invoice" && objEmailDetails != null && objEmailDetails.SmtpInvoiceUserName.ToStr().Trim().Length > 0)? objEmailDetails.SmtpInvoiceUserName.ToStr().Trim() : objEmailDetails.EmailAddress.ToStr().Trim(); txtTo.Text = ComapnyEmail; RadMenuItem item = null; item = new RadMenuItem(); item.Text = "Customer"; item.Click += new EventHandler(item_Click); btnPickEmail.Items.Add(item); item = new RadMenuItem(); item.Text = "Driver"; item.Click += new EventHandler(item_Click); btnPickEmail.Items.Add(item); item = new RadMenuItem(); item.Text = "Company"; item.Click += new EventHandler(item_Click); btnPickEmail.Items.Add(item); objSubcompany = objEmailDetails; LoadDefaultSettings(); txtSubject.Focus(); txtSubject.Select(); this.FormClosed += new FormClosedEventHandler(frmEmail_FormClosed); }
public void SendEmail(string invoiceNo, string email) { reportViewer1.Tag = "invoice"; if (AppVars.objSubCompany.UseDifferentEmailForInvoices.ToBool()) { Gen_SubCompany objNewSubCompany = new Gen_SubCompany(); objNewSubCompany = General.CopyPropertiesTo <Gen_SubCompany, Gen_SubCompany>(AppVars.objSubCompany, objNewSubCompany); General.ShowEmailForm(reportViewer1, "Driver Commission Transaction # " + invoiceNo, email, objNewSubCompany); } else { General.ShowEmailForm(reportViewer1, "Driver Commission Transaction # " + invoiceNo, email); } }
public void GenerateReport() { try { reportViewer1.LocalReport.EnableExternalImages = true; Microsoft.Reporting.WinForms.ReportParameter[] param = new Microsoft.Reporting.WinForms.ReportParameter[18]; Gen_SubCompany objSubCompany = AppVars.objSubCompany; if (this.DataSource.Count > 0) { try { if (DataSource[0].SubCompanyId != AppVars.objSubCompany.Id) { objSubCompany = General.GetObject <Gen_SubCompany>(c => c.Id == DataSource[0].SubCompanyId); if (objSubCompany == null) { objSubCompany = AppVars.objSubCompany; } } } catch { if (objSubCompany == null) { objSubCompany = AppVars.objSubCompany; } } } string address = objSubCompany.Address; string telNo = string.Empty; string sortCode = objSubCompany.SortCode.ToStr(); string accountNo = objSubCompany.AccountNo.ToStr(); string accountTitle = objSubCompany.AccountTitle.ToStr(); string bank = objSubCompany.BankName.ToStr(); string hasBankDetails = "1"; if (string.IsNullOrEmpty(sortCode) && string.IsNullOrEmpty(accountNo) && string.IsNullOrEmpty(accountTitle) && string.IsNullOrEmpty(bank)) { hasBankDetails = "0"; } if (!string.IsNullOrEmpty(sortCode)) { sortCode = "Sort Code : " + sortCode; } if (!string.IsNullOrEmpty(accountTitle)) { accountTitle = "Account Title : " + accountTitle; } // if (!string.IsNullOrEmpty(bank)) // bank = "Bank : " + bank; string website = objSubCompany.WebsiteUrl.ToStr(); if (!string.IsNullOrEmpty(website)) { website += " , "; } website += "Email:" + objSubCompany.EmailAddress.ToStr(); string companyNumber = objSubCompany.CompanyNumber.ToStr(); if (!string.IsNullOrEmpty(companyNumber)) { companyNumber = "Company Number: " + companyNumber; } string vatNumber = objSubCompany.CompanyVatNumber.ToStr(); if (!string.IsNullOrEmpty(vatNumber)) { vatNumber = "VAT Number: " + vatNumber; } param[0] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Address", address); param[1] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Footer", objSubCompany.WebsiteUrl.ToStr()); param[2] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_MobileNo", "Mobile: " + objSubCompany.EmergencyNo.ToStr()); param[3] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Website", website); param[4] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Email", "Email: " + objSubCompany.EmailAddress.ToStr()); param[5] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_CompanyNumber", companyNumber); param[6] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_VATNumber", vatNumber); param[7] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_SortCode", sortCode); param[8] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_AccountTitle", accountTitle); param[9] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Bank", bank); List <ClsLogo> objLogo = new List <ClsLogo>(); objLogo.Add(new ClsLogo { ImageInBytes = objSubCompany.CompanyLogo != null ? objSubCompany.CompanyLogo.ToArray() : null }); ReportDataSource imageDataSource = new ReportDataSource("Taxi_AppMain_Classes_ClsLogo", objLogo); this.reportViewer1.LocalReport.DataSources.Add(imageDataSource); string path = @"File:"; param[10] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Path", path); param[11] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_CompanyHeader", objSubCompany.CompanyName.ToStr()); //int? companyId = this.DataSource.FirstOrDefault().DefaultIfEmpty().CompanyId; //decimal invoiceGrandTotal = this.DataSource.FirstOrDefault().DefaultIfEmpty().InvoiceTotal.ToDecimal() + this.DataSource.FirstOrDefault().DefaultIfEmpty().AdminFees.ToDecimal(); //var data = this.DataSource.FirstOrDefault().DefaultIfEmpty(); telNo = "Tel No. " + objSubCompany.TelephoneNo; if (!string.IsNullOrEmpty(accountNo)) { accountNo = "Account No : " + accountNo; } param[12] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Telephone", telNo); param[13] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_AccountNo", accountNo); param[14] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_HasBankDetails", hasBankDetails); int driverId = this.DataSource.FirstOrDefault().DefaultIfEmpty().DriverId.ToInt(); string phcdriver = " "; string phcVehicle = " "; string vehicleDetails = " "; if (driverId > 0) { using (TaxiDataContext db = new TaxiDataContext()) { db.DeferredLoadingEnabled = false; var list = db.Fleet_Driver_Documents.Where(c => c.DriverId == driverId && (c.DocumentId == Enums.DRIVER_DOCUMENTS.PCODriver || c.DocumentId == Enums.DRIVER_DOCUMENTS.PCOVehicle)) .Select(c => new { c.BadgeNumber, c.DocumentId }).ToList(); foreach (var item in list) { if (item.DocumentId.ToInt() == Enums.DRIVER_DOCUMENTS.PCODriver) { phcdriver = item.BadgeNumber.ToStr(); if (phcdriver.ToStr().Trim().Length == 0) { phcdriver = " "; } } if (item.DocumentId.ToInt() == Enums.DRIVER_DOCUMENTS.PCOVehicle) { phcVehicle = item.BadgeNumber.ToStr(); if (phcVehicle.ToStr().Trim().Length == 0) { phcVehicle = " "; } } } var vehicleDAta = db.Fleet_Drivers.Where(c => c.Id == driverId).Select(args => new { args.VehicleMake, args.VehicleModel, args.VehicleNo }).FirstOrDefault(); if (vehicleDAta != null) { vehicleDetails = "Vehicle Details : " + vehicleDAta.VehicleMake.ToStr() + " - " + vehicleDAta.VehicleModel.ToStr() + " - " + vehicleDAta.VehicleNo.ToStr(); } } } if (phcdriver.ToStr().Trim().Length > 0) { phcdriver = "PHC Driver : " + phcdriver; } if (phcVehicle.ToStr().Trim().Length > 0) { phcVehicle = "PHC Vehicle : " + phcVehicle; } param[15] = new Microsoft.Reporting.WinForms.ReportParameter("ReportParameter_PHCDriver", phcdriver); param[16] = new Microsoft.Reporting.WinForms.ReportParameter("ReportParameter_PHCVehicle", phcVehicle); param[17] = new Microsoft.Reporting.WinForms.ReportParameter("ReportParameter_VehicleDetails", vehicleDetails); reportViewer1.LocalReport.SetParameters(param); int cnt = this.DataSource.Count; int minRows = 8; if (cnt < minRows) { for (int i = 0; i < minRows - cnt; i++) { // this.DataSource.Add(new Vu_BookingLog { Id = data.Id, CompanyId = data.CompanyId }); } } this.vw_BookingUpdateBindingSource.DataSource = this.DataSource1; this.Vu_BookingLogBindingSource.DataSource = this.DataSource; // this.Vu_BookingBaseBindingSource.DataSource = this.DataSource1; // this.reportViewer1.ZoomPercent = 100; this.reportViewer1.SetDisplayMode(DisplayMode.Normal); // this.reportViewer1.ZoomMode = Microsoft.Reporting.WinForms.ZoomMode.Percent; } catch (Exception ex) { ENUtils.ShowMessage(ex.Message); } }
public bool EmailReport(string reportType, string fromEmail, string toEmail, string subject, string messageBody) { bool rtn = true; try { Warning[] warnings; string[] streamids; string mimeType; string encoding; string extension; byte[] bytes = ReportViewer1.LocalReport.Render( reportType, null, out mimeType, out encoding, out extension, out streamids, out warnings); string path = General.GetSharedNetworkPath().ToStr().Trim(); if (path == string.Empty || Directory.Exists(path) == false) { path = Application.StartupPath; } if (reportType.ToStr().ToLower() == "excel") { reportType = "xls"; } if (objSubcompany == null) { objSubcompany = AppVars.objSubCompany; } if (objSubcompany != null) { objSubcompany.IsTpCompany = ReportViewer1.Tag.ToStr() == "invoice" && objSubcompany != null && objSubcompany.UseDifferentEmailForInvoices.ToBool() ? true : false; } path += "\\" + FileTitle + "." + reportType; FileInfo file = new FileInfo(path); using (FileStream fs = file.Create()) { fs.Write(bytes, 0, bytes.Length); fs.Flush(); fs.Close(); fs.Dispose(); List <Attachment> myAttach = new List <Attachment>(); myAttach.Add(new System.Net.Mail.Attachment(file.FullName)); Taxi_AppMain.Email.Send(subject, messageBody, fromEmail, toEmail, myAttach, objSubcompany); myAttach[0].Dispose(); File.Delete(path); } if (this.IsInternalEmail == false) { try { this.Close(); } catch { EmailSent = true; } } } catch (Exception ex) { rtn = false; if (this.IsInternalEmail == false) { ENUtils.ShowMessage(ex.Message); } } return(rtn); }
public void GenerateReport() { try { if (ddlCompany.SelectedValue == null) { pnlCriteria.Visible = false; } reportViewer1.LocalReport.EnableExternalImages = true; if (ObjSubCompany == null) { ObjSubCompany = AppVars.objSubCompany; } Microsoft.Reporting.WinForms.ReportParameter[] param = new Microsoft.Reporting.WinForms.ReportParameter[27]; string address = ObjSubCompany.Address; string telNo = string.Empty; string sortCode = ObjSubCompany.SortCode.ToStr(); string accountNo = ObjSubCompany.AccountNo.ToStr(); string accountTitle = ObjSubCompany.AccountTitle.ToStr(); string bank = ObjSubCompany.BankName.ToStr(); string hasBankDetails = "1"; if (string.IsNullOrEmpty(sortCode) && string.IsNullOrEmpty(accountNo) && string.IsNullOrEmpty(accountTitle) && string.IsNullOrEmpty(bank)) { hasBankDetails = "0"; } if (!string.IsNullOrEmpty(sortCode)) { sortCode = "Sort Code : " + sortCode; } if (!string.IsNullOrEmpty(accountTitle)) { accountTitle = "Account Title : " + accountTitle; } string website = ObjSubCompany.WebsiteUrl.ToStr(); if (!string.IsNullOrEmpty(website)) { website += " , "; } website += "Email:" + ObjSubCompany.EmailAddress.ToStr(); string companyNumber = ObjSubCompany.CompanyNumber.ToStr(); if (!string.IsNullOrEmpty(companyNumber)) { companyNumber = "Company Number: " + companyNumber; } string vatNumber = ObjSubCompany.CompanyVatNumber.ToStr(); param[0] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Address", address); param[18] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Footer", ObjSubCompany.WebsiteUrl.ToStr()); param[14] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_MobileNo", "Mobile: " + ObjSubCompany.EmergencyNo.ToStr()); param[15] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Website", website); param[16] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Email", "Email: " + ObjSubCompany.EmailAddress.ToStr()); param[20] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_CompanyNumber", companyNumber); param[21] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_VATNumber", vatNumber); param[7] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_SortCode", sortCode); param[9] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_AccountTitle", accountTitle); param[10] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Bank", bank); List <ClsLogo> objLogo = new List <ClsLogo>(); objLogo.Add(new ClsLogo { ImageInBytes = ObjSubCompany.CompanyLogo != null ? ObjSubCompany.CompanyLogo.ToArray() : null }); ReportDataSource imageDataSource = new ReportDataSource("Taxi_AppMain_Classes_ClsLogo", objLogo); this.reportViewer1.LocalReport.DataSources.Add(imageDataSource); string path = @"File:"; param[2] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Path", path); param[6] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_CompanyHeader", ObjSubCompany.CompanyName.ToStr()); param[22] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_CompanyHeading", ObjSubCompany.CompanyName.ToStr()); int?driverId = this.DataSource.FirstOrDefault().DefaultIfEmpty().DriverId; var data = this.DataSource.FirstOrDefault().DefaultIfEmpty(); telNo = "Tel No. " + ObjSubCompany.TelephoneNo; if (!string.IsNullOrEmpty(accountNo)) { accountNo = "Account No : " + accountNo; } param[1] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Telephone", telNo); param[8] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_AccountNo", accountNo); string vat = "0"; decimal discountAmount = 0.00m; decimal valueAddedTax = 0.0m; string discount = string.Format("{0:c}", discountAmount); discount = discount.Substring(1); string grandTotal = ""; param[17] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Discount", discount); param[3] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_InvoiceTotal", grandTotal); param[4] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_HasVat", vat); param[5] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_VAT", valueAddedTax.ToStr()); param[11] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_HasDepartment", "0"); param[12] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Net", "0"); param[13] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_HasCostCenter", "0"); param[19] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_HasBankDetails", hasBankDetails); int cnt = this.DataSource.Count; string BalanceType = string.Empty; int DriverId = 0; if (this.DataSource.Count > 0) { DriverId = this.DataSource.FirstOrDefault().DriverId.ToInt(); int Id = this.DataSource.FirstOrDefault().Id.ToInt();; var query = General.GetObject <DriverRent>(c => c.DriverId == DriverId && c.Id < Id); string StatementDate = string.Empty; if (query == null) { BalanceType = "Initial Balance"; StatementDate = string.Format("{0:dd/MM}", this.DataSource.FirstOrDefault().TransDate); } else { BalanceType = "Balance from statement " + query.TransNo; StatementDate = string.Format("{0:dd/MM}", query.TransDate); } param[23] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_jobCount", cnt.ToStr()); param[24] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_BalanceType", BalanceType); param[25] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_StatementDate", StatementDate); string balance = string.Empty; decimal bal = this.DataSource.FirstOrDefault().DefaultIfEmpty().Balance.ToDecimal(); //if(bal>=0) //{ balance = "Balance Due £" + string.Format("{0:f2}", bal); //} //else //{ // balance = "You are due to receive £" + string.Format("{0:f2}", bal); // balance = balance.Replace("-", "").Trim(); //} param[26] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Balance", balance); } else { param[23] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_jobCount", cnt.ToStr()); param[24] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_BalanceType", BalanceType); // param[28] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_AccountExpenses", AccountExpenses.ToStr()); param[25] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_StatementDate", ""); param[26] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Balance", ""); } reportViewer1.LocalReport.SetParameters(param); this.vu_DriverRentExpenseBindingSource.DataSource = this.DataSource; this.vu_FleetDriverRentExpenseBindingSource.DataSource = this.DataSource2; this.reportViewer1.ZoomPercent = 100; this.reportViewer1.ZoomMode = Microsoft.Reporting.WinForms.ZoomMode.Percent; this.reportViewer1.RefreshReport(); } catch (Exception ex) { ENUtils.ShowMessage(ex.Message); } }
public static void Send(string subject, string Emailmessage, string FromEmail, string ToEmail, List <Attachment> attachments, Gen_SubCompany objSubCompany) { Attachments = attachments; Send(subject, Emailmessage, FromEmail, ToEmail, objSubCompany); }
public static void Send(string subject, string Emailmessage, string FromEmail, string ToEmail, Gen_SubCompany objSubCompany) { Gen_SysPolicy_Configuration obj = Taxi_AppMain.General.GetObject <Gen_SysPolicy_Configuration>(c => c.SysPolicyId == 1); if (obj == null) { throw new Exception("Email Configuration is not defined in Settings."); } else { if (string.IsNullOrEmpty(obj.SmtpHost) || string.IsNullOrEmpty(obj.Port) || string.IsNullOrEmpty(obj.UserName) || string.IsNullOrEmpty(obj.Password)) { throw new Exception("InComplete Email Configuration. Please contact it to Admin."); } } using (MailMessage message = new MailMessage()) { string emptyName = "..."; string smptHost = AppVars.objPolicyConfiguration.SmtpHost; int port = AppVars.objPolicyConfiguration.Port.ToInt(); string userName = obj.UserName.ToStr().Trim(); string pwd = obj.Password.ToStr().Trim(); string emailcc = AppVars.objSubCompany.EmailCC.ToStr().Trim(); bool enableSSL = AppVars.objPolicyConfiguration.EnableSSL.ToBool(); string companyName = AppVars.objSubCompany.CompanyName.ToStr(); if (objSubCompany != null && objSubCompany.SmtpHost.ToStr().Trim().Length > 0) { smptHost = objSubCompany.SmtpHost.ToStr().Trim(); port = objSubCompany.SmtpPort.ToInt(); userName = objSubCompany.SmtpUserName.ToStr().Trim(); pwd = objSubCompany.SmtpPassword.ToStr().Trim(); emailcc = objSubCompany.EmailCC.ToStr().Trim(); enableSSL = objSubCompany.SmtpHasSSL.ToBool(); companyName = objSubCompany.CompanyName.ToStr().Trim(); if (objSubCompany.IsTpCompany.ToBool() && objSubCompany.UseDifferentEmailForInvoices.ToBool()) { smptHost = objSubCompany.SmtpInvoiceHost.ToStr().Trim(); port = objSubCompany.SmtpInvoicePort.ToInt(); userName = objSubCompany.SmtpInvoiceUserName.ToStr().Trim(); pwd = objSubCompany.SmtpInvoicePassword.ToStr().Trim(); enableSSL = objSubCompany.SmtpInvoiceSSL.ToBool(); FromEmail = userName; } } foreach (var item in Attachments) { emptyName = item.Name; message.Attachments.Add(item); } System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient(smptHost, port); smtp.EnableSsl = enableSSL; NetworkCredential mailAuthentication = new NetworkCredential(userName, pwd); char[] arr = new char[] { ',' }; string[] toArr = ToEmail.Split(arr); foreach (var item in toArr) { message.To.Add(new MailAddress(item.Trim())); } if (string.IsNullOrEmpty(subject)) { subject = emptyName; } if (string.IsNullOrEmpty(Emailmessage)) { Emailmessage = emptyName; } if (emailcc.Length > 0) { message.CC.Add(emailcc); } message.From = new MailAddress(FromEmail.Trim(), companyName); message.IsBodyHtml = true; message.Subject = subject; message.Body = Emailmessage; // smtp.DeliveryMethod= SmtpDeliveryMethod. smtp.Credentials = mailAuthentication; FieldInfo transport = smtp.GetType().GetField("transport", BindingFlags.NonPublic | BindingFlags.Instance); FieldInfo authModules = transport.GetValue(smtp).GetType().GetField("authenticationModules", BindingFlags.NonPublic | BindingFlags.Instance); Array modulesArray = authModules.GetValue(transport.GetValue(smtp)) as Array; modulesArray.SetValue(modulesArray.GetValue(3), 1); smtp.Send(message); } }
public void GenerateReport() { try { Microsoft.Reporting.WinForms.ReportParameter[] param = null; UM_Form_Template objTemplate = General.GetObject <UM_Form_Template>(c => c.UM_Form.FormName == this.Name && c.IsDefault == true); string className = "Taxi_AppMain.ReportDesigns." + objTemplate.TemplateName.ToStr() + "_"; if (objTemplate.TemplateName.ToStr() == "Template1") { this.reportViewer1.LocalReport.ReportEmbeddedResource = className + "rptDriverStatement.rdlc"; param = new Microsoft.Reporting.WinForms.ReportParameter[19]; } else if (objTemplate.TemplateName.ToStr() == "Template2") { this.reportViewer1.LocalReport.ReportEmbeddedResource = className + "rptDriverStatement.rdlc"; param = new Microsoft.Reporting.WinForms.ReportParameter[19]; } else if (objTemplate.TemplateName.ToStr() == "Template3" || objTemplate.TemplateName.ToStr() == "Template4") { GenerateReport3(objTemplate.TemplateName.ToStr().Trim()); return; // this.reportViewer1.LocalReport.ReportEmbeddedResource = className + "rptDriverStatement.rdlc"; // param = new Microsoft.Reporting.WinForms.ReportParameter[26]; } reportViewer1.LocalReport.EnableExternalImages = true; if (objSubCompany == null) { objSubCompany = AppVars.objSubCompany; } string address = objSubCompany.Address; string telNo = "Tel No. " + objSubCompany.TelephoneNo; param[0] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Address", address); param[1] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Telephone", telNo); List <ClsLogo> objLogo = new List <ClsLogo>(); objLogo.Add(new ClsLogo { ImageInBytes = objSubCompany.CompanyLogo != null ? objSubCompany.CompanyLogo.ToArray() : null }); ReportDataSource imageDataSource = new ReportDataSource("Taxi_AppMain_Classes_ClsLogo", objLogo); this.reportViewer1.LocalReport.DataSources.Add(imageDataSource); string path = @"File:"; param[2] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Path", path); param[3] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Period", this.DatePeriod); // Summary Calculations decimal JobsSum = this.DataSource.Sum(c => c.TotalCharges.ToDecimal()); int jobsCnt = this.DataSource.Count; string jobsTotal = string.Format("{0:c}", JobsSum); jobsTotal = jobsTotal.Substring(1); jobsTotal = jobsTotal.Insert(0, "£ "); decimal zeroValue = 0.00m; string zeroStr = string.Format("{0:c}", zeroValue); zeroStr = zeroStr.Substring(1); zeroStr = zeroStr.Insert(0, "£ "); decimal totalCashAccountAmount = this.DataSource.Where(c => c.CompanyId != null && c.AccountTypeId.ToInt() == Enums.ACCOUNT_TYPE.CASH && c.DriverCommissionType.ToStr() == "Amount").Sum(c => c.DriverCommission.ToDecimal()); string totalCashAccountAmountStr = string.Format("{0:c}", totalCashAccountAmount); totalCashAccountAmountStr = totalCashAccountAmountStr.Substring(1); totalCashAccountAmountStr = totalCashAccountAmountStr.Insert(0, "£ "); string totalAccountBookings = this.DataSource.Count(c => c.CompanyId != null && c.AccountTypeId == Enums.ACCOUNT_TYPE.ACCOUNT).ToStr(); decimal totalAccountCharges = this.DataSource.Where(c => c.CompanyId != null && c.AccountTypeId == Enums.ACCOUNT_TYPE.ACCOUNT).Sum(c => c.TotalCharges.ToDecimal()); string totalAccountBookingsCharges = string.Format("{0:c}", totalAccountCharges).Substring(1); totalAccountBookingsCharges = totalAccountBookingsCharges.Insert(0, "£ "); string totalCashBooking = this.DataSource.Count(c => c.CompanyId == null || (c.CompanyId != null && c.AccountTypeId == Enums.ACCOUNT_TYPE.CASH)).ToStr(); string totalCashBookingCharges = string.Format("{0:c}", this.DataSource.Where(c => c.CompanyId == null || (c.CompanyId != null && c.AccountTypeId == Enums.ACCOUNT_TYPE.CASH)) .Sum(c => c.TotalCharges.ToDecimal())); totalCashBookingCharges = totalCashBookingCharges.Substring(1); totalCashBookingCharges = totalCashBookingCharges.Insert(0, "£ "); decimal driverMonthlyRent = 0; if (Rent > 0) { driverMonthlyRent = (Rent).ToDecimal() + totalCashAccountAmount; } else { driverMonthlyRent = ObjDriver.DriverMonthlyRent.ToDecimal() + totalCashAccountAmount; } string driverMonthlyRentRate = string.Format("{0:c}", driverMonthlyRent); driverMonthlyRentRate = driverMonthlyRentRate.Substring(1); driverMonthlyRentRate = driverMonthlyRentRate.Insert(0, "£ "); decimal driverOwed = totalAccountCharges - driverMonthlyRent; string driverOwedRate = "£ " + string.Format("{0:#.00}", driverOwed); if (StatementType == 2) { driverMonthlyRentRate = "£ 0.00"; driverOwedRate = jobsTotal; } //UM_Form_Template objTemplate = General.GetObject<UM_Form_Template>(c => c.UM_Form.FormName == this.Name && c.IsDefault == true); //string className = "Taxi_AppMain.ReportDesigns." + objTemplate.TemplateName.ToStr() + "_"; //if (objTemplate.TemplateName.ToStr() == "Template1") //{ // this.reportViewer1.LocalReport.ReportEmbeddedResource = className + "rptDriverStatement.rdlc"; //} //else if (objTemplate.TemplateName.ToStr() == "Template2") //{ // this.reportViewer1.LocalReport.ReportEmbeddedResource = className + "rptDriverStatement.rdlc"; //} //else if (objTemplate.TemplateName.ToStr() == "Template3") //{ // this.reportViewer1.LocalReport.ReportEmbeddedResource = className + "rptDriverStatement.rdlc"; //} param[4] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_JobsTotal", jobsTotal); param[5] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_AdditionsQuantity", totalAccountBookings.ToStr() + " account booking"); param[6] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_AdditionsAccountsGross", totalAccountBookingsCharges); param[7] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_AdditionsAccountsGrossTotal", totalAccountBookingsCharges); param[8] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_DeductionsCashQuantity", totalCashBooking + " cash booking"); param[9] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_DeductionsCashGross", totalCashBookingCharges); param[10] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_DeductionsCashGrossTotal", totalCashBookingCharges); param[11] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_TotalAdditions", totalAccountBookingsCharges); param[12] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_TotalDeductions", driverMonthlyRentRate); param[13] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_OverallTotal", jobsTotal); param[14] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_BalanceBFD", zeroStr); param[15] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_DriverOwed", driverOwedRate.ToStr()); param[16] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_JobsCnt", jobsCnt.ToStr()); param[17] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_StatementType", this.StatementType.ToStr()); param[18] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_TotalCommissionAmount", totalCashAccountAmountStr.ToStr()); //param[19] = new Microsoft.Reporting.WinForms.ReportParameter("Report_RentWise", (Rent).ToStr()); // reportViewer1.LocalReport.SetParameters(param); this.Vu_BookingBaseBindingSource.DataSource = this.DataSource; this.reportViewer1.ZoomPercent = 100; this.reportViewer1.ZoomMode = Microsoft.Reporting.WinForms.ZoomMode.Percent; this.reportViewer1.RefreshReport(); } catch (Exception ex) { ENUtils.ShowMessage(ex.Message); } }
public void GenerateReport3(string templateNo) { try { Microsoft.Reporting.WinForms.ReportParameter[] param = null; string className = "Taxi_AppMain.ReportDesigns." + templateNo + "_"; this.reportViewer1.LocalReport.SubreportProcessing += new SubreportProcessingEventHandler(LocalReport_SubreportProcessing); this.reportViewer1.LocalReport.ReportEmbeddedResource = className + "rptDriverStatement.rdlc"; decimal PDARent = ObjDriver.PDARent.ToDecimal(); if (templateNo == "Template3") { param = new Microsoft.Reporting.WinForms.ReportParameter[22]; } else if (templateNo == "Template4") { param = new Microsoft.Reporting.WinForms.ReportParameter[23]; param[22] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_DriverPDARent", PDARent.ToStr()); } reportViewer1.LocalReport.EnableExternalImages = true; if (objSubCompany == null) { objSubCompany = AppVars.objSubCompany; } string address = objSubCompany.Address; string telNo = "Tel No. " + objSubCompany.TelephoneNo; List <ClsLogo> objLogo = new List <ClsLogo>(); objLogo.Add(new ClsLogo { ImageInBytes = objSubCompany.CompanyLogo != null ? objSubCompany.CompanyLogo.ToArray() : null }); ReportDataSource imageDataSource = new ReportDataSource("Taxi_AppMain_Classes_ClsLogo", objLogo); this.reportViewer1.LocalReport.DataSources.Add(imageDataSource); string path = @"File:"; param[0] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Path", path); // param[3] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Period", this.DatePeriod); // Summary Calculations decimal JobsSum = this.DataSource2.Sum(c => c.FareRate.ToDecimal() + c.MeetAndGreetCharges.ToDecimal()); int jobsCnt = this.DataSource2.Count; string jobsTotal = string.Format("{0:c}", JobsSum); jobsTotal = jobsTotal.Substring(1); jobsTotal = jobsTotal.Insert(0, "£ "); decimal zeroValue = 0.00m; string zeroStr = string.Format("{0:c}", zeroValue); zeroStr = zeroStr.Substring(1); zeroStr = zeroStr.Insert(0, "£ "); decimal totalCashAccountAmount = this.DataSource2.Where(c => c.CompanyId != null && c.AccountTypeId.ToInt() == Enums.ACCOUNT_TYPE.CASH && c.DriverCommissionType.ToStr() == "Amount").Sum(c => c.DriverCommission.ToDecimal()); string totalCashAccountAmountStr = string.Format("{0:c}", totalCashAccountAmount); totalCashAccountAmountStr = totalCashAccountAmountStr.Substring(1); totalCashAccountAmountStr = totalCashAccountAmountStr.Insert(0, "£ "); string totalAccountBookings = this.DataSource2.Count(c => c.CompanyId != null && c.AccountTypeId == Enums.ACCOUNT_TYPE.ACCOUNT).ToStr(); decimal totalAccountCharges = this.DataSource2.Where(c => c.CompanyId != null && c.AccountTypeId == Enums.ACCOUNT_TYPE.ACCOUNT).Sum(c => c.FareRate.ToDecimal() + c.MeetAndGreetCharges.ToDecimal()); string totalAccountBookingsCharges = string.Format("{0:c}", totalAccountCharges).Substring(1); totalAccountBookingsCharges = totalAccountBookingsCharges.Insert(0, "£ "); string totalCashBooking = this.DataSource2.Count(c => c.CompanyId == null || (c.CompanyId != null && c.AccountTypeId == Enums.ACCOUNT_TYPE.CASH)).ToStr(); string totalCashBookingCharges = string.Format("{0:c}", this.DataSource2.Where(c => c.CompanyId == null || (c.CompanyId != null && c.AccountTypeId == Enums.ACCOUNT_TYPE.CASH)) .Sum(c => c.FareRate.ToDecimal() + c.MeetAndGreetCharges.ToDecimal())); totalCashBookingCharges = totalCashBookingCharges.Substring(1); totalCashBookingCharges = totalCashBookingCharges.Insert(0, "£ "); decimal driverMonthlyRent = 0; if (Rent > 0) { driverMonthlyRent = (Rent).ToDecimal() + totalCashAccountAmount; } else { driverMonthlyRent = ObjDriver.DriverMonthlyRent.ToDecimal() + totalCashAccountAmount; } string driverMonthlyRentRate = string.Format("{0:c}", driverMonthlyRent); driverMonthlyRentRate = driverMonthlyRentRate.Substring(1); driverMonthlyRentRate = driverMonthlyRentRate.Insert(0, "£ "); // Add pda rent driverMonthlyRent = driverMonthlyRent + PDARent; decimal driverOwed = totalAccountCharges - driverMonthlyRent; string driverOwedRate = "£ " + string.Format("{0:#.00}", driverOwed); if (StatementType == 2) { driverMonthlyRentRate = "£ 0.00"; driverOwedRate = jobsTotal; } param[1] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_JobsTotal", jobsTotal); param[2] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_AdditionsQuantity", totalAccountBookings.ToStr() + " account booking"); param[3] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_AdditionsAccountsGross", totalAccountBookingsCharges); param[4] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_AdditionsAccountsGrossTotal", totalAccountBookingsCharges); param[5] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_DeductionsCashQuantity", totalCashBooking + " cash booking"); param[6] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_DeductionsCashGross", totalCashBookingCharges); param[7] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_DeductionsCashGrossTotal", totalCashBookingCharges); param[8] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_TotalAdditions", totalAccountBookingsCharges); param[9] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_TotalDeductions", driverMonthlyRentRate); param[10] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_OverallTotal", jobsTotal); param[11] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_BalanceBFD", zeroStr); param[12] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_DriverOwed", driverOwedRate.ToStr()); param[13] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_JobsCnt", jobsCnt.ToStr()); param[14] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_StatementType", this.StatementType.ToStr()); // param[18] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_TotalCommissionAmount", totalCashAccountAmountStr.ToStr()); //param[19] = new Microsoft.Reporting.WinForms.ReportParameter("Report_RentWise", (Rent).ToStr()); // // var query =ObjDriver General.GetObject<Fleet_Driver>(c => c.Id == driverid); string PCODRiverExpiryDate = string.Format("{0:dd/MM/yyyy}", ObjDriver.PCODriverExpiryDate.ToDateorNull()); string PCOVehicleExpiryDate = string.Format("{0:dd/MM/yyyy}", ObjDriver.PCOVehicleExpiryDate.ToDateorNull()); string MOT2ExpiryDate = string.Format("{0:dd/MM/yyyy}", ObjDriver.MOT2ExpiryDate.ToDateorNull()); string MOTExpiryDate = string.Format("{0:dd/MM/yyyy}", ObjDriver.MOTExpiryDate.ToDateorNull()); string InsuranceExpiryDate = string.Format("{0:dd/MM/yyyy}", ObjDriver.InsuranceExpiryDate.ToDateorNull()); string LicenseExpiryDate = string.Format("{0:dd/MM/yyyy}", ObjDriver.DrivingLicenseExpiryDate.ToDateorNull()); string RoadTaxiExpiryDate = string.Format("{0:dd/MM/yyyy}", ObjDriver.RoadTaxiExpiryDate.ToDateorNull()); param[15] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_PCODRiverExpiryDate", PCODRiverExpiryDate); param[16] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_PCOVehicleExpiryDate", PCOVehicleExpiryDate); param[17] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_MOT2ExpiryDate", MOT2ExpiryDate); param[18] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_MOTExpiryDate", MOTExpiryDate); param[19] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_InsuranceExpiryDate", InsuranceExpiryDate); param[20] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_LicenseExpiryDate", LicenseExpiryDate); param[21] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_RoadTaxExpiryDate", RoadTaxiExpiryDate); var list2 = (from a in new Taxi_Model.TaxiDataContext().stp_VehicleUsage(fromDate, tillDate, driverId, companyId, statementType) select new stp_VehicleUsageResult { VehicleType = a.VehicleType, VehicleNo = a.VehicleNo, Accbkgs = a.Accbkgs, AccTotat = a.AccTotat, CashBkgs = a.CashBkgs, CashTotal = a.CashTotal, Booking = a.Booking, Total = a.Total }).ToList(); ReportDataSource courierDataSource = new ReportDataSource("Taxi_Model_stp_VehicleUsageResult", list2); this.reportViewer1.LocalReport.DataSources.Add(courierDataSource); reportViewer1.LocalReport.SetParameters(param); this.stp_DriverCommisionResultBindingSource.DataSource = this.DataSource2; this.reportViewer1.ZoomPercent = 100; this.reportViewer1.ZoomMode = Microsoft.Reporting.WinForms.ZoomMode.Percent; this.reportViewer1.RefreshReport(); } catch (Exception ex) { ENUtils.ShowMessage(ex.Message); } }
public void GenerateReport() { string pickCommissionFromCharges = AppVars.objPolicyConfiguration.PickCommissionFromCharges.ToBool() == true ? "1" : "0"; reportViewer1.LocalReport.EnableExternalImages = true; if (objSubCompany == null) { objSubCompany = AppVars.objSubCompany; } Microsoft.Reporting.WinForms.ReportParameter[] param = new Microsoft.Reporting.WinForms.ReportParameter[23]; string address = objSubCompany.Address; string telNo = "Tel No. " + objSubCompany.TelephoneNo; param[0] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Address", address); param[1] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Telephone", telNo); if (!string.IsNullOrEmpty(this.TemplatePath.ToStr().Trim())) { this.reportViewer1.LocalReport.ReportEmbeddedResource = this.TemplatePath.ToStr().Replace("Template1_", "").ToStr().Trim(); } List <ClsLogo> objLogo = new List <ClsLogo>(); objLogo.Add(new ClsLogo { ImageInBytes = objSubCompany.CompanyLogo != null ? objSubCompany.CompanyLogo.ToArray() : null }); ReportDataSource imageDataSource = new ReportDataSource("Taxi_AppMain_Classes_ClsLogo", objLogo); this.reportViewer1.LocalReport.DataSources.Add(imageDataSource); string path = @"File:"; param[2] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Path", path); param[3] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Period", this.DatePeriod); // Summary Calculations decimal ExtraSum = this.DataSource.Sum(c => c.ExtraDropCharges.ToDecimal()); string TotalExtraSum = string.Format("{0:c}", ExtraSum); TotalExtraSum = TotalExtraSum.Substring(1); TotalExtraSum = TotalExtraSum.Insert(0, "£ "); decimal JobsSum = this.DataSource.Sum(c => c.TotalCharges.ToDecimal()); int jobsCnt = this.DataSource.Count; string jobsTotal = string.Format("{0:c}", JobsSum); jobsTotal = jobsTotal.Substring(1); jobsTotal = jobsTotal.Insert(0, "£ "); decimal zeroValue = 0.00m; string zeroStr = string.Format("{0:c}", zeroValue); zeroStr = zeroStr.Substring(1); zeroStr = zeroStr.Insert(0, "£ "); // Old Calculation 27 Nov 14 string totalAccountBookings = this.DataSource.Count(c => c.CompanyId != null && c.PaymentTypeId != Enums.PAYMENT_TYPES.CASH).ToStr(); decimal totalAccountCharges = this.DataSource.Where(c => c.CompanyId != null && c.PaymentTypeId != Enums.PAYMENT_TYPES.CASH).Sum(c => c.TotalCharges.ToDecimal()); string totalAccountBookingsCharges = string.Format("{0:c}", totalAccountCharges).Substring(1); totalAccountBookingsCharges = totalAccountBookingsCharges.Insert(0, "£ "); decimal totalCashBooking = this.DataSource.Count(c => c.CompanyId == null || (c.CompanyId != null && c.PaymentTypeId == Enums.PAYMENT_TYPES.CASH)).ToDecimal(); decimal SumofTotalCashBookingChrgs = this.DataSource.Where(c => c.CompanyId == null || (c.CompanyId != null && c.PaymentTypeId == Enums.PAYMENT_TYPES.CASH)).Sum(c => c.TotalCharges.ToDecimal()); string totalCashBookingCharges = string.Format("{0:c}", this.DataSource.Where(c => c.CompanyId == null || (c.CompanyId != null && c.PaymentTypeId == Enums.PAYMENT_TYPES.CASH)).Sum(c => c.TotalCharges.ToDecimal())); totalCashBookingCharges = totalCashBookingCharges.Substring(1); totalCashBookingCharges = totalCashBookingCharges.Insert(0, "£ "); decimal SumOfAccountandCashJobTotal = totalAccountCharges + SumofTotalCashBookingChrgs; string TotalSumOfAccountandCashJobTotal = string.Format("{0:c}", SumOfAccountandCashJobTotal); TotalSumOfAccountandCashJobTotal = TotalSumOfAccountandCashJobTotal.Substring(1); TotalSumOfAccountandCashJobTotal = TotalSumOfAccountandCashJobTotal.Insert(0, "£ "); decimal totalCommission = 0.00m; if (AppVars.objPolicyConfiguration.PickCommissionFromCharges.ToBool()) { if (NoACCommission == false) { totalCommission = this.DataSource.Sum(c => c.IsCommissionWise == true ? (c.DriverCommissionType == "Percent" ? ((c.FareRate * c.DriverCommission) / 100) : c.DriverCommission):((c.FareRate * Commision) / 100)).ToDecimal(); } else { totalCommission = this.DataSource.Where(c => c.CompanyId == null) .Sum(c => c.DriverCommissionType == "Percent" ? ((c.FareRate * c.DriverCommission) / 100) : c.DriverCommission).ToDecimal(); } } else { if (Commision > 0) { if (NoACCommission == false) { totalCommission = this.DataSource.Sum(c => c.DriverCommissionType == "Percent" ? ((c.TotalCharges * Commision) / 100) : c.DriverCommission).ToDecimal(); } else { totalCommission = this.DataSource.Where(c => c.CompanyId == null).Sum(c => c.DriverCommissionType == "Percent" ? ((c.TotalCharges * Commision) / 100) : c.DriverCommission).ToDecimal(); } } else { if (NoACCommission == false) { totalCommission = this.DataSource.Sum(c => c.DriverCommissionType == "Percent" ? ((c.TotalCharges * c.DriverCommission) / 100) : c.DriverCommission).ToDecimal(); } else { totalCommission = this.DataSource.Where(c => c.CompanyId == null).Sum(c => c.DriverCommissionType == "Percent" ? ((c.TotalCharges * c.DriverCommission) / 100) : c.DriverCommission).ToDecimal(); } } } string driverTotalCommission = string.Format("{0:c}", totalCommission); driverTotalCommission = driverTotalCommission.Substring(1); driverTotalCommission = driverTotalCommission.Insert(0, "£ "); string totalSettingsCommission = driverTotalCommission; string driverOwedRate = "£ " + string.Format("{0:c}", totalCommission).Substring(1); if (StatementType == Taxi_AppMain.frmDriverReport.eStatementType.CashStatement) { driverTotalCommission = "£ 0.00"; driverOwedRate = jobsTotal; } else if (StatementType == Taxi_AppMain.frmDriverReport.eStatementType.Both || StatementType == Taxi_AppMain.frmDriverReport.eStatementType.AccountStatement) { driverOwedRate = "£ " + string.Format("{0:#.##}", totalCommission - totalAccountCharges); } param[4] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_JobsTotal", jobsTotal); param[5] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_AdditionsQuantity", totalAccountBookings.ToStr() + " account booking"); param[6] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_AdditionsAccountsGross", totalAccountBookingsCharges); param[7] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_AdditionsAccountsGrossTotal", totalAccountBookingsCharges); param[8] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_DeductionsCashQuantity", totalCashBooking + " cash booking"); param[9] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_DeductionsCashGross", totalCashBookingCharges); param[10] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_DeductionsCashGrossTotal", totalCashBookingCharges); param[11] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_TotalAdditions", TotalSumOfAccountandCashJobTotal); param[12] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_TotalDeductions", driverTotalCommission); param[13] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_OverallTotal", TotalSumOfAccountandCashJobTotal); param[14] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_BalanceBFD", zeroStr); param[15] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_DriverOwed", driverOwedRate); param[16] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_JobsCnt", jobsCnt.ToStr()); param[17] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_StatementType", this.StatementType.ToStr()); param[18] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_CommissionTotal", totalSettingsCommission); param[19] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_PickCommissionFromCharges", pickCommissionFromCharges); param[20] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_TotalExtraDrop", TotalExtraSum); param[21] = new Microsoft.Reporting.WinForms.ReportParameter("Report_CommissionWise", (Commision).ToStr()); param[22] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_NoACComm", AppVars.objPolicyConfiguration.NoCommissionFromAccount.ToBool() ? "1" : "0"); reportViewer1.LocalReport.SetParameters(param); reportViewer1.LocalReport.SetParameters(param); this.Vu_BookingBaseBindingSource.DataSource = this.DataSource; this.reportViewer1.ZoomPercent = 100; this.reportViewer1.ZoomMode = Microsoft.Reporting.WinForms.ZoomMode.Percent; this.reportViewer1.RefreshReport(); }
public void GenerateReport() { try { if (this.DataSource.Count > 0 && this.DataSource[0].AuthCode.ToStr().Trim().Length > 0) { chkPaymentSummary.Visible = true; } reportViewer1.LocalReport.EnableExternalImages = true; Microsoft.Reporting.WinForms.ReportParameter[] param = new Microsoft.Reporting.WinForms.ReportParameter[6]; objSubCompany = AppVars.objSubCompany; if (this.DataSource.Count > 0 && this.DataSource[0].SubCompanyId != null) { objSubCompany = General.GetObject <Gen_SubCompany>(c => c.Id == this.DataSource[0].SubCompanyId); if (objSubCompany == null) { objSubCompany = AppVars.objSubCompany; } } List <ClsLogo> objLogo = new List <ClsLogo>(); objLogo.Add(new ClsLogo { ImageInBytes = objSubCompany.CompanyLogo != null ? objSubCompany.CompanyLogo.ToArray() : null }); ReportDataSource imageDataSource = new ReportDataSource("Taxi_AppMain_Classes_ClsLogo", objLogo); this.reportViewer1.LocalReport.DataSources.Add(imageDataSource); string path = @"File:"; param[0] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_CompanyLogo", path); string header = " " + objSubCompany.Address.ToStr() + ",\n" + " Telephone No:" + objSubCompany.TelephoneNo; header += ". Fax:" + objSubCompany.Fax.ToStr(); header += "\nEmergency Contact No:" + objSubCompany.EmergencyNo.ToStr() + ". " + objSubCompany.WebsiteUrl; header += "\n Email:" + objSubCompany.EmailAddress.ToStr(); param[1] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Header", header); decimal SurchargeAmount = 0.00m; string cardNumber = string.Empty; if (chkPaymentSummary.Checked && this.DataSource.Count > 0 && (this.DataSource[0].PaymentTypeId.ToInt() == Enums.PAYMENT_TYPES.CREDIT_CARD || this.DataSource[0].PaymentTypeId.ToInt() == Enums.PAYMENT_TYPES.BANK_ACCOUNT || this.DataSource[0].PaymentTypeId.ToInt() == Enums.PAYMENT_TYPES.CREDIT_CARD_PAID) && this.DataSource[0].AuthCode.ToStr().Trim().Length > 0) { Booking_Payment objPayment = General.GetObject <Booking_Payment>(c => c.BookingId == this.DataSource.FirstOrDefault().Id).DefaultIfEmpty(); if (objPayment != null) { SurchargeAmount = objPayment.SurchargeAmount.ToDecimal(); if (objPayment.CardNumber.ToStr().Length >= 16) { cardNumber = "**************" + objPayment.CardNumber.Substring(14).ToStr(); } } } string criteria = ddlCriteria.Text; if (this.DataSource.Count > 0) { if (this.DataSource[0].CompanyId.ToInt() == 0 && criteria == "Customer") { criteria = "Driver"; } } param[2] = new Microsoft.Reporting.WinForms.ReportParameter("CreditCardExtraCharges", SurchargeAmount.ToStr()); //AppVars.objPolicyConfiguration.CreditCardExtraCharges.ToStr()); //Report_Parameter_CreditCardExtraCharges param[3] = new Microsoft.Reporting.WinForms.ReportParameter("CardNumber", cardNumber); param[4] = new Microsoft.Reporting.WinForms.ReportParameter("ReportFor", criteria); param[5] = new Microsoft.Reporting.WinForms.ReportParameter("PaymentSummary", chkPaymentSummary.Checked?"1":"0"); reportViewer1.LocalReport.SetParameters(param); //ReportDataSource data = new ReportDataSource("vuBookingDetailBindingSource", this.DataSource); //this.reportViewer1.LocalReport.DataSources.Add(data); this.vuBookingDetailBindingSource.DataSource = this.DataSource; this.reportViewer1.ZoomPercent = 100; //if (Debugger.IsAttached) //{ // this.reportViewer1.SetDisplayMode(DisplayMode.PrintLayout); //} ////else // this.reportViewer1.SetDisplayMode(DisplayMode.PrintLayout); this.reportViewer1.ZoomMode = Microsoft.Reporting.WinForms.ZoomMode.Percent; this.reportViewer1.RefreshReport(); } catch (Exception ex) { ENUtils.ShowMessage(ex.Message); } }
public void SendEmail(string invoiceNo, string email, Gen_SubCompany objSubCompany) { General.ShowEmailForm(reportViewer1, "Customer Invoice # " + invoiceNo, email, objSubCompany, true); }