private void UpdateDriverCommission(decimal rentLimit) { try { long?updateCommissionId = null; using (TaxiDataContext db = new TaxiDataContext()) { updateCommissionId = db.Fleet_DriverCommision_Charges.OrderByDescending(c => c.Id).FirstOrDefault().DefaultIfEmpty().TransId; if (updateCommissionId.ToLong() > 0) { Fleet_DriverCommision objCommission = db.Fleet_DriverCommisions.FirstOrDefault(c => c.Id == updateCommissionId); if (objCommission != null && objCommission.CommissionTotal > rentLimit) { decimal Credit = 0.00m; decimal Debit = 0.00m; decimal totalCredit = 0.00m; decimal totalDebit = 0.00m; decimal owedBalance = 0.00m; decimal Currentbalance = 0.00m; decimal pdaRent = objCommission.PDARent.ToDecimal(); decimal collectionAndDelivery = objCommission.CollectionDeliveryCharges.ToDecimal(); decimal accountJobsTotal = objCommission.Fleet_DriverCommision_Charges.Where(c => c.Booking.PaymentTypeId != Enums.PAYMENT_TYPES.CASH).Sum(c => (c.Booking.FareRate + c.Booking.MeetAndGreetCharges)).ToDecimal(); decimal jobsFareTotal = objCommission.Fleet_DriverCommision_Charges.Sum(c => (c.Booking.FareRate + c.Booking.MeetAndGreetCharges)).ToDecimal(); decimal agentTotal = objCommission.Fleet_DriverCommision_Charges.Where(c => c.Booking.PaymentTypeId == Enums.PAYMENT_TYPES.CASH).Sum(c => c.Booking.AgentCommission).ToDecimal(); // decimal commissionTotal = objCommission.Fleet_DriverCommision_Charges.Sum(c => ((c.Booking.FareRate + c.Booking.MeetAndGreetCharges) * objCommission.DriverCommision) / 100).ToDecimal(); decimal commissionTotal = rentLimit; decimal owed = Math.Round((pdaRent + agentTotal + commissionTotal) - accountJobsTotal, 2); if (objCommission.Fleet_DriverCommissionExpenses.Count > 0) { Debit = objCommission.Fleet_DriverCommissionExpenses.Sum(c => c.Debit).ToDecimal(); Credit = objCommission.Fleet_DriverCommissionExpenses.Sum(c => c.Credit).ToDecimal(); } totalCredit = (commissionTotal + Credit); totalDebit = (accountJobsTotal + Debit); owedBalance = (totalCredit - totalDebit); Currentbalance = owedBalance; objCommission.CommissionTotal = commissionTotal; objCommission.AccJobsTotal = accountJobsTotal; objCommission.Balance = Currentbalance; objCommission.AgentFeesTotal = agentTotal; objCommission.JobsTotal = jobsFareTotal; objCommission.DriverOwed = owed; db.SubmitChanges(); } } } } catch (Exception ex) { ENUtils.ShowMessage(ex.Message); } }
public DriversController(TaxiDataContext dbContext) { DbContext = dbContext; }
private void Display() { try { int Id = ddlCompany.SelectedValue.ToInt(); grdPayment.RowCount = 0; using (TaxiDataContext db = new TaxiDataContext()) { var item = (from a in db.Invoices.Where(c => (c.CompanyId == Id) && (InvoiceId == 0 || c.Id == InvoiceId)) orderby a.Id descending select new { Id = a.Id, a.InvoiceTotal, a.TotalInvoiceAmount, a.InvoiceNo, a.Gen_Company.HasVat, a.CurrentBalance, a.Gen_Company.AdminFees, a.Gen_Company.DiscountPercentage }).FirstOrDefault(); var objCreditNote = db.InvoiceCreditNotes.Where(c => c.InvoiceId == InvoiceId).Select(c => new { c.Id, c.CreditNoteTotal }).FirstOrDefault(); if (item == null) { lblMessage.Visible = true; grdPayment.Rows.Clear(); txtInvoiceno.Text = ""; txtBalance.Value = 0; txtInvoiceTotal.Text = "0.00"; return; } lblMessage.Visible = false; InvoiceId = item.Id.ToInt();; txtInvoiceno.Text = item.InvoiceNo; decimal creditNoteTotal = 0.00m; decimal Total = item.InvoiceTotal.ToDecimal(); decimal adminFees = item.AdminFees.ToInt(); decimal discountAmount = 0.00m; if (objCreditNote != null) { creditNoteTotal = objCreditNote.CreditNoteTotal.ToDecimal(); } if (item.DiscountPercentage.ToDecimal() > 0) { lblDiscount.Text = "Discount " + string.Format("{0:##0.##}", item.DiscountPercentage.ToDecimal()) + "%"; discountAmount = ((Total * item.DiscountPercentage) / 100).ToDecimal(); Total = Total - discountAmount; if (creditNoteTotal > 0) { discountAmount = ((creditNoteTotal * item.DiscountPercentage) / 100).ToDecimal(); creditNoteTotal = creditNoteTotal - discountAmount; } } if (item.HasVat.ToBool()) { Total = (Total + ((Total * 20) / 100)); if (creditNoteTotal > 0) { creditNoteTotal = (creditNoteTotal + ((creditNoteTotal * 20) / 100)); } } else { Total = (Total + ((Total * adminFees) / 100)); if (creditNoteTotal > 0) { creditNoteTotal = (creditNoteTotal + ((creditNoteTotal * adminFees) / 100)); } } txtInvoiceTotal.Text = Total.ToStr(); if (objCreditNote != null) { lblCreditNote.Visible = true; txtCreditNote.Visible = true; txtCreditNote.Text = creditNoteTotal.ToStr(); } else { txtCreditNote.Text = creditNoteTotal.ToStr(); } var data1 = db.invoice_Payments.Where(c => c.invoiceId == item.Id).OrderBy(c => c.id); var query = (from a in data1 select new { Id = a.id, invoiceID = a.invoiceId, Payment = a.InvoicePayment, Balance = a.Balance, Date = a.PaymentDate, a.AddBy, a.AddOn }).AsQueryable(); if (query.Count() > 0) { DataTable dt = query.ToDataTable(); for (int i = 0; i < dt.Rows.Count; i++) { GridViewRowInfo row = null; if (grdPayment.CurrentRow != null) { row = grdPayment.CurrentRow; } else { row = grdPayment.Rows.AddNew(); } row.Cells[COL_PAYMENT.PAYMENT].Value = dt.Rows[i]["Payment"].ToDecimal(); row.Cells[COL_PAYMENT.BALANCE].Value = dt.Rows[i]["Balance"].ToDecimal(); row.Cells[COL_PAYMENT.DATE].Value = dt.Rows[i]["Date"].ToDateTime(); row.Cells[COL_PAYMENT.AddOn].Value = dt.Rows[i]["AddOn"].ToDateTime(); row.Cells[COL_PAYMENT.AddBy].Value = dt.Rows[i]["AddBy"]; row.Cells[COL_PAYMENT.ID].Value = dt.Rows[i]["Id"].ToInt(); row.Cells[COL_PAYMENT.MASTERID].Value = InvoiceId; grdPayment.CurrentRow = null; } } if (Total > 0 && grdPayment.Rows.Count == 0) { txtBalance.Value = Total - creditNoteTotal; } else { txtBalance.Value = item.CurrentBalance.ToDecimal(); } } } catch (Exception ex) { ENUtils.ShowMessage(ex.Message); } }
public static async Task <(Taxi Taxi, Driver Driver, int ID)> AddDummyRideAsync(this TaxiDataContext DbContext) { var newTaxi = await DbContext.AddDummyTaxiAsync(); var newDriver = await DbContext.AddDummyDriverAsync(); var newRideID = await DbContext.StartRideAsync(newTaxi.Taxi, newDriver.Driver); return(newTaxi.Taxi, newDriver.Driver, newRideID); }
public void GenerateReport() { try { if (ddlCompany.SelectedValue == null) { pnlCriteria.Visible = false; } reportViewer1.LocalReport.EnableExternalImages = true; if (ObjSubCompany == null) { ObjSubCompany = AppVars.objSubCompany; } Microsoft.Reporting.WinForms.ReportParameter[] param = new Microsoft.Reporting.WinForms.ReportParameter[28]; string address = ObjSubCompany.Address; string telNo = string.Empty; string sortCode = ObjSubCompany.SortCode.ToStr(); string accountNo = ObjSubCompany.AccountNo.ToStr(); string accountTitle = ObjSubCompany.AccountTitle.ToStr(); string bank = ObjSubCompany.BankName.ToStr(); string hasBankDetails = "1"; if (string.IsNullOrEmpty(sortCode) && string.IsNullOrEmpty(accountNo) && string.IsNullOrEmpty(accountTitle) && string.IsNullOrEmpty(bank)) { hasBankDetails = "0"; } if (!string.IsNullOrEmpty(sortCode)) { sortCode = "Sort Code : " + sortCode; } if (!string.IsNullOrEmpty(accountTitle)) { accountTitle = "Account Title : " + accountTitle; } string website = ObjSubCompany.WebsiteUrl.ToStr(); if (!string.IsNullOrEmpty(website)) { website += " , "; } website += "Email:" + ObjSubCompany.EmailAddress.ToStr(); string companyNumber = ObjSubCompany.CompanyNumber.ToStr(); if (!string.IsNullOrEmpty(companyNumber)) { companyNumber = "Company Number: " + companyNumber; } string vatNumber = ObjSubCompany.CompanyVatNumber.ToStr(); //if (AppVars.objPolicyConfiguration.DefaultClientId.ToStr().Trim() == "yeAr$ettle_ltd_t/A_c!ty_cAr$") //{ // vatNumber = "Acc No : 11616162" + Environment.NewLine + // "Sort Code : 83-07-06" + Environment.NewLine + // "Ref No : Call Sign" + Environment.NewLine + // "Bank : Royal Bank of Scotland"; //} param[0] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Address", address); param[18] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Footer", ObjSubCompany.WebsiteUrl.ToStr()); param[14] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_MobileNo", "Mobile: " + ObjSubCompany.EmergencyNo.ToStr()); param[15] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Website", website); param[16] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Email", "Email: " + ObjSubCompany.EmailAddress.ToStr()); param[20] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_CompanyNumber", companyNumber); param[21] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_VATNumber", vatNumber); param[7] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_SortCode", sortCode); param[9] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_AccountTitle", accountTitle); param[10] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Bank", bank); List <ClsLogo> objLogo = new List <ClsLogo>(); objLogo.Add(new ClsLogo { ImageInBytes = ObjSubCompany.CompanyLogo != null ? ObjSubCompany.CompanyLogo.ToArray() : null }); ReportDataSource imageDataSource = new ReportDataSource("Taxi_AppMain_Classes_ClsLogo", objLogo); this.reportViewer1.LocalReport.DataSources.Add(imageDataSource); string path = @"File:"; param[2] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Path", path); param[6] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_CompanyHeader", ObjSubCompany.CompanyName.ToStr()); param[22] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_CompanyHeading", ObjSubCompany.CompanyName.ToStr()); int?driverId = this.DataSource.FirstOrDefault().DefaultIfEmpty().DriverId; var data = this.DataSource.FirstOrDefault().DefaultIfEmpty(); telNo = "Tel No. " + ObjSubCompany.TelephoneNo; if (!string.IsNullOrEmpty(accountNo)) { accountNo = "Account No : " + accountNo; } param[1] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Telephone", telNo); param[8] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_AccountNo", accountNo); string vat = "0"; decimal discountAmount = 0.00m; decimal valueAddedTax = VAT; 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[19] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_HasBankDetails", hasBankDetails); int cnt = this.DataSource.Count; string BalanceType = string.Empty; int DriverId = 0; string oldBalanceDate = string.Empty; if (this.DataSource.Count > 0) { DriverId = this.DataSource.FirstOrDefault().DriverId.ToInt(); int Id = this.DataSource.FirstOrDefault().Id.ToInt(); string StatementDate = string.Empty; using (TaxiDataContext db = new TaxiDataContext()) { var query = db.DriverRents.Where(c => c.DriverId == driverId && c.Id < Id).OrderByDescending(c => c.Id).FirstOrDefault(); if (query == null) { BalanceType = "Initial Balance"; StatementDate = string.Format("{0:dd/MM}", this.DataSource.FirstOrDefault().TransDate); } else { BalanceType = "Balance from statement " + query.TransNo.ToStr(); StatementDate = string.Format("{0:dd/MM}", this.DataSource.FirstOrDefault().TransDate); try { oldBalanceDate = string.Format("{0:dd/MM}", query.TransDate.ToDate()); } catch { oldBalanceDate = StatementDate; } } } param[23] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_jobCount", cnt.ToStr()); param[24] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_BalanceType", BalanceType); param[25] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_StatementDate", StatementDate); param[13] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_HasCostCenter", oldBalanceDate); string balance = string.Empty; decimal bal = this.DataSource.FirstOrDefault().DefaultIfEmpty().Balance.ToDecimal(); //if(bal>=0) //{ balance = "Balance Due £" + string.Format("{0:f2}", bal); //} //else //{ // balance = "You are due to receive £" + string.Format("{0:f2}", bal); // balance = balance.Replace("-", "").Trim(); //} param[26] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Balance", balance); param[27] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_DisplayType", this.DisplayCriteriaType); } else { param[23] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_jobCount", cnt.ToStr()); param[24] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_BalanceType", BalanceType); // param[28] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_AccountExpenses", AccountExpenses.ToStr()); param[25] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_StatementDate", ""); param[26] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Balance", ""); param[27] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_DisplayType", this.DisplayCriteriaType); } if (templateName.ToStr().Length == 0) { using (TaxiDataContext db = new TaxiDataContext()) { templateName = db.UM_Form_Templates.Where(c => c.UM_Form.FormName == "frmDriverRentDebitCredit3" && c.IsDefault == true).Select(c => c.TemplateName).FirstOrDefault(); if (templateName.ToStr().Trim().Length > 0) { templateName = templateName + "_"; } } } if (templateName.ToStr().Trim().Length == 0) { templateName = " "; } this.reportViewer1.LocalReport.ReportEmbeddedResource = "Taxi_AppMain.ReportDesigns." + templateName.ToStr().Trim() + "rptDriverRentExpenses3.rdlc"; reportViewer1.LocalReport.SetParameters(param); this.vu_DriverRentExpenseBindingSource.DataSource = this.DataSource; this.vu_FleetDriverRentExpenseBindingSource.DataSource = this.DataSource2; this.reportViewer1.ZoomPercent = 100; this.reportViewer1.ZoomMode = Microsoft.Reporting.WinForms.ZoomMode.Percent; this.reportViewer1.RefreshReport(); } catch (Exception ex) { ENUtils.ShowMessage(ex.Message); } }
private void SaveBooking() { string reason = txtCancelReason.Text.Trim(); if (string.IsNullOrEmpty(reason)) { reason = "XXX"; //ENUtils.ShowMessage("Please enter Cancel Reason..."); //return; } if (objMaster == null || objMaster.Current == null) { objMaster.GetByPrimaryKey(BookingId); } if (objMaster.Current == null) { Close(); return; } bool cancelReturnJob = false; long?returnBookingId = null; if (objMaster.Current.JourneyTypeId.ToInt() == Enums.JOURNEY_TYPES.RETURN) { DialogResult dialog = MessageBox.Show("Do you want to cancel Return Booking as well ?", "", MessageBoxButtons.YesNoCancel); if (dialog == System.Windows.Forms.DialogResult.Yes) { cancelReturnJob = true; } else if (dialog == System.Windows.Forms.DialogResult.Cancel) { return; } } this._onlineBookingId = objMaster.Current.OnlineBookingId.ToLong(); using (TaxiDataContext db = new TaxiDataContext()) { //db.stp_CancelBooking(BookingId, reason,AppVars.LoginObj.UserName.ToStr()); db.stp_CancelBookingWithUserLog(BookingId, reason, AppVars.LoginObj.UserName.ToStr(), AppVars.LoginObj.LuserId.ToInt()); jobIds = objMaster.Current.Id.ToStr(); if (cancelReturnJob && objMaster.Current.BookingReturns.Count > 0) { returnBookingId = objMaster.Current.BookingReturns[0].Id; db.stp_CancelBookingWithUserLog(returnBookingId, reason, AppVars.LoginObj.UserName.ToStr(), AppVars.LoginObj.LuserId.ToInt()); jobIds += "," + returnBookingId.ToStr(); } //db.stp_AddUserLogs(AppVars.LoginObj.LuserId.ToInt(),"JOB CANCELLED",3); // db.stp_BookingLog(BookingId, AppVars.LoginObj.UserName.ToStr(), "Job is Cancelled ! Reason : " + reason); } IsSaved = true; try { int driverId = objMaster.Current.DriverId.ToInt(); if (objMaster.Current.BookingStatusId.ToInt() != Enums.BOOKINGSTATUS.WAITING && driverId > 0) { if (objMaster.Current.JobCode.ToStr().Length > 0 && AppVars.objPolicyConfiguration.EnableGhostJob.ToBool()) { // new BroadcasterData().BroadCastToAll(RefreshTypes.REFRESH_ACTIVE_DASHBOARD); General.SendMessageToPDA("request broadcast=" + RefreshTypes.REFRESH_ACTIVE_DASHBOARD); } else { if (General.GetQueryable <Fleet_DriverQueueList>(c => c.DriverId == driverId && c.CurrentJobId == BookingId).Count() > 0) { new Thread(delegate() { CancelCurrentBookingFromPDA(BookingId, driverId); }).Start(); // RefreshBookingListOnActive(); // new BroadcasterData().BroadCastToAll(RefreshTypes.REFRESH_ACTIVE_DASHBOARD); General.SendMessageToPDA("request broadcast=" + RefreshTypes.REFRESH_ACTIVE_DASHBOARD); } else { if (objMaster.Current.BookingStatusId.ToInt() == Enums.BOOKINGSTATUS.PENDING_START) { new Thread(delegate() { General.ReCallPreBooking(BookingId, driverId); }).Start(); } else { new Thread(delegate() { ReCallFOJBookingFromPDA(BookingId, driverId); }).Start(); } // new BroadcasterData().BroadCastToAll(RefreshTypes.REFRESH_ACTIVE_DASHBOARD); General.SendMessageToPDA("request broadcast=" + RefreshTypes.REFRESH_ACTIVE_DASHBOARD); // RefreshActiveData(); } } this.IsRefresh = true; Thread.Sleep(500); } if (objMaster.Current.BookingTypeId.ToInt() == Enums.BOOKING_TYPES.THIRDPARTY) { General.UpdateThirdPartyJobStatus(objMaster.Current, objMaster.Current.Id, "declined"); } if (chkCancellationSMS.Checked && objMaster.Current != null && objMaster.Current.CustomerMobileNo.ToStr().Length >= 9 && AppVars.objPolicyConfiguration.SMSCancelJob.ToStr().Trim().Length > 0) { string rtnMsg = string.Empty; EuroSMS sms = new EuroSMS(); sms.Message = GetMessage(AppVars.objPolicyConfiguration.SMSCancelJob.ToStr(), objMaster.Current, objMaster.Current.Id); sms.ToNumber = objMaster.Current.CustomerMobileNo.ToStr().Trim(); sms.Send(ref rtnMsg); } } catch { } SendCancelEmail(); this.Close(); }
private void Save() { decimal Fare = txtFare.Value; decimal custFare = txtCustFare.Value; decimal compFare = txtCompFare.Value; decimal oldFares = 0.00m; decimal oldTotalCharges = 0.00m; decimal TotalCharges = 0.00m; if (ObjMaster.Current != null) { bool allowUpdateTransaction = false; try { long id = ObjMaster.Current.Id; if (AppVars.listUserRights.Count(c => c.formName == "frmBooking" && (c.functionId == "LOCK BOOKING AFTER TRANSACTION")) > 0) { int reasonCnt = 0; string error = string.Empty; using (TaxiDataContext db = new TaxiDataContext()) { if (db.Invoice_Charges.Count(c => c.BookingId == id) > 0) { reasonCnt++; error = reasonCnt + ". Account Invoice Exist" + Environment.NewLine; } if (db.DriverRent_Charges.Count(c => c.BookingId == id) > 0) { reasonCnt++; error += reasonCnt + ". Driver Rent Statement Exist" + Environment.NewLine; } if (db.Fleet_DriverCommision_Charges.Count(c => c.BookingId == id) > 0) { reasonCnt++; error += reasonCnt + ". Driver Commission Statement Exist" + Environment.NewLine; } } if (error.Length > 0) { ENUtils.ShowMessage("You cannot edit this booking" + Environment.NewLine + Environment.NewLine + "Reasons:-" + Environment.NewLine + error); return; } } else { allowUpdateTransaction = true; } } catch { } string pdafares = AppVars.objPolicyConfiguration.PDAFaresPropertyName.ToStr().ToLower().Trim(); ObjMaster.CheckDataValidation = false; ObjMaster.AllowUpdateTransaction = allowUpdateTransaction; ObjMaster.Edit(); oldFares = ObjMaster.Current.FareRate.ToDecimal(); oldTotalCharges = ObjMaster.Current.TotalCharges.ToDecimal(); ObjMaster.Current.FareRate = Fare; ObjMaster.Current.CustomerPrice = custFare; ObjMaster.Current.CompanyPrice = compFare; ObjMaster.DisableUpdateReturnJob = true; ObjMaster.CheckCustomerValidation = false; farerate = Fare; if (oldFares != Fare) { ObjMaster.Current.Booking_Logs.Add(new Booking_Log { BookingId = ObjMaster.Current.Id, User = AppVars.LoginObj.LoginName, BeforeUpdate = "Fares : " + oldFares, AfterUpdate = "Update from (Edit Fare) ,Fares : " + Fare, UpdateDate = DateTime.Now }); General.UpdateOnlineBookingFares(ObjMaster.Current.OnlineBookingId.ToLong(), Fare, ObjMaster.Current.BookingTypeId.ToInt()); } if (ObjMaster.Current.CompanyId == null) { ObjMaster.Current.TotalCharges = ObjMaster.Current.FareRate.ToDecimal() + ObjMaster.Current.ExtraDropCharges.ToDecimal() + ObjMaster.Current.MeetAndGreetCharges.ToDecimal() + ObjMaster.Current.CongtionCharges.ToDecimal(); } else { ObjMaster.Current.TotalCharges = ObjMaster.Current.CompanyPrice.ToDecimal() + ObjMaster.Current.ParkingCharges.ToDecimal() + ObjMaster.Current.WaitingCharges.ToDecimal() + ObjMaster.Current.ExtraDropCharges.ToDecimal(); } TotalCharges = ObjMaster.Current.TotalCharges.ToDecimal(); ObjMaster.Save(); this.Close(); //if (openForm == 1) //{ // // AppVars.frmMDI.RefreshDashBoardBookings(); // // General.RefreshListWithoutSelected<frmBookingDashBoard>("frmBookingDashBoard1"); //} if (openForm == 2) { (Application.OpenForms.OfType <Form>().FirstOrDefault(c => c.Name == "frmBookingDashBoard") as frmBookingDashBoard).RefreshBookingList(); // AppVars.frmMDI.RefreshDashBoardBookings(); } else if (openForm == 0) { General.RefreshListWithoutSelected <frmBookingsList>("frmBookingsList1"); } // For TCP Connection if (ObjMaster.Current.DriverId != null && ObjMaster.Current.Gen_PaymentType.ShowFaresOnPDA.ToStr() == "1" && (ObjMaster.Current.BookingStatusId == Enums.BOOKINGSTATUS.ONROUTE || ObjMaster.Current.BookingStatusId == Enums.BOOKINGSTATUS.ARRIVED || ObjMaster.Current.BookingStatusId == Enums.BOOKINGSTATUS.POB || ObjMaster.Current.BookingStatusId == Enums.BOOKINGSTATUS.STC) && AppVars.objPolicyConfiguration.IsListenAll.ToBool() && !string.IsNullOrEmpty(AppVars.objPolicyConfiguration.ListenerIP.ToStr().Trim())) { if (pdafares == "totalcharges") { oldFares = oldTotalCharges; Fare = TotalCharges; } if (oldFares != Fare) { string A_Phone = ObjMaster.Current.CustomerPhoneNo.ToStr(); string Phone = ObjMaster.Current.CustomerPhoneNo.ToStr(); string mobNo = ObjMaster.Current.CustomerMobileNo; if (string.IsNullOrEmpty(mobNo)) { mobNo = " "; } else if (!string.IsNullOrEmpty(A_Phone)) { mobNo = Phone + "/" + A_Phone; } string A_Account = ObjMaster.Current.Gen_Company.DefaultIfEmpty().CompanyName.ToStr(); if (string.IsNullOrEmpty(A_Account)) { A_Account = " "; } string babySeats = ObjMaster.Current.BabySeats.ToStr().Trim(); if (string.IsNullOrEmpty(babySeats)) { babySeats = " "; } string A_journeyType = "O/W"; if (ObjMaster.Current.JourneyTypeId.ToInt() == Enums.JOURNEY_TYPES.WAITANDRETURN) { A_journeyType = "W/R"; } string A_Via = " "; if (ObjMaster.Current.ViaString.ToStr().Trim().Length > 0) { int i = 1; A_Via = string.Join(" * ", ObjMaster.Current.Booking_ViaLocations.Select(c => "(" + i++.ToStr() + ")" + c.ViaLocValue.ToStr()).ToArray <string>()); } string msg = (!string.IsNullOrEmpty(ObjMaster.Current.FromDoorNo) ? ObjMaster.Current.FromDoorNo + "-" + ObjMaster.Current.FromAddress + ObjMaster.Current.Gen_Zone1.DefaultIfEmpty().ZoneName.ToStr() : ObjMaster.Current.FromAddress + ObjMaster.Current.Gen_Zone1.DefaultIfEmpty().ZoneName.ToStr()) + ">>" + (!string.IsNullOrEmpty(ObjMaster.Current.ToDoorNo) ? ObjMaster.Current.ToDoorNo + "-" + ObjMaster.Current.ToAddress + ObjMaster.Current.Gen_Zone.DefaultIfEmpty().ZoneName.ToStr() : ObjMaster.Current.ToAddress + ObjMaster.Current.Gen_Zone.DefaultIfEmpty().ZoneName.ToStr()) + ">>" + string.Format("{0:dd/MM/yyyy HH:mm}", ObjMaster.Current.PickupDateTime) + ">>" + ObjMaster.Current.CustomerName + ">>" + mobNo + ">>" + ObjMaster.Current.SpecialRequirements.ToStr() + " " + ">>" + Fare + ">>" + ObjMaster.Current.Fleet_VehicleType.DefaultIfEmpty().VehicleType.ToStr() + ">>" + A_Account + ">>" + A_journeyType + ">>" + ObjMaster.Current.Gen_PaymentType.PaymentType.ToStr() + ">>" + A_Via + ">>" + ObjMaster.Current.NoofPassengers.ToInt() + ">>" + ObjMaster.Current.NoofLuggages.ToInt() + ">>" + babySeats; new Thread(delegate() { General.SendMessageToPDA("request pda=" + ObjMaster.Current.DriverId + "=" + ObjMaster.Current.Id + "=" + "Update Job>>" + ObjMaster.Current.DriverId + ">>" + ObjMaster.Current.Id + ">>" + msg + "=8"); }).Start(); } } } }
private void NoShow() { try { if (ddl_Driver.SelectedValue == null) { ENUtils.ShowMessage("Select any Driver"); return; } else { int driverId = ddl_Driver.SelectedValue.ToInt(); var list = from a in General.GetQueryable <Fleet_DriverQueueList>(c => c.Id > 0) where a.DriverId == driverId && a.Status == true && a.CurrentJobId != null select new { Id = a.Id, }; string val = list.ToStr(); if (list.Count() != 0) { long jobId = 0; using (TaxiDataContext db = new TaxiDataContext()) { jobId = db.Fleet_DriverQueueLists.FirstOrDefault(c => c.Id == list.FirstOrDefault().Id).DefaultIfEmpty().CurrentJobId.ToLong(); } if (jobId != 0) { string[] driverNo = (ddl_Driver.SelectedItem.Text).Split('-'); new Thread(delegate() { int loopCnt = 1; while (loopCnt < 3) { bool success = General.ReCallBookingWithStatus(jobId.ToLong(), driverId.ToInt(), Enums.BOOKINGSTATUS.NOPICKUP, Enums.Driver_WORKINGSTATUS.AVAILABLE); if (success) { break; } else { loopCnt++; } } }).Start(); Thread.Sleep(500); new BroadcasterData().BroadCastToAll(RefreshTypes.REFRESH_DASHBOARD); // (Application.OpenForms.OfType<Form>().FirstOrDefault(c => c.Name == "frmBookingDashBoard") as frmBookingDashBoard).RefreshData(); using (TaxiDataContext db = new TaxiDataContext()) { db.stp_BookingLog(jobId, AppVars.LoginObj.UserName.ToStr(), "Controller Pressed NO Pickup from Driver (" + driverNo[0] + ")"); } } else { MessageBox.Show("No Current Job Found"); } } } } catch (Exception ex) { } }
private void ReCallJob() { if (ddl_Driver.SelectedValue == null) { return; } try { int driverId = ddl_Driver.SelectedValue.ToInt(); int statusId = 0; long jobId = 0; string driverNO = string.Empty; using (TaxiDataContext db = new TaxiDataContext()) { Fleet_DriverQueueList objLogin = db.Fleet_DriverQueueLists.FirstOrDefault(c => c.Status == true && c.DriverId == driverId); if (objLogin != null) { statusId = objLogin.DriverWorkStatusId.ToInt(); jobId = objLogin.CurrentJobId.ToLong(); driverNO = objLogin.Fleet_Driver.DriverNo.ToStr(); } } if (jobId == 0) { MessageBox.Show("No Current Job Found"); return; } else { if (statusId == Enums.Driver_WORKINGSTATUS.NOTAVAILABLE || statusId == Enums.Driver_WORKINGSTATUS.SOONTOCLEAR) { MessageBox.Show("Job cannot be Re-Call as driver is on " + "POB or STC Status."); return; } } if (DialogResult.Yes == RadMessageBox.Show("Are you sure you want to Re-Call a Booking ? ", "", MessageBoxButtons.YesNo, RadMessageIcon.Question)) { new Thread(delegate() { int loopCnt = 1; bool success = false; while (loopCnt < 3) { success = General.ReCallBooking(jobId, driverId); if (success) { break; } else { loopCnt++; } } }).Start(); using (TaxiDataContext dbX = new TaxiDataContext()) { dbX.stp_BookingLog(jobId, AppVars.LoginObj.UserName.ToStr(), "Recall Job from Driver (" + driverNO + ")"); } // new BroadcasterData().BroadCastToAll(RefreshTypes.REFRESH_DASHBOARD); } } catch { } }
public override void Save() { try { if (grdPostCodes.RowCount == 0) { ENUtils.ShowMessage("Required : Post Code"); return; } StringBuilder sb = new StringBuilder(); StringBuilder sb2 = new StringBuilder(); //sb.Append("delete from StreetsData.dbo.Localization;"); //sb.Append("delete from StreetsData.dbo.LocalizationDetails;"); List <string> objList = new List <string>(); string PostCode = string.Join(",", grdPostCodes.Rows.Select(c => c.Cells[COLS.PostCode].Value.ToStr()).ToArray <string>()); string NewPostCode = string.Empty; foreach (var item in PostCode.Split(',')) { string Word = string.Empty; for (int i = 0; i < item.Length; i++) { if (item[i].ToStr().IsNumeric() == true) { objList.Add(Word); break; } else { Word += item[i].ToStr(); } } } //var list = objList.Distinct().ToList(); //foreach (var item in list) //{ // sb.Append("insert into PAFDb.dbo.Localization (PostCode) values ('" + item.ToStr() + "%" + "');"); //} var list2 = grdPostCodes.Rows.Select(c => c.Cells[COLS.PostCode].Value).ToList(); foreach (var item in list2) { sb2.Append("insert into PAFDb.dbo.LocalizationDetail (PostCode) values ('" + item.ToStr() + "');"); } using (TaxiDataContext db = new TaxiDataContext()) { db.stp_SaveLocalaization(sb.ToStr(), sb2.ToStr()); } General.LoadZoneList(); this.Close(); } catch (Exception ex) { ENUtils.ShowMessage(ex.Message); } }
private void TrackDriver() { if (ddl_Driver.SelectedValue == null) { ENUtils.ShowMessage("Select any Driver"); } try { int driverId = ddl_Driver.SelectedValue.ToInt(); using (TaxiDataContext db = new TaxiDataContext()) { var objLogin = db.Fleet_DriverQueueLists.FirstOrDefault(c => c.Status == true && c.DriverId == driverId); if (objLogin == null) { ENUtils.ShowMessage("Driver is not Login"); } else { long jobId = objLogin.CurrentJobId.ToLong(); if (File.Exists(Application.StartupPath + "\\Booking\\TreasureBooking.exe")) { ClsDataTransfer polObj = new ClsDataTransfer(); foreach (System.Reflection.PropertyInfo item in AppVars.objPolicyConfiguration.GetType().GetProperties()) { try { if (polObj.GetType().GetProperty(item.Name) != null) { polObj.GetType().GetProperty(item.Name).SetValue(polObj, item.GetValue(AppVars.objPolicyConfiguration, null), null); } } catch { } } polObj.DataString = System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"].ToStr().Replace(" ", "**"); string pol = Newtonsoft.Json.JsonConvert.SerializeObject(polObj, Newtonsoft.Json.Formatting.Indented).Replace(" ", "~").Replace(Environment.NewLine, "").Replace("\"", "*"); string s = "XXX"; Process pp = new Process(); pp.StartInfo.FileName = Application.StartupPath + "\\Booking\\TreasureBooking.exe"; pp.StartInfo.Arguments = s + " " + pol + " " + Newtonsoft.Json.JsonConvert.SerializeObject(AppVars.LoginObj, Newtonsoft.Json.Formatting.Indented).Replace(" ", "").Replace(Environment.NewLine, "").Replace("\"", "*") + " " + Newtonsoft.Json.JsonConvert.SerializeObject(AppVars.keyLocations, Newtonsoft.Json.Formatting.Indented).Replace(" ", "").Replace(Environment.NewLine, "").Replace("\"", "*") + " " + Newtonsoft.Json.JsonConvert.SerializeObject(AppVars.zonesList, Newtonsoft.Json.Formatting.Indented).Replace(" ", "").Replace(Environment.NewLine, "").Replace("\"", "*"); pp.StartInfo.Arguments += " " + "rptJobRouthPathGoogle" + " " + jobId + " " + "true" + " " + driverId; pp.Start(); Thread.Sleep(500); // pp.WaitForExit(); } else { rptJobRouthPathGoogle rpt = new rptJobRouthPathGoogle(jobId > 0 ? db.Bookings.FirstOrDefault(c => c.Id == jobId) : null, true, driverId); rpt.ShowDialog(); rpt.Dispose(); GC.Collect(); } } } } catch (Exception ex) { ENUtils.ShowMessage(ex.Message); } }
void grdPaymentHistory_CommandCellClick(object sender, EventArgs e) { try { //if (grdPaymentHistory.CurrentRow != null && grdPaymentHistory.CurrentRow is GridViewDataRowInfo) //{ // long paymentId = grdPaymentHistory.CurrentRow.Cells["Id"].Value.ToLong(); // if (grdPaymentHistory.Rows.Count > 1 && paymentId < grdPaymentHistory.Rows.Where(c => c.Index != grdPaymentHistory.CurrentRow.Index) // .OrderByDescending((c => c.Cells["Id"].Value.ToLong())).FirstOrDefault().Cells["Id"].Value.ToLong()) // { // ENUtils.ShowMessage("Payment History will be Delete in Reverse Order"); // return; // } // else // { // decimal commissionPay=grdPaymentHistory.CurrentRow.Cells["CommissionPay"].Value.ToDecimal(); // using (TaxiDataContext db = new TaxiDataContext()) // { // db.stp_UpdateDriverCommissionPayment(CommissionId, paymentId, commissionPay); // } // grdPaymentHistory.CurrentRow.Delete(); // DisplayRecord(); // } //} GridCommandCellElement gridCell = (GridCommandCellElement)sender; if (gridCell.ColumnInfo.Name.ToLower() == "btndelete") { if (DialogResult.Yes == RadMessageBox.Show("Are you sure you want to delete a Record ? ", "", MessageBoxButtons.YesNo, RadMessageIcon.Question)) { long Id = grdPaymentHistory.CurrentRow.Cells["Id"].Value.ToLong(); if (grdPaymentHistory.CurrentRow != null && grdPaymentHistory.CurrentRow is GridViewDataRowInfo) { if (grdPaymentHistory.Rows.Count > 1 && Id < grdPaymentHistory.Rows.Where(c => c.Index != grdPaymentHistory.CurrentRow.Index) .OrderByDescending((c => c.Cells["Id"].Value.ToLong())).FirstOrDefault().Cells["Id"].Value.ToLong()) { ENUtils.ShowMessage("Expenses History will be Delete in Reverse Order"); return; } } string Type = grdPaymentHistory.CurrentRow.Cells[COLS.Type].Value.ToStr().ToLower(); decimal Amount = grdPaymentHistory.CurrentRow.Cells[COLS.Amount].Value.ToDecimal(); decimal CurrentBalance = numCurrBalance.Value.ToDecimal(); grdPaymentHistory.CurrentRow.Delete(); if (Type == "credit") { //if (CurrentBalance > 0) //{ numCurrBalance.Value = (CurrentBalance - Amount); } else { //if (CurrentBalance > 0) //{ numCurrBalance.Value = (CurrentBalance + Amount); } objDriverCommision.GetByPrimaryKey(CommissionId); objDriverCommision.Edit(); objDriverCommision.Current.Balance = numCurrBalance.Value.ToDecimal(); objDriverCommision.Save(); using (TaxiDataContext db = new TaxiDataContext()) { var query = db.Fleet_DriverCommissionExpenses.Single(c => c.Id == Id); db.Fleet_DriverCommissionExpenses.DeleteOnSubmit(query); db.SubmitChanges(); } DisplayRecord(); } } } catch (Exception ex) { ENUtils.ShowMessage(ex.Message); } }
private void UpdatePaymentCollection() { try { string Error = string.Empty; if (grdLister.Rows.Count() > 0 && grdLister.Rows.Count(c => c.Cells["IsPaid"].Value.ToBool() == true) == 0) { Error = "Please select record to update"; } if (!string.IsNullOrEmpty(Error)) { ENUtils.ShowMessage(Error); return; } if (grdLister.Rows.Count(c => c.Cells["IsPaid"].Value.ToBool() == true) > 0) { foreach (var item in grdLister.Rows.Where(c => c.Cells["IsPaid"].Value.ToBool() == true)) { long TranId = item.Cells["TransId"].Value.ToLong(); if (TranId > 0) { try { int IsPaid = item.Cells["IsPaid"].Value.ToBool() == true ? 1 : 0; // decimal adjustments = row.Cells[COLS.Adjustment].Value.ToDecimal(); string query = "update fleet_drivercommision set IsWeeklyPaid=" + IsPaid + " where Id=" + TranId; using (TaxiDataContext db = new TaxiDataContext()) { db.stp_RunProcedure(query); } UpdateDriverCommission(item.Cells["TotalRentCommission"].Value.ToDecimal()); //PopulateData(); DateTime?dtFrom = item.Cells["FromDate"].Value.ToDateorNull(); DateTime?dtTill = item.Cells["ToDate"].Value.ToDateorNull(); string DateRange = string.Format("{0:dd/MMMM/yyyy}", dtFrom) + " to " + string.Format("{0:dd/MMMM/yyyy}", dtTill); int DriverId = item.Cells["Id"].Value.ToInt(); int Id = 0; objDriverWeeklyRentHistory = new DriverWeeklyRentHistoryBO(); var MasterQuery = General.GetObject <Fleet_DriverWeeklyRentHistory>(c => (c.FromDate == dtFrom && c.TillDate == dtTill)); if (MasterQuery != null) { Id = MasterQuery.Id; objDriverWeeklyRentHistory.GetByPrimaryKey(Id); objDriverWeeklyRentHistory.Edit(); objDriverWeeklyRentHistory.Current.EditBy = AppVars.LoginObj.LuserId.ToInt(); objDriverWeeklyRentHistory.Current.EditLog = AppVars.LoginObj.UserName; objDriverWeeklyRentHistory.Current.EditOn = DateTime.Now; } else { objDriverWeeklyRentHistory.New(); objDriverWeeklyRentHistory.Current.AddBy = AppVars.LoginObj.LuserId.ToInt(); objDriverWeeklyRentHistory.Current.AddLog = AppVars.LoginObj.UserName; objDriverWeeklyRentHistory.Current.AddOn = DateTime.Now; } objDriverWeeklyRentHistory.Current.DateRange = DateRange; objDriverWeeklyRentHistory.Current.FromDate = dtFrom; objDriverWeeklyRentHistory.Current.TillDate = dtTill; objDriverWeeklyRentHistory.Current.CreatedOn = DateTime.Now; if (objDriverWeeklyRentHistory.Current.Fleet_DriverWeeklyRentHistory_Details.Count(c => c.DriverId == DriverId) == 0) { objDriverWeeklyRentHistory.Current.Fleet_DriverWeeklyRentHistory_Details.Add(new Fleet_DriverWeeklyRentHistory_Detail { TransId = objDriverWeeklyRentHistory.PrimaryKeyValue.ToInt(), AccountBookings = item.Cells["AccountBookings"].Value.ToDecimal(), Active = item.Cells["Active"].Value.ToStr(), DriverNo = item.Cells["DriverNo"].Value.ToStr(), DriverId = DriverId, RentComm = item.Cells["TotalRentCommission"].Value.ToDecimal(), IsPaid = item.Cells["IsPaid"].Value.ToBool(), OfficeToPay = item.Cells["OfficeToPay"].Value.ToDecimal(), PreviousBalance = item.Cells["PreviousBalance"].Value.ToDecimal(), DriverToPay = item.Cells["DriverToPay"].Value.ToDecimal() }); } else { Fleet_DriverWeeklyRentHistory_Detail objDriverWeeklyRentDetail = objDriverWeeklyRentDetail = objDriverWeeklyRentHistory.Current.Fleet_DriverWeeklyRentHistory_Details.FirstOrDefault(c => c.DriverId == DriverId); objDriverWeeklyRentDetail.TransId = objDriverWeeklyRentHistory.PrimaryKeyValue.ToInt(); objDriverWeeklyRentDetail.IsPaid = item.Cells["IsPaid"].Value.ToBool();; objDriverWeeklyRentDetail.AccountBookings = item.Cells["AccountBookings"].Value.ToDecimal(); objDriverWeeklyRentDetail.Active = item.Cells["Active"].Value.ToStr(); objDriverWeeklyRentDetail.DriverNo = item.Cells["DriverNo"].Value.ToStr(); objDriverWeeklyRentDetail.DriverId = DriverId; objDriverWeeklyRentDetail.RentComm = item.Cells["TotalRentCommission"].Value.ToDecimal(); objDriverWeeklyRentDetail.OfficeToPay = item.Cells["OfficeToPay"].Value.ToDecimal(); objDriverWeeklyRentDetail.PreviousBalance = item.Cells["PreviousBalance"].Value.ToDecimal(); objDriverWeeklyRentDetail.DriverToPay = item.Cells["DriverToPay"].Value.ToDecimal(); } objDriverWeeklyRentHistory.Save(); objDriverWeeklyRentHistory.Clear(); } catch (Exception ex) { ENUtils.ShowMessage(ex.Message); } } } } PopulateData(); } catch (Exception ex) { ENUtils.ShowMessage(ex.Message); } }
void grdLister_CommandCellClick(object sender, EventArgs e) { GridCommandCellElement gridCell = (GridCommandCellElement)sender; if (gridCell.ColumnInfo.Name == "btnUpdate") { GridViewRowInfo row = gridCell.RowInfo; if (row is GridViewDataRowInfo) { long TranId = row.Cells["TransId"].Value.ToLong(); if (TranId > 0) { try { int IsPaid = row.Cells["IsPaid"].Value.ToBool() == true ? 1 : 0; // decimal adjustments = row.Cells[COLS.Adjustment].Value.ToDecimal(); string query = "update fleet_drivercommision set IsWeeklyPaid=" + IsPaid + " where Id=" + TranId; using (TaxiDataContext db = new TaxiDataContext()) { db.stp_RunProcedure(query); } UpdateDriverCommission(grdLister.CurrentRow.Cells["TotalRentCommission"].Value.ToDecimal()); PopulateData(); DateTime?dtFrom = grdLister.CurrentRow.Cells["FromDate"].Value.ToDateorNull(); DateTime?dtTill = grdLister.CurrentRow.Cells["ToDate"].Value.ToDateorNull(); string DateRange = string.Format("{0:dd/MMMM/yyyy}", dtFrom) + " to " + string.Format("{0:dd/MMMM/yyyy}", dtTill); int DriverId = grdLister.CurrentRow.Cells["Id"].Value.ToInt(); int Id = 0; objDriverWeeklyRentHistory = new DriverWeeklyRentHistoryBO(); var MasterQuery = General.GetObject <Fleet_DriverWeeklyRentHistory>(c => (c.FromDate == dtFrom && c.TillDate == dtTill)); if (MasterQuery != null) { Id = MasterQuery.Id; objDriverWeeklyRentHistory.GetByPrimaryKey(Id); objDriverWeeklyRentHistory.Edit(); objDriverWeeklyRentHistory.Current.EditBy = AppVars.LoginObj.LuserId.ToInt(); objDriverWeeklyRentHistory.Current.EditLog = AppVars.LoginObj.UserName; objDriverWeeklyRentHistory.Current.EditOn = DateTime.Now; } else { objDriverWeeklyRentHistory.New(); objDriverWeeklyRentHistory.Current.AddBy = AppVars.LoginObj.LuserId.ToInt(); objDriverWeeklyRentHistory.Current.AddLog = AppVars.LoginObj.UserName; objDriverWeeklyRentHistory.Current.AddOn = DateTime.Now; } objDriverWeeklyRentHistory.Current.DateRange = DateRange; objDriverWeeklyRentHistory.Current.FromDate = dtFrom; objDriverWeeklyRentHistory.Current.TillDate = dtTill; objDriverWeeklyRentHistory.Current.CreatedOn = DateTime.Now; if (objDriverWeeklyRentHistory.Current.Fleet_DriverWeeklyRentHistory_Details.Count(c => c.DriverId == DriverId) == 0) { objDriverWeeklyRentHistory.Current.Fleet_DriverWeeklyRentHistory_Details.Add(new Fleet_DriverWeeklyRentHistory_Detail { TransId = objDriverWeeklyRentHistory.PrimaryKeyValue.ToInt(), AccountBookings = grdLister.CurrentRow.Cells["AccountBookings"].Value.ToDecimal(), Active = grdLister.CurrentRow.Cells["Active"].Value.ToStr(), DriverNo = grdLister.CurrentRow.Cells["DriverNo"].Value.ToStr(), DriverId = DriverId, RentComm = grdLister.CurrentRow.Cells["TotalRentCommission"].Value.ToDecimal(), IsPaid = grdLister.CurrentRow.Cells["IsPaid"].Value.ToBool(), OfficeToPay = grdLister.CurrentRow.Cells["OfficeToPay"].Value.ToDecimal(), PreviousBalance = grdLister.CurrentRow.Cells["PreviousBalance"].Value.ToDecimal(), DriverToPay = grdLister.CurrentRow.Cells["DriverToPay"].Value.ToDecimal() }); } else { Fleet_DriverWeeklyRentHistory_Detail objDriverWeeklyRentDetail = objDriverWeeklyRentDetail = objDriverWeeklyRentHistory.Current.Fleet_DriverWeeklyRentHistory_Details.FirstOrDefault(c => c.DriverId == DriverId); //var query2 = General.GetObject<Fleet_DriverWeeklyRentHistory_Detail>(c => (c.TransId == objDriverWeeklyRentHistory.PrimaryKeyValue.ToInt() && c.DriverId == DriverId)); //if (query2 != null) //{ // int HistoryId = query2.Id; // using (TaxiDataContext db = new TaxiDataContext()) // { // Fleet_DriverWeeklyRentHistory_Detail objDriverWeeklyRentDetail = db.Fleet_DriverWeeklyRentHistory_Details.FirstOrDefault(c => c.Id == HistoryId); objDriverWeeklyRentDetail.TransId = objDriverWeeklyRentHistory.PrimaryKeyValue.ToInt(); objDriverWeeklyRentDetail.IsPaid = grdLister.CurrentRow.Cells["IsPaid"].Value.ToBool();; objDriverWeeklyRentDetail.AccountBookings = grdLister.CurrentRow.Cells["AccountBookings"].Value.ToDecimal(); objDriverWeeklyRentDetail.Active = grdLister.CurrentRow.Cells["Active"].Value.ToStr(); objDriverWeeklyRentDetail.DriverNo = grdLister.CurrentRow.Cells["DriverNo"].Value.ToStr(); objDriverWeeklyRentDetail.DriverId = DriverId; objDriverWeeklyRentDetail.RentComm = grdLister.CurrentRow.Cells["TotalRentCommission"].Value.ToDecimal(); objDriverWeeklyRentDetail.OfficeToPay = grdLister.CurrentRow.Cells["OfficeToPay"].Value.ToDecimal(); objDriverWeeklyRentDetail.PreviousBalance = grdLister.CurrentRow.Cells["PreviousBalance"].Value.ToDecimal(); objDriverWeeklyRentDetail.DriverToPay = grdLister.CurrentRow.Cells["DriverToPay"].Value.ToDecimal(); // db.SubmitChanges(); // } // } } objDriverWeeklyRentHistory.Save(); objDriverWeeklyRentHistory.Clear(); } 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); } }
private void BreakDriver() { if (ddl_Driver.SelectedValue == null) { return; } try { if (General.GetQueryable <Fleet_DriverQueueList>(null).Count(c => c.Status == true && c.DriverId == ddl_Driver.SelectedValue.ToInt()) == 0) { return; } // ddl_Driver.DropDownListElement.AutoCompleteSuggest.SU.AutoCompleteSuggest.SuggestMode int statusId = Enums.Driver_WORKINGSTATUS.ONBREAK; using (TaxiDataContext db = new TaxiDataContext()) { var obj = db.Fleet_DriverQueueLists.FirstOrDefault(c => c.Status == true && c.DriverId == ddl_Driver.SelectedValue.ToInt()); if (obj != null && (obj.DriverWorkStatusId == Enums.Driver_WORKINGSTATUS.AVAILABLE || obj.DriverWorkStatusId == Enums.Driver_WORKINGSTATUS.ONBREAK)) { if (obj.DriverWorkStatusId == Enums.Driver_WORKINGSTATUS.ONBREAK) { statusId = Enums.Driver_WORKINGSTATUS.AVAILABLE; } db.stp_ChangeDriverStatus(ddl_Driver.SelectedValue.ToInt(), statusId); new BroadcasterData().BroadCastToAll(RefreshTypes.REFRESH_DASHBOARD_DRIVER); try { int loopCnt = 1; while (loopCnt < 3) { bool success = General.SendMessageToPDA("request pda=" + ddl_Driver.SelectedValue.ToInt() + "=" + 0 + "=" + "Message>>" + "onbreak--x" + ">>" + String.Format("{0:dd/MM/yyyy HH:mm:ss}", DateTime.Now) + "=4").Result.ToBool(); if (success) { break; } else { loopCnt++; } } } catch (Exception ex) { } } } } catch { } }
private void PopulateGraph() { try { string DateStatus = ""; DateTime FromDate = DateTime.Now.ToDate(); DateTime TillDate = DateTime.Now.ToDate(); DateTime Last_WK_FromDate = DateTime.Now.ToDate(); DateTime Last_WK_TillDate = DateTime.Now.ToDate(); using (Taxi_Model.TaxiDataContext db = new TaxiDataContext()) { if (DateType == "CURRENT_WEEK") { FromDate = DateTime.Now.GetStartOfCurrentWeek().ToDate(); TillDate = DateTime.Now.GetEndOfCurrentWeek().ToDate(); Last_WK_FromDate = DateTime.Now.GetStartOfCurrentWeek().ToDate().AddDays(-7); Last_WK_TillDate = DateTime.Now.GetStartOfCurrentWeek().ToDate().AddDays(-1); DateStatus = " For " + string.Format("{0:dd/MM/yyyy}", FromDate.ToDate()) + " to " + string.Format("{0:dd/MM/yyyy}", TillDate.ToDate()); } //else if (DateType == "LAST_WEEK") //{ //} else if (DateType == "MONTHLY") { FromDate = new DateTime(Year, Month, 1); TillDate = new DateTime(Year, Month, DateTime.DaysInMonth(Year, Month)); //Last_WK_FromDate = new DateTime(Year, Month - 1, 1); //Last_WK_TillDate = new DateTime(Year, Month - 1, DateTime.DaysInMonth(Year, Month - 1)); DateStatus = " For " + string.Format("{0:dd/MM/yyyy}", FromDate.ToDate()) + " to " + string.Format("{0:dd/MM/yyyy}", TillDate.ToDate()); } else if (DateType == "Datewise") { FromDate = from; TillDate = till; //Last_WK_FromDate = new DateTime(Year, Month - 1, 1); //Last_WK_TillDate = new DateTime(Year, Month - 1, DateTime.DaysInMonth(Year, Month - 1)); DateStatus = " For " + string.Format("{0:dd/MM/yyyy}", FromDate.ToDate()) + " to " + string.Format("{0:dd/MM/yyyy}", TillDate.ToDate()); } else if (DateType == "DAILY") { FromDate = DateTime.Today.ToDateTime(); TillDate = DateTime.Now.ToDateTime(); DateStatus = "For " + string.Format("{0:dd/MM/yyyy}", FromDate.ToDate()) + " to " + string.Format("{0:dd/MM/yyyy}", TillDate.ToDate()); } FromDate = FromDate.ToDate(); TillDate = TillDate.ToDate() + TimeSpan.Parse("23:59:59"); var Value = db.stp_GraphData(User_Id, DayName, ReportType, FromDate, TillDate, Last_WK_FromDate, Last_WK_TillDate).ToList(); if (Value.Count > 0) { if (ReportType == "ACCOUNT_CASH") { //int CashBooking = Value[0].CashBookings.ToInt(); //int AccountBooking = Value[0].AccountBookings.ToInt(); //int[] yValues = { CashBooking, AccountBooking }; //string[] xNames = { "Cash: " + CashBooking, "Account: " + AccountBooking }; //MainChart.Series[0].Points.DataBindXY(xNames, yValues); //MainChart.Series[0].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Pie; //MainChart.Series[1].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Pie; //lblTop.Text = "Account VS Cash"; //MainChart.Titles[0].Text = "Account VS Cash " + DateStatus; } else if (ReportType == "WEEKLY_JOBS") { //int?[] Totalbookings = Value.Where(c => c.Status == "CurrentWeek").Select(c => c.Total_Booking).ToArray(); //string[] DaysName = Value.Where(c => c.Status == "CurrentWeek").Select(c => c.Days).ToArray(); //MainChart.Series[0].Name = "Job Cureent Week"; //MainChart.Series[0].Points.DataBindXY(DaysName, Totalbookings); //MainChart.Series[0].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Column; //int?[] LastTotalbookings = Value.Where(c => c.Status == "lastWeek").Select(c => c.Total_Booking).ToArray(); //string[] LastDaysName = Value.Where(c => c.Status == "lastWeek").Select(c => c.Days).ToArray(); //MainChart.Series[1].Name = "History Average"; //MainChart.Series[1].Points.DataBindXY(LastDaysName, LastTotalbookings); //lblTop.Text = "Job History"; //for (int i = 0; i < MainChart.Series[0].Points.Count; i++) //{ // MainChart.Series[0].Points[i].Label = MainChart.Series[0].Points[i].YValues[0].ToStr(); //} //for (int i = 0; i < MainChart.Series[1].Points.Count; i++) //{ // MainChart.Series[1].Points[i].Label = MainChart.Series[1].Points[i].YValues[0].ToStr(); //} //MainChart.Titles[0].Text = "Jobs History " + DateStatus; } else if (ReportType == "DAILY_TOTAL_JOBS") { //int?[] Totalbookings = Value.Where(c => c.Status == "CurrentDay").Select(c => c.Total_Booking).ToArray(); //string[] DaysName = Value.Where(c => c.Status == "CurrentDay").Select(c => c.Days).ToArray(); //MainChart.Series[0].Name = "Job Cureent Day"; //MainChart.Series[0].Points.DataBindXY(DaysName, Totalbookings); //MainChart.Series[0].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Column; //int?[] LastTotalbookings = Value.Where(c => c.Status == "lastDay").Select(c => c.Total_Booking).ToArray(); //string[] LastDaysName = Value.Where(c => c.Status == "lastDay").Select(c => c.Days).ToArray(); //MainChart.Series[1].Name = "History Average"; //MainChart.Series[1].Points.DataBindXY(LastDaysName, LastTotalbookings); //lblTop.Text = "Job History"; //for (int i = 0; i < MainChart.Series[0].Points.Count; i++) //{ // MainChart.Series[0].Points[i].Label = MainChart.Series[0].Points[i].YValues[0].ToStr(); // MainChart.Series[0].Points[i].Font = new System.Drawing.Font("Trebuchet MS", 10F, System.Drawing.FontStyle.Bold); //} //for (int i = 0; i < MainChart.Series[1].Points.Count; i++) //{ // MainChart.Series[1].Points[i].Label = MainChart.Series[1].Points[i].YValues[0].ToStr(); //} //MainChart.Titles[0].Text = "Jobs History " + DateStatus; } else if (ReportType == "HOUR_JOBS") { //int?[] Totalbookings = Value.Where(c => c.HourStatus == "Today_Hour").Select(c => c.TotalHourBookings).ToArray(); //string[] hour = Value.Where(c => c.HourStatus == "Today_Hour").Select(c => c.OnHour.ToStr()).ToArray(); //MainChart.Series[0].Name = "Today"; //MainChart.Series[0].Points.DataBindXY(hour, Totalbookings); //MainChart.Series[0].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Column; //int?[] AvgTotalbooking = Value.Where(c => c.HourStatus == "Avg_Hour").Select(c => c.TotalHourBookings).ToArray(); //string[] Avghour = Value.Where(c => c.HourStatus == "Avg_Hour").Select(c => c.OnHour.ToStr()).ToArray(); //MainChart.Series[1].Name = "Average"; //MainChart.Series[1].Points.DataBindXY(Avghour, AvgTotalbooking); //lblTop.Text = "jobs Per Hour"; //for (int i = 0; i < MainChart.Series[0].Points.Count; i++) //{ // MainChart.Series[0].Points[i].Label = MainChart.Series[0].Points[i].YValues[0].ToStr(); //} //for (int i = 0; i < MainChart.Series[1].Points.Count; i++) //{ // MainChart.Series[1].Points[i].Label = MainChart.Series[1].Points[i].YValues[0].ToStr(); //} //MainChart.Titles[0].Text = "jobs Per Hour" + DateStatus; } else if (ReportType == "TOP_BOTTOM_DRIVERS") { //FromDate = FromDate.ToDate(); //TillDate = TillDate.ToDate() + TimeSpan.Parse("23:59:59"); //var DriverList = db.stp_GraphData(User_Id, DayName, ReportType, FromDate, TillDate, Last_WK_FromDate, Last_WK_TillDate).OrderByDescending(c => c.DriverStatus).ToList(); //int?[] Totalbookings = DriverList.Select(c => c.TotalDriverJobs).ToArray(); //string[] Driver = DriverList.Select(c => c.DriverNo).ToArray(); //MainChart.Series[0].Name = "Top Driver"; //MainChart.Series[0].Points.DataBindXY(Driver, Totalbookings); //MainChart.Series[0].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Column; //for (int i = 0; i < MainChart.Series[0].Points.Count; i++) //{ // MainChart.Series[0].Points[i].Label = MainChart.Series[0].Points[i].YValues[0].ToStr(); //} //for (int i = 0; i < MainChart.Series[1].Points.Count; i++) //{ // MainChart.Series[1].Points[i].Label = MainChart.Series[1].Points[i].YValues[0].ToStr(); //} //MainChart.Titles[0].Text = "Top=Bottom Drivers " + DateStatus; //MainChart.Series[0].Points[3].Color = Color.Orange; //MainChart.Series[0].Points[4].Color = Color.Orange; //MainChart.Series[0].Points[5].Color = Color.Orange; //MainChart.Series[1].Name = "Bottom Driver"; //MainChart.Series[1].Color = Color.Orange; //lblTop.Text = "Top=Bottom Drivers"; } else if (ReportType == "YEARLY_BOOKINGS") { //foreach (var obj in Value.Where(c => c.YearlyStatus == "Cureent_Year")) //{ // DataPoint point = new DataPoint(); // point.Label = obj.TotalMonthlyBooking.ToStr(); // point.AxisLabel = obj.month.ToStr(); // point.LabelForeColor = Color.Navy; // point.YValues[0] = (double)obj.TotalMonthlyBooking; // point.XValue = Convert.ToDouble(obj.month_No); // MainChart.Series[0].Points.Add(point); //} //MainChart.Series[0].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line; //foreach (var obj in Value.Where(c => c.YearlyStatus == "Last_Year")) //{ // DataPoint point = new DataPoint(); // point.Label = obj.TotalMonthlyBooking.ToStr(); // point.AxisLabel = obj.month.ToStr(); // point.LabelForeColor = Color.Navy; // point.YValues[0] = (double)obj.TotalMonthlyBooking; // point.XValue = Convert.ToDouble(obj.month_No); // MainChart.Series[1].Points.Add(point); //} //MainChart.Series[1].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line; //MainChart.Series[0].Name = "Job This Year"; //MainChart.Series[1].Name = "History Average"; //MainChart.Series[0].BorderWidth = 5; //MainChart.Series[1].BorderWidth = 5; //lblTop.Text = "Job This Year/historical"; //MainChart.Titles["Title1"].Text = "Job This Year/historical"; } else if (ReportType == "TOTAL_DESPATCH") { //int?[] TotalDespatch = Value.Select(c => c.TotalDespatch).ToArray(); //string[] Controller = Value.Select(c => c.Despatchby).ToArray(); //MainChart.Series[0].Name = "Top 3 operater(jobs Dispatch)"; //MainChart.Series[0].Points.DataBindXY(Controller, TotalDespatch); //MainChart.Series[0].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Column; //for (int i = 0; i < MainChart.Series[0].Points.Count; i++) //{ // MainChart.Series[0].Points[i].Label = MainChart.Series[0].Points[i].YValues[0].ToStr(); //} //MainChart.Series[1].Enabled = false; //lblTop.Text = "Jobs Dispatch"; //MainChart.Titles[0].Text = "Jobs Dispatch" + DateStatus; } // else if (ReportType == "TOTAL_TAKEN_All_OPERATOR") // { // int?[] TotalDespatch = Value.Select(c => c.TotalDespatch).ToArray(); // string[] Controller = Value.Select(c => c.ControllerName).ToArray(); // MainChart.Series[0].Name = "All operater(jobs Taken)"; // MainChart.Series[0].Points.DataBindXY(Controller, TotalDespatch); // MainChart.Series[0].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Column; // var colors = new List<Color> // { // Color.Blue, // Color.Red, // Color.Yellow, // Color.Green, // Color.Pink, // Color.AliceBlue, // Color.Aqua, // Color.Aquamarine, // Color.Azure, // Color.Beige, // Color.Bisque, // Color.BlueViolet, // Color.Chartreuse, // Color.Coral, // Color.Cornsilk, // Color.DarkOrange, // Color.DarkSalmon, // Color.Fuchsia, // Color.Maroon // }; // for (int i = 0; i < MainChart.Series[0].Points.Count; i++) // { // MainChart.Series[0].Points[i].Label = MainChart.Series[0].Points[i].YValues[0].ToStr(); // MainChart.Series[0].Points[i].Color = colors[i]; // MainChart.Series[0].Points[i].Font = new System.Drawing.Font("Trebuchet MS", 10F, System.Drawing.FontStyle.Bold); // } // MainChart.Series[1].Enabled = false; // lblTop.Text = "Jobs Taken"; // MainChart.Titles[1].Text = "Operators"; // MainChart.Titles[2].Text = "No of Bookings"; // MainChart.Titles[0].Text = "Jobs Taken" + DateStatus; // } // else if (ReportType == "WEEKLY_JOBS_TAKEN") // { // int?[] TotalDespatch = Value.Select(c => c.TotalHourBookings).ToArray(); // string User = Value.Select(c => c.ControllerName).FirstOrDefault().ToStrIfEmpty(); // string[] Controller = Value.Select(c => c.OnHour.ToStr()).ToArray(); // MainChart.Series[0].Name = "Weekly Jobs By " + User + ""; // MainChart.Series[0].Points.DataBindXY(Controller, TotalDespatch); // MainChart.Series[0].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Column; // for (int i = 0; i < MainChart.Series[0].Points.Count; i++) // { // MainChart.Series[0].Points[i].Label = MainChart.Series[0].Points[i].YValues[0].ToStr(); // MainChart.Series[0].Points[i].Font = new System.Drawing.Font("Trebuchet MS", 10F, System.Drawing.FontStyle.Bold); // } // MainChart.Series[1].Enabled = false; // lblTop.Text = "Weekly Jobs"; // MainChart.Titles[0].Text = "Weekly Jobs" + DateStatus; // MainChart.Titles[1].Text = "Week No"; // MainChart.Titles[2].Text = "No of Bookings"; // } // else if (ReportType == "DAILY_JOBS") // { // int?[] TotalDespatch = Value.Select(c => c.TotalHourBookings).ToArray(); // string User = Value.Select(c => c.ControllerName).FirstOrDefault().ToStrIfEmpty(); // int?[] Controller = Value.Select(c => c.OnHour).ToArray(); // MainChart.Series[0].Name = "Daily Jobs By " + User + ""; // MainChart.Series[0].Points.DataBindXY(Controller, TotalDespatch); // MainChart.Series[0].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Column; // for (int i = 0; i < MainChart.Series[0].Points.Count; i++) // { // MainChart.Series[0].Points[i].Label = MainChart.Series[0].Points[i].YValues[0].ToStr(); // // MainChart.ChartAreas.["ChartArea1"].AxisX.LabelStyle.Font = new System.Drawing.Font("Trebuchet MS", 2.25F, System.Drawing.FontStyle.Bold); // MainChart.Series[0].Points[i].Font = new System.Drawing.Font("Trebuchet MS", 10F, System.Drawing.FontStyle.Bold); // } // //MainChart.Series[1].Font = Font.Bold; // MainChart.Series[1].Enabled = false; // lblTop.Text = "Daily Jobs"; // MainChart.Titles[0].Text = "Daily Jobs" + DateStatus; // MainChart.Titles[1].Text = "Hours"; // MainChart.Titles[2].Text = "No of Bookings"; // } // else if (ReportType == "MONTHLY_JOBS_TAKEN") // { // int?[] TotalDespatch = Value.Select(c => c.Total_Booking).ToArray(); // string User = Value.Select(c => c.ControllerName).FirstOrDefault().ToStrIfEmpty(); // string[] Controller = Value.Select(c => c.Bookingmonth).ToArray(); // MainChart.Series[0].Name = "Monthly Jobs By " + User +""; // MainChart.Series[0].Points.DataBindXY(Controller, TotalDespatch); // MainChart.Series[0].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Column; // for (int i = 0; i < MainChart.Series[0].Points.Count; i++) // { // MainChart.Series[0].Points[i].Label = MainChart.Series[0].Points[i].YValues[0].ToStr(); // MainChart.Series[0].Points[i].Font = new System.Drawing.Font("Trebuchet MS", 10F, System.Drawing.FontStyle.Bold); // } // MainChart.Series[1].Enabled = false; // lblTop.Text = "Monthly Jobs"; // MainChart.Titles[2].Text = "No of Bookings"; // MainChart.Titles[1].Text = "Month"; // MainChart.Titles[0].Text = "Monthly Jobs" + DateStatus; // } // else if (ReportType == "VEHICLE_EARNING") // { // decimal?[] TotalEarning = Value.Select(c => c.DriverTotalEarning).ToArray(); // string[] Controller = Value.Select(c => c.ControllerName).ToArray(); // MainChart.Series[0].Name = "All Vehicle(Vehicle Earning)"; // MainChart.Series[0].Points.DataBindXY(Controller, TotalEarning); // MainChart.Series[0].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Column; // for (int i = 0; i < MainChart.Series[0].Points.Count; i++) // { // MainChart.Series[0].Points[i].Label = MainChart.Series[0].Points[i].YValues[0].ToStr(); // MainChart.Series[0].Points[i].Font = new System.Drawing.Font("Trebuchet MS", 10F, System.Drawing.FontStyle.Bold); // } // MainChart.Series[1].Enabled = false; // lblTop.Text = "Vehicle Earning"; // // MainChart.Titles[0].Text = "Jobs Taken" + DateStatus; // MainChart.Titles[1].Text = "Vehicle"; // MainChart.Titles[2].Text = "Bookings"; // } // else if (ReportType == "COMPANY_VEHICLE_EARNING") // { // decimal?[] TotalEarning = Value.Select(c => c.DriverTotalEarning).ToArray(); // string[] Controller = Value.Select(c => c.ControllerName).ToArray(); // MainChart.Series[0].Name = "All Company Vehicle(Company Vehicle Earning)"; // MainChart.Series[0].Points.DataBindXY(Controller, TotalEarning); // MainChart.Series[0].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Column; // for (int i = 0; i < MainChart.Series[0].Points.Count; i++) // { // MainChart.Series[0].Points[i].Label = MainChart.Series[0].Points[i].YValues[0].ToStr(); // MainChart.Series[0].Points[i].Font = new System.Drawing.Font("Trebuchet MS", 10F, System.Drawing.FontStyle.Bold); // } // MainChart.Series[1].Enabled = false; // lblTop.Text = "Company Vehicle Earning"; // // MainChart.Titles[0].Text = "Jobs Taken" + DateStatus; // MainChart.Titles[1].Text = "Company Vehicle"; // MainChart.Titles[2].Text = "Bookings"; // } // else if (ReportType == "TOTAL_DESPATCH_All_OPERATOR") // { // int?[] TotalDespatch = Value.Select(c => c.TotalDespatch).ToArray(); // string[] Controller = Value.Select(c => c.Despatchby).ToArray(); // MainChart.Series[0].Name = "All operater(jobs Dispatch)"; // MainChart.Series[0].Points.DataBindXY(Controller, TotalDespatch); // MainChart.Series[0].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Column; // var colors = new List<Color> // { // Color.Blue, // Color.Red, // Color.Yellow, // Color.Green, // Color.Pink, // Color.AliceBlue, // Color.Aqua, // Color.Aquamarine, // Color.Azure, // Color.Beige, // Color.Bisque, // Color.BlueViolet, // Color.Chartreuse, // Color.Coral, // Color.Cornsilk, // Color.DarkOrange, // Color.DarkSalmon, // Color.Fuchsia, // Color.Maroon // }; // for (int i = 0; i < MainChart.Series[0].Points.Count; i++) // { // MainChart.Series[0].Points[i].Label = MainChart.Series[0].Points[i].YValues[0].ToStr(); // MainChart.Series[0].Points[i].Color = colors[i]; // MainChart.Series[0].Points[i].Font = new System.Drawing.Font("Trebuchet MS", 10F, System.Drawing.FontStyle.Bold); // } // MainChart.Series[1].Enabled = false; // lblTop.Text = "Jobs Dispatch"; // MainChart.Titles[1].Text = "Operators"; // MainChart.Titles[2].Text = "No of Bookings"; // MainChart.Titles[0].Text = "Jobs Dispatch" + DateStatus; // } // else if (ReportType == "DRIVER_RECOVERED_BOOKING") // { // int?[] TotalRejectedJobs = Value.Select(c => c.rejectedjobs).ToArray(); // string[] DriverName = Value.Select(c => c.DriverName).ToArray(); // MainChart.Series[0].Name = "Drivers(Recovered Jobs)"; // MainChart.Series[0].Points.DataBindXY(DriverName, TotalRejectedJobs); // MainChart.Series[0].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Column; // for (int i = 0; i < MainChart.Series[0].Points.Count; i++) // { // MainChart.Series[0].Points[i].Label = MainChart.Series[0].Points[i].YValues[0].ToStr(); // MainChart.Series[0].Points[i].Font = new System.Drawing.Font("Trebuchet MS", 10F, System.Drawing.FontStyle.Bold); // } // MainChart.Series[1].Enabled = false; // lblTop.Text = "Drivers Recovered Jobs"; // MainChart.Titles[1].Text = "Drivers"; // MainChart.Titles[2].Text = "No of Booking"; // MainChart.Titles[0].Text = "Drivers Recovered Jobs" + DateStatus; // } // else if (ReportType == "TOTAL_CALLRECIVE") // { // int?[] TotalCall = Value.Select(c => c.TotalCallRecive).ToArray(); // string[] Controller = Value.Select(c => c.ControllerName).ToArray(); // MainChart.Series[0].Name = "Top 3 operater(Call Received)"; // MainChart.Series[0].Points.DataBindXY(Controller, TotalCall); // MainChart.Series[0].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Column; // for (int i = 0; i < MainChart.Series[0].Points.Count; i++) // { // MainChart.Series[0].Points[i].Label = MainChart.Series[0].Points[i].YValues[0].ToStr(); // MainChart.Series[0].Points[i].Font = new System.Drawing.Font("Trebuchet MS", 10F, System.Drawing.FontStyle.Bold); // } // MainChart.Series[1].Enabled = false; // lblTop.Text = "Jobs Taken"; // MainChart.Titles[0].Text = "Jobs Taken" + DateStatus; // } // else if (ReportType == "DRIVER_REJECT_BOOKING") // { // int?[] TotalRejectedJobs = Value.Select(c => c.rejectedjobs).ToArray(); // string[] DriverName = Value.Select(c => c.DriverName).ToArray(); // MainChart.Series[0].Name = "Top 3 Drivers(Rejected Jobs)"; // MainChart.Series[0].Points.DataBindXY(DriverName, TotalRejectedJobs); // MainChart.Series[0].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Column; // for (int i = 0; i < MainChart.Series[0].Points.Count; i++) // { // MainChart.Series[0].Points[i].Label = MainChart.Series[0].Points[i].YValues[0].ToStr(); // MainChart.Series[0].Points[i].Font = new System.Drawing.Font("Trebuchet MS", 10F, System.Drawing.FontStyle.Bold); // } // MainChart.Series[1].Enabled = false; // lblTop.Text = "Drivers Rejected Jobs"; // MainChart.Titles[1].Text = "Drivers"; // MainChart.Titles[2].Text = "No of Booking"; // MainChart.Titles[0].Text = "Drivers Rejected Jobs" + DateStatus; // } // else if (ReportType == "LATE_BOOKING_DISPATCH") // { // int?[] TotallateJobs = Value.Select(c => c.TotalLateBooking).ToArray(); // string[] jobLateBy = Value.Select(c => c.BookingLateBy).ToArray(); // MainChart.Series[0].Name = "Top 3 operator(Late Jobs)"; // MainChart.Series[0].Points.DataBindXY(jobLateBy, TotallateJobs); // MainChart.Series[0].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Column; // for (int i = 0; i < MainChart.Series[0].Points.Count; i++) // { // MainChart.Series[0].Points[i].Label = MainChart.Series[0].Points[i].YValues[0].ToStr(); // MainChart.Series[0].Points[i].Font = new System.Drawing.Font("Trebuchet MS", 10F, System.Drawing.FontStyle.Bold); // } // MainChart.Series[1].Enabled = false; // lblTop.Text = "Operator Late Jobs"; // MainChart.Titles[0].Text = "Operator Late Jobs" + DateStatus; // } // else if (ReportType == "COMPLAINT_DRIVERS") // { // int?[] TotalComplaints = Value.Select(c => c.TotalCompaintsForDriver).ToArray(); // string[] DriverNameComplaint = Value.Select(c => c.CompalintForDriver).ToArray(); // MainChart.Series[0].Name = "Complaints For Drivers"; // MainChart.Series[0].Points.DataBindXY(DriverNameComplaint, TotalComplaints); // MainChart.Series[0].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Column; // for (int i = 0; i < MainChart.Series[0].Points.Count; i++) // { // MainChart.Series[0].Points[i].Label = MainChart.Series[0].Points[i].YValues[0].ToStr(); // } // MainChart.Series[1].Enabled = false; // lblTop.Text = "Complaints For Drivers"; // MainChart.Titles[0].Text = "Complaints For Drivers" + DateStatus; // } // else if (ReportType == "COMPLAINT_CONTROLLER") // { // int?[] TotalComplaints = Value.Select(c => c.TotalCompaintsForController).ToArray(); // string[] OperatorNameComplaint = Value.Select(c => c.CompalintForController).ToArray(); // MainChart.Series[0].Name = "Complaints For Operators"; // MainChart.Series[0].Points.DataBindXY(OperatorNameComplaint, TotalComplaints); // MainChart.Series[0].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Column; // for (int i = 0; i < MainChart.Series[0].Points.Count; i++) // { // MainChart.Series[0].Points[i].Label = MainChart.Series[0].Points[i].YValues[0].ToStr(); // MainChart.Series[0].Points[i].Font = new System.Drawing.Font("Trebuchet MS", 10F, System.Drawing.FontStyle.Bold); // } // MainChart.Series[1].Enabled = false; // lblTop.Text = "Complaints For Operators"; // MainChart.Titles[0].Text = "Complaints For Operators" + DateStatus; // } // else if (ReportType == "DRIVER_TOTAL_EARNING") // { // decimal?[] TotalEarning = Value.Select(c => c.DriverTotalEarning).ToArray(); // string[] DriverName = Value.Select(c => c.EarningDriverName).ToArray(); // MainChart.Series[0].Name = "Top 3 Driver(Earning)"; // MainChart.Series[0].Points.DataBindXY(DriverName, TotalEarning); // MainChart.Series[0].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Column; // for (int i = 0; i < MainChart.Series[0].Points.Count; i++) // { // MainChart.Series[0].Points[i].Label = MainChart.Series[0].Points[i].YValues[0].ToStr(); // MainChart.Series[0].Points[i].Font = new System.Drawing.Font("Trebuchet MS", 10F, System.Drawing.FontStyle.Bold); // } // MainChart.Series[1].Enabled = false; // lblTop.Text = "Driver Earning"; // MainChart.Titles[0].Text = "Driver Earning" + DateStatus; // } // else if (ReportType == "MONTHLY_BOOKINGS") // { // int?[] Totalbookings = Value.Select(c => c.MonthlyBookings).ToArray(); // string[] MonthName = Value.Select(c => c.Bookingmonth).ToArray(); // MainChart.Series[0].Name = "Monthly Jobs"; // MainChart.Series[0].Points.DataBindXY(MonthName, Totalbookings); // MainChart.Series[0].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Column; // for (int i = 0; i < MainChart.Series[0].Points.Count; i++) // { // MainChart.Series[0].Points[i].Label = MainChart.Series[0].Points[i].YValues[0].ToStr(); // MainChart.Series[0].Points[i].Font = new System.Drawing.Font("Trebuchet MS", 10F, System.Drawing.FontStyle.Bold); // } // MainChart.Series[0].Points[0].Color = Color.Orange; // // MainChart.Series[0].Points[1].Color = Color.Orange; // MainChart.Series[1].Name = "History Average"; // MainChart.Series[1].Color = Color.Orange; // lblTop.Text = "Monthly Jobs"; // MainChart.Titles[0].Text = "Monthly Jobs" + DateStatus; // } //} //else //{ // ENUtils.ShowMessage("Data Not found.."); // _cond = false; // //frmShowGraphs frm = new frmShowGraphs(); // //DockWindow doc = UI.MainMenuForm.MainMenuFrm.GetDockByName("frmShowGraphs1"); // //if (doc == null) // //{ // // doc.Close(); // //} // //MainMenuForm.MainMenuFrm.ShowForm(frm); //} } } } catch (Exception ex) { ENUtils.ShowErrorMessage(ex.Message); } }
private void PopulateInbox() { try { grdInbox.Rows.Clear(); //var list = (from a in General.GetQueryable<InternalMessaging>(null) // join b in General.GetQueryable<UM_User>(null) // on a.ReceiveTo equals b.Id // orderby a.AddOn ascending // select new // { // Id = a.Id, // Reciever = b.UserName, // MessageText = a.MessageText, // DateTime = string.Format("{0:MM/dd/yyyy HH:mm:ss tt}", a.AddOn.Value) // }).ToList(); using (TaxiDataContext db = new TaxiDataContext()) { var list = (from a in db.InternalMessagings join b in db.UM_Users on a.ReceiveTo equals b.Id where a.ReceiveTo == AppVars.LoginObj.LuserId orderby a.AddOn descending select new { Id = a.Id, Reciever = a.SenderName, MessageText = a.MessageText, DateTime = a.AddOn //!= null ? string.Format("{0:MM/dd/yyyy HH:mm:ss tt}", a.AddOn.Value) : "" }).ToList(); int cnt = list.Count; int minRows = 8; if (cnt < minRows) { for (int i = 0; i < minRows - cnt; i++) { // list.Add(new vu_Invoice { Id = data.Id, BookingId = data.BookingId, HasBookedBy = data.HasBookedBy, HasOrderNo = data.HasOrderNo, HasPupilNo = data.HasPupilNo }); list.Add(null); } } int rowCount = list.Count; grdInbox.RowCount = rowCount; for (int i = 0; i < rowCount; i++) { if (list[i] != null) { grdInbox.Rows[i].Cells[COLS.Id].Value = list[i].Id; grdInbox.Rows[i].Cells[COLS.DateTime].Value = list[i].DateTime; grdInbox.Rows[i].Cells[COLS.Reciever].Value = list[i].Reciever != null ? list[i].Reciever : ""; grdInbox.Rows[i].Cells[COLS.MessageText].Value = list[i].MessageText != null ? list[i].MessageText : ""; } } grdInbox.MultiSelect = false; this.grdInbox.CellBorderStyle = DataGridViewCellBorderStyle.None; } } catch (Exception ex) { ENUtils.ShowMessage(ex.Message); } }
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 Login() { try { TaxiDataContext db = new TaxiDataContext(); UM_User obj = db.UM_Users.FirstOrDefault(c => (c.IsActive == true) && (c.UserName.ToLower() == txtUserName.Text.Trim().ToLower() && c.Passwrd.ToLower() == txtPassword.Text.Trim().ToLower())); if (obj == null) { RadMessageBox.Show("Invalid UserName or Password.", "EuroSoftTech", MessageBoxButtons.OK, RadMessageIcon.Error); txtUserName.Focus(); db.Dispose(); return; } else { AppVars.objSubCompany = db.Gen_SubCompanies.FirstOrDefault(c => c.Id == obj.SubcompanyId); if (AppVars.objSubCompany == null) { db.Dispose(); ENUtils.ShowMessage("This user is not created properly" + Environment.NewLine + "Define Subcompany for that user in Users Menu."); return; } AppVars.DefaultSubCompanyId = AppVars.objSubCompany.Id; } if (this.InvokeRequired) { DisplayProgressBar d = new DisplayProgressBar(ShowLoadingImage); this.BeginInvoke(d); } else { ShowLoadingImage(); } frmMainMenu frm = new frmMainMenu(); if (IsAutoLogin) { frm.showWarning = false; } frm.ObjLoginUser = new DAL.LoginUser(); frm.ObjLoginUser.SysGen = obj.UM_SecurityGroup.SysGen.ToBool(); frm.ObjLoginUser.LgroupId = obj.SecurityGroupId.ToInt(); frm.ObjLoginUser.LoginName = obj.UserName; frm.ObjLoginUser.LuserId = obj.Id; frm.ObjLoginUser.UserName = obj.UserName; frm.ObjLoginUser.Email = obj.Email; frm.ObjLoginUser.Password = obj.Passwrd; frm.ObjLoginUser.LsessionId = db.stp_ControlerLogins(frm.ObjLoginUser.LuserId.ToInt(), null, null, Environment.MachineName).FirstOrDefault().Id.ToInt(); frm.ObjLoginUser.IsAdmin = obj.ConfirmPasswrd.ToStr() == "1"?true:false; AppVars.LoginObj = frm.ObjLoginUser; AppVars.AppTheme = obj.ThemeName; frm.CurrentTheme = obj.ThemeName; frm.ShowAllBookings = obj.ShowAllBookings.ToBool(); frm.ShowAllDrivers = obj.ShowAllDrivers.ToBool(); frm.ShowDriverFilter = obj.ShowDriverFilter.ToBool(); frm.ShowBookingFilter = obj.ShowBookingFilter.ToBool(); AppVars.ShowAllBookings = obj.ShowAllBookings.ToBool(); AppVars.CanTransferJob = obj.TransferBooking.ToBool(); AppVars.IsTelephonist = obj.Fax.ToStr() == "1" ? true : false; frm.Show(); this.ShowInTaskbar = false; this.Hide(); frmLoading.Close(); db.Dispose(); // Close(); } catch (Exception ex) { ENUtils.ShowMessage(ex.Message); } }
private void UpdateDriverRent() { try { if (RentId == 0) { ENUtils.ShowMessage("Driver Rent is not Generated"); return; } if (chkOther.Checked) { ddlRentPayReason.SelectedValue = null; } decimal RentDue = lblRentDue.Text.ToDecimal(); decimal RentPay = spnRentPay.Value.ToDecimal(); decimal RentPaid = (RentPay + RentDue); decimal CurrentBalance = numCurrBalance.Value.ToDecimal(); int? rentPayReasonId = ddlRentPayReason.SelectedValue.ToIntorNull(); string rentPayReasonText = txtReason.Text.Trim(); bool IsNewReason = false; using (TaxiDataContext db = new TaxiDataContext()) { if (rentPayReasonId == null && !string.IsNullOrEmpty(rentPayReasonText)) { try { DriverRentPayReason objRentPayReason = new DriverRentPayReason(); rentPayReasonId = db.DriverRentPayReasons.OrderByDescending(c => c.Id).FirstOrDefault().Id + 1; objRentPayReason.Id = rentPayReasonId.ToInt(); objRentPayReason.RentReason = rentPayReasonText; db.DriverRentPayReasons.InsertOnSubmit(objRentPayReason); db.SubmitChanges(); IsNewReason = true; } catch { } } db.stp_UpdateDriverRentWithReason(RentId, CurrentBalance, RentPay, rentPayReasonId); } if (IsNewReason) { ComboFunctions.FillRentPayReasonCombo(ddlRentPayReason); } //else //{ // DriverRentBO rentBo = new DriverRentBO(); // rentBo.GetByPrimaryKey(RentId); // if (rentBo.Current != null) // { // rentBo.Current.RentPayReasonId = ddlRentPayReason.SelectedValue.ToIntorNull(); // rentBo.Current.Balance // } //} DisplayRecord(); // this.Close(); } catch (Exception ex) { ENUtils.ShowMessage(ex.Message); } }
public void GenerateReport(decimal VAT) { try { if (optFullDetail.ToggleState == Telerik.WinControls.Enumerations.ToggleState.On) { DisplayCriteriaType = ""; } else if (optAccountJobs.ToggleState == Telerik.WinControls.Enumerations.ToggleState.On) { DisplayCriteriaType = "account_"; } else if (optSummaryDetails.ToggleState == Telerik.WinControls.Enumerations.ToggleState.On) { DisplayCriteriaType = "summary_"; } reportViewer1.LocalReport.EnableExternalImages = true; if (objSubcompany == null) { objSubcompany = AppVars.objSubCompany; } //Microsoft.Reporting.WinForms.ReportParameter[] param = new Microsoft.Reporting.WinForms.ReportParameter[27]; Microsoft.Reporting.WinForms.ReportParameter[] param = new Microsoft.Reporting.WinForms.ReportParameter[28]; string address = objSubcompany.Address; string telNo = string.Empty; string sortCode = objSubcompany.SortCode.ToStr(); string accountNo = objSubcompany.AccountNo.ToStr(); string accountTitle = objSubcompany.AccountTitle.ToStr(); string bank = objSubcompany.BankName.ToStr(); string hasBankDetails = "1"; if (string.IsNullOrEmpty(sortCode) && string.IsNullOrEmpty(accountNo) && string.IsNullOrEmpty(accountTitle) && string.IsNullOrEmpty(bank)) { hasBankDetails = "0"; } if (!string.IsNullOrEmpty(sortCode)) { sortCode = "Sort Code : " + sortCode; } if (!string.IsNullOrEmpty(accountTitle)) { accountTitle = "Account Title : " + accountTitle; } string website = objSubcompany.WebsiteUrl.ToStr(); if (!string.IsNullOrEmpty(website)) { website += " , "; } website += "Email:" + objSubcompany.EmailAddress.ToStr(); string companyNumber = objSubcompany.CompanyNumber.ToStr(); if (!string.IsNullOrEmpty(companyNumber)) { companyNumber = "Company Number: " + companyNumber; } string vatNumber = objSubcompany.CompanyVatNumber.ToStr(); param[0] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Address", address); param[18] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Footer", objSubcompany.WebsiteUrl.ToStr()); param[14] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_MobileNo", "Mobile: " + objSubcompany.EmergencyNo.ToStr()); param[15] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Website", website); param[16] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Email", "Email: " + objSubcompany.EmailAddress.ToStr()); param[20] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_CompanyNumber", companyNumber); param[21] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_VATNumber", vatNumber); param[7] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_SortCode", sortCode); param[9] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_AccountTitle", accountTitle); param[10] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Bank", bank); List <ClsLogo> objLogo = new List <ClsLogo>(); objLogo.Add(new ClsLogo { ImageInBytes = objSubcompany.CompanyLogo != null ? objSubcompany.CompanyLogo.ToArray() : null }); ReportDataSource imageDataSource = new ReportDataSource("Taxi_AppMain_Classes_ClsLogo", objLogo); this.reportViewer1.LocalReport.DataSources.Add(imageDataSource); string path = @"File:"; param[2] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Path", path); param[6] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_CompanyHeader", objSubcompany.CompanyName.ToStr()); param[22] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_CompanyHeading", objSubcompany.CompanyName.ToStr()); int?driverId = this.DataSource.FirstOrDefault().DefaultIfEmpty().DriverId; var data = this.DataSource.FirstOrDefault().DefaultIfEmpty(); telNo = "Tel No. " + objSubcompany.TelephoneNo; if (!string.IsNullOrEmpty(accountNo)) { accountNo = "Account No : " + accountNo; } //var objTemplate = General.GetObject<UM_Form_Template>(c => c.UM_Form.FormName == this.Name && c.IsDefault == true); //string className = "Taxi_AppMain.ReportDesigns."; //if (objTemplate!=null) //{ // if (objTemplate.TemplateName == "Template1") // { // this.reportViewer1.LocalReport.ReportEmbeddedResource = className + "rptDriverRentTrasaction.rdlc"; // } // else if (objTemplate.TemplateName == "Template2") // { // this.reportViewer1.LocalReport.ReportEmbeddedResource = className + "rptDriverRentTrasaction2.rdlc"; // } // else if (objTemplate.TemplateName == "Template3") // { // this.reportViewer1.LocalReport.ReportEmbeddedResource = className + "rptDriverRentTrasaction3.rdlc"; // } // else if (objTemplate.TemplateName == "Template4") // { // this.reportViewer1.LocalReport.ReportEmbeddedResource = className + "rptDriverRentTrasaction4.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 = VAT; 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[19] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_HasBankDetails", hasBankDetails); int cnt = this.DataSource.Count; //NC //decimal JobTotal = 0; // string AccountBooking = string.Empty; // string CashBooking = string.Empty; // AccountBooking = string.Format("{0:£ #.##}", this.DataSource.Where(c => c.CompanyId != null).Sum(c => c.FareRate.ToDecimal())); // CashBooking = string.Format("{0:£ #.##}", this.DataSource.Where(c => c.CompanyId == null).Sum(c => c.FareRate.ToDecimal())); // JobTotal = this.DataSource.Sum(c => c.FareRate.Value.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); //comment //string BalanceType = string.Empty; //int DriverId = this.DataSource.FirstOrDefault().DefaultIfEmpty().DriverId.ToInt(); //int Id = this.DataSource.FirstOrDefault().DefaultIfEmpty().Id.ToInt(); ; //var query=General.GetObject<DriverRent>(c=>c.DriverId==DriverId && c.Id<Id); //string StatementDate = string.Empty; //if (query == null) //{ // BalanceType = "Initial Balance"; // StatementDate = string.Format("{0:dd/MM}", this.DataSource.FirstOrDefault().DefaultIfEmpty().TransDate); //} //else //{ // BalanceType = "Balance from statement "+query.TransNo; // StatementDate = string.Format("{0:dd/MM}", query.TransDate); //} //param[23] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_jobCount", cnt.ToStr()); //param[24] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_BalanceType", BalanceType); //param[25] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_StatementDate", StatementDate); // string balance=string.Empty; //decimal bal=this.DataSource.FirstOrDefault().DefaultIfEmpty().Balance.ToDecimal(); //if(bal>=0) //{ // balance = "You are due to Pay £" + string.Format("{0:f2}", bal); //} //else //{ // balance = "You are due to receive £" + string.Format("{0:f2}", bal); // balance = balance.Replace("-", "").Trim(); //} //param[26] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Balance", balance); //reportViewer1.LocalReport.SetParameters(param); ////this.vu_DriverRentBindingSource.DataSource = this.DataSource; //this.vu_DriverRentExpenseBindingSource.DataSource = this.DataSource; //this.vu_FleetDriverRentExpenseBindingSource.DataSource = this.DataSource2; //this.reportViewer1.ZoomPercent = 100; //this.reportViewer1.ZoomMode = Microsoft.Reporting.WinForms.ZoomMode.Percent; //this.reportViewer1.RefreshReport(); string BalanceType = string.Empty; int DriverId = 0; string oldBalanceDate = string.Empty; if (this.DataSource.Count > 0) { DriverId = this.DataSource.FirstOrDefault().DriverId.ToInt(); int Id = this.DataSource.FirstOrDefault().Id.ToInt();; // var query = General.GetObject<DriverRent>(c => c.DriverId == DriverId && c.Id < Id); string StatementDate = string.Empty; //if (query == null) //{ // BalanceType = "Initial Balance"; // StatementDate = string.Format("{0:dd/MM}", this.DataSource.FirstOrDefault().TransDate); //} //else //{ // BalanceType = "Balance from statement " + query.TransNo; // StatementDate = string.Format("{0:dd/MM}", query.TransDate); //} using (TaxiDataContext db = new TaxiDataContext()) { var query = db.DriverRents.Where(c => c.DriverId == driverId && c.Id < Id).OrderByDescending(c => c.Id).FirstOrDefault(); if (query == null) { BalanceType = "Initial Balance"; StatementDate = string.Format("{0:dd/MM}", this.DataSource.FirstOrDefault().TransDate); } else { BalanceType = "Balance from statement " + query.TransNo.ToStr(); StatementDate = string.Format("{0:dd/MM}", this.DataSource.FirstOrDefault().TransDate); try { oldBalanceDate = string.Format("{0:dd/MM}", query.TransDate.ToDate()); } catch { oldBalanceDate = StatementDate; } } } // string Commision = (JobTotal * DriverCommision / 100).ToStr(); param[13] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_HasCostCenter", oldBalanceDate); param[23] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_jobCount", cnt.ToStr()); param[24] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_BalanceType", BalanceType); // param[28] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_AccountExpenses", AccountExpenses.ToStr()); param[25] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_StatementDate", StatementDate); //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 bal = this.DataSource.FirstOrDefault().DefaultIfEmpty().Balance.ToDecimal(); string balance = "Balance Due £" + string.Format("{0:f2}", bal); //if (bal >= 0) //{ // balance = "You are due to Pay £" + string.Format("{0:f2}", bal); //} //else //{ // balance = "You are due to receive £" + string.Format("{0:f2}", bal); // balance = balance.Replace("-", "").Trim(); //} param[26] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Balance", balance); } else { param[23] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_jobCount", cnt.ToStr()); param[24] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_BalanceType", BalanceType); // param[28] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_AccountExpenses", AccountExpenses.ToStr()); param[25] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_StatementDate", ""); param[26] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Balance", ""); } param[27] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_DisplayType", this.DisplayCriteriaType); if (templateName.ToStr().Length == 0) { using (TaxiDataContext db = new TaxiDataContext()) { templateName = db.UM_Form_Templates.Where(c => c.UM_Form.FormName == "frmDriverRentDebitCredit3" && c.IsDefault == true).Select(c => c.TemplateName).FirstOrDefault(); if (templateName.ToStr().Trim().Length > 0) { templateName = templateName + "_"; } } } if (templateName.ToStr().Trim().Length == 0) { templateName = " "; } this.reportViewer1.LocalReport.ReportEmbeddedResource = "Taxi_AppMain.ReportDesigns." + templateName.ToStr().Trim() + "rptDriverRentExpenses3.rdlc"; reportViewer1.LocalReport.SetParameters(param); //this.vu_DriverRentBindingSource.DataSource = this.DataSource; this.vu_DriverRentExpenseBindingSource.DataSource = this.DataSource; this.vu_FleetDriverRentExpenseBindingSource.DataSource = this.DataSource2; this.reportViewer1.ZoomPercent = 100; this.reportViewer1.ZoomMode = Microsoft.Reporting.WinForms.ZoomMode.Percent; this.reportViewer1.RefreshReport(); } catch (Exception ex) { ENUtils.ShowMessage(ex.Message); } }
private void UpdateDriverCommission() { try { if (CommissionId == 0) { ENUtils.ShowMessage("Driver Commission is not Generated"); return; } if (chkOther.Checked) { ddlCommissionPayReason.SelectedValue = null; } decimal CommissionDue = lblCommissionDue.Text.ToDecimal(); decimal CommissionPay = spnCommissionPay.Value.ToDecimal(); decimal CommissionPaid = (CommissionPay + CommissionDue); decimal CurrentBalance = numCurrBalance.Value.ToDecimal(); int? CommissionPayReasonId = ddlCommissionPayReason.SelectedValue.ToIntorNull(); string CommissionPayReasonText = txtReason.Text.Trim(); bool IsNewReason = false; using (TaxiDataContext db = new TaxiDataContext()) { if (CommissionPayReasonId == null && !string.IsNullOrEmpty(CommissionPayReasonText)) { try { //DriverRentPayReason objRentPayReason = new DriverRentPayReason(); //rentPayReasonId = db.DriverRentPayReasons.OrderByDescending(c => c.Id).FirstOrDefault().Id + 1; //objRentPayReason.Id = rentPayReasonId.ToInt(); //objRentPayReason.RentReason = rentPayReasonText; //db.DriverRentPayReasons.InsertOnSubmit(objRentPayReason); //db.SubmitChanges(); DriverCommissionPayReason objCommissionPayReason = new DriverCommissionPayReason(); CommissionPayReasonId = db.DriverCommissionPayReasons.OrderByDescending(c => c.Id).FirstOrDefault().Id + 1; objCommissionPayReason.Id = CommissionPayReasonId.ToInt(); objCommissionPayReason.CommissionReason = CommissionPayReasonText; db.DriverCommissionPayReasons.InsertOnSubmit(objCommissionPayReason); db.SubmitChanges(); IsNewReason = true; } catch { } } db.stp_UpdateDriverCommissionWithReason(CommissionId, CurrentBalance, CommissionPay, CommissionPayReasonId); } if (IsNewReason) { ComboFunctions.FillCommissionReasonCombo(ddlCommissionPayReason); } spnCommissionPay.Value = 0.00m; DisplayRecord(); } catch (Exception ex) { ENUtils.ShowMessage(ex.Message); } }
private void Save() { try { int defaultAllocationLimit = AppVars.objPolicyConfiguration.AllocateDrvPreExistJobLimit.ToInt(); int? driverId = ddl_Driver.SelectedValue.ToIntorNull(); int? oldDriverId = null; string oldDriverNo = string.Empty; long jobId = 0; bool cancelJob = false; DateTime?pickupDateAndTime = ObjMaster.Current.PickupDateTime.ToDateTimeorNull(); //if (driverId != null && defaultAllocationLimit>0 && // General.GetQueryable<Booking>(null).Count(c => c.DriverId == driverId && c.Id!=ObjMaster.Current.Id // && (c.BookingStatusId==Enums.BOOKINGSTATUS.WAITING || c.BookingStatusId==Enums.BOOKINGSTATUS.PENDING) // && // ( // (c.PickupDateTime.Value<=pickupDateAndTime // && (c.PickupDateTime.Value >= pickupDateAndTime.Value.AddMinutes(-defaultAllocationLimit)) ) // || (c.PickupDateTime.Value >= pickupDateAndTime // && (c.PickupDateTime.Value <= pickupDateAndTime.Value.AddMinutes(defaultAllocationLimit))) // ) // ) > 0) //{ // if (DialogResult.No == MessageBox.Show("This driver already have a Job Allocated at this time "+ // Environment.NewLine + "Do you still want to Allocate it ? ", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question)) // { // return; // } //} if (driverId != null) { var ObjDriver = General.GetObject <Fleet_Driver>(c => c.Id == driverId); if (ObjDriver != null) { allocateDrvNo = ObjDriver.DriverNo.ToStr().Trim(); if (ObjDriver.VehicleTypeId != null) { if (ObjMaster.Current.AttributeValues.ToStr().Trim().Length > 0) { string[] bookingAttrs = ObjMaster.Current.AttributeValues.ToStr().Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); string drvAttributes = ObjDriver.AttributeValues.ToStr() + "," + ObjDriver.Fleet_VehicleType.AttributeValues; int totalAttr = bookingAttrs.Count(); int matchCnt = 0; string unmatchedAttrValue = string.Empty; string[] drvAttrsArr = drvAttributes.ToStr().Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); foreach (var item in bookingAttrs) { if (drvAttrsArr.Count(c => c.ToLower() == item.ToLower()) > 0) { matchCnt++; } else { unmatchedAttrValue += item + ","; } } if (matchCnt != totalAttr) { if (unmatchedAttrValue.EndsWith(",")) { unmatchedAttrValue = unmatchedAttrValue.Substring(0, unmatchedAttrValue.LastIndexOf(",")); } MessageBox.Show(("Driver : " + ObjDriver.DriverNo + " doesn't have attributes (" + unmatchedAttrValue + ")"), "Warning"); return; } } if (AppVars.listUserRights.Count(c => c.functionId == "RESTRICT ON DESPATCH JOB TO INVALID VEHICLE DRIVER") > 0) { string vehAttributes = ObjMaster.Current.Fleet_VehicleType.DefaultIfEmpty().AttributeValues.ToStr().Trim(); if (vehAttributes.Length > 0) { bool MatchedAttr = false; foreach (var item in vehAttributes.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)) { if (ObjDriver.VehicleTypeId.ToInt() == item.ToInt()) { MatchedAttr = true; break; } } if (MatchedAttr == false) { MessageBox.Show("This Job is for " + ObjMaster.Current.Fleet_VehicleType.VehicleType.ToStr() + " Vehicle" + Environment.NewLine + "and Driver no " + ObjDriver.DriverNo + " have " + ObjDriver.Fleet_VehicleType.VehicleType + "."); return; } } else { if (ObjDriver.Fleet_VehicleType.NoofPassengers.ToInt() < ObjMaster.Current.Fleet_VehicleType.NoofPassengers.ToInt()) { MessageBox.Show("This Job is for " + ObjMaster.Current.Fleet_VehicleType.VehicleType.ToStr() + " Vehicle" + Environment.NewLine + "and Driver no " + ObjDriver.DriverNo + " have " + ObjDriver.Fleet_VehicleType.VehicleType + "."); return; } } } else { if (ObjDriver.Fleet_VehicleType.NoofPassengers.ToInt() < ObjMaster.Current.Fleet_VehicleType.NoofPassengers.ToInt()) { if (DialogResult.No == MessageBox.Show("This Job is for " + ObjMaster.Current.Fleet_VehicleType.VehicleType.ToStr() + " Vehicle" + Environment.NewLine + "and Driver no " + ObjDriver.DriverNo + " have " + ObjDriver.Fleet_VehicleType.VehicleType + "." + Environment.NewLine + "Do you still want to Allocate this Job to that Driver " + ObjDriver.DriverNo + " ?", "Despatch", MessageBoxButtons.YesNo)) { return; } } } } } try { if ((driverId != null && ObjMaster.Current.DriverId == null) || (driverId != null && ObjMaster.Current.DriverId != null && driverId != ObjMaster.Current.DriverId)) { if (IsDriverDocumentExpired(driverId.ToInt(), ObjDriver)) { return; } } } catch { } } if (ObjMaster.Current != null) { if (driverId != null || (ObjMaster.Current.DriverId != null && ObjMaster.Current.BookingStatusId.ToInt() == Enums.BOOKINGSTATUS.WAITING)) { //if ((driverId != null && ObjMaster.Current.DriverId == null) || (driverId!=null && ObjMaster.Current.DriverId!=null && driverId!=ObjMaster.Current.DriverId)) //{ // if (IsDriverDocumentExpired(driverId.ToInt())) // return; //} if (driverId == null && ObjMaster.Current.DriverId != null) { oldDriverNo = ObjMaster.Current.Fleet_Driver.DriverNo.ToStr(); } if (ObjMaster.Current.DriverId != null) { oldDriverId = ObjMaster.Current.DriverId; } ObjMaster.CheckDataValidation = false; ObjMaster.Edit(); ObjMaster.Current.DriverId = driverId; ObjMaster.Current.IsConfirmedDriver = driverId != null ? chkConfirmed.Checked:false; if (ObjMaster.Current.BookingStatusId.ToInt() == Enums.BOOKINGSTATUS.NOTACCEPTED) { ObjMaster.Current.BookingStatusId = Enums.BOOKINGSTATUS.WAITING; } if (driverId == null || (oldDriverId != null && oldDriverId != driverId && ObjMaster.Current.BookingStatusId != Enums.BOOKINGSTATUS.WAITING)) { ObjMaster.Current.BookingStatusId = Enums.BOOKINGSTATUS.WAITING; cancelJob = true; } jobId = ObjMaster.Current.Id; allocatedJobId = jobId; ObjMaster.CheckCustomerValidation = false; ObjMaster.DisableUpdateReturnJob = true; ObjMaster.Save(); if (ObjMaster.Current.BookingTypeId.ToInt() == Enums.BOOKING_TYPES.THIRDPARTY && ObjMaster.Current.OnlineBookingId != null) { General.UpdateThirdPartyJobStatus(null, jobId, "allocated"); } this.Close(); if (IsOpenFrom == 1) { RefreshTodayBookingsDashboard(); } else { RefreshTodayAndPreBookingsDashboard(); // AppVars.frmMDI.RefreshTodayAnPreDashboard(); } string Msg = string.Empty; if (driverId != null) { if (chkConfirmed.Checked) { Msg = "Job is Allocated and confirmed to Driver (" + ObjMaster.Current.Fleet_Driver.DriverNo.ToStr() + ")"; } else { Msg = "Job is Allocated to Driver (" + ObjMaster.Current.Fleet_Driver.DriverNo.ToStr() + ")"; } } else if (driverId == null && !string.IsNullOrEmpty(oldDriverNo)) { Msg = "Job is De-Allocated from Driver (" + oldDriverNo + ")"; } using (TaxiDataContext db = new TaxiDataContext()) { db.stp_BookingLog(ObjMaster.Current.Id, AppVars.LoginObj.UserName.ToStr(), Msg); if (cancelJob) { if (AppVars.objPolicyConfiguration.DespatchOfflineJobs.ToBool()) { db.stp_DeleteDrvOfflineJob(ObjMaster.Current.Id, oldDriverId); } } } if (cancelJob) { //For TCP Connection if (AppVars.objPolicyConfiguration.IsListenAll.ToBool()) { new Thread(delegate() { General.SendMessageToPDA("request pda=" + oldDriverId + "=" + jobId + "=Cancelled Pre Job>>" + jobId + "=2"); }).Start(); } } } else { ENUtils.ShowMessage("Required: Driver"); } } } catch (Exception ex) { } }
private void GenerateReport() { try { int VehicleId = ddlCompanyVehicle.SelectedValue.ToInt(); if (dtpFromDate.Value != null && dtpFromDate.Value.Value.Year == 1753) { dtpFromDate.Value = null; } if (dtpTillDate.Value != null && dtpTillDate.Value.Value.Year == 1753) { dtpTillDate.Value = null; } DateTime?fromDate = dtpFromDate.Value.ToDateorNull(); DateTime?tillDate = dtpTillDate.Value.ToDateorNull(); string Error = string.Empty; if (fromDate.Value == null) { Error = "Required : From Date"; } if (tillDate.Value == null) { if (string.IsNullOrEmpty(Error)) { Error = "Required : To Date"; } else { Error += Environment.NewLine + "Required : To Date"; } } if (!string.IsNullOrEmpty(Error)) { ENUtils.ShowMessage(Error); return; } if (tillDate != null) { tillDate = tillDate + TimeSpan.Parse("23:59:59"); } using (TaxiDataContext db = new TaxiDataContext()) { var list = db.stp_GetVehicleLoginHistory(fromDate.Value, tillDate.Value, VehicleId).ToList(); if (ddlDriver.SelectedValue.ToInt() != 0) { list = list.Where(c => c.DriverId == ddlDriver.SelectedValue.ToInt()).ToList(); } var list2 = (list.AsEnumerable().OrderBy(item => item.DriverNo, new NaturalSortComparer <string>())).ToList(); this.stp_GetVehicleLoginHistoryResultBindingSource.DataSource = list2; } Microsoft.Reporting.WinForms.ReportParameter[] param = new Microsoft.Reporting.WinForms.ReportParameter[4]; string address = AppVars.objSubCompany.Address; string telNo = "Tel No. " + AppVars.objSubCompany.TelephoneNo; param[0] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Heading", AppVars.objSubCompany.CompanyName.ToStr()); param[1] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Address", address); param[2] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Telephone", telNo); //Report_Parameter_AverageJobsPerDay string heading = string.Empty; if (fromDate != null && tillDate != null) { heading = "Period: " + string.Format("{0:dd/MM/yyyy}", fromDate) + " to " + string.Format("{0:dd/MM/yyyy}", tillDate); } param[3] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Criteria", heading); //param[4] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_AverageJobsPerDay", s.ToStr()); //param[5] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_AverageWorkingPerDay", sWorking); reportViewer1.LocalReport.SetParameters(param); this.reportViewer1.ZoomPercent = 100; this.reportViewer1.ZoomMode = Microsoft.Reporting.WinForms.ZoomMode.Percent; this.reportViewer1.RefreshReport(); } catch (Exception ex) { ENUtils.ShowMessage(ex.Message); } }
private void DeletePaymentHistory() { 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; } 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 this Record ?", "", 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["TransId"].Value.ToInt(); TranId = item.Cells["TransId"].Value.ToLong(); if (TranId > 0) { try { //int Id = row.Cells["Id"].Value.ToInt(); //int TransId = row.Cells["TranId"].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(); } } } } catch (Exception ex) { ENUtils.ShowMessage(ex.Message); } } } PopulateData(); } } } catch (Exception ex) { ENUtils.ShowMessage(ex.Message); } }
public RidesController(TaxiDataContext dbContext) { DbContext = dbContext; }
public override void PopulateData() { try { int RangeId = ddlDateRange.SelectedValue.ToInt(); int DriverId = ddlDriver.SelectedValue.ToInt(); string Error = string.Empty; if (RangeId == 0) { Error = "Required: Date Range"; } if (!string.IsNullOrEmpty(Error)) { ENUtils.ShowMessage(Error); return; } int idx = 0; int val = 0; int driverTypeId = optRent.Checked ? Enums.DRIVERTYPES.RENT : Enums.DRIVERTYPES.COMMISSION; using (TaxiDataContext db = new TaxiDataContext()) { var list = (from a in db.stp_GetDriverWeeklyRentHistory(RangeId, DriverId) select new { a.Id, a.TransId, a.Active, a.AccountBookings, a.RentComm, // a.DriverName, a.DriverNo, a.DriverToPay, a.OfficeToPay, a.PreviousBalance, IsPaid = a.IsPaid, Paid = a.IsPaid != null && a.IsPaid == true ? "Paid" : "", a.FromDate, ToDate = a.TillDate, PaidValue = a.IsPaid != null && a.IsPaid == true ? 1 : 0 }).ToList(); //var list = (from a in db.stp_DriverPaymentAccountBookings(driverTypeId, 115.00m) // select new // { // a.Id, // a.TransId, // a.Active, // a.AccountBookings, // a.TotalRentCommission, // a.DriverName, // a.DriverNo, // a.DriverToPay, // a.OfficeToPay, // a.PreviousBalance, // IsPaid = a.IsWeeklyPaid, // Paid = a.IsWeeklyPaid != null && a.IsWeeklyPaid == true ? "Paid" : "", // a.FromDate, // a.ToDate, // PaidValue=a.IsWeeklyPaid != null && a.IsWeeklyPaid == true ?1:0 // }).ToList(); if (list.Count == 0) { grdLister.RowCount = 0; return; } var list2 = (list.AsEnumerable().OrderBy(item => item.DriverNo, new NaturalSortComparer <string>())).ToList(); idx = grdLister.CurrentRow != null ? grdLister.CurrentRow.Cells["Id"].Value.ToInt() : -1; val = grdLister.TableElement.VScrollBar.Value; grdLister.BeginUpdate(); grdLister.RowCount = list2.Count; for (int i = 0; i < list2.Count; i++) { grdLister.Rows[i].Cells["Id"].Value = list2[i].Id; grdLister.Rows[i].Cells["TransId"].Value = list2[i].TransId; grdLister.Rows[i].Cells["Active"].Value = list2[i].Active; grdLister.Rows[i].Cells["DriverNo"].Value = list2[i].DriverNo; grdLister.Rows[i].Cells["AccountBookings"].Value = list2[i].AccountBookings; grdLister.Rows[i].Cells["PaidAccountBookings"].Value = list2[i].IsPaid.ToBool() ? list2[i].AccountBookings : 0.00m; grdLister.Rows[i].Cells["TotalRentCommission"].Value = list2[i].RentComm; grdLister.Rows[i].Cells["PaidTotalRentCommission"].Value = list2[i].IsPaid.ToBool() ? list2[i].RentComm : 0.00m; grdLister.Rows[i].Cells["OfficeToPay"].Value = list2[i].OfficeToPay; grdLister.Rows[i].Cells["PaidOfficeToPay"].Value = list2[i].IsPaid.ToBool() ? list2[i].OfficeToPay : 0.00m; grdLister.Rows[i].Cells["DriverToPay"].Value = list2[i].DriverToPay; grdLister.Rows[i].Cells["PaidDriverToPay"].Value = list2[i].IsPaid.ToBool() ? list2[i].DriverToPay : 0.00m; grdLister.Rows[i].Cells["PreviousBalance"].Value = list2[i].PreviousBalance.ToDecimal(); grdLister.Rows[i].Cells["PaidPreviousBalance"].Value = list2[i].IsPaid.ToBool() && list2[i].PreviousBalance.ToDecimal() < 0 ? list2[i].PreviousBalance.ToDecimal() : 0.00m; grdLister.Rows[i].Cells["IsPaid"].Value = list2[i].IsPaid.ToBool(); grdLister.Rows[i].Cells["Paid"].Value = list2[i].Paid.ToStr(); grdLister.Rows[i].Cells["FromDate"].Value = list2[i].FromDate.ToDate(); grdLister.Rows[i].Cells["ToDate"].Value = list2[i].ToDate.ToDate(); grdLister.Rows[i].Cells["PaidValue"].Value = list2[i].PaidValue.ToInt(); grdLister.Rows[i].Cells["Check"].Value = false; } grdLister.EndUpdate(); } SetDefaultColumnSettings(); AddSummaries(); UpdatePeriod(); if (idx > 0) { grdLister.CurrentRow = grdLister.Rows.FirstOrDefault(c => c.Cells["Id"].Value.ToInt() == idx); } if (grdLister.TableElement.VScrollBar.Maximum >= val) { grdLister.TableElement.VScrollBar.Value = val; } } catch (Exception ex) { ENUtils.ShowMessage(ex.Message); } }
public override void PopulateData() { try { string FromPostCode = null; string ToPostCode = null; int FromLocId = 0; int ToLocId = 0; int FromZoneId = 0; int ToZoneId = 0; if (rbtnPostCode.IsChecked == true) { string PostCode = txtPostCode.Text.Trim(); if (string.IsNullOrEmpty(PostCode)) { ENUtils.ShowMessage("Requierd : Post Code"); return; } if (rbtnPickup.IsChecked == true) { FromPostCode = PostCode; } else if (rbtnDestination.IsChecked == true) { ToPostCode = PostCode; } else { FromPostCode = PostCode; ToPostCode = PostCode; } } else if (rbtnLocation.IsChecked == true) { int LocationId = ddlLocation.SelectedValue.ToInt(); if (LocationId == 0) { ENUtils.ShowMessage("Requierd : Loaction Code"); return; } if (rbtnPickup.IsChecked == true) { FromLocId = LocationId; } else if (rbtnDestination.IsChecked == true) { ToLocId = LocationId; } else { ToLocId = LocationId; FromLocId = LocationId; } } else { int ZoneId = ddlArea.SelectedValue.ToInt(); if (ZoneId == 0) { ENUtils.ShowMessage("Requierd : Area Code"); return; } if (rbtnPickup.IsChecked == true) { FromZoneId = ZoneId; } else if (rbtnDestination.IsChecked == true) { ToZoneId = ZoneId; } else { FromZoneId = ZoneId; ToZoneId = ZoneId; } } using (TaxiDataContext db = new TaxiDataContext()) { var list = db.stp_JobStatistics(FromPostCode, ToPostCode, FromLocId, ToLocId, FromZoneId, ToZoneId, fromDate.Value.ToDate(), tillDate.Value.ToDate()).ToList(); if (list.Count() > 0) { grdJobsStatistics.Columns.Clear(); grdJobsStatistics.DataSource = list; grdJobsStatistics.Columns["BookingNo"].Width = 150; grdJobsStatistics.Columns["PickupDateTime"].Width = 145; grdJobsStatistics.Columns["VehicleType"].Width = 130; grdJobsStatistics.Columns["FromAddress"].Width = 280; grdJobsStatistics.Columns["ToAddress"].Width = 280; grdJobsStatistics.Columns["DriverName"].Width = 130; grdJobsStatistics.Columns["StatusName"].Width = 130; grdJobsStatistics.Columns["BookingNo"].HeaderText = "Booking No"; grdJobsStatistics.Columns["PickupDateTime"].HeaderText = "Pickup Date Time"; grdJobsStatistics.Columns["VehicleType"].HeaderText = "Vehicle Type"; grdJobsStatistics.Columns["FromAddress"].HeaderText = "From Address"; grdJobsStatistics.Columns["ToAddress"].HeaderText = "To Address"; grdJobsStatistics.Columns["DriverName"].HeaderText = "Driver Name"; grdJobsStatistics.Columns["StatusName"].HeaderText = "Status"; } else { grdJobsStatistics.Columns.Clear(); grdJobsStatistics.Rows.Clear(); FormatGrid(); } lblTotalJobs.Text = "Total Jobs : " + grdJobsStatistics.Rows.Count(); } } catch (Exception ex) { ENUtils.ShowMessage(ex.Message); } }
void menu_showJobs_Click(object sender, EventArgs e) { try { RadMenuItem item = (RadMenuItem)sender; GridViewRowInfo row = grdLister.CurrentRow; using (TaxiDataContext db = new TaxiDataContext()) { db.DeferredLoadingEnabled = false; if (row != null && row is GridViewDataRowInfo) { string mobileNo = row.Cells["MobileNo"].Value.ToString(); string name = row.Cells["Name"].Value.ToString(); DateTime?fromDate = DateTime.Now.ToDate(); DateTime?tillDate = DateTime.Now.ToDate(); List <Booking> list = null; if (rdAll.ToggleState == ToggleState.On) { fromDate = null; tillDate = null; // list = db.stp_AppUsers(fromDate, tillDate, 1).ToList(); // .Where(c => (c.CustomerMobileNo == mobileNo || c.CustomerPhoneNo == mobileNo) && c.CustomerName == name).ToList(); list = db.Bookings.Where(c => (c.CustomerMobileNo == mobileNo) && (c.CustomerName == name)).ToList(); } else if (rdRegular.ToggleState == ToggleState.On) { fromDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month - 1, DateTime.Now.Day); tillDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day); list = db.Bookings.Where(c => (c.CustomerMobileNo == mobileNo) && (c.CustomerName == name) && (c.BookingDate.Value >= fromDate && c.BookingDate.Value <= tillDate) ).ToList(); } else if (rdDateTime.ToggleState == ToggleState.On) { fromDate = dtpFromDate.Value.ToDateTimeorNull(); tillDate = dtpToDate.Value.ToDateTimeorNull(); if (fromDate != null && dtpFromTime.Value != null && dtpFromTime.Value.Value != null) { fromDate = (fromDate.Value.ToDate() + dtpFromTime.Value.Value.TimeOfDay).ToDateTime(); } if (tillDate != null && dtptilltime.Value != null && dtptilltime.Value.Value != null) { tillDate = (tillDate.Value.ToDate() + dtptilltime.Value.Value.TimeOfDay).ToDateTime(); } //list = General.GetQueryable<Booking>(c => (c.BookingDate.Value >= fromDate && c.BookingDate.Value <= tillDate) // && (c.CustomerMobileNo == mobileNo)).ToList(); // list = db.Bookings.Where(c => c.CustomerMobileNo == mobileNo || c.CustomerPhoneNo == mobileNo).ToList(); list = db.Bookings.Where(c => (c.CustomerMobileNo == mobileNo) && (c.CustomerName == name)).ToList(); } if (list.Count > 0) { frmDriverJobs frmDrvJobs = new frmDriverJobs(list, row.Cells["Name"].Value.ToStr(), "Customer"); frmDrvJobs.StartPosition = FormStartPosition.CenterScreen; frmDrvJobs.ShowDialog(); frmDrvJobs.Dispose(); } else { MessageBox.Show("No Booking(s) Found"); } } } } catch { } }