Пример #1
0
        void grdLister_CommandCellClick(object sender, EventArgs e)
        {
            GridCommandCellElement gridCell = (GridCommandCellElement)sender;

            if (gridCell.ColumnInfo.Name == "btnDelete")
            {
                GridViewRowInfo row = gridCell.RowInfo;

                if (row is GridViewDataRowInfo)
                {
                    long TranId = row.Cells["TransId"].Value.ToLong();


                    if (TranId > 0)
                    {
                        try
                        {
                            int Id      = row.Cells["Id"].Value.ToInt();
                            int TransId = row.Cells["TransId"].Value.ToInt();

                            using (TaxiDataContext db = new TaxiDataContext())
                            {
                                if (db.GetTable <Fleet_DriverWeeklyRentHistory_Detail>().Count(c => c.TransId == TransId) == 1)
                                {
                                    Fleet_DriverWeeklyRentHistory objHistory = db.GetTable <Fleet_DriverWeeklyRentHistory>().FirstOrDefault(c =>
                                                                                                                                            (c.Id == TranId));


                                    if (objHistory != null)
                                    {
                                        db.Fleet_DriverWeeklyRentHistories.DeleteOnSubmit(objHistory);
                                        db.SubmitChanges();
                                    }
                                }
                                else
                                {
                                    Fleet_DriverWeeklyRentHistory_Detail objDetail = db.Fleet_DriverWeeklyRentHistory_Details.FirstOrDefault(c => c.Id == Id);


                                    if (objDetail != null)
                                    {
                                        db.Fleet_DriverWeeklyRentHistory_Details.DeleteOnSubmit(objDetail);
                                        db.SubmitChanges();
                                    }
                                }
                            }


                            PopulateData();
                        }
                        catch (Exception ex)
                        {
                            ENUtils.ShowMessage(ex.Message);
                        }
                    }
                }
            }
        }
        private List <object[]> ShowCustomerInvoiceBookingMultiLister(Expression <Func <Booking, bool> > _condition, Expression <Func <Invoice_Charge, bool> > _invoiceCondition, string[] hiddenColumns, DateTime?fromDate, DateTime?tillDate)
        {
            Taxi_Model.TaxiDataContext db = new TaxiDataContext();

            var list1 = db.GetTable <Booking>().Where(_condition).Where(b => b.PickupDateTime.Value.Date >= fromDate && b.PickupDateTime.Value.Date <= tillDate).AsEnumerable();
            var list2 = db.GetTable <Invoice_Charge>().Where(_invoiceCondition);

            var list = (from b in list1
                        join c in list2 on b.Id equals c.BookingId into table2
                        from c in table2.DefaultIfEmpty()
                        where (c == null)
                        select new
            {
                Id = b.Id,


                BookingDate = b.BookingDate,
                PickupDate = b.PickupDateTime,

                RefNo = b.BookingNo,
                Vehicle = b.Fleet_VehicleType.VehicleType,
                OrderNo = b.OrderNo,
                PupilNo = b.PupilNo,
                Passenger = b.CustomerName,
                PickupPoint = b.FromAddress,
                Destination = b.ToAddress,
                Charges = b.CustomerPrice.ToDecimal(),

                CompanyId = b.CompanyId,
                CompanyName = b.CompanyId != null ? b.Gen_Company.CompanyName : "",
                Parking = b.ParkingCharges.ToDecimal(),
                Waiting = b.WaitingCharges.ToDecimal(),
                ExtraDrop = b.ExtraDropCharges.ToDecimal(),
                MeetAndGreet = b.MeetAndGreetCharges.ToDecimal(),
                Congtion = b.CongtionCharges.ToDecimal(),
                Total = b.TotalCharges.ToDecimal(),
                PaymentTypeId = b.PaymentTypeId
            }).ToList();


            frmLister frm = new frmLister(list, "Id", true, hiddenColumns);


            frm.HiddenColumns = hiddenColumns;
            frm.ShowDialog();

            return(frm.ListofData);
        }
        private void btnDeleteHistory_Click(object sender, EventArgs e)
        {
            try
            {
                int RangeId = ddlDateRange.SelectedValue.ToInt();


                if (RangeId == 0)
                {
                    ENUtils.ShowMessage("Please select a DateRange History");
                    return;
                }

                using (TaxiDataContext db = new TaxiDataContext())
                {
                    Fleet_DriverCommissionCollectionHistory objHistory = db.GetTable <Fleet_DriverCommissionCollectionHistory>().FirstOrDefault(c =>
                                                                                                                                                (c.Id == RangeId));


                    if (objHistory != null)
                    {
                        db.Fleet_DriverCommissionCollectionHistories.DeleteOnSubmit(objHistory);
                        db.SubmitChanges();
                    }
                }


                ComboFunctions.FillDriverCommissionCollectionHistoryCombo(ddlDateRange);
                grdLister.Rows.Clear();
            }
            catch (Exception ex)
            {
                ENUtils.ShowMessage(ex.Message);
            }
        }
        private void FillSubCompanyCombo()
        {
            try
            {
                using (TaxiDataContext db = new TaxiDataContext())
                {
                    ddlSubCompany.DisplayMember = "CompanyName";
                    ddlSubCompany.ValueMember   = "Id";
                    ddlSubCompany.DataSource    = db.GetTable <Gen_SubCompany>().Select(args => new { args.Id, args.CompanyName }).ToList();

                    ddlSubCompany.DropDownStyle = ComboBoxStyle.DropDownList;
                    ddlSubCompany.SelectedValue = AppVars.objSubCompany.Id;
                }
            }
            catch (Exception ex)
            {
                ENUtils.ShowMessage(ex.Message);
            }
        }
        private void btnCustomerLister_Click(object sender, EventArgs e)
        {
            try
            {
                string mobNo = txtMobileNo.Text.Trim();
                string telNo = txtTelephoneNo.Text.Trim();

                using (TaxiDataContext db = new TaxiDataContext())
                {
                    var list = db.GetTable <Customer>().Where(c => c.Name != "" && (c.MobileNo == mobNo || mobNo == "") && (c.TelephoneNo == telNo || telNo == ""))

                               .Select(args => new
                    {
                        args.Id,
                        args.Name,
                        args.DoorNo,
                        args.Address1,
                        args.TelephoneNo,
                        args.MobileNo,
                    }).OrderBy(c => c.Name).ToList();

                    object[] obj = ShowFormLister(list, "Id");


                    if (obj != null)
                    {
                        txtCustomerName.Text = obj[2].ToStr();

                        txtDoorNo.Text   = obj[3].ToStr();
                        txtAddress1.Text = obj[4].ToStr();
                        // ddlCustomer.SelectedValue = obj[1].ToInt();
                        //txtAddress1.Text = obj[2].ToStr();
                        //txtTelephoneNo.Text = obj[3].ToStr().Trim();
                        //txtMobileNo.Text = obj[4].ToStr().Trim();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private void PopulateData()
        {
            using (TaxiDataContext db = new TaxiDataContext())
            {
                Table <Fare_IncrementSetting> Fare = db.GetTable <Fare_IncrementSetting>();

                var list = from c in Fare
                           select new FareIncreament
                {
                    Id = c.Id,
                    IsFareIncreament = c.EnableIncrement,
                    FromDateTime     = c.FromDate,
                    TillDateTime     = c.TillDate,
                    IncreamentRate   = Convert.ToDecimal(c.IncrementRate),
                    IncreamentType   = c.IncrementType,
                    CriteriaBy       = c.CriteriaBy
                };



                grdFareIncreament.DataSource = list.ToList();

                //var query = from c in General.GetQueryable<Fare_IncrementSetting>(null).AsEnumerable()

                //			select new
                //			{
                //				Id = c.Id,
                //				EnableIncrement = c.EnableIncrement,
                //				FromDate = c.FromDate,
                //				TillDate = c.TillDate,
                //				IncrementRate = c.IncrementRate,
                //				IncrementType = c.IncrementType,
                //			};

                //grdFareIncreament.DataSource = list.ToList();

                (grdFareIncreament.Columns["FromDateTime"] as GridViewDateTimeColumn).FormatString = "{0:dd/MM/yyyy HH:mm}";
                (grdFareIncreament.Columns["TillDateTime"] as GridViewDateTimeColumn).FormatString = "{0:dd/MM/yyyy HH:mm}";



                grdFareIncreament.Columns["CriteriaBy"].IsVisible        = false;
                grdFareIncreament.Columns["Id"].IsVisible                = false;
                grdFareIncreament.Columns["IsFareIncreament"].HeaderText = "Active";
                grdFareIncreament.Columns["FromDateTime"].HeaderText     = "From Date/Time";
                grdFareIncreament.Columns["TillDateTime"].HeaderText     = "Till Date/Time";
                grdFareIncreament.Columns["IncreamentType"].HeaderText   = "Type";
                grdFareIncreament.Columns["IncreamentRate"].HeaderText   = "Rate";

                grdFareIncreament.Columns["FromDateTime"].Width   = 120;
                grdFareIncreament.Columns["TillDateTime"].Width   = 120;
                grdFareIncreament.Columns["IncreamentType"].Width = 100;
                grdFareIncreament.Columns["IncreamentRate"].Width = 100;


                if (grdFareIncreament.Rows.Count > 0)
                {
                    chkEnableIncrement.Checked = grdFareIncreament.Rows[0].Cells["IsFareIncreament"].Value.ToBool();
                }
            }

            GridViewCommandColumn col = new GridViewCommandColumn();

            col.Width = 60;

            col.Name           = "delete";
            col.UseDefaultText = true;
            col.ImageLayout    = System.Windows.Forms.ImageLayout.Center;
            col.DefaultText    = "Delete";
            col.TextAlignment  = System.Drawing.ContentAlignment.MiddleCenter;

            grdFareIncreament.Columns.Add(col);
            grdFareIncreament.CommandCellClick += GrdFareIncreament_CommandCellClick;
        }
        public override void PopulateData()
        {
            //Start lines adil 21/5/13
            string searchTxt = txtSearch.Text.ToLower().Trim();
            string col       = ddlColumns.Text.Trim().ToLower();


            bool col_driverno = false;
            bool col_name     = false;

            if (col == string.Empty)
            {
                col_name = true;
            }

            else if (col == "driverno")
            {
                col_driverno = true;
            }
            else if (col == "name")
            {
                col_name = true;
            }



            //End of lines



            //var data1 = General.GetQueryable<Fleet_DriverQueueList>(null).AsEnumerable().OrderBy(item => item.Fleet_Driver.DriverNo, new NaturalSortComparer<string>());

            //var query = (from a in data1
            //             where a.Status.ToBool() &&
            //               ((col_driverno && (a.Fleet_Driver.DriverNo.ToStr().ToLower()== searchTxt
            //               || searchTxt == string.Empty))
            //               || (col_name && (a.Fleet_Driver.DriverName.ToStr().ToLower().Contains(searchTxt)
            //               || searchTxt == string.Empty)) )


            //             select new
            //             {
            //                 Id = a.Id,
            //                 DriverId = a.Fleet_Driver.Id,
            //                 DriverNo = a.Fleet_Driver.DriverNo,
            //                 Name = a.Fleet_Driver.DriverName,
            //                 LoginDateTime = a.LoginDateTime
            //             }).ToList();


            //   var data1 = General.GetQueryable<Fleet_DriverQueueList>(null).AsEnumerable().OrderBy(item => item.Fleet_Driver.DriverNo, new NaturalSortComparer<string>());

            using (TaxiDataContext db = new TaxiDataContext())
            {
                var query = (from a in db.GetTable <Fleet_DriverQueueList>()
                             where a.Status != null && a.Status == true &&
                             ((col_driverno && (a.Fleet_Driver.DriverNo.ToLower() == searchTxt ||
                                                searchTxt == string.Empty)) ||
                              (col_name && (a.Fleet_Driver.DriverName.ToLower().Contains(searchTxt) ||
                                            searchTxt == string.Empty)))


                             select new
                {
                    Id = a.Id,
                    DriverId = a.Fleet_Driver.Id,
                    DriverNo = a.Fleet_Driver.DriverNo,
                    Name = a.Fleet_Driver.DriverName,
                    LoginDateTime = a.LoginDateTime
                }).ToList().OrderBy(item => item.DriverNo, new NaturalSortComparer <string>());


                grdLister.DataSource = query;
            }

            lblTotalLogins.Text = "Total Login Driver(s) : " + grdLister.Rows.Count.ToStr();
        }
        private void DeleteDriverPayment()
        {
            try
            {
                string Error = string.Empty;
                if (grdLister.Rows.Count() > 0 && grdLister.Rows.Count(c => c.Cells["Check"].Value.ToBool() == true) == 0)
                {
                    Error = "Please select record to delete";
                }

                if (!string.IsNullOrEmpty(Error))
                {
                    ENUtils.ShowMessage(Error);
                    return;
                }
                //long TranId = row.Cells[COLS.TranId].Value.ToLong();
                int  Id      = 0;
                int  TransId = 0;
                long TranId  = 0;
                if (grdLister.Rows.Count(c => c.Cells["Check"].Value.ToBool() == true) > 0)
                {
                    if (DialogResult.Yes == RadMessageBox.Show("Are you sure you want to delete Driver Payment", "", MessageBoxButtons.YesNo, RadMessageIcon.Question))
                    {
                        foreach (var item in grdLister.Rows.Where(c => c.Cells["Check"].Value.ToBool() == true))
                        {
                            //long TranId = row.Cells["TranId"].Value.ToLong();
                            Id      = item.Cells["Id"].Value.ToInt();
                            TransId = item.Cells["TranId"].Value.ToInt();
                            TranId  = item.Cells["TranId"].Value.ToLong();

                            if (TranId > 0)
                            {
                                try
                                {
                                    using (TaxiDataContext db = new TaxiDataContext())
                                    {
                                        if (db.GetTable <Fleet_DriverCommissionCollectionHistory_Detail>().Count(c => c.TransId == TransId) == 1)
                                        {
                                            Fleet_DriverCommissionCollectionHistory objHistory = db.GetTable <Fleet_DriverCommissionCollectionHistory>().FirstOrDefault(c =>
                                                                                                                                                                        (c.Id == TranId));


                                            if (objHistory != null)
                                            {
                                                db.Fleet_DriverCommissionCollectionHistories.DeleteOnSubmit(objHistory);
                                                db.SubmitChanges();
                                            }
                                        }
                                        else
                                        {
                                            Fleet_DriverCommissionCollectionHistory_Detail objDetail = db.Fleet_DriverCommissionCollectionHistory_Details.FirstOrDefault(c => c.Id == Id);


                                            if (objDetail != null)
                                            {
                                                db.Fleet_DriverCommissionCollectionHistory_Details.DeleteOnSubmit(objDetail);
                                                db.SubmitChanges();
                                            }
                                        }
                                    }
                                }
                                catch (Exception ex)
                                {
                                    ENUtils.ShowMessage(ex.Message);
                                }
                            }
                        }
                        PopulateData();
                    }
                }
            }
            catch (Exception ex)
            {
                ENUtils.ShowMessage(ex.Message);
            }
        }
Пример #9
0
        private void btnExport_Click(object sender, EventArgs e)
        {
            try
            {
                if (DialogResult.OK == saveFileDialog1.ShowDialog())
                {
                    if (radGridView1 == null)
                    {
                        InitializeExportGrid();
                    }

                    DateTime recentDays = DateTime.Now.AddDays(-1);

                    //   radGridView1.VirtualMode = true;
                    radGridView1.Columns.Clear();
                    radGridView1.Columns.Add(new GridViewTextBoxColumn("RefNo", "RefNo"));

                    radGridView1.Columns.Add(new GridViewTextBoxColumn("PickupDate", "PickupDate"));
                    radGridView1.Columns.Add(new GridViewTextBoxColumn("From", "From"));
                    radGridView1.Columns.Add(new GridViewTextBoxColumn("To", "To"));
                    radGridView1.Columns.Add(new GridViewTextBoxColumn("Customer", "Customer"));
                    radGridView1.Columns.Add(new GridViewTextBoxColumn("Telephone", "Telephone"));
                    radGridView1.Columns.Add(new GridViewTextBoxColumn("MobileNo", "MobileNo"));

                    radGridView1.Columns.Add(new GridViewTextBoxColumn("Account", "Account"));
                    radGridView1.Columns.Add(new GridViewTextBoxColumn("Vehicle", "Vehicle"));
                    radGridView1.Columns.Add(new GridViewTextBoxColumn("Price", "Price"));
                    radGridView1.Columns.Add(new GridViewTextBoxColumn("Drv", "Drv"));

                    radGridView1.Columns.Add(new GridViewTextBoxColumn("Status", "Status"));


                    int bookingstatusId = ddlColumns.SelectedValue.ToInt();



                    DateTime?fromDate = dtpFromDate.Value.ToDateorNull();
                    DateTime?toDate   = dtpToDate.Value.ToDateorNull();


                    using (TaxiDataContext db = new TaxiDataContext())
                    {
                        var query = (from a in db.GetTable <ArchiveBooking>().Where(c => (bookingstatusId == 0 || c.BookingStatusId == bookingstatusId) &&
                                                                                    ((fromDate == null || c.PickupDateTime.Value.Date >= fromDate) && (toDate == null || c.PickupDateTime.Value.Date <= toDate)
                                                                                    )


                                                                                    )


                                     join b in db.GetTable <Fleet_VehicleType>() on a.VehicleTypeId equals b.Id
                                     join ee in db.GetTable <BookingStatus>() on a.BookingStatusId equals ee.Id

                                     join c in db.GetTable <Fleet_Driver>() on a.DriverId equals c.Id into table2
                                     from z in table2.DefaultIfEmpty()
                                     join d in db.GetTable <Gen_Company>() on a.CompanyId equals d.Id into table3
                                     from acc in table3.DefaultIfEmpty()


                                     select new
                        {
                            Id = a.Id,
                            RefNumber = a.BookingNo,
                            BookingDate = a.BookingDate,
                            PickupDate = a.PickupDateTime,
                            Passenger = a.CustomerName,
                            TelephoneNo = a.CustomerPhoneNo,
                            MobileNo = a.CustomerMobileNo,
                            From = a.FromDoorNo != string.Empty ? a.FromDoorNo + " - " + a.FromAddress : a.FromAddress,
                            To = a.ToDoorNo != string.Empty ? a.ToDoorNo + " - " + a.ToAddress : a.ToAddress,
                            Fare = a.FareRate,
                            Account = acc != null ? acc.CompanyName : "",
                            Driver = z != null ? z.DriverNo : "",
                            DriverId = a.DriverId,
                            Vehicle = b.VehicleType,
                            Status = ee.StatusName,
                            StatusColor = ee.BackgroundColor,
                            BookingTypeId = a.BookingTypeId,
                            VehicleBgColor = b.BackgroundColor,
                            VehicleTextColor = b.TextColor,
                            BackgroundColor1 = acc.BackgroundColor,
                            TextColor1 = acc.TextColor,

                            FromLocTypeId = a.FromLocTypeId,
                            ToLocTypeId = a.ToLocTypeId,
                        }).OrderByDescending(c => c.PickupDate).ToList();



                        radGridView1.RowCount = query.Count;
                        for (int i = 0; i < query.Count; i++)
                        {
                            radGridView1.Rows[i].Cells["RefNo"].Value = query[i].RefNumber;

                            radGridView1.Rows[i].Cells["PickupDate"].Value = " " + string.Format("{0:dd/MM/yyyy HH:mm}", query[i].PickupDate) + " ";
                            radGridView1.Rows[i].Cells["From"].Value       = query[i].From;
                            radGridView1.Rows[i].Cells["To"].Value         = query[i].To;
                            radGridView1.Rows[i].Cells["Customer"].Value   = query[i].Passenger;
                            radGridView1.Rows[i].Cells["Telephone"].Value  = " " + query[i].TelephoneNo + " ";
                            radGridView1.Rows[i].Cells["MobileNo"].Value   = " " + query[i].MobileNo + " ";

                            radGridView1.Rows[i].Cells["Account"].Value = query[i].Account;
                            radGridView1.Rows[i].Cells["Vehicle"].Value = query[i].Vehicle;
                            radGridView1.Rows[i].Cells["Drv"].Value     = query[i].Driver;

                            radGridView1.Rows[i].Cells["Price"].Value  = query[i].Fare;
                            radGridView1.Rows[i].Cells["Status"].Value = query[i].Status;
                        }


                        radGridView1.Columns["RefNo"].HeaderText = "Ref #";

                        radGridView1.Columns["PickupDate"].HeaderText = "Pickup Date-Time";

                        radGridView1.Columns["From"].HeaderText = "Pick-up Address";
                        radGridView1.Columns["To"].HeaderText   = "Drop-off Address";


                        exporter = new RadGridViewExcelExporter();
                        BackgroundWorker worker = new BackgroundWorker();
                        worker.DoWork             += new DoWorkEventHandler(worker_DoWork);
                        worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bg_RunWorkerCompleted);
                        worker.RunWorkerAsync(saveFileDialog1.FileName);
                        exporter.Progress += new ProgressHandler(exportProgress);

                        this.btnExport.Enabled = false;
                    }
                }
            }
            catch (Exception ex)
            {
                ENUtils.ShowMessage(ex.Message);
            }
        }
Пример #10
0
        public override void PopulateData()
        {
            try
            {
                int bookingstatusId = ddlColumns.SelectedValue.ToInt();

                DateTime?fromDate = dtpFromDate.Value.ToDateorNull();
                DateTime?toDate   = dtpToDate.Value.ToDateorNull();

                using (TaxiDataContext db = new TaxiDataContext())
                {
                    var query = (from a in db.GetTable <ArchiveBooking>().Where(c => (bookingstatusId == 0 || c.BookingStatusId == bookingstatusId) &&
                                                                                ((fromDate == null || c.PickupDateTime.Value.Date >= fromDate) && (toDate == null || c.PickupDateTime.Value.Date <= toDate)
                                                                                )

                                                                                )

                                 join b in db.GetTable <Fleet_VehicleType>() on a.VehicleTypeId equals b.Id
                                 join e in db.GetTable <BookingStatus>() on a.BookingStatusId equals e.Id

                                 join c in db.GetTable <Fleet_Driver>() on a.DriverId equals c.Id into table2
                                 from z in table2.DefaultIfEmpty()
                                 join d in db.GetTable <Gen_Company>() on a.CompanyId equals d.Id into table3
                                 from acc in table3.DefaultIfEmpty()

                                 select new
                    {
                        Id = a.Id,
                        RefNumber = a.BookingNo,
                        BookingDate = a.BookingDate,
                        PickupDate = a.PickupDateTime,
                        Passenger = a.CustomerName,
                        ContactNo = a.CustomerMobileNo != null && a.CustomerMobileNo != "" ? a.CustomerMobileNo + Environment.NewLine + a.CustomerPhoneNo : a.CustomerPhoneNo,
                        From = a.FromDoorNo != string.Empty ? a.FromDoorNo + " - " + a.FromAddress : a.FromAddress,
                        To = a.ToDoorNo != string.Empty ? a.ToDoorNo + " - " + a.ToAddress : a.ToAddress,
                        Fare = a.FareRate,
                        Account = acc != null ? acc.CompanyName : "",
                        Driver = z != null ? z.DriverNo : "",
                        DriverId = a.DriverId,
                        Vehicle = b.VehicleType,
                        Status = e.StatusName,
                        StatusColor = e.BackgroundColor,
                        BookingTypeId = a.BookingTypeId,
                        VehicleBgColor = b.BackgroundColor,
                        VehicleTextColor = b.TextColor,
                        BackgroundColor1 = acc.BackgroundColor,
                        TextColor1 = acc.TextColor,
                        MobileNo = a.CustomerMobileNo,
                        FromLocTypeId = a.FromLocTypeId,
                        ToLocTypeId = a.ToLocTypeId,
                    }).OrderByDescending(c => c.PickupDate).ToList();


                    //    this.grdLister.TableElement.BeginUpdate();

                    grdLister.DataSource = query;
                    //    this.grdLister.TableElement.EndUpdate();
                }
            }
            catch (Exception ex)
            {
            }
        }
Пример #11
0
        public override void PopulateData()
        {
            try
            {
                string searchTxt = txtSearch.Text.ToLower().Trim();
                string col       = ddlColumns.Text.Trim().ToLower();



                bool col_name     = false;
                bool col_phone    = false;
                bool col_mobileno = false;
                bool col_address  = false;
                bool col_doorno   = false;

                if (col == "name")
                {
                    col_name = true;
                }

                else if (col == "phone")
                {
                    col_phone = true;
                }

                else if (col == "mobileno")
                {
                    col_mobileno = true;
                }

                else if (col == "address")
                {
                    col_address = true;
                }
                else if (col == "doorno")
                {
                    col_doorno = true;
                }


                if (searchTxt.Length < 3 && col != "doorno")
                {
                    searchTxt = string.Empty;
                }


                DateTime dtBefore = DateTime.Now;


                using (TaxiDataContext db = new TaxiDataContext())
                {
                    var data1 = db.GetTable <Customer>();

                    int cnt = data1.Count();
                    if (skip + pageSize > cnt && cnt - pageSize > 0)
                    {
                        skip = cnt - pageSize;
                    }
                    else if (cnt <= pageSize)
                    {
                        skip = 0;
                    }

                    var query = from a in data1

                                where
                                (col_name && (a.Name != null && a.Name.ToLower().Contains(searchTxt) || searchTxt == string.Empty)) ||
                                (col_phone && (a.TelephoneNo != null && a.TelephoneNo.ToLower().Contains(searchTxt) || searchTxt == string.Empty)) ||
                                (col_mobileno && (a.MobileNo != null && a.MobileNo.ToLower().Contains(searchTxt) || searchTxt == string.Empty)) ||
                                (col_address && (a.Address1 != null && a.Address1.ToLower().Contains(searchTxt) || searchTxt == string.Empty)) ||
                                (col_doorno && (a.DoorNo.ToStr().ToLower().Contains(searchTxt) || searchTxt == string.Empty))

                                orderby a.Name
                                select new
                    {
                        Id         = a.Id,
                        Name       = a.Name,
                        Phone      = a.TelephoneNo,
                        MobileNo   = a.MobileNo,
                        Email      = a.Email,
                        Address    = a.DoorNo != null && a.DoorNo != string.Empty ? a.DoorNo + " - " + a.Address1 : a.Address1,
                        Doorno     = a.DoorNo,
                        BlackList  = a.BlackList,
                        DisableIVR = a.AccountNo
                    };



                    this.grdLister.TableElement.BeginUpdate();

                    if (excludeSkip == false)
                    {
                        grdLister.DataSource = query.Skip(skip).Take(pageSize).ToList();
                    }
                    else
                    {
                        grdLister.DataSource = query.ToList();
                    }

                    this.grdLister.TableElement.EndUpdate();

                    var secs = DateTime.Now.Subtract(dtBefore).TotalMilliseconds;

                    lblTotal.Text = "Total Customers : " + cnt.ToStr();
                }
            }
            catch (Exception ex)
            {
                ENUtils.ShowMessage(ex.Message);
            }
        }
        private void LoadCommisionList()
        {
            try
            {
                string searchTxt = txtSearch.Text.ToStr().ToLower().Trim();
                string col       = ddlColumns.Text.ToStr().Trim().ToLower();

                if (searchTxt.Length < 3)
                {
                    searchTxt = string.Empty;
                }


                bool col_No         = false;
                bool col_DriverName = false;
                if (col == "driver no")
                {
                    col_No = true;
                }
                if (col == "driver name")
                {
                    col_DriverName = true;
                }

                //var query = from a in General.GetQueryable<Fleet_Driver>(c => c.IsActive == true && c.DriverTypeId == 2).AsEnumerable()

                //            where

                //       (col_No && (a.DriverNo.ToLower().Contains(searchTxt) || searchTxt == string.Empty))
                //       || (col_DriverName && (a.DriverName.ToLower().Contains(searchTxt) || searchTxt == string.Empty))
                //            select new
                //            {
                //                Id = a.Id,
                //                No = a.DriverNo,
                //                Name = a.DriverName,
                //                MobileNo = a.MobileNo,
                //                LastDate = a.Fleet_DriverCommisions.Count > 0 ? a.Fleet_DriverCommisions[a.Fleet_DriverCommisions.Count - 1].TransDate : null
                //            };

                using (TaxiDataContext db = new TaxiDataContext())
                {
                    var query = from a in db.GetTable <Fleet_Driver>().Where(c => c.DriverTypeId == 2 && c.IsActive == true)
                                join b in db.GetTable <Fleet_DriverCommision>() on a.Id equals b.DriverId into table2

                                from b in table2.DefaultIfEmpty().OrderByDescending(c => c.TransDate).Take(1)

                                where
                                (
                        (col_No && (a.DriverNo.ToLower().Contains(searchTxt) || searchTxt == string.Empty)) ||
                        (col_DriverName && (a.DriverName.ToLower().Contains(searchTxt) || searchTxt == string.Empty))
                                )
                                select new
                    {
                        Id       = a.Id,
                        No       = a.DriverNo,
                        Name     = a.DriverName,
                        MobileNo = a.MobileNo,
                        LastDate = b != null ? b.TransDate : null
                    };


                    grdLister.DataSource = query.AsEnumerable().OrderBy(item => item.No, new NaturalSortComparer <string>()).ToList();
                }

                //   db.Dispose();
            }
            catch (Exception ex)
            {
                ENUtils.ShowErrorMessage(ex.Message);
            }
        }
Пример #13
0
        public override void PopulateData()
        {
            try
            {
                string searchTxt = txtSearch.Text.ToStr().ToLower().Trim();
                string col       = ddlColumns.Text.ToStr().Trim().ToLower();

                if (searchTxt.Length < 3)
                {
                    searchTxt = string.Empty;
                }

                if (AppVars.objPolicyConfiguration.EnablePOI.ToBool())
                {
                    string PostCode = string.Empty;
                    string Address  = string.Empty;

                    if (col == "post code")
                    {
                        PostCode = txtSearch.Text.ToStr();
                    }
                    else if (col == "address")
                    {
                        Address = txtSearch.Text.ToStr();
                    }

                    using (TaxiDataContext db = new TaxiDataContext())
                    {
                        var list = (from a in db.stp_GetRoadLevelAddress(PostCode, Address)
                                    select new
                        {
                            Id = a.Id,
                            Address = a.Street,
                            PostCode = a.PostCode,
                            ZoneId = 0,
                            Zone = ""
                        }).ToList();;

                        int cnt = list.Count;
                        if (skip + pageSize > cnt && cnt - pageSize > 0)
                        {
                            skip = cnt - pageSize;
                        }
                        else if (cnt <= pageSize)
                        {
                            skip = 0;
                        }
                        //.Skip(skip).Take(pageSize).OrderBy(c => c.Address)

                        var list2 = list.Skip(skip).Take(pageSize).OrderBy(c => c.Address).ToList();
                        AddressList = list2;
                    }
                }
                else
                {
                    var list1 = General.GetQueryable <Gen_Address>(null).Count();



                    if (this.IsFind)
                    {
                        //  bool col_name = false;

                        bool col_postCode = false;

                        bool col_address = false;
                        bool col_zone    = false;

                        if (col == "post code")
                        {
                            col_postCode = true;
                        }

                        else if (col == "address")
                        {
                            col_address = true;
                        }
                        else if (col == "zone")
                        {
                            col_zone = true;
                        }

                        int cnt = list1;
                        if (skip + pageSize > cnt && cnt - pageSize > 0)
                        {
                            skip = cnt - pageSize;
                        }
                        else if (cnt <= pageSize)
                        {
                            skip = 0;
                        }


                        int findZoneId = 0;

                        if (col_zone)
                        {
                            findZoneId = General.GetObject <Gen_Zone>(c => c.ZoneName.Contains(searchTxt) || c.ShortName.Contains(searchTxt)).DefaultIfEmpty().Id;
                        }


                        using (TaxiDataContext db = new TaxiDataContext())
                        {
                            var list = (from a in db.GetTable <Gen_Address>()
                                        join b in db.GetTable <Gen_Zone>() on a.ZoneId equals b.Id into table2
                                        from b in table2.DefaultIfEmpty()

                                        where

                                        (col_postCode && (a.PostalCode.ToUpper().Contains(searchTxt) || searchTxt == string.Empty)

                                         || (col_address && (a.AddressLine1 != null && a.AddressLine1.ToUpper().Contains(searchTxt) || searchTxt == string.Empty)) ||
                                         (col_zone && findZoneId != 0 && (a.ZoneId != null && a.ZoneId == findZoneId || searchTxt == string.Empty))


                                        )

                                        select new
                            {
                                Id = a.EntityID,
                                Address = a.AddressLine1,
                                PostCode = a.PostalCode,
                                ZoneId = a.ZoneId,
                                Zone = a.ZoneId != null ? b.ZoneName : ""
                            }).Skip(skip).Take(pageSize).OrderBy(c => c.Address).ToList();

                            AddressList = list;
                        }



                        HasError = false;
                    }
                    else
                    {
                        using (TaxiDataContext db = new TaxiDataContext())
                        {
                            var list = (from a in db.GetTable <Gen_Address>()
                                        join b  in db.GetTable <Gen_Zone>() on a.ZoneId equals b.Id into table2
                                        from b in table2.DefaultIfEmpty()

                                        select new
                            {
                                Id = a.EntityID,
                                Address = a.AddressLine1,
                                PostCode = a.PostalCode,
                                ZoneId = a.ZoneId,
                                Zone = a.ZoneId != null ? b.ZoneName : ""
                            }).Skip(skip).Take(pageSize).OrderBy(c => c.Address).ToList();

                            AddressList = list;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                HasError = true;
            }
        }