Exemple #1
0
        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)
                {
                    frmDriverCommisionTransactionExpensesReport frm = new frmDriverCommisionTransactionExpensesReport(1);

                    var list  = General.GetQueryable <vu_DriverCommisionExpense>(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);
            }
        }
Exemple #2
0
        private void PrintStatement()
        {
            try
            {
                //        if (grdDriverRentLastStatement.Rows.Where(c => c.Cells["Check"].Value.ToBool() == true).Count() > 0)
                //        {
                //            foreach (var item in grdDriverRentLastStatement.Rows.Where(c => c.Cells["Check"].Value.ToBool() == true))
                //            {
                //                long Id = item.Cells[COLS.Id].Value.ToLong();
                //                ReportPrintDocument rpt = null;
                //                frmDriverCommisionTransactionExpensesReport2 frm = null;
                //                if (Id > 0)
                //                {
                //                    frm = new frmDriverCommisionTransactionExpensesReport2(1);
                //                    var list = General.GetQueryable<vu_DriverCommisionExpenses2>(a => a.Id == Id).OrderBy(c => c.PickupDate).ToList();
                //                    int count = list.Count;

                //                    frm.DataSource = list;
                //                    var list2 = General.GetQueryable<vu_FleetDriverCommissionExpense>(c => c.CommissionId == Id).OrderBy(c => c.Date).ToList();
                //                    frm.DataSource2 = list2;

                //                    frm.IsFareAndWaitingWise = this.IsFareAndWaitingWiseComm;

                //                    frm.GenerateReport();
                //                    rpt = new ReportPrintDocument(frm.reportViewer1.LocalReport);
                //                    rpt.Print();
                //                    rpt.Dispose();
                //                }
                //            }
                //        }
                //        else
                //        {
                //            ENUtils.ShowMessage("Please select statement to Print");
                //        }
                //    }
                //    catch (Exception ex)
                //    {
                //        ENUtils.ShowMessage(ex.Message);
                //    }
                //}



                if (grdDriverRentLastStatement.Rows.Where(c => c.Cells["Check"].Value.ToBool() == true).Count() > 0)
                {
                    //foreach (var item in grdDriverRentLastStatement.Rows.Where(c => c.Cells["Check"].Value.ToBool() == true))
                    //{
                    //    long Id = item.Cells[COLS.Id].Value.ToLong();
                    //    ReportPrintDocument rpt = null;
                    //    frmDriverCommisionTransactionExpensesReport3 frm = null;
                    //    if (Id > 0)
                    //    {
                    //        frm = new frmDriverCommisionTransactionExpensesReport3(1);
                    //        var list = General.GetQueryable<vu_DriverCommisionExpenses2>(a => a.Id == Id).OrderBy(c => c.PickupDate).ToList();
                    //        int count = list.Count;

                    //        frm.DataSource = list;
                    //        var list2 = General.GetQueryable<vu_FleetDriverCommissionExpense>(c => c.CommissionId == Id).OrderBy(c => c.Date).ToList();
                    //        frm.DataSource2 = list2;

                    //        frm.IsFareAndWaitingWise = this.IsFareAndWaitingWiseComm;

                    //        frm.GenerateReport();
                    //        rpt = new ReportPrintDocument(frm.reportViewer1.LocalReport);
                    //        rpt.Print();
                    //        rpt.Dispose();
                    //    }
                    //}



                    var rows = grdDriverRentLastStatement.Rows.Where(c => c.Cells["Check"].Value.ToBool() == true).ToList();

                    var list = (from a in rows.Where(c => c.Cells[COLS.Id].Value.ToInt() > 0)
                                select new
                    {
                        CommissionId = a.Cells[COLS.Id].Value.ToInt(),
                        DriverId = a.Cells[COLS.DriverId].Value.ToInt(),
                        Driver = a.Cells[COLS.DriverNo].Value.ToStr()
                    }).ToList();



                    if (list.Count > 0)
                    {
                        frmDriverCommisionTransactionExpensesReport frm = new frmDriverCommisionTransactionExpensesReport(list, DateTime.Now.ToDate(), DateTime.Now.ToDate());
                        frm.ShowDialog();
                        frm.Dispose();
                    }
                }
                else
                {
                    ENUtils.ShowMessage("Please select statement to Print");
                }
            }
            catch (Exception ex)
            {
                ENUtils.ShowMessage(ex.Message);
            }
        }
Exemple #3
0
        //public bool SendEmailInternally(frmEmail frmE, string subject, string invoiceNo, string email)
        //{

        //    frmE.ReportViewer1 = this.reportViewer1;
        //    frmE.FileTitle = "Commission for " + invoiceNo.ToStr();
        //    frmE.EmailSubject = subject;
        //    frmE.ToEmail = email;
        //    frmE.txtTo.Text = email;
        //    frmE.txtSubject.Text = subject;
        //    frmE.txtAttachment.Text = "Commission for " + invoiceNo;

        //    frmE.SendEmail(true);

        //    return frmE.IsEmailSent;
        //    //         General.ShowEmailForm(reportViewer1, "Account Invoice # " + invoiceNo, email);

        //}


        private void PrintDocument(long TransId)
        {
            try
            {
                try
                {
                    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 = 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)
                    {
                        frmDriverCommisionTransactionExpensesReport frm = new frmDriverCommisionTransactionExpensesReport(1);
                        frm.CompanyHeader = AppVars.objSubCompany.CompanyName.ToStr().Trim();

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


                        List <Fleet_Driver> driversList = General.GetGeneralList <Fleet_Driver>(c => c.DriverTypeId == 2);
                        frmEmail            frmEmail    = new frmEmail(null, "", "");


                        foreach (var item in rows)
                        {
                            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();

                            ReportPrintDocument rpt = new ReportPrintDocument(frm.reportViewer1.LocalReport);
                            rpt.Print();
                            rpt.Dispose();
                        }
                    }
                }
                catch (Exception ex)
                {
                    ENUtils.ShowMessage(ex.Message);
                }
            }
            catch (Exception ex)
            {
            }
        }