private void SaveChanges()
        {
            try
            {
                string addressQuery  = string.Empty;
                string locationQuery = string.Empty;

                foreach (var item in grdAddresses.Rows.Where(c => c.Cells["Zone"].Value != null && c.Cells["Zone"].Value.ToInt() != c.Cells["OldZoneId"].Value.ToInt()))
                {
                    addressQuery += "UPDATE GEN_ADDRESSES SET ZONEID=" + item.Cells["Zone"].Value.ToInt() + " where addressline1='" + item.Cells["FullAddress"].Value.ToStr() + "';" + Environment.NewLine;


                    AppVars.listOfAddress.FirstOrDefault(c => c.AddressLine1 == item.Cells["FullAddress"].Value.ToStr()
                                                         ).DefaultIfEmpty().ZoneId = item.Cells["Zone"].Value.ToInt();
                }


                foreach (var item in grdLocations.Rows.Where(c => c.Cells["Zone"].Value != null && c.Cells["Zone"].Value.ToInt() != c.Cells["OldZoneId"].Value.ToInt()))
                {
                    locationQuery += "UPDATE GEN_LOCATIONS SET ZONEID=" + item.Cells["Zone"].Value.ToInt() + " where LOCATIONNAME='" + item.Cells["Street"].Value.ToStr() + "' AND POSTCODE='" + item.Cells["PostCode"].Value.ToStr() + "';" + Environment.NewLine;
                }


                using (TaxiDataContext db = new TaxiDataContext())
                {
                    if (addressQuery.ToStr().Trim() != string.Empty)
                    {
                        db.stp_RunProcedure(addressQuery);
                    }

                    if (locationQuery.ToStr().Trim() != string.Empty)
                    {
                        db.stp_RunProcedure(locationQuery);
                    }
                }

                if (addressQuery.ToStr().Length > 0 || locationQuery.ToStr().Length > 0)
                {
                    RefreshRecords();
                }
            }
            catch (Exception ex)
            {
                ENUtils.ShowMessage(ex.Message);
            }
        }
Ejemplo n.º 2
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);
            }
        }
Ejemplo n.º 3
0
        void grdLister_CommandCellClick(object sender, EventArgs e)
        {
            try
            {
                GridCommandCellElement gridCell = (GridCommandCellElement)sender;


                if (gridCell.ColumnInfo.Name == "btnDelete")
                {
                    GridViewRowInfo row          = grdLister.CurrentRow;
                    string          AddressName  = row.Cells[COLS.Address].Value.ToStr();
                    string          AddressLine1 = row.Cells[COLS.AddressLine1].Value.ToStr();
                    long            Id           = row.Cells[COLS.Id].Value.ToLong();
                    var             query        = General.GetObject <Gen_RecentAddress>(c => (c.Id == Id) && (c.AddressLine1.Contains(AddressName)));
                    if (query != null)
                    {
                        string[] result = query.AddressLine1.Split(new string[] { "</add>" }, StringSplitOptions.RemoveEmptyEntries);
                        if (result.Count() > 1)
                        {
                            AddressLine1 = AddressLine1.Replace(AddressName, "");
                            AddressLine1 = AddressLine1.Replace("<add></add>", "");
                            using (TaxiDataContext db = new TaxiDataContext())
                            {
                                if (!string.IsNullOrEmpty(AddressLine1))
                                {
                                    db.stp_RunProcedure("update Gen_RecentAddresses set AddressLine1='" + AddressLine1 + "' where Id=" + Id + "");
                                }
                                else
                                {
                                    db.stp_RunProcedure("delete  from Gen_RecentAddresses where Id=" + Id + "");
                                }
                            }
                        }
                        else
                        {
                            using (TaxiDataContext db = new TaxiDataContext())
                            {
                                db.stp_RunProcedure("delete  from Gen_RecentAddresses where Id=" + Id + "");
                            }
                        }

                        row.Delete();
                        //   LoadRecentAddress();
                        //query.AddressLine1.Contains("").cou
                    }
                }
            }
            catch (Exception ex)
            {
                ENUtils.ShowMessage(ex.Message);
            }
        }
Ejemplo n.º 4
0
        private void btnClearAddresses_Click(object sender, EventArgs e)
        {
            if (DialogResult.Yes == MessageBox.Show("are you sure you want to clear all recent addresses ?", "", MessageBoxButtons.YesNo))
            {
                try
                {
                    using (TaxiDataContext db = new TaxiDataContext())
                    {
                        db.stp_RunProcedure("delete  from Gen_RecentAddresses");
                    }

                    LoadRecentAddress();
                }
                catch
                {
                }
            }
        }
Ejemplo n.º 5
0
 private void DeleteAddress()
 {
     try
     {
         string Error          = string.Empty;
         int    LocationTypeId = ddlLocationTypes2.SelectedValue.ToInt();
         if (grdLocations.Rows.Where(c => c.Cells[COLSD.Delete].Value.ToBool() == true).Count() == 0)//|| grdDeleteLocations.Rows.Where(c => c.Cells[COLSD.Delete].Value.ToBool() == true).Count() == 0)
         {
             Error = "Please select address to delete";
         }
         if (LocationTypeId == 0)
         {
             if (String.IsNullOrEmpty(Error))
             {
                 Error = "Required : Location Types";
             }
             else
             {
                 Error += Environment.NewLine + "Required : Location Types";
             }
         }
         if (!string.IsNullOrEmpty(Error))
         {
             ENUtils.ShowMessage(Error);
             return;
         }
         //var DeleteAddressList=grdLocations.Rows.Where(c=>c.Cells[COLSD.Delete].Value.ToBool()==true).Select(c)
         string DeleteIds = string.Join(",", (grdLocations.Rows.Where(c =>
                                                                      (c.Cells[COLSD.Delete].Value.ToBool() == true)
                                                                      )
                                              .Select(c => c.Cells[COLSD.Id].Value.ToString()).ToArray <string>()));
         string DeleteAddress = "delete from Gen_Locations where Id in(" + DeleteIds + ")";
         using (TaxiDataContext db = new TaxiDataContext())
         {
             db.stp_RunProcedure(DeleteAddress);
         }
         DisplayDeleteLocation(LocationTypeId);
     }
     catch (Exception ex)
     {
         ENUtils.ShowMessage(ex.Message);
     }
 }
Ejemplo n.º 6
0
 private void btnUpdate_Click(object sender, EventArgs e)
 {
     if (txtDetails.Text.Trim().Length == 0)
     {
         MessageBox.Show("Required : Information");
     }
     else
     {
         try
         {
             using (TaxiDataContext db = new TaxiDataContext())
             {
                 db.stp_RunProcedure("update gen_company set CompanyInformation='" + txtDetails.Text.Trim() + "' where id=" + this._UniqueId);
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
     }
 }
Ejemplo n.º 7
0
        private void radButton1_Click_1(object sender, EventArgs e)
        {
            try
            {
                StringBuilder st = new StringBuilder();
                if (grdFares.Rows.Where(c => c.Cells[COLS.CheckBox].Value.ToBool()).Count() == 0)
                {
                    return;
                }
                if (DialogResult.Yes == RadMessageBox.Show("Are you sure you want to delete Selected Booking(s) ? ", "", MessageBoxButtons.YesNo, RadMessageIcon.Question))
                {
                    foreach (GridViewRowInfo row in grdFares.Rows.Where(c => c.Cells[COLS.CheckBox].Value.ToBool()))
                    {
                        st.Append("delete from Fare_CustomJourneys where Id =" + row.Cells[COLS.Id].Value.ToInt() + " ");
                    }
                    using (TaxiDataContext db = new TaxiDataContext())
                    {
                        db.stp_RunProcedure(st.ToStr());
                    }


                    SetDisplayRecords();
                }
            }
            catch (Exception ex)
            {
                if (objeCustomBO.Errors.Count > 0)
                {
                    ENUtils.ShowMessage(objeCustomBO.ShowErrors());
                }
                else
                {
                    ENUtils.ShowMessage(ex.Message);
                }
            }
        }
Ejemplo n.º 8
0
        public override void Save()
        {
            try
            {
                int LocationTypeId = ddlLocations.SelectedValue.ToInt();


                string ExcludeIds = string.Join(",", (grdPostCodes.Rows.Where(c =>
                                                                              (c.Cells[COLS.Exclude].Value.ToBool() == true && (c.Cells[COLS.Id].Value.ToInt() > 0))
                                                                              )
                                                      .Select(c => c.Cells[COLS.Id].Value.ToString()).ToArray <string>()));


                var Selectlist = (from a in grdPostCodes.Rows.Where(c => (c.Cells[COLS.Select].Value.ToBool() == true) && (c.Cells[COLS.Id].Value.ToInt() == 0))
                                  select new
                {
                    AddressName = a.Cells[COLS.AddressName].Value
                }).ToList();


                string ExcludeList = string.Empty; //"delete from Gen_Locations where Id in("+ExcludeIds+");";
                if (!string.IsNullOrEmpty(ExcludeIds))
                {
                    ExcludeList = "delete from Gen_Locations where Id in(" + ExcludeIds + ");";
                }


                StringBuilder sb           = new StringBuilder();
                string        PostCode     = string.Empty;
                string        ShortKey     = string.Empty;
                string        LocationName = string.Empty;
                sb.Append(ExcludeList);
                foreach (var item in Selectlist)
                {
                    PostCode     = General.GetPostCodeMatch(item.AddressName.ToStr()).Trim();
                    LocationName = item.AddressName.ToStr();

                    if (PostCode.Length > 0)
                    {
                        LocationName = LocationName.Replace(PostCode, "").ToStr().Trim();
                    }

                    if (LocationName.Contains("'"))
                    {
                        LocationName = LocationName.Replace("'", "").Trim();
                    }


                    ShortKey  = objLocationType.Where(c => c.Id == LocationTypeId).FirstOrDefault().ShortCutKey.ToStr().ToLower();
                    ShortKey += " " + LocationName[0].ToStr().ToLower();
                    sb.Append("insert into Gen_Locations (LocationName,LocationTypeId,Address,PostCode,ShortCutKey) values('" + LocationName + "'," + LocationTypeId + ",'" + item.AddressName.ToStr().Replace("'", "").Trim() + "','" + PostCode + "','" + ShortKey + "');");
                }


                using (TaxiDataContext db = new TaxiDataContext())
                {
                    db.stp_RunProcedure(sb.ToStr());
                }
            }
            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);
                        }
                    }
                }
            }
        }
        void grdLocations_CommandCellClick(object sender, EventArgs e)
        {
            try
            {
                GridCommandCellElement gridCell = (GridCommandCellElement)sender;
                string name = gridCell.ColumnInfo.Name.ToLower();

                GridViewRowInfo row = gridCell.RowElement.RowInfo;

                string street   = row.Cells["Street"].Value.ToStr().Trim();
                string postCode = row.Cells["PostCode"].Value.ToStr().Trim();
                int    zoneId   = row.Cells["Zone"].Value.ToInt();

                if (zoneId == 0)
                {
                    ENUtils.ShowMessage("Plot cannot be empty");
                    return;
                }

                if (string.IsNullOrEmpty(street))
                {
                    ENUtils.ShowMessage("Street cannot be empty");
                    return;
                }



                if (string.IsNullOrEmpty(postCode))
                {
                    ENUtils.ShowMessage("PostCode cannot be empty");
                    return;
                }



                string addressQuery = string.Empty;

                if (name == "delete")
                {
                    if (DialogResult.Yes == RadMessageBox.Show("are you sure ?", "Delete", MessageBoxButtons.YesNo))
                    {
                        addressQuery = "delete from Gen_locations  where LOCATIONNAME='" + row.Cells["OldStreet"].Value.ToStr() + "' AND POSTCODE='" + row.Cells["OldPostCode"].Value.ToStr() + "';" + Environment.NewLine;


                        row.Delete();
                    }
                    else
                    {
                        return;
                    }
                }
                else if (name == "edit")
                {
                    street = street.Replace("'A", "A").ToStr().Trim().Replace("'B", "B").ToStr().Trim().Replace("'C", "C").Replace("'C", "C").ToStr().Trim()
                             .Replace("'D", "D").ToStr().Trim().Replace("'E", "E").ToStr().Trim().Replace("'F", "F").ToStr().Trim().Replace("'G", "G").ToStr().Trim().Replace("'H", "H").ToStr().Trim()
                             .Replace("'I", "I").ToStr().Trim().Replace("'J", "J").ToStr().Trim().Replace("'K", "K").ToStr().Trim().Replace("'L", "L").ToStr().Trim()
                             .Replace("'M", "M").ToStr().Trim().Replace("'N", "N").ToStr().Trim().Replace("'O", "O").ToStr().Trim().Replace("'P", "P").ToStr().Trim()
                             .Replace("'Q", "Q").ToStr().Trim().Replace("'R", "R").ToStr().Trim().Replace("'S", "S").ToStr().Trim().Replace("'T", "T").ToStr().Trim().Replace("'U", "U").ToStr().Trim()
                             .Replace("'V", "V").ToStr().Trim().Replace("'W", "W").ToStr().Trim().Replace("'X", "X").ToStr().Trim().Replace("'Y", "Y").ToStr().Trim()
                             .Replace("'Z", "Z").ToStr().Trim();

                    street = street.Replace("\r\n", "").ToStr().Trim();
                    street = street.Replace(",", "").ToStr().Trim();

                    string OLDStreet = row.Cells["OldStreet"].Value.ToStr();
                    OLDStreet = OLDStreet.Replace("'A", "''A").ToStr().Trim().Replace("'B", "''B").ToStr().Trim().Replace("'C", "''C")
                                .Replace("'D", "''D").ToStr().Trim().Replace("'E", "''E").ToStr().Trim().Replace("'F", "''F").ToStr().Trim().Replace("'G", "''G").ToStr().Trim().Replace("'H", "''H").ToStr().Trim()
                                .Replace("'I", "''I").ToStr().Trim().Replace("'J", "''J").ToStr().Trim().Replace("'K", "''K").ToStr().Trim().Replace("'L", "''L").ToStr().Trim()
                                .Replace("'M", "''M").ToStr().Trim().Replace("'N", "''N").ToStr().Trim().Replace("'O", "''O").ToStr().Trim().Replace("'P", "''P").ToStr().Trim()
                                .Replace("'Q", "''Q").ToStr().Trim().Replace("'R", "''R").ToStr().Trim().Replace("'S", "''S").ToStr().Trim().Replace("'T", "''T").ToStr().Trim().Replace("'U", "''U").ToStr().Trim()
                                .Replace("'V", "''V").ToStr().Trim().Replace("'W", "''W").ToStr().Trim().Replace("'X", "''X").ToStr().Trim().Replace("'Y", "''Y").ToStr().Trim()
                                .Replace("'Z", "''Z").ToStr().Trim();

                    addressQuery += "UPDATE GEN_LOCATIONS SET locationname='" + street + "',PostCode='" + postCode + "',ZoneId=" + zoneId + " where LOCATIONNAME='" + OLDStreet + "' AND POSTCODE='" + row.Cells["OldPostCode"].Value.ToStr() + "';" + Environment.NewLine;
                }



                // addressQuery = addressQuery.Replace("SET locationname=", "SET locationname='").ToStr().Trim();

                using (TaxiDataContext db = new TaxiDataContext())
                {
                    if (addressQuery.ToStr().Trim() != string.Empty)
                    {
                        db.stp_RunProcedure(addressQuery);
                    }
                }

                if (addressQuery.ToStr().Length > 0)
                {
                    RefreshRecords();
                }
            }
            catch (Exception ex)
            {
                ENUtils.ShowMessage(ex.Message);
            }
        }
        void grdAddresses_CommandCellClick(object sender, EventArgs e)
        {
            try
            {
                GridCommandCellElement gridCell = (GridCommandCellElement)sender;
                string name = gridCell.ColumnInfo.Name.ToLower();

                GridViewRowInfo row         = gridCell.RowElement.RowInfo;
                string          fullAddress = row.Cells["FullAddress"].Value.ToStr().Trim().ToUpper();


                string street   = row.Cells["Street"].Value.ToStr().Trim().ToUpper();
                string postCode = row.Cells["PostCode"].Value.ToStr().Trim().ToUpper();

                int zoneId = row.Cells["Zone"].Value.ToInt();

                if (zoneId == 0)
                {
                    ENUtils.ShowMessage("Plot cannot be empty");
                    return;
                }

                if (string.IsNullOrEmpty(street))
                {
                    ENUtils.ShowMessage("Street cannot be empty");
                    return;
                }



                if (string.IsNullOrEmpty(postCode))
                {
                    ENUtils.ShowMessage("PostCode cannot be empty");
                    return;
                }

                string addressQuery = string.Empty;



                if (name == "delete")
                {
                    if (DialogResult.Yes == RadMessageBox.Show("are you sure ?", "Delete", MessageBoxButtons.YesNo))
                    {
                        addressQuery = "delete from GEN_ADDRESSES where addressline1='" + fullAddress + "';" + Environment.NewLine;


                        row.Delete();
                    }
                    else
                    {
                        return;
                    }
                }
                else if (name == "edit")
                {
                    street = street.Replace("'A", "A").ToStr().Trim().Replace("'B", "B").ToStr().Trim().Replace("'C", "C").Replace("'C", "C").ToStr().Trim()
                             .Replace("'D", "D").ToStr().Trim().Replace("'E", "E").ToStr().Trim().Replace("'F", "F").ToStr().Trim().Replace("'G", "G").ToStr().Trim().Replace("'H", "H").ToStr().Trim()
                             .Replace("'I", "I").ToStr().Trim().Replace("'J", "J").ToStr().Trim().Replace("'K", "K").ToStr().Trim().Replace("'L", "L").ToStr().Trim()
                             .Replace("'M", "M").ToStr().Trim().Replace("'N", "N").ToStr().Trim().Replace("'O", "O").ToStr().Trim().Replace("'P", "P").ToStr().Trim()
                             .Replace("'Q", "Q").ToStr().Trim().Replace("'R", "R").ToStr().Trim().Replace("'S", "S").ToStr().Trim().Replace("'T", "T").ToStr().Trim().Replace("'U", "U").ToStr().Trim()
                             .Replace("'V", "V").ToStr().Trim().Replace("'W", "W").ToStr().Trim().Replace("'X", "X").ToStr().Trim().Replace("'Y", "Y").ToStr().Trim()
                             .Replace("'Z", "Z").ToStr().Trim();

                    street = street.Replace("\r\n", "").ToStr().Trim();
                    street = street.Replace(",", "").ToStr().Trim();


                    string OLDaDDRESS = row.Cells["FullAddress"].Value.ToStr();

                    OLDaDDRESS = OLDaDDRESS.Replace("'A", "''A").ToStr().Trim().Replace("'B", "''B").ToStr().Trim().Replace("'C", "''C")
                                 .Replace("'D", "''D").ToStr().Trim().Replace("'E", "''E").ToStr().Trim().Replace("'F", "''F").ToStr().Trim().Replace("'G", "''G").ToStr().Trim().Replace("'H", "''H").ToStr().Trim()
                                 .Replace("'I", "''I").ToStr().Trim().Replace("'J", "''J").ToStr().Trim().Replace("'K", "''K").ToStr().Trim().Replace("'L", "''L").ToStr().Trim()
                                 .Replace("'M", "''M").ToStr().Trim().Replace("'N", "''N").ToStr().Trim().Replace("'O", "''O").ToStr().Trim().Replace("'P", "''P").ToStr().Trim()
                                 .Replace("'Q", "''Q").ToStr().Trim().Replace("'R", "''R").ToStr().Trim().Replace("'S", "''S").ToStr().Trim().Replace("'T", "''T").ToStr().Trim().Replace("'U", "''U").ToStr().Trim()
                                 .Replace("'V", "''V").ToStr().Trim().Replace("'W", "''W").ToStr().Trim().Replace("'X", "''X").ToStr().Trim().Replace("'Y", "''Y").ToStr().Trim()
                                 .Replace("'Z", "''Z").ToStr().Trim();



                    addressQuery = "update GEN_ADDRESSES SET addressline1='" + street + " " + postCode + "',PostalCode='" + postCode + "',ZoneId=" + zoneId + "  where addressline1='" + OLDaDDRESS + "';" + Environment.NewLine;
                }



                using (TaxiDataContext db = new TaxiDataContext())
                {
                    if (addressQuery.ToStr().Trim() != string.Empty)
                    {
                        db.stp_RunProcedure(addressQuery);
                    }
                }

                if (addressQuery.ToStr().Length > 0)
                {
                    if (name == "delete")
                    {
                        AppVars.listOfAddress.RemoveAll(c => c.AddressLine1 == fullAddress);

                        addresses.RemoveAll(c => c.AddressLine1 == fullAddress);
                    }
                    else if (name == "edit")
                    {
                        var obj = AppVars.listOfAddress.FirstOrDefault(c => c.AddressLine1 == fullAddress);
                        if (obj != null)
                        {
                            obj.AddressLine1 = street + " " + postCode;
                            obj.PostalCode   = postCode;


                            var obj1 = addresses.FirstOrDefault(c => c.AddressLine1 == fullAddress);
                            if (obj1 != null)
                            {
                                obj1.AddressLine1 = street + " " + postCode;
                                obj1.PostalCode   = postCode;

                                if (obj1.ZoneId != zoneId)
                                {
                                    obj.ZoneId = zoneId;

                                    obj1.ZoneId = zoneId;

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