示例#1
0
        private void InitializeConstructor()
        {
            this.ObjDriver      = General.GetObject <Fleet_Driver>(c => c.Id == this.DriverId);
            btnTestConn.Enabled = Convert.ToBoolean(ObjDriver.HasPDA);
            if (btnTestConn.Enabled == false)
            {
                txtTitle.Width += 112;
            }


            LoadConversation();



            //   timer1.Start();
            this.Shown += new EventHandler(frmMessages_Shown);

            txtTitle.Text = ObjDriver.DriverNo.ToStr() + " - " + ObjDriver.DriverName.ToStr();


            RadListDataItem item = new RadListDataItem();

            item.Text     = "Today";
            item.Value    = "0";
            item.Selected = true;
            ddlShow.Items.Add(item);


            item       = new RadListDataItem();
            item.Text  = "Yesterday";
            item.Value = "1";
            ddlShow.Items.Add(item);


            item       = new RadListDataItem();
            item.Text  = "Customer";
            item.Value = "2";
            ddlShow.Items.Add(item);

            item       = new RadListDataItem();
            item.Text  = "All";
            item.Value = "365";
            ddlShow.Items.Add(item);


            ddlShow.SelectedIndexChanged += new Telerik.WinControls.UI.Data.PositionChangedEventHandler(ddlShow_SelectedIndexChanged);
            //   this.FormClosing += new FormClosingEventHandler(frmMessages_FormClosing);


            if (AppVars.listUserRights.Count(c => c.functionId == "DISABLE VIEW ALL MESSAGES") > 0)
            {
                ddlShow.Visible = false;
            }
        }
 private void ddl_Driver_SelectedIndexChanged(object sender, Telerik.WinControls.UI.Data.PositionChangedEventArgs e)
 {
     try
     {
         if (IsLoaded)
         {
             int          id  = ddl_Driver.SelectedValue.ToInt();
             Fleet_Driver obj = General.GetObject <Fleet_Driver>(c => c.Id == id);
             LoadDriverSettings(obj);
         }
     }
     catch (Exception ex)
     {
     }
 }
        private void EmailInvoices(long TransId)
        {
            bool IsSuccess = false;

            try
            {
                string subject = txtSubject.Text.Trim();

                if (string.IsNullOrEmpty(subject))
                {
                    ENUtils.ShowMessage("Required : Email Subject");
                    return;
                }

                List <GridViewRowInfo> rows = null;


                if (TransId == 0)
                {
                    rows = grdDriverCommission.Rows.Where(c => c.Cells["Check"].Value.ToBool() == true).ToList();
                }
                else
                {
                    rows = grdDriverCommission.Rows.Where(c => c.Cells["CommissionId"].Value.ToLong() == TransId).ToList();
                }



                //List<long> invoiceIds = rows.Select(c => c.Cells["CommissionId"].Value.ToLong()).ToList<long>();


                List <long> invoiceIds = new List <long>();

                if (TransId == 0)
                {
                    invoiceIds = rows.Select(c => c.Cells["CommissionId"].Value.ToLong()).ToList <long>();
                }
                else
                {
                    invoiceIds = new List <long>();
                    invoiceIds.Add(TransId);
                }


                if (invoiceIds.Count > 0)
                {
                    frmDriverCommisionTransactionExpensesReport3 frm = new frmDriverCommisionTransactionExpensesReport3(1);

                    var list  = General.GetQueryable <vu_DriverCommisionExpenses2>(a => invoiceIds.Contains(a.Id)).ToList();
                    var list2 = General.GetQueryable <vu_FleetDriverCommissionExpense>(a => invoiceIds.Contains(a.Id)).ToList();

                    List <Fleet_Driver> driversList = General.GetQueryable <Fleet_Driver>(c => c.DriverTypeId == 2).ToList();

                    frmEmail frmEmail = new frmEmail(null, "", "");

                    Fleet_Driver objDriver = null;
                    foreach (var item in rows.Where(c => c.Cells["Check"].Value.ToBool()))
                    {
                        frm.DataSource  = list.Where(c => c.Id == item.Cells["CommissionId"].Value.ToLong()).OrderBy(c => c.PickupDate).ToList();
                        frm.DataSource2 = list2.Where(c => c.CommissionId == item.Cells["CommissionId"].Value.ToLong()).OrderBy(c => c.Date).ToList();

                        frm.GenerateReport();

                        objDriver = driversList.FirstOrDefault(c => c.Id == item.Cells["DriverId"].Value.ToInt());
                        //string email = driversList.FirstOrDefault(c => c.Id == item.Cells[COLS.Id].Value.ToInt()).DefaultIfEmpty().Email.ToStr().Trim();
                        string email = objDriver.Email.ToStr().Trim();

                        if (!string.IsNullOrEmpty(email))
                        {
                            IsSuccess = frm.SendEmailInternally(frmEmail, subject, objDriver.DriverNo.ToStr().Trim(), email);
                        }
                    }


                    if (frmEmail != null && frmEmail.IsDisposed == false)
                    {
                        frmEmail.Close();
                        GC.Collect();
                    }


                    if (IsSuccess)
                    {
                        RadDesktopAlert alert = new RadDesktopAlert();
                        alert.ContentText = "Email has been sent successfully";
                        alert.Show();
                    }
                    // ENUtils.ShowMessage("Email has been sent successfully");
                }
            }
            catch (Exception ex)
            {
                ENUtils.ShowMessage(ex.Message);
            }
        }
        public void GenerateReport()
        {
            try
            {
                reportViewer1.LocalReport.EnableExternalImages = true;


                //UM_Form_Template objTemplate = General.GetObject<UM_Form_Template>(c => c.UM_Form.FormName == this.Name && c.IsDefault == true);

                //if (objTemplate == null)
                //{
                //    ENUtils.ShowMessage("Report Template is not defined in Settings");
                //    return;
                //}


                //string className = "Taxi_AppMain.ReportDesigns." + objTemplate.TemplateName.ToStr() + "_";

                //if (objTemplate.TemplateName.ToStr() == "Template1")
                //{
                //    this.reportViewer1.LocalReport.ReportEmbeddedResource = "Taxi_AppMain.ReportDesigns." + "rptDriverCommisionExpenses.rdlc";
                //}
                //else if (objTemplate.TemplateName.ToStr() == "Template2" || objTemplate.TemplateName.ToStr() == "Template3")
                //{
                //    this.reportViewer1.LocalReport.ReportEmbeddedResource = className + "rptDriverCommisionExpenses.rdlc";
                //    //rptDriverCommisionExpenses
                //}

                Microsoft.Reporting.WinForms.ReportParameter[] param = new Microsoft.Reporting.WinForms.ReportParameter[31];


                string address = AppVars.objSubCompany.Address;
                string telNo   = string.Empty;


                string sortCode     = AppVars.objSubCompany.SortCode.ToStr();
                string accountNo    = AppVars.objSubCompany.AccountNo.ToStr();
                string accountTitle = AppVars.objSubCompany.AccountTitle.ToStr();
                string bank         = AppVars.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 = AppVars.objSubCompany.WebsiteUrl.ToStr();
                if (!string.IsNullOrEmpty(website))
                {
                    website += " , ";
                }

                website += "Email:" + AppVars.objSubCompany.EmailAddress.ToStr();


                string companyNumber = AppVars.objSubCompany.CompanyNumber.ToStr();
                if (!string.IsNullOrEmpty(companyNumber))
                {
                    companyNumber = "Company Number: " + companyNumber;
                }

                string vatNumber = AppVars.objSubCompany.CompanyVatNumber.ToStr();
                if (!string.IsNullOrEmpty(vatNumber))
                {
                    vatNumber = "VAT Number: " + vatNumber;
                }


                param[0] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Address", address);

                param[18] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Footer", AppVars.objSubCompany.WebsiteUrl.ToStr());

                param[14] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_MobileNo", "Mobile: " + AppVars.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: " + AppVars.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 = AppVars.objSubCompany.CompanyLogo != null ? AppVars.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", AppVars.objSubCompany.CompanyName.ToStr());



                int?driverId = this.DataSource.FirstOrDefault().DefaultIfEmpty().DriverId;

                var data = this.DataSource.FirstOrDefault().DefaultIfEmpty();


                telNo = "Telephone: " + AppVars.objSubCompany.TelephoneNo + ", Fax: " + AppVars.objSubCompany.Fax + ", E-mail: " + AppVars.objSubCompany.EmailAddress + ", Website:" + AppVars.objSubCompany.WebsiteUrl;

                if (!string.IsNullOrEmpty(accountNo))
                {
                    accountNo = "Account No : " + accountNo;
                }


                // string className = "Taxi_AppMain.ReportDesigns.";
                //if (IsCheck == 1)
                //{

                //    if (IsFareAndWaitingWise)
                //    {
                //        this.reportViewer1.LocalReport.ReportEmbeddedResource = className + "rptDriverCommisionTrasaction3.rdlc";

                //    }
                //    else
                //    {



                //        this.reportViewer1.LocalReport.ReportEmbeddedResource = className + "rptDriverCommisionTrasaction4.rdlc";
                //    }
                //}
                //else
                //{
                //    this.reportViewer1.LocalReport.ReportEmbeddedResource = className + "rptDriverCommisionTrasaction2.rdlc";
                //}

                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);


                string AccountBooking = string.Empty;
                string CashBooking    = string.Empty;



                Fleet_Driver obj             = General.GetObject <Fleet_Driver>(c => c.Id == driverId);
                decimal      DriverCommision = obj.DriverCommissionPerBooking.ToDecimal();



                decimal JobTotal = 0;
                if (this.IsFareAndWaitingWise)
                {
                    AccountBooking = string.Format("{0:£ #.##}", this.DataSource.Where(c => c.CompanyId != null && c.BookingTypeId.ToInt() == Enums.ACCOUNT_TYPE.ACCOUNT).Sum(c => c.FareRate.ToDecimal() + c.WaitingCharges.ToDecimal()));
                    CashBooking    = string.Format("{0:£ #.##}", this.DataSource.Where(c => c.CompanyId == null || c.BookingTypeId.ToInt() == Enums.ACCOUNT_TYPE.CASH).Sum(c => c.FareRate.ToDecimal() + c.WaitingCharges.ToDecimal()));
                    JobTotal       = this.DataSource.Sum(c => c.FareRate.Value.ToDecimal() + c.WaitingCharges.ToDecimal());
                }
                else
                {
                    AccountBooking = string.Format("{0:£ #.##}", this.DataSource.Where(c => c.CompanyId != null && c.BookingTypeId.ToInt() == Enums.ACCOUNT_TYPE.ACCOUNT).Sum(c => c.FareRate.ToDecimal() + c.ParkingCharges.ToDecimal() + c.WaitingCharges.ToDecimal()));
                    CashBooking    = string.Format("{0:£ #.##}", this.DataSource.Where(c => c.CompanyId == null || c.BookingTypeId.ToInt() == Enums.ACCOUNT_TYPE.CASH).Sum(c => c.FareRate.ToDecimal() + c.ParkingCharges.ToDecimal() + c.WaitingCharges.ToDecimal()));
                    JobTotal       = this.DataSource.Sum(c => c.FareRate.ToDecimal() + c.ParkingCharges.ToDecimal() + c.WaitingCharges.ToDecimal());
                }


                param[22] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_AccountJobTotal", AccountBooking);
                param[23] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_CashJobTotal", CashBooking);
                string BalanceType = string.Empty;
                int    DriverId    = this.DataSource.FirstOrDefault().DriverId.ToInt();
                int    Id          = this.DataSource.FirstOrDefault().Id.ToInt();;
                var    query       = General.GetObject <Fleet_DriverCommision>(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);
                }

                string  Commision    = (JobTotal * DriverCommision / 100).ToStr();
                decimal AccountTotal = (this.DataSource.Sum(c => c.AccountJobsTotal)).ToDecimal();
                //   decimal AccountCommision=(25*AccountTotal/100);
                decimal CashTotal = (this.DataSource.Sum(c => c.CashJobsTotal)).ToDecimal();
                //  decimal CashCommision=(25*CashTotal/100);
                // decimal TotalDebit = this.DataSource2.Sum(c => c.Debit).ToDecimal();
                //  decimal TotalCredit = this.DataSource2.Sum(c=>c.Credit).ToDecimal();



                //  decimal commissionTotal = this.data


                //   var objRecord=  General.GetObject<Fleet_DriverCommision>(c => c.Id == Id);


                //if (objRecord != null)
                //{

                //    commissionTotal = objRecord.CommissionTotal.ToDecimal() + objRecord.AgentFeesTotal.ToDecimal();
                //}

                if (AppVars.objPolicyConfiguration.PriceRangeWiseCommission.ToBool())
                {
                    List <Fleet_Driver_CommissionRange> listofRange = obj.Fleet_Driver_CommissionRanges.ToList();

                    if (listofRange.Count == 0)
                    {
                        listofRange = GetSystemCommissionRange();
                    }

                    Commision = Math.Round(this.DataSource
                                           .Sum(c => c.IsCommissionWise.ToBool() ? (c.DriverCommissionType == "Percent" ? ((c.TotalCharges * c.DriverCommissionOnBooking) / 100) : c.DriverCommissionOnBooking) : (((c.FareRate * listofRange.FirstOrDefault(a => c.TotalCharges >= a.FromPrice && c.FareRate <= a.ToPrice).DefaultIfEmpty().CommissionValue.ToDecimal()) / 100))).ToDecimal(), 2).ToStr();
                }


                param[24] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Commision", Commision);

                string DriverGrandTotal = "";

                if (this.DataSource != null)
                {
                    DriverGrandTotal = (this.DataSource[0].DriverCommision + this.DataSource[0].Extra + this.DataSource[0].fuel + this.DataSource[0].OldBalance).ToStr();
                }

                param[25] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_GrandTotal", DriverGrandTotal);

                int     cnt             = this.DataSource.Count;
                decimal AccountExpenses = 0.00m;
                //    decimal DropOfCharges=this.DataSource.Sum(c=>c.ExtraDropOfCharges).ToDecimal();
                //   decimal PickUpCharges=this.DataSource.Sum(c=>c.ExtraPickUpCharges).ToDecimal();
                //  AccountExpenses=(DropOfCharges+PickUpCharges);
                param[26] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_jobCount", cnt.ToStr());
                param[27] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_BalanceType", BalanceType);
                param[28] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_AccountExpenses", AccountExpenses.ToStr());
                param[29] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_StatementDate", StatementDate);
                //Report_Parameter_StatementDate

                string balance = string.Empty;

                decimal bal = this.DataSource.FirstOrDefault().DefaultIfEmpty().Balance.ToDecimal();


                if (bal >= 0)
                {
                    balance = "You are due to receive £" + string.Format("{0:f2}", bal);
                }
                else
                {
                    balance = "You are due to Pay £" + string.Format("{0:f2}", bal);

                    balance = balance.Replace("-", "").Trim();
                }


                param[30] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Balance", balance);


                //   string strCommissionTotal = string.Format("{0:f2}", commissionTotal);
                //    param[31] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_CommissionTotal", strCommissionTotal);



                //int minRows = 12;
                //if (cnt < minRows)
                //{
                //    for (int i = 0; i < minRows - cnt; i++)
                //    {
                //        this.DataSource.Add(new vu_DriverCommisionExpenses2 { Id = data.Id, BookingId = data.BookingId, });//, Passenger = data.Passenger, FromAddress = data.FromAddress, ToAddress = data.ToAddress });

                //    }

                //}
                reportViewer1.LocalReport.SetParameters(param);
                this.vu_DriverCommisionExpenses2BindingSource.DataSource     = this.DataSource;
                this.vu_FleetDriverCommissionExpenseBindingSource.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);
            }
        }
示例#5
0
        public void GenerateReport()
        {
            try
            {
                reportViewer1.LocalReport.EnableExternalImages = true;



                Microsoft.Reporting.WinForms.ReportParameter[] param = new Microsoft.Reporting.WinForms.ReportParameter[27];

                string address = AppVars.objSubCompany.Address;
                string telNo   = string.Empty;



                string sortCode     = AppVars.objSubCompany.SortCode.ToStr();
                string accountNo    = AppVars.objSubCompany.AccountNo.ToStr();
                string accountTitle = AppVars.objSubCompany.AccountTitle.ToStr();
                string bank         = AppVars.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 = AppVars.objSubCompany.WebsiteUrl.ToStr();
                if (!string.IsNullOrEmpty(website))
                {
                    website += " , ";
                }

                website += "Email:" + AppVars.objSubCompany.EmailAddress.ToStr();


                string companyNumber = AppVars.objSubCompany.CompanyNumber.ToStr();
                if (!string.IsNullOrEmpty(companyNumber))
                {
                    companyNumber = "Company Number: " + companyNumber;
                }

                string vatNumber = AppVars.objSubCompany.CompanyVatNumber.ToStr();
                if (!string.IsNullOrEmpty(vatNumber))
                {
                    vatNumber = "VAT Number: " + vatNumber;
                }


                param[0] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Address", address);

                param[18] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Footer", AppVars.objSubCompany.WebsiteUrl.ToStr());

                param[14] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_MobileNo", "Mobile: " + AppVars.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: " + AppVars.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 = AppVars.objSubCompany.CompanyLogo != null ? AppVars.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", AppVars.objSubCompany.CompanyName.ToStr());



                int?driverId = this.DataSource.FirstOrDefault().DefaultIfEmpty().DriverId;

                var data = this.DataSource.FirstOrDefault().DefaultIfEmpty();


                telNo = "Tel No. " + AppVars.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);



                param[22] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_AccountJobTotal", "");
                param[23] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_CashJobTotal", "");


                Fleet_Driver obj = General.GetObject <Fleet_Driver>(c => c.Id == driverId);


                param[24] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Commision", "");

                string DriverGrandTotal = "";

                param[25] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_GrandTotal", DriverGrandTotal);

                param[26] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_ReportFor", ReportFor);

                reportViewer1.LocalReport.SetParameters(param);


                int cnt = this.DataSource.Count;



                this.vu_DriverCommisionBindingSource.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);
            }
        }
        private void LoadDriverSettings(Fleet_Driver driver)
        {
            try
            {
                if (driver != null)
                {
                    this.ObjDriver         = driver;
                    lblDriverMobNo.Visible = true;
                    txtDriverMobNo.Visible = true;
                    if (string.IsNullOrEmpty(driver.MobileNo.ToStr().Trim()))
                    {
                        txtDriverMobNo.Text      = "Not found";
                        txtDriverMobNo.ForeColor = Color.Red;
                    }
                    else
                    {
                        string mobNo = driver.MobileNo.ToStr().Trim();
                        int    idx   = -1;
                        if (!Debugger.IsAttached)
                        {
                            if (mobNo.StartsWith("044") == true)
                            {
                                idx   = mobNo.IndexOf("044");
                                mobNo = mobNo.Substring(idx + 3);
                                mobNo = mobNo.Insert(0, "+44");
                            }

                            if (mobNo.StartsWith("07"))
                            {
                                mobNo = mobNo.Substring(1);
                            }

                            if (mobNo.StartsWith("044") == false || mobNo.StartsWith("+44") == false)
                            {
                                mobNo = mobNo.Insert(0, "+44");
                            }
                        }

                        txtDriverMobNo.Text = mobNo;
                        DateTime nowDate = DateTime.Now.ToDate();

                        // New Code for PDA Driver No

                        //

                        if (driver.MOTExpiryDate != null && driver.MOTExpiryDate.ToDate() < nowDate)
                        {
                            lblNocMessage.Visible   = true;
                            lblNocMessage.Text      = "Driver MOT Expired : " + string.Format("{0:dd/MM/yyyy}", driver.MOTExpiryDate);
                            lblNocMessage.ForeColor = Color.Red;
                        }
                        else if (driver.MOT2ExpiryDate != null && driver.MOT2ExpiryDate.ToDate() < nowDate)
                        {
                            lblNocMessage.Visible   = true;
                            lblNocMessage.Text      = "Driver MOT 2 Expired : " + string.Format("{0:dd/MM/yyyy}", driver.MOT2ExpiryDate);
                            lblNocMessage.ForeColor = Color.Red;
                        }
                        else if (driver.InsuranceExpiryDate != null && driver.InsuranceExpiryDate.ToDate() < nowDate)
                        {
                            lblNocMessage.Visible   = true;
                            lblNocMessage.Text      = "Insurance Expired : " + string.Format("{0:dd/MM/yyyy}", driver.InsuranceExpiryDate);
                            lblNocMessage.ForeColor = Color.Red;
                        }

                        else if (driver.PCODriverExpiryDate != null && driver.PCODriverExpiryDate.ToDate() < nowDate)
                        {
                            lblNocMessage.Visible   = true;
                            lblNocMessage.Text      = "PCO Driver Expired : " + string.Format("{0:dd/MM/yyyy}", driver.PCODriverExpiryDate);
                            lblNocMessage.ForeColor = Color.Red;
                        }

                        else if (driver.PCOVehicleExpiryDate != null && driver.PCOVehicleExpiryDate.ToDate() < nowDate)
                        {
                            lblNocMessage.Visible   = true;
                            lblNocMessage.Text      = "PCO Vehicle Expired : " + string.Format("{0:dd/MM/yyyy}", driver.PCOVehicleExpiryDate);
                            lblNocMessage.ForeColor = Color.Red;
                        }

                        else if (driver.DrivingLicenseExpiryDate != null && driver.DrivingLicenseExpiryDate.ToDate() < nowDate)
                        {
                            lblNocMessage.Visible   = true;
                            lblNocMessage.Text      = "Driving License Expired : " + string.Format("{0:dd/MM/yyyy}", driver.DrivingLicenseExpiryDate);
                            lblNocMessage.ForeColor = Color.Red;
                        }

                        else
                        {
                            lblNocMessage.Visible = false;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }
        public void GenerateReport()
        {
            try
            {
                if (ddlCompany.SelectedValue == null)
                {
                    pnlCriteria.Visible = false;
                }

                reportViewer1.LocalReport.EnableExternalImages = true;



                Microsoft.Reporting.WinForms.ReportParameter[] param = new Microsoft.Reporting.WinForms.ReportParameter[27];


                string address = AppVars.objSubCompany.Address;
                string telNo   = string.Empty;


                string sortCode     = AppVars.objSubCompany.SortCode.ToStr();
                string accountNo    = AppVars.objSubCompany.AccountNo.ToStr();
                string accountTitle = AppVars.objSubCompany.AccountTitle.ToStr();
                string bank         = AppVars.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 = AppVars.objSubCompany.WebsiteUrl.ToStr();
                if (!string.IsNullOrEmpty(website))
                {
                    website += " , ";
                }

                website += "Email:" + AppVars.objSubCompany.EmailAddress.ToStr();


                string companyNumber = AppVars.objSubCompany.CompanyNumber.ToStr();
                if (!string.IsNullOrEmpty(companyNumber))
                {
                    companyNumber = "Company Number: " + companyNumber;
                }

                string vatNumber = AppVars.objSubCompany.CompanyVatNumber.ToStr();
                if (!string.IsNullOrEmpty(vatNumber))
                {
                    vatNumber = "VAT Number: " + vatNumber;
                }



                param[0] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Address", address);

                param[18] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Footer", AppVars.objSubCompany.WebsiteUrl.ToStr());

                param[14] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_MobileNo", "Mobile: " + AppVars.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: " + AppVars.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 = AppVars.objSubCompany.CompanyLogo != null ? AppVars.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", AppVars.objSubCompany.CompanyName.ToStr());



                int?driverId = this.DataSource.FirstOrDefault().DefaultIfEmpty().DriverId;

                var data = this.DataSource.FirstOrDefault().DefaultIfEmpty();


                telNo = "Tel No. " + AppVars.objSubCompany.TelephoneNo;

                if (!string.IsNullOrEmpty(accountNo))
                {
                    accountNo = "Account No : " + accountNo;
                }


                string className = "Taxi_AppMain.ReportDesigns.";
                if (IsCheck == 1)
                {
                    if (IsFareAndWaitingWise)
                    {
                        this.reportViewer1.LocalReport.ReportEmbeddedResource = className + "rptDriverCommisionTrasaction3.rdlc";
                    }
                    else
                    {
                        this.reportViewer1.LocalReport.ReportEmbeddedResource = className + "rptDriverCommisionTrasaction4.rdlc";
                    }
                }
                else
                {
                    this.reportViewer1.LocalReport.ReportEmbeddedResource = className + "rptDriverCommisionTrasaction2.rdlc";
                }

                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);


                string AccountBooking = string.Empty;
                string CashBooking    = string.Empty;



                Fleet_Driver obj             = General.GetObject <Fleet_Driver>(c => c.Id == driverId);
                decimal      DriverCommision = obj.DriverCommissionPerBooking.ToDecimal();



                decimal JobTotal = 0;
                if (this.IsFareAndWaitingWise)
                {
                    AccountBooking = string.Format("{0:£ #.##}", this.DataSource.Where(c => c.CompanyId != null).Sum(c => c.FareRate.ToDecimal() + c.WaitingCharges.ToDecimal()));
                    CashBooking    = string.Format("{0:£ #.##}", this.DataSource.Where(c => c.CompanyId == null).Sum(c => c.FareRate.ToDecimal() + c.WaitingCharges.ToDecimal()));
                    JobTotal       = this.DataSource.Sum(c => c.FareRate.Value.ToDecimal() + c.WaitingCharges.ToDecimal());
                }
                else
                {
                    AccountBooking = string.Format("{0:£ #.##}", this.DataSource.Where(c => c.CompanyId != null).Sum(c => c.FareRate.ToDecimal() + c.ParkingCharges.ToDecimal() + c.WaitingCharges.ToDecimal()));
                    CashBooking    = string.Format("{0:£ #.##}", this.DataSource.Where(c => c.CompanyId == null).Sum(c => c.FareRate.ToDecimal() + c.ParkingCharges.ToDecimal() + c.WaitingCharges.ToDecimal()));
                    JobTotal       = this.DataSource.Sum(c => c.FareRate.ToDecimal() + c.ParkingCharges.ToDecimal() + c.WaitingCharges.ToDecimal());
                }


                param[22] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_AccountJobTotal", AccountBooking);
                param[23] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_CashJobTotal", CashBooking);



                string Commision = (JobTotal * DriverCommision / 100).ToStr();


                if (AppVars.objPolicyConfiguration.PriceRangeWiseCommission.ToBool())
                {
                    List <Fleet_Driver_CommissionRange> listofRange = obj.Fleet_Driver_CommissionRanges.ToList();

                    if (listofRange.Count == 0)
                    {
                        listofRange = GetSystemCommissionRange();
                    }

                    Commision = Math.Round(this.DataSource
                                           .Sum(c => c.IsCommissionWise.ToBool() ? (c.DriverCommissionType == "Percent" ? ((c.TotalCharges * c.DriverCommissionOnBooking) / 100) : c.DriverCommissionOnBooking) : (((c.FareRate * listofRange.FirstOrDefault(a => c.TotalCharges >= a.FromPrice && c.FareRate <= a.ToPrice).DefaultIfEmpty().CommissionValue.ToDecimal()) / 100))).ToDecimal(), 2).ToStr();
                }


                param[24] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Commision", Commision);

                string DriverGrandTotal = "";

                if (this.DataSource != null)
                {
                    DriverGrandTotal = (this.DataSource[0].DriverCommision + this.DataSource[0].Extra + this.DataSource[0].fuel + this.DataSource[0].OldBalance).ToStr();
                }

                param[25] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_GrandTotal", DriverGrandTotal);

                int cnt = this.DataSource.Count;
                param[26] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_jobCount", cnt.ToStr());
                reportViewer1.LocalReport.SetParameters(param);



                this.vu_DriverCommisionBindingSource.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);
            }
        }
        private bool IsDriverDocumentExpired(int driverId, Fleet_Driver ObjDriver)
        {
            bool rtn = false;

            try
            {
                if (ObjDriver == null)
                {
                    ObjDriver = General.GetObject <Fleet_Driver>(c => c.Id == driverId);
                }

                if (ObjDriver != null)
                {
                    string msg = string.Empty;


                    DateTime nowDate        = DateTime.Now.ToDate();
                    DateTime?pickupDateTime = ObjMaster.Current.PickupDateTime;



                    if (ObjDriver.MOTExpiryDate != null && (ObjDriver.MOTExpiryDate.ToDate() < nowDate || ObjDriver.MOTExpiryDate.ToDate() < pickupDateTime.ToDate()))
                    {
                        if (ObjDriver.MOTExpiryDate.ToDate() < nowDate)
                        {
                            msg += "Driver MOT Expired :       " + string.Format("{0:dd/MM/yyyy}", ObjDriver.MOTExpiryDate) + Environment.NewLine;
                        }
                        else
                        {
                            msg += "Driver MOT is Expiring at :       " + string.Format("{0:dd/MM/yyyy}", ObjDriver.MOTExpiryDate) + Environment.NewLine;
                        }
                    }
                    if (ObjDriver.MOT2ExpiryDate != null && ObjDriver.MOT2ExpiryDate.ToDate() < nowDate)
                    {
                        // if (ObjDriver.MOT2ExpiryDate.ToDate() < nowDate)
                        msg += "Driver MOT 2 Expired :    " + string.Format("{0:dd/MM/yyyy}", ObjDriver.MOT2ExpiryDate) + Environment.NewLine;
                        //else
                        //    msg += "Driver MOT 2 is Expiring :    " + string.Format("{0:dd/MM/yyyy}", ObjDriver.MOT2ExpiryDate) + Environment.NewLine;
                    }
                    if (ObjDriver.InsuranceExpiryDate != null && (ObjDriver.InsuranceExpiryDate < nowDate || ObjDriver.InsuranceExpiryDate < pickupDateTime))
                    {
                        if (ObjDriver.InsuranceExpiryDate < nowDate)
                        {
                            msg += "Insurance Expired :          " + string.Format("{0:dd/MM/yyyy HH:mm}", ObjDriver.InsuranceExpiryDate) + Environment.NewLine;
                        }
                        else
                        {
                            msg += "Insurance is Expiring at :          " + string.Format("{0:dd/MM/yyyy HH:mm}", ObjDriver.InsuranceExpiryDate) + Environment.NewLine;
                        }
                    }

                    if (ObjDriver.PCODriverExpiryDate != null && (ObjDriver.PCODriverExpiryDate.ToDate() < nowDate || ObjDriver.PCODriverExpiryDate.ToDate() < pickupDateTime.ToDate()))
                    {
                        if (ObjDriver.PCODriverExpiryDate.ToDate() < nowDate)
                        {
                            msg += "PCO Driver Expired :       " + string.Format("{0:dd/MM/yyyy}", ObjDriver.PCODriverExpiryDate) + Environment.NewLine;
                        }
                        else
                        {
                            msg += "PCO Driver is Expiring at :        " + string.Format("{0:dd/MM/yyyy}", ObjDriver.PCODriverExpiryDate) + Environment.NewLine;
                        }
                    }

                    if (ObjDriver.PCOVehicleExpiryDate != null && (ObjDriver.PCOVehicleExpiryDate.ToDate() < nowDate || ObjDriver.PCOVehicleExpiryDate.ToDate() < pickupDateTime.ToDate()))
                    {
                        if (ObjDriver.PCOVehicleExpiryDate.ToDate() < nowDate)
                        {
                            msg += "PCO Vehicle Expired :     " + string.Format("{0:dd/MM/yyyy}", ObjDriver.PCOVehicleExpiryDate) + Environment.NewLine;
                        }
                        else
                        {
                            msg += "PCO Vehicle is Expiring at :      " + string.Format("{0:dd/MM/yyyy}", ObjDriver.PCOVehicleExpiryDate) + Environment.NewLine;
                        }
                    }

                    if (ObjDriver.DrivingLicenseExpiryDate != null && (ObjDriver.DrivingLicenseExpiryDate.ToDate() < nowDate || ObjDriver.DrivingLicenseExpiryDate.ToDate() < pickupDateTime.ToDate()))
                    {
                        if (ObjDriver.DrivingLicenseExpiryDate.ToDate() < nowDate)
                        {
                            msg += "Driving License Expired :  " + string.Format("{0:dd/MM/yyyy}", ObjDriver.DrivingLicenseExpiryDate) + Environment.NewLine;
                        }
                        else
                        {
                            msg += "Driving License is Expiring at :  " + string.Format("{0:dd/MM/yyyy}", ObjDriver.DrivingLicenseExpiryDate) + Environment.NewLine;
                        }
                    }

                    if (ObjDriver.RoadTaxiExpiryDate != null && (ObjDriver.RoadTaxiExpiryDate.ToDate() < nowDate || ObjDriver.RoadTaxiExpiryDate.ToDate() < pickupDateTime.ToDate()))
                    {
                        if (ObjDriver.RoadTaxiExpiryDate.ToDate() < nowDate)
                        {
                            msg += "Road Tax Expired :            " + string.Format("{0:dd/MM/yyyy}", ObjDriver.RoadTaxiExpiryDate);
                        }
                        else
                        {
                            msg += "Road Tax is Expiring at :            " + string.Format("{0:dd/MM/yyyy}", ObjDriver.RoadTaxiExpiryDate);
                        }
                    }


                    if (!string.IsNullOrEmpty(msg))
                    {
                        msg = "Cannot Allocate Driver" + Environment.NewLine + msg;
                        rtn = true;

                        ENUtils.ShowMessage(msg);
                    }
                }
            }
            catch (Exception ex)
            {
            }

            return(rtn);
        }
        private void EmailInvoices(long TransId)
        {
            bool IsSuccess = false;

            try
            {
                string subject = txtSubject.Text.Trim();

                if (string.IsNullOrEmpty(subject))
                {
                    ENUtils.ShowMessage("Required : Email Subject");
                    return;
                }


                if (txtBody.Text.Trim().Length > 0)
                {
                    subject += "||" + txtBody.Text;
                }

                List <GridViewRowInfo> rows = null;


                if (TransId == 0)
                {
                    rows = grdLister.Rows.Where(c => c.Cells["Check"].Value.ToBool() == true).ToList();
                }
                else
                {
                    rows = grdLister.Rows.Where(c => c.Cells["RentId"].Value.ToLong() == TransId).ToList();
                }



                //List<long> invoiceIds = rows.Select(c => c.Cells["RentId"].Value.ToLong()).ToList<long>();


                List <long> invoiceIds = new List <long>();

                if (TransId == 0)
                {
                    invoiceIds = rows.Select(c => c.Cells["RentId"].Value.ToLong()).ToList <long>();
                }
                else
                {
                    invoiceIds = new List <long>();
                    invoiceIds.Add(TransId);
                }


                if (invoiceIds.Count > 0)
                {
                    frmDriverRentTransactionExpensesReport3 frm = new frmDriverRentTransactionExpensesReport3(1);
                    frm.reportViewer1.Tag = "invoice";
                    var list  = General.GetQueryable <vu_DriverRentExpense>(a => invoiceIds.Contains(a.Id)).ToList();
                    var list2 = General.GetQueryable <vu_FleetDriverRentExpense>(a => invoiceIds.Contains(a.Id)).ToList();

                    List <Fleet_Driver> driversList = General.GetQueryable <Fleet_Driver>(c => c.DriverTypeId == 1).ToList();

                    frmEmail frmEmail = new frmEmail(null, "", "");

                    Fleet_Driver objDriver = null;
                    foreach (var item in rows.Where(c => c.Cells["Check"].Value.ToBool()))
                    {
                        if (optFullDetail.ToggleState == Telerik.WinControls.Enumerations.ToggleState.On)
                        {
                            frm.optFullDetail.ToggleState = Telerik.WinControls.Enumerations.ToggleState.On;
                        }
                        else if (optAccountJobs.ToggleState == Telerik.WinControls.Enumerations.ToggleState.On)
                        {
                            frm.optAccountJobs.ToggleState = Telerik.WinControls.Enumerations.ToggleState.On;
                        }
                        else if (optSummaryDetails.ToggleState == Telerik.WinControls.Enumerations.ToggleState.On)
                        {
                            frm.optSummaryDetails.ToggleState = Telerik.WinControls.Enumerations.ToggleState.On;
                        }
                        frm.DataSource  = list.Where(c => c.Id == item.Cells["RentId"].Value.ToLong()).OrderBy(c => c.PickupDate).ToList();
                        frm.DataSource2 = list2.Where(c => c.RentId == item.Cells["RentId"].Value.ToLong()).OrderBy(c => c.Date).ToList();
                        //    frm.objSubcompany = objSubcompany;
                        frm.objSubcompany = driversList.FirstOrDefault(C => C.Id == item.Cells["DriverId"].Value.ToInt()).DefaultIfEmpty().Gen_SubCompany.DefaultIfEmpty();

                        frm.GenerateReport(item.Cells["VAT"].Value.ToDecimal());

                        objDriver = driversList.FirstOrDefault(c => c.Id == item.Cells["DriverId"].Value.ToInt());
                        //string email = driversList.FirstOrDefault(c => c.Id == item.Cells[COLS.Id].Value.ToInt()).DefaultIfEmpty().Email.ToStr().Trim();
                        string email = "";

                        if (objDriver != null)
                        {
                            email = objDriver.Email.ToStr().Trim();
                        }

                        if (!string.IsNullOrEmpty(email))
                        {
                            IsSuccess = frm.SendEmailInternally(frmEmail, subject, objDriver.DriverNo.ToStr().Trim(), email);
                        }
                    }


                    if (frmEmail != null && frmEmail.IsDisposed == false)
                    {
                        frmEmail.Close();
                        GC.Collect();
                    }


                    if (IsSuccess)
                    {
                        RadDesktopAlert alert = new RadDesktopAlert();
                        alert.ContentText = "Email has been sent successfully";
                        alert.Show();
                    }
                    // ENUtils.ShowMessage("Email has been sent successfully");
                }
            }
            catch (Exception ex)
            {
                ENUtils.ShowMessage(ex.Message);
            }
        }
        private void LoginDriver()
        {
            try
            {
                bool IsValidate = false;

                List <int?> ids = grdDrivers.Rows.Where(c => c.Cells["colChk"].Value.ToBool()).Select(c => c.Cells["colId"].Value.ToIntorNull()).ToList();

                if (ids.Count == 0)
                {
                    IsValidate = true;
                    ENUtils.ShowMessage("Please select a Driver");
                    return;
                }

                //  List<int?> ids = lstDriver.SelectedItems.Select(c => c.Value.ToIntorNull()).ToList();

                using (TaxiDataContext db = new TaxiDataContext())
                {
                    if (db.Fleet_DriverQueueLists.Count(c => ids.Contains(c.DriverId) && c.Status == true) > 0)
                    {
                        ENUtils.ShowMessage("Some Selected Driver(s)  already in the Login List..");
                        IsValidate = true;
                        grdDrivers.Focus();
                        // lstDriver.Focus();
                        return;
                    }
                }

                //if (totalFleets> 0 &&  grdDrivers.Rows.Where(c=>c.Cells["colChk"].Value.ToBool().Any(c => c.Cells["colVeh"].Value.ToIntorNull()==null))
                //{
                //    ENUtils.ShowMessage("Required Vehicle");
                //    return;


                //}



                DriverQueueBO objMaster = null;
                int?          driverId  = null;
                string        driverNos = "";
                foreach (GridViewRowInfo row in grdDrivers.Rows.Where(c => c.Cells["colChk"].Value.ToBool()))
                {
                    driverId = row.Cells["colId"].Value.ToIntorNull();

                    objMaster = new DriverQueueBO();
                    objMaster.New();

                    objMaster.Current.DriverId      = driverId;
                    objMaster.Current.FleetMasterId = row.Cells["colVeh"].Value.ToIntorNull();

                    objMaster.Current.IsManualLogin = true;


                    if (objMaster.Current.FleetMasterId == null)
                    {
                        using (TaxiDataContext db = new TaxiDataContext())
                        {
                            int cnt = db.Fleet_Driver_PDASettings.Where(c => c.DriverId == objMaster.Current.DriverId && (c.HasCompanyCars != null && c.HasCompanyCars == true)).Count();


                            if (cnt > 0)
                            {
                                IsValidate = true;
                                ENUtils.ShowMessage("Required Vehicle");
                                break;
                            }
                        }
                    }
                    else
                    {
                        using (TaxiDataContext db = new TaxiDataContext())
                        {
                            int cnt = db.Fleet_DriverQueueLists.Where(c => c.Status == true && c.FleetMasterId == objMaster.Current.FleetMasterId).Count();


                            if (cnt > 0)
                            {
                                IsValidate = true;
                                ENUtils.ShowMessage("Driver is already loggedIn with this Vehicle");
                                break;
                            }
                        }
                    }


                    objMaster.Current.Status        = true;
                    objMaster.Current.LoginDateTime = DateTime.Now;
                    objMaster.Current.QueueDateTime = DateTime.Now;
                    objMaster.Current.WaitSinceOn   = DateTime.Now;


                    DateTime nowDate = DateTime.Now.ToDate();
                    TimeSpan TimeNow = DateTime.Now.TimeOfDay;
                    int?     LoginID = AppVars.LoginObj.LgroupId.ToInt();

                    bool manualuntickHasPda = true;
                    //     bool manualuntickHasPda = AppVars.listUserRights.Count(c => c.functionId == "DISABLE HASPDA ON MANUAL LOGIN DRIVER") > 0;


                    var data1 = General.GetQueryable <Fleet_Driver>(c => c.Id == driverId).AsEnumerable();
                    var data2 = General.GetQueryable <Fleet_Driver_Shift>(c => c.DriverId == driverId);
                    var query = (from a in data1
                                 join b in data2 on a.Id equals b.DriverId
                                 select new
                    {
                        DriverNo = a.DriverNo,
                        ShiftName = b.Driver_Shift.ShiftName,
                        FTime = b.FromTime.Value.TimeOfDay,
                        TTime = b.ToTime.Value.TimeOfDay,
                    }).AsQueryable();
                    DataTable dt     = query.ToDataTable();
                    string    ShiftN = "";

                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        ShiftN += dt.Rows[i]["ShiftName"].ToStr() + " " + dt.Rows[i]["FTime"].ToStr().Substring(0, 5) + " to " + dt.Rows[i]["TTime"].ToStr().Substring(0, 5) + " ";
                    }



                    Fleet_Driver obj      = General.GetObject <Fleet_Driver>(c => c.Id == driverId);
                    string       DriverNo = obj.DriverNo.ToStr();

                    if (General.GetQueryable <Fleet_Driver_Shift>(c => c.DriverId == driverId && c.Driver_Shift_ID == 7).Count() > 0)
                    {
                        if (General.GetQueryable <Fleet_Driver>(c => c.Id == driverId && c.MOTExpiryDate < nowDate || c.MOTExpiryDate == null && c.MOT2ExpiryDate < nowDate || c.MOT2ExpiryDate == null && c.DrivingLicenseExpiryDate < nowDate || c.DrivingLicenseExpiryDate == null && c.PCODriverExpiryDate < nowDate || c.PCODriverExpiryDate == null && c.PCOVehicleExpiryDate < nowDate || c.PCOVehicleExpiryDate == null).Count(c => ids.Contains(c.Id)) > 0)
                        {
                            if (LoginID == 2)
                            {
                                IsValidate = true;
                                ENUtils.ShowMessage("Driver License Is Expire Driver Not Login..");
                                return;
                            }
                        }
                        driverNos += "," + row.Cells["DriverNo"].Value.ToStr();


                        objMaster.IsManualLoggedInUnTickHasPDA = manualuntickHasPda;

                        objMaster.Save();
                    }
                    else
                    {
                        if (General.GetQueryable <Fleet_Driver_Shift>(c => c.DriverId == driverId && c.FromTime.Value.TimeOfDay < TimeNow && c.ToTime.Value.TimeOfDay > TimeNow).Count() > 0)
                        {
                            if (General.GetQueryable <Fleet_Driver>(c => c.Id == driverId && c.MOTExpiryDate < nowDate || c.MOTExpiryDate == null && c.MOT2ExpiryDate < nowDate || c.MOT2ExpiryDate == null && c.DrivingLicenseExpiryDate < nowDate || c.DrivingLicenseExpiryDate == null && c.PCODriverExpiryDate < nowDate || c.PCODriverExpiryDate == null && c.PCOVehicleExpiryDate < nowDate || c.PCOVehicleExpiryDate == null).Count(c => ids.Contains(c.Id)) > 0)
                            {
                                if (LoginID == 2)
                                {
                                    IsValidate = true;
                                    ENUtils.ShowMessage("Driver License Is Expire Driver Not Login..");
                                    return;
                                }
                            }
                            driverNos += "," + row.Cells["DriverNo"].Value.ToStr();

                            objMaster.IsManualLoggedInUnTickHasPDA = manualuntickHasPda;
                            objMaster.Save();
                        }
                        else
                        {
                            IsValidate = true;
                            ENUtils.ShowMessage("Driver " + DriverNo + " not available \n Driver Shift: " + ShiftN);
                        }
                    }
                }

                General.RefreshListWithoutSelected <frmDriverLoginList>("frmDriverLoginList1");

                General.BroadCastRefreshWaitingDrivers();

                if (IsValidate == false)
                {
                    try
                    {
                        if (driverNos.ToStr().StartsWith(","))
                        {
                            driverNos = driverNos.Remove(0, 1);
                        }

                        if (driverNos.ToStr().EndsWith(","))
                        {
                            driverNos = driverNos.Remove(driverNos.Length - 1);
                        }

                        //GridViewComboBoxColumn comboBoxColumn = this.radGridView1.Columns["column"] as GridViewComboBoxColumn;
                        //object value = this.radGridView1.Rows[0].Cells["SupplierColumn"].Value;
                        //string text = (string)comboBoxColumn.GetLookupValue(value);
                    }
                    catch
                    {
                    }

                    General.AddUserLog("Driver(s) (" + driverNos + ") Manually Login Controller", 3);



                    this.Close();
                }
            }
            catch (Exception ex)
            {
                ENUtils.ShowMessage(ex.Message);
            }
        }