void grdLister_CommandCellClick(object sender, EventArgs e)
        {
            GridCommandCellElement gridCell = (GridCommandCellElement)sender;

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

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


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

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


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

                                {
                                    Fleet_DriverCommissionCollectionHistory_Detail objDetail = db.Fleet_DriverCommissionCollectionHistory_Details.FirstOrDefault(c => c.Id == Id);


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


                            PopulateData();
                        }
                        catch (Exception ex)
                        {
                            ENUtils.ShowMessage(ex.Message);
                        }
                    }
                }
            }
        }
        private bool SaveSettings()
        {
            bool rtn = false;

            try
            {
                using (TaxiDataContext db = new TaxiDataContext())
                {
                    db.PeakTimeSettings.DeleteAllOnSubmit(db.PeakTimeSettings);

                    db.SubmitChanges();


                    foreach (var item in grdPeak.Rows)
                    {
                        int fromDay = item.Cells["FromDay"].Value.ToStr().Split(new char[] { ',' })[1].Trim().Replace("]", "").Trim().ToInt();
                        int tillDay = item.Cells["TillDay"].Value.ToStr().Split(new char[] { ',' })[1].Trim().Replace("]", "").Trim().ToInt();


                        db.PeakTimeSettings.InsertOnSubmit(new PeakTimeSetting
                        {
                            FromDay          = fromDay,
                            ToDay            = tillDay,
                            FromTime         = item.Cells["FromTime"].Value.ToDateTime(),
                            ToTill           = item.Cells["TillTime"].Value.ToDateTime(),
                            ZoneId           = item.Cells["Plot"].Value.ToInt(),
                            IncrementPercent = item.Cells["IncrementPercentage"].Value.ToDecimal(),
                            IsAmountWise     = item.Cells["AmountWise"].Value.ToBool(),
                            Amount           = item.Cells["Amount"].Value.ToDecimal()
                        });


                        db.SubmitChanges();
                    }

                    var objGen = db.Gen_SysPolicy_Configurations.FirstOrDefault();

                    objGen.PeakTimeIncPercent = numIncrementRate.Value.ToInt();

                    db.SubmitChanges();
                }

                AppVars.objPolicyConfiguration = General.GetObject <Gen_SysPolicy_Configuration>(c => c.Id != 0);



                rtn = true;
            }
            catch (Exception ex)
            {
                ENUtils.ShowMessage(ex.Message);
            }


            return(rtn);
        }
        private void GrdOnlineBookingSettings_CommandCellClick(object sender, EventArgs e)
        {
            try
            {
                GridCommandCellElement gridCell = (GridCommandCellElement)sender;
                if (gridCell.ColumnInfo.Name.ToLower() == "btndelete")
                {
                    if (DialogResult.Yes == RadMessageBox.Show("Are you sure you want to delete Entery? ", "", MessageBoxButtons.YesNo, RadMessageIcon.Question))
                    {
                        int Id = grdOnlineBookingSettings.CurrentRow.Cells[COL_ZONE.Id].Value.ToInt();
                        if (Id > 0)
                        {
                            using (TaxiDataContext db = new TaxiDataContext())
                            {
                                var query = db.OnlineBookingSettings_Details.FirstOrDefault(c => c.Id == Id);
                                db.OnlineBookingSettings_Details.DeleteOnSubmit(query);
                                db.SubmitChanges();
                            }
                        }
                        RadGridView grid = gridCell.GridControl;

                        grid.CurrentRow.Delete();
                    }
                }
            }
            catch (Exception ex)
            {
                ENUtils.ShowMessage(ex.Message);
            }
        }
        private void btnDeleteHistory_Click(object sender, EventArgs e)
        {
            try
            {
                int RangeId = ddlDateRange.SelectedValue.ToInt();


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

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


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


                ComboFunctions.FillDriverCommissionCollectionHistoryCombo(ddlDateRange);
                grdLister.Rows.Clear();
            }
            catch (Exception ex)
            {
                ENUtils.ShowMessage(ex.Message);
            }
        }
Beispiel #5
0
        void grdSMSTemplets_RowsChanging(object sender, GridViewCollectionChangingEventArgs e)
        {
            try
            {
                if (e.Action == Telerik.WinControls.Data.NotifyCollectionChangedAction.Remove)
                {
                    if (grdSMSTemplets.CurrentRow != null && grdSMSTemplets.CurrentRow is GridViewDataRowInfo)
                    {
                        int id = grdSMSTemplets.CurrentRow.Cells["Id"].Value.ToInt();

                        using (TaxiDataContext db = new TaxiDataContext())
                        {
                            var obj = db.Fleet_DriverTemplets.FirstOrDefault(c => c.Id == id);

                            if (obj != null)
                            {
                                db.Fleet_DriverTemplets.DeleteOnSubmit(obj);
                                db.SubmitChanges();
                            }
                        }
                    }
                }
            }
            catch
            {
            }
        }
        private void GrdFareIncreament_CommandCellClick(object sender, EventArgs e)
        {
            try
            {
                GridCommandCellElement gridCell = (GridCommandCellElement)sender;


                if (gridCell.ColumnInfo.Name == "delete")
                {
                    int id = gridCell.RowInfo.Cells["Id"].Value.ToInt();


                    if (id > 0)
                    {
                        using (TaxiDataContext db = new TaxiDataContext())
                        {
                            Fare_IncrementSetting objfare = db.Fare_IncrementSettings.FirstOrDefault(c => c.Id == id);
                            db.Fare_IncrementSettings.DeleteOnSubmit(objfare);
                            db.SubmitChanges();

                            gridCell.RowInfo.Delete();
                        }
                    }
                }
            }
            catch
            {
            }
        }
Beispiel #7
0
        private void UpdateEmailSettings()
        {
            try
            {
                if (grdLister.Rows.Count == 1)
                {
                    using (TaxiDataContext db = new TaxiDataContext())
                    {
                        Gen_SysPolicy_Configuration objPolicy = db.Gen_SysPolicy_Configurations.FirstOrDefault();

                        if (objPolicy != null)
                        {
                            objPolicy.SmtpHost  = objMaster.Current.SmtpHost.ToStr();
                            objPolicy.UserName  = objMaster.Current.SmtpUserName.ToStr();
                            objPolicy.Password  = objMaster.Current.SmtpPassword.ToStr();
                            objPolicy.Port      = objMaster.Current.SmtpPort.ToStr();
                            objPolicy.EnableSSL = objMaster.Current.SmtpHasSSL.ToBool();


                            db.SubmitChanges();
                        }
                    }
                }
            }
            catch
            {
            }
        }
Beispiel #8
0
        void grdDrivers_CommandCellClick(object sender, EventArgs e)
        {
            try
            {
                if (grdDrivers.CurrentRow != null && grdDrivers.CurrentRow is GridViewDataRowInfo)
                {
                    decimal drvfares = grdDrivers.CurrentRow.Cells["Bid"].Value.ToDecimal();
                    int?    driverId = grdDrivers.CurrentRow.Cells["DriverId"].Value.ToIntorNull();

                    bool IsDespatched = false;
                    long jobId        = _objBooking.Id;


                    using (TaxiDataContext db = new TaxiDataContext())
                    {
                        Booking obj = db.Bookings.FirstOrDefault(c => c.Id == jobId);

                        if (obj != null)
                        {
                            obj.Booking_Logs.Add(new Booking_Log
                            {
                                BookingId    = obj.Id,
                                UpdateDate   = DateTime.Now,
                                BeforeUpdate = "Old Fares : £" + Math.Round(obj.FareRate.ToDecimal(), 2),
                                AfterUpdate  = "Fares changed to Lowest Bid Driver Rate £" + drvfares
                            });

                            obj.FareRate = drvfares;
                            db.SubmitChanges();
                        }
                    }



                    if (_objBooking.PickupDateTime.Value.Date <= DateTime.Now.Date && General.GetQueryable <Fleet_DriverQueueList>(c => c.DriverId == driverId && c.Status == true).Count() > 0)
                    {
                        frmDespatchJob frm = new frmDespatchJob((General.GetObject <Booking>(c => c.Id == _objBooking.Id)), driverId, true);
                        frm.StartPosition = FormStartPosition.CenterScreen;
                        frm.ShowDialog();
                        IsDespatched = frm.IsDespatched;

                        frm.Dispose();
                    }
                    else
                    {
                        frmDespatchPreBooking frmPreDespatch = new frmDespatchPreBooking(General.GetObject <Booking>(c => c.Id == _objBooking.Id), driverId, true);
                        frmPreDespatch.StartPosition = FormStartPosition.CenterScreen;
                        frmPreDespatch.ShowDialog();
                        IsDespatched = frmPreDespatch.SuccessDespatched;

                        frmPreDespatch.Dispose();
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }
        void grdPaymentHistory_CommandCellClick(object sender, EventArgs e)
        {
            try
            {
                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);
                        }
                        objDriverRent.GetByPrimaryKey(RentId);
                        objDriverRent.Edit();
                        objDriverRent.Current.Balance = numCurrBalance.Value.ToDecimal();

                        objDriverRent.Save();
                        using (TaxiDataContext db = new TaxiDataContext())
                        {
                            var query = db.Fleet_DriverRentExpenses.Single(c => c.Id == Id);
                            db.Fleet_DriverRentExpenses.DeleteOnSubmit(query);
                            db.SubmitChanges();
                        }
                        DisplayRecord();
                    }
                }
            }
            catch (Exception ex)
            {
                ENUtils.ShowMessage(ex.Message);
            }
        }
Beispiel #10
0
        private void SaveDriverShift()
        {
            try
            {
                List <Fleet_Driver_Shift> objShiftList = new List <Fleet_Driver_Shift>();

                List <int> objFleet_Driver_ShiftId = new List <int>();

                for (int i = 0; i < grdDriverShift.Rows.Count; i++)
                {
                    int DriverId = grdDriverShift.Rows[i].Cells[COLS.DriverId].Value.ToInt();

                    int Driver_Shift_ID = grdDriverShift.Rows[i].Cells[COLS.Driver_Shift_ID].Value.ToInt();

                    int Fleet_Driver_Shift_ID = grdDriverShift.Rows[i].Cells[COLS.Fleet_Driver_Shift_ID].Value.ToInt();

                    if (Driver_Shift_ID == objMaster.Current.Id)
                    {
                        if (grdDriverShift.Rows[i].Cells[COLS.Check].Value.ToBool() == false)
                        {
                            objFleet_Driver_ShiftId.Add(Fleet_Driver_Shift_ID);
                        }
                    }
                    else
                    {
                        if (grdDriverShift.Rows[i].Cells[COLS.Check].Value.ToBool())
                        {
                            objShiftList.Add(new Fleet_Driver_Shift {
                                DriverId = DriverId, Driver_Shift_ID = objMaster.Current.Id
                            });
                        }
                    }
                }

                using (TaxiDataContext db = new TaxiDataContext())
                {
                    var list = db.Fleet_Driver_Shifts.Where(x => objFleet_Driver_ShiftId.Contains(x.Id)).ToList();
                    if (list.Count > 0)
                    {
                        db.Fleet_Driver_Shifts.DeleteAllOnSubmit(list);
                    }
                    if (objShiftList.Count > 0)
                    {
                        db.Fleet_Driver_Shifts.InsertAllOnSubmit(objShiftList);
                    }
                    db.SubmitChanges();
                }
            }
            catch (Exception ex)
            {
                ENUtils.ShowMessage(ex.Message);
            }
        }
        private void TransferJob()
        {
            try
            {
                int ThirdPartyCompanyId = ddlThirdPartyCompany.SelectedValue.ToInt();
                if (ThirdPartyCompanyId == 0)
                {
                    ENUtils.ShowMessage("Required : Company to transfer job");
                    return;
                }


                string subCompanyName = ddlThirdPartyCompany.Text.Trim();



                using (TaxiDataContext db = new TaxiDataContext())
                {
                    Booking obj = db.Bookings.FirstOrDefault(c => c.Id == JobId);


                    if (obj != null)
                    {
                        string OldSubCompanyName = this.objBooking.Gen_SubCompany.DefaultIfEmpty().CompanyName.ToStr();

                        obj.SubcompanyId = ThirdPartyCompanyId;

                        obj.Booking_Logs.Add(new Booking_Log
                        {
                            User          = AppVars.LoginObj.UserName.ToStr(),
                            BeforeUpdate  = "Transfer From : " + OldSubCompanyName
                            , AfterUpdate = "Transfer To : " + subCompanyName, BookingId = JobId, UpdateDate = DateTime.Now
                        });
                        db.SubmitChanges();
                    }
                }

                new BroadcasterData().BroadCastToAll(RefreshTypes.REFRESH_BOOKING_DASHBOARD);

                if (Application.OpenForms.OfType <Form>().Count(c => c.Name == "frmBookingsList") > 0)
                {
                    (Application.OpenForms.OfType <Form>().FirstOrDefault(c => c.Name == "frmBookingsList") as frmBookingsList).SetRefreshWhenActive("");
                }

                this.Close();

                //}
            }
            catch (Exception ex)
            {
                ENUtils.ShowMessage(ex.Message);
            }
        }
Beispiel #12
0
        private void grid_CommandCellClick(object sender, EventArgs e)
        {
            GridCommandCellElement gridCell = (GridCommandCellElement)sender;

            if (gridCell.ColumnInfo.Name.ToLower() == "btndelete")
            {
                if (DialogResult.Yes == RadMessageBox.Show("Are you sure you want to delete Payment. ? ", "", MessageBoxButtons.YesNo, RadMessageIcon.Question))
                {
                    try
                    {
                        RadGridView grid = gridCell.GridControl;

                        GridViewRowInfo row       = grdPayment.CurrentRow;
                        int             Id        = row.Cells[COL_PAYMENT.ID].Value.ToInt();
                        decimal         Payment   = row.Cells[COL_PAYMENT.PAYMENT].Value.ToDecimal();
                        int             InvoiceId = row.Cells[COL_PAYMENT.MASTERID].Value.ToInt();
                        if (Id > 0)
                        {
                            using (TaxiDataContext db = new TaxiDataContext())
                            {
                                var query = db.invoice_Payments.FirstOrDefault(c => c.id == Id);
                                db.invoice_Payments.DeleteOnSubmit(query);
                                var query2 = db.Invoices.FirstOrDefault(c => c.Id == InvoiceId);
                                query2.CurrentBalance = (query2.CurrentBalance + Payment);
                                query2.PaidAmount     = (query2.PaidAmount - Payment);


                                if (query2.CurrentBalance > 0)
                                {
                                    query2.InvoicePaymentTypeID = Enums.INVOICE_PAYMENTTYPES.CUSTOM;
                                }

                                db.SubmitChanges();
                            }


                            grid.CurrentRow.Delete();
                        }
                    }
                    catch (Exception ex)
                    {
                        ENUtils.ShowMessage(ex.Message);
                    }
                }
            }
        }
Beispiel #13
0
 void menu_Click(object sender, EventArgs e)
 {
     if (grdInbox.CurrentRow.Cells[COLS.Id].Value != null)
     {
         int Id = grdInbox.CurrentRow.Cells[COLS.Id].Value.ToInt();
         if (Id > 0)
         {
             using (TaxiDataContext db = new TaxiDataContext())
             {
                 InternalMessaging objInternalMessaging = db.InternalMessagings.Single(c => c.Id == Id);
                 db.InternalMessagings.DeleteOnSubmit(objInternalMessaging);
                 db.SubmitChanges();
                 PopulateInbox();
                 PopulateSent();
             }
         }
     }
 }
Beispiel #14
0
        void grdFormShortCuts_CommandCellClick(object sender, EventArgs e)
        {
            GridCommandCellElement gridCell = (GridCommandCellElement)sender;
            string name = gridCell.ColumnInfo.Name.ToLower();

            GridViewRowInfo row = gridCell.RowElement.RowInfo;


            if (name == "edit")
            {
                int Id = grdFormShortCuts.CurrentRow.Cells["Id"].Value.ToInt();
                if (Id > 0)
                {
                    OnDisplayRecord(Id);
                }
            }


            else if (name == "delete")
            {
                if (DialogResult.Yes == RadMessageBox.Show("Are you sure you want to delete a Short Key ? ", "", MessageBoxButtons.YesNo, RadMessageIcon.Question))
                {
                    try
                    {
                        int Id = grdFormShortCuts.CurrentRow.Cells["Id"].Value.ToInt();
                        if (Id > 0)
                        {
                            using (TaxiDataContext db = new TaxiDataContext())
                            {
                                var obj = db.UM_FormShortCuts.FirstOrDefault(c => c.Id == Id);
                                db.UM_FormShortCuts.DeleteOnSubmit(obj);
                                db.SubmitChanges();
                            }
                            grdFormShortCuts.CurrentRow.Delete();
                            ClearFields();
                        }
                    }
                    catch (Exception ex)
                    {
                        ENUtils.ShowMessage(ex.Message);
                    }
                }
            }
        }
Beispiel #15
0
        private void SaveAndClose()
        {
            try
            {
                input_values = string.Join(",", grdAttributesList.Rows.Cast <DataGridViewRow>().Where(r => r.Cells[Col_BookingAttributesList.Default].Value.ToBool() == true).Select(c => c.Cells[Col_BookingAttributesList.ShortName].Value.ToStr()).ToArray <string>());


                input_Ids = string.Join(",", grdAttributesList.Rows.Cast <DataGridViewRow>().Where(r => r.Cells[Col_BookingAttributesList.Default].Value.ToBool() == true).Select(c => c.Cells[Col_BookingAttributesList.Id].Value.ToStr()).ToArray <string>());



                using (TaxiDataContext db = new TaxiDataContext())
                {
                    Customer objCust = db.Customers.FirstOrDefault(c => c.Id == this.CustomerId);

                    if (objCust != null)
                    {
                        objCust.ExcludedDriverIds = input_Ids;
                        db.SubmitChanges();


                        if (objCust.MobileNo.ToStr().Trim().Length > 0 && objCust.TelephoneNo.ToStr().Trim().Length == 0)
                        {
                            db.stp_RunProcedure("update booking set excludeddriverids='" + input_Ids + "' where customermobileno='" + objCust.MobileNo.ToStr().Trim() + "' and bookingstatusid=1");
                        }
                        else if (objCust.MobileNo.ToStr().Trim().Length == 0 && objCust.TelephoneNo.ToStr().Trim().Length > 0)
                        {
                            db.stp_RunProcedure("update booking set excludeddriverids='" + input_Ids + "' where CustomerPhoneNo='" + objCust.TelephoneNo.ToStr().Trim() + "' and bookingstatusid=1");
                        }
                        else if (objCust.MobileNo.ToStr().Trim().Length > 0 && objCust.TelephoneNo.ToStr().Trim().Length > 0)
                        {
                            db.stp_RunProcedure("update booking set excludeddriverids='" + input_Ids + "' where CustomerPhoneNo='" + objCust.TelephoneNo.ToStr().Trim() + "' and customermobileno='" + objCust.MobileNo.ToStr().Trim() + "' and bookingstatusid=1");
                        }
                    }
                }

                this.Close();
            }
            catch (Exception ex)
            {
                ENUtils.ShowMessage(ex.Message);
            }
        }
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            int driverId = ddl_Driver.SelectedValue.ToInt();

            if (driverId > 0)
            {
                try
                {
                    using (TaxiDataContext db = new TaxiDataContext())
                    {
                        db.Fleet_Drivers.FirstOrDefault(c => c.Id == driverId).PDALoginBlocked = chkRentPaid.Checked;
                        db.SubmitChanges();
                    }
                }
                catch
                {
                }
            }
        }
Beispiel #17
0
        private void Save()
        {
            try
            {
                decimal Rate = spnFarePrice.Value.ToDecimal();
                if (Rate == 0)
                {
                    ENUtils.ShowMessage("Required : Fare Rate");
                    return;
                }
                using (TaxiDataContext db = new TaxiDataContext())
                {
                    if (EditType == 1)
                    {
                        db.stp_UpdateFare_ChargesDetails(Id, Rate);
                    }
                    else if (EditType == 2)
                    {
                        Fare_ZoneWisePricing objFare = db.Fare_ZoneWisePricings.FirstOrDefault(c => c.Id == Id);

                        if (objFare != null)
                        {
                            objFare.Price = Rate.ToDecimal();
                            db.SubmitChanges();
                        }
                    }


                    General.RefreshListWithoutSelected <frmFaresList>("frmFaresList1");
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                ENUtils.ShowMessage(ex.Message);
            }
        }
Beispiel #18
0
        void grdFormShortCuts_CommandCellClick(object sender, EventArgs e)
        {
            GridCommandCellElement gridCell = (GridCommandCellElement)sender;
            string name = gridCell.ColumnInfo.Name.ToLower();

            GridViewRowInfo row = gridCell.RowElement.RowInfo;


            if (name == "edit")
            {
                int Id = grdFormShortCuts.CurrentRow.Cells["Id"].Value.ToInt();
                if (Id > 0)
                {
                    frmFormShortCuts frm = new frmFormShortCuts();
                    frm.OnDisplayRecord(Id);
                    frm.ShowDialog();
                    frm.Dispose();
                }
            }


            else if (name == "delete")
            {
                int Id = grdFormShortCuts.CurrentRow.Cells["Id"].Value.ToInt();
                if (Id > 0)
                {
                    using (TaxiDataContext db = new TaxiDataContext())
                    {
                        var obj = db.UM_FormShortCuts.FirstOrDefault(c => c.Id == Id);
                        db.UM_FormShortCuts.DeleteOnSubmit(obj);
                        db.SubmitChanges();
                        grdFormShortCuts.CurrentRow.Delete();
                    }
                }
            }
        }
Beispiel #19
0
        private void GrdDriverShift_CommandCellClick(object sender, EventArgs e)
        {
            GridCommandCellElement gridCell = (GridCommandCellElement)sender;

            if (gridCell.ColumnInfo.Name.ToLower() == "btnedit")
            {
                GridViewRowInfo row = grdDriverShift.CurrentRow;

                //EditShit(row);
            }
            else if (gridCell.ColumnInfo.Name.ToLower() == "btndelete")
            {
                GridViewRowInfo row = grdDriverShift.CurrentRow;
                int             Id  = row.Cells[COLS.Id].Value.ToInt();
                using (TaxiDataContext db = new TaxiDataContext())
                {
                    var query = db.Fleet_Driver_Shifts.FirstOrDefault(c => c.Id == Id);
                    db.Fleet_Driver_Shifts.DeleteOnSubmit(query);
                    db.SubmitChanges();
                }
                RadGridView grid = gridCell.GridControl;
                grid.CurrentRow.Delete();
            }
        }
        void worker_DoWork(object sender, DoWorkEventArgs e)
        {
            try
            {
                var listMain = (from a in grdPostCodes.Rows.Where(c => c.Cells[COLS.Check].Value.ToBool() == true)
                                select new
                {
                    Id = a.Cells[COLS.Id].Value,
                    PostCode = a.Cells[COLS.PostCode].Value.ToStr()
                }).ToList();


                bool allowUpdating = false;
                foreach (var item in listMain)
                {
                    using (TaxiDataContext db = new TaxiDataContext())
                    {
                        allowUpdating = false;

                        var listofCoordinates = db.stp_GetCoordinatesByRoadLevelData(item.Id.ToInt(), string.Empty).ToList();


                        if (item.PostCode.Length == 1 && listofCoordinates.Count != db.Gen_Coordinates.Count(c => c.PostCode[0] == item.PostCode[0] && SqlMethods.Like(c.PostCode, "[A-Z][0-9]%")))
                        {
                            allowUpdating = true;
                        }
                        else if (item.PostCode.Length > 1 && listofCoordinates.Count != db.Gen_Coordinates.Count(c => c.PostCode.StartsWith(item.PostCode)))
                        {
                            allowUpdating = true;
                        }

                        if (allowUpdating)
                        {
                            CurrentRow cr = new CurrentRow();
                            cr.Total       = listofCoordinates.Count;
                            cr.UpdateValue = item.PostCode;

                            int cnter = 0;
                            foreach (var item2 in listofCoordinates)
                            {
                                try
                                {
                                    if (IsFormClosed)
                                    {
                                        break;
                                    }

                                    db.Gen_Coordinates.InsertOnSubmit(new Gen_Coordinate {
                                        PostCode = item2.PostCode, Latitude = item2.Latitude, Longitude = item2.Longitude
                                    });
                                    db.SubmitChanges();
                                }
                                catch
                                {
                                }

                                cnter++;
                                cr.index = cnter;
                                worker.ReportProgress(cnter, cr);
                            }
                            //    List<Gen_Coordinate> cc = new List<Gen_Coordinate>();
                            //foreach (var item2 in listofCoordinates)
                            //{
                            //    try
                            //    {

                            //        if (IsFormClosed)
                            //            break;

                            //      //  db.Gen_Coordinates.InsertOnSubmit(new Gen_Coordinate { PostCode = item2.PostCode, Latitude = item2.Latitude, Longitude = item2.Longitude });
                            //      //  db.SubmitChanges();


                            //            if (cc.Count < 500)
                            //            {
                            //                cc.Add(new Gen_Coordinate { PostCode = item2.PostCode, Latitude = item2.Latitude, Longitude = item2.Longitude });
                            //            }
                            //            else
                            //            {
                            //                db.Gen_Coordinates.InsertAllOnSubmit(cc);
                            //                //db.Gen_Coordinates.InsertOnSubmit(new Gen_Coordinate { PostCode = item2.PostCode, Latitude = item2.Latitude, Longitude = item2.Longitude });
                            //                db.SubmitChanges();

                            //                if (listofCoordinates.Count + 500 > listofCoordinates.Count)
                            //                {
                            //                    cnter = listofCoordinates.Count;
                            //                }
                            //                else
                            //                {
                            //                    cnter += 500;
                            //                }
                            //                cc.Clear();


                            //                cr.index = cnter;
                            //                worker.ReportProgress(cnter, cr);
                            //            }

                            //        }
                            //    catch
                            //    {


                            //    }



                            //}
                        }
                    }

                    if (IsFormClosed)
                    {
                        break;
                    }
                }


                e.Result = "Completed";
            }
            catch (Exception ex)
            {
                e.Result = ex.Message;
            }
        }
Beispiel #21
0
        public bool OnSave()
        {
            try
            {
                if (objMaster.PrimaryKeyValue == null)
                {
                    objMaster.New();
                }
                else
                {
                    objMaster.Edit();
                }


                objMaster.Current.CompanyName  = txtCompanyName.Text.Trim();
                objMaster.Current.EmailAddress = txtCompanyEmail.Text.Trim();
                objMaster.Current.Address      = txtAddress.Text.Trim();
                objMaster.Current.TelephoneNo  = txtTelNo.Text.Trim();
                objMaster.Current.EmergencyNo  = txtCompanyEmergencyNo.Text.Trim();
                objMaster.Current.WebsiteUrl   = txtCompanyWebsite.Text.Trim();
                objMaster.Current.Fax          = txtCompanyFax.Text.Trim();

                objMaster.Current.EmailCC  = txtEmailCC.Text.Trim();
                objMaster.Current.IsSysGen = false;


                if (pb_logo.GetImage() != null)
                {
                    objMaster.Current.CompanyLogo = pb_logo.GetByteArrayOfImage();
                }
                else
                {
                    objMaster.Current.CompanyLogo = null;
                }

                objMaster.Current.BankName         = txtBank.Text.Trim();
                objMaster.Current.AccountNo        = txtAccountNo.Text.Trim();
                objMaster.Current.AccountTitle     = txtAccountTitle.Text.Trim();
                objMaster.Current.CompanyNumber    = txtCompanyNumber.Text.Trim();
                objMaster.Current.CompanyVatNumber = txtVATNumber.Text.Trim();
                objMaster.Current.SortCode         = txtSortCode.Text.Trim();
                objMaster.Current.IbanNumber       = txtIBAN.Text.Trim();
                objMaster.Current.BlcNumber        = txtBLC.Text.Trim();

                objMaster.Current.BackgroundColor = txtBgColor.Tag.ToInt();

                string mapIcon = ddlMapIcon.SelectedValue.ToStr().Trim();
                if (string.IsNullOrEmpty(mapIcon))
                {
                    mapIcon = ddlMapIcon.Items[0].Value.ToStr();
                }


                objMaster.Current.MapIcon = mapIcon;


                objMaster.Current.SmtpHasSSL   = smtpchkIsSecureConn.Checked;
                objMaster.Current.SmtpHost     = SmtpHost.Text.Trim();
                objMaster.Current.SmtpPassword = smtpPassword.Text.Trim();
                objMaster.Current.SmtpPort     = smtpPort.Text.Trim();
                objMaster.Current.SmtpUserName = smtpUserName.Text.Trim();

                objMaster.Current.UseDifferentEmailForInvoices = chkUseInvoiceEmail.Checked;
                objMaster.Current.SmtpInvoiceUserName          = smtpInvoiceEmail.Text.ToStr().Trim();
                objMaster.Current.SmtpInvoicePassword          = smtpInvoicePassword.Text.ToStr().Trim();
                objMaster.Current.SmtpInvoiceHost = smtpInvoiceHost.Text.ToStr().Trim();
                objMaster.Current.SmtpInvoicePort = smtpInvoicePort.Text.Trim();
                objMaster.Current.SmtpInvoiceSSL  = smtpInvoiceSSL.Checked;

                objMaster.Current.DisableAcceptEmail  = chkDisableAcceptEmail.Checked;
                objMaster.Current.DisableDeclineEmail = chkDisableDeclineEmail.Checked;

                objMaster.Current.ConnectionString = txtCLINumbers.Text.Trim();
                objMaster.Save();

                //

                chkAmount.Checked = true;

                using (TaxiDataContext db = new TaxiDataContext())
                {
                    if (db.Gen_ServiceCharges.Where(c => c.SubCompanyId == objMaster.Current.Id).Count() == 0)
                    {
                        Gen_ServiceCharge objServiceCharge = new Gen_ServiceCharge();
                        objServiceCharge.SubCompanyId = objMaster.Current.Id;
                        objServiceCharge.AmountWise   = chkAmount.Checked;
                        if (chkAmount.Checked)
                        {
                            objServiceCharge.ServiceChargePercent = 0;
                            objServiceCharge.ServiceChargeAmount  = numBookingFees.Value.ToDecimal();
                        }
                        else
                        {
                            objServiceCharge.ServiceChargeAmount  = 0;
                            objServiceCharge.ServiceChargePercent = numBookingFees.Value.ToDecimal();
                        }
                        db.Gen_ServiceCharges.InsertOnSubmit(objServiceCharge);
                        db.SubmitChanges();
                    }
                    else
                    {
                        // int Id = db.Gen_ServiceCharges.Where(c => c.SubCompanyId == objMaster.Current.Id).FirstOrDefault().Id;
                        var query = db.Gen_ServiceCharges.FirstOrDefault(c => c.SubCompanyId == objMaster.Current.Id);
                        query.AmountWise = chkAmount.Checked;
                        if (chkAmount.Checked)
                        {
                            query.ServiceChargePercent = 0;
                            query.ServiceChargeAmount  = numBookingFees.Value.ToDecimal();
                        }
                        else
                        {
                            query.ServiceChargeAmount  = 0;
                            query.ServiceChargePercent = numBookingFees.Value.ToDecimal();
                        }

                        db.SubmitChanges();
                    }
                }
                //


                OnNew();

                PopulateData();


                UpdateEmailSettings();

                return(true);
            }
            catch (Exception ex)
            {
                if (objMaster.Errors.Count > 0)
                {
                    ENUtils.ShowMessage(objMaster.ShowErrors());
                }
                else
                {
                    ENUtils.ShowMessage(ex.Message);
                }
                return(false);
            }
        }
Beispiel #22
0
        private bool SaveSettings()
        {
            bool rtn = false;

            try
            {
                using (TaxiDataContext db = new TaxiDataContext())
                {
                    var obj = db.TripletSettings.FirstOrDefault();

                    if (obj == null)
                    {
                        obj = new TripletSetting();
                    }


                    obj.JobPrice  = numJobPrice.Value.ToDecimal();
                    obj.ShiftType = chkEnableIncrement.Checked ? 1 : 0;


                    if (obj.Id == 0)
                    {
                        db.TripletSettings.InsertOnSubmit(obj);
                    }


                    db.SubmitChanges();


                    var objPolicy = db.Gen_SysPolicy_Configurations.FirstOrDefault();

                    if (optAutoDespRule1.ToggleState == ToggleState.On)
                    {
                        objPolicy.AutoDespatchType = 1;
                    }

                    else if (optAutoDespRule2.ToggleState == ToggleState.On)
                    {
                        objPolicy.AutoDespatchType = 2;
                    }

                    else if (optAutoDespRule3.ToggleState == ToggleState.On)
                    {
                        objPolicy.AutoDespatchType = 3;
                    }

                    else if (optAutoDespRule4.ToggleState == ToggleState.On)
                    {
                        objPolicy.AutoDespatchType = 4;
                    }

                    else if (optAutoDespRule5.ToggleState == ToggleState.On)
                    {
                        objPolicy.AutoDespatchType = 5;
                    }



                    objPolicy.AutoDespatchNearestDrvRadius   = numAutoDespDrvRadius.Value.ToDecimal();
                    objPolicy.AutoDespatchLongestWaitingMins = numAutoDespLongestWaitingMins.Value.ToInt();
                    objPolicy.AutoDespatchPriorityForAccJobs = chkAccJobs.Checked;

                    objPolicy.AutoDespatchPriorityForAllocatedDrv = chkPriorityForAllocDrvs.Checked;

                    db.SubmitChanges();
                }

                General.LoadConfiguration();


                ((frmBookingDashBoard)System.Windows.Forms.Application.OpenForms.OfType <Form>().FirstOrDefault(c => c.Name == "frmBookingDashBoard")).SetAutoDespatchMode(AppVars.objPolicyConfiguration.EnableAutoDespatch.ToBool(), false);


                //  (Application.OpenForms.OfType<Form>().FirstOrDefault(c => c.Name == "frmBookingDashBoard") as frmBookingDashBoard).GetTripletObject();

                rtn = true;
            }
            catch (Exception ex)
            {
                ENUtils.ShowMessage(ex.Message);
            }


            return(rtn);
        }
        private bool SaveSettings()
        {
            bool rtn = false;

            try
            {
                //if (dtpFromDate.Value == null)
                //{
                //	ENUtils.ShowMessage("Required : From Date");
                //	return rtn;

                //}

                //if (dtpTillDate.Value == null)
                //{
                //	ENUtils.ShowMessage("Required : Till Date");
                //	return rtn;

                //}


                //if (dtpFromDate.Value.ToDate() > dtpTillDate.Value.ToDate())
                //{
                //	ENUtils.ShowMessage("Required : From Date must be less than Till Date");
                //	return rtn;

                //}


                //string criteriaBy = ddlIncrementType.Text.Trim().ToLower();

                //if (optDateTimeWise.ToggleState == ToggleState.On)
                //	criteriaBy += "=1";
                //else if (optDateWise.ToggleState == ToggleState.On)
                //	criteriaBy += "=2";
                //else if (optTimeWise.ToggleState == ToggleState.On)
                //	criteriaBy += "=3";


                using (TaxiDataContext db = new TaxiDataContext())
                {
                    List <int> Ids = grdFareIncreament.Rows.Select(callnotification => Convert.ToInt32(callnotification.Cells["Id"].Value)).ToList();

                    for (int i = 0; i < grdFareIncreament.Rows.Count; i++)
                    {
                        int id = grdFareIncreament.Rows[i].Cells["Id"].Value.ToInt();
                        Fare_IncrementSetting objFare = null;

                        if (id.ToInt() > 0)
                        {
                            objFare = db.Fare_IncrementSettings.FirstOrDefault(c => c.Id == id);
                        }
                        else
                        {
                            objFare = new Fare_IncrementSetting();
                        }


                        objFare.FromDate        = grdFareIncreament.Rows[i].Cells["FromDateTime"].Value.ToDateTime();
                        objFare.TillDate        = grdFareIncreament.Rows[i].Cells["TillDateTime"].Value.ToDateTime();
                        objFare.IncrementRate   = grdFareIncreament.Rows[i].Cells["IncreamentRate"].Value.ToDecimal();
                        objFare.EnableIncrement = chkEnableIncrement.Checked;
                        objFare.IncrementType   = grdFareIncreament.Rows[i].Cells["IncreamentType"].Value.ToString().ToLower();


                        objFare.CriteriaBy = grdFareIncreament.Rows[i].Cells["CriteriaBy"].Value.ToInt();



                        if (objFare.Id == 0)
                        {
                            db.Fare_IncrementSettings.InsertOnSubmit(objFare);
                        }

                        db.SubmitChanges();
                    }
                }


                return(true);
            }
            //db.stp_SaveFareIncrementSettings(dtpFromDate.Value, dtpTillDate.Value, criteriaBy, numIncrementRate.Value.ToDecimal(), chkEnableIncrement.Checked);

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


            return(rtn);
        }
        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);
            }
        }
        private void DeleteDriverPayment()
        {
            try
            {
                string Error = string.Empty;
                if (grdLister.Rows.Count() > 0 && grdLister.Rows.Count(c => c.Cells["Check"].Value.ToBool() == true) == 0)
                {
                    Error = "Please select record to delete";
                }

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

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


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


                                            if (objDetail != null)
                                            {
                                                db.Fleet_DriverCommissionCollectionHistory_Details.DeleteOnSubmit(objDetail);
                                                db.SubmitChanges();
                                            }
                                        }
                                    }
                                }
                                catch (Exception ex)
                                {
                                    ENUtils.ShowMessage(ex.Message);
                                }
                            }
                        }
                        PopulateData();
                    }
                }
            }
            catch (Exception ex)
            {
                ENUtils.ShowMessage(ex.Message);
            }
        }
        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);
            }
        }
        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);
            }
        }