public ActionResult CityGridViewPartialDelete(System.Int32 CityID)
        {
            if (CityID >= 0)
            {
                try
                {
                    BusinessLogicLayer.Components.Persons.CityLogic logic = new BusinessLogicLayer.Components.Persons.CityLogic();
                    if (!logic.HasCities(CityID))
                    {
                        Qiyas.BusinessLogicLayer.Entity.Persons.City city = new BusinessLogicLayer.Entity.Persons.City(CityID);
                        city.Delete();
                    }
                    else
                    {
                        ViewData["EditError"] = Resources.MainResource.CityHasAssociatedData;
                    }
                }
                catch (Exception e)
                {
                    ViewData["EditError"] = e.Message;
                }
            }
            var model = new BusinessLogicLayer.Components.Persons.CityLogic().GetAll();

            return(PartialView("_CityGridViewPartial", model));
        }
        public ActionResult CityGridViewPartialUpdate([ModelBinder(typeof(DevExpressEditorsBinder))] Qiyas.BusinessLogicLayer.Entity.Persons.City item)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    if (!CityExists(item.Name, item.CityID))
                    {
                        Qiyas.BusinessLogicLayer.Entity.Persons.City city = new BusinessLogicLayer.Entity.Persons.City(item.CityID);
                        city.StateRegionID = item.StateRegionID;
                        city.Name          = item.Name;
                        city.IsActive      = item.IsActive;
                        city.Save();
                    }
                    else
                    {
                        ViewData["EditError"] = Resources.MainResource.CityExistsCheck;
                    }
                }
                catch (Exception e)
                {
                    ViewData["EditError"] = e.Message;
                }
            }
            else
            {
                ViewData["EditError"] = Resources.MainResource.PleaseCorrectErrors;
            }
            var model = new BusinessLogicLayer.Components.Persons.CityLogic().GetAll();

            return(PartialView("_CityGridViewPartial", model));
        }
        private bool CityExists(string city, int id)
        {
            var currentUser = new BusinessLogicLayer.Entity.Persons.City(id);
            var checkUser   = new BusinessLogicLayer.Components.Persons.CityLogic().GetByName(city);

            if (checkUser == null)
            {
                return(false);
            }
            if (!currentUser.HasObject && checkUser != null)
            {
                return(true);
            }
            else if (currentUser.HasObject && checkUser != null && currentUser.CityID != checkUser.CityID)
            {
                return(true);
            }

            return(false);
        }
        private void xrTableCellCityandCenter_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
        {
            XRTableCell cell = sender as XRTableCell;

            if (cell == null)
            {
                return;
            }
            int id = 0;

            if (string.IsNullOrEmpty(cell.Text))
            {
                return;
            }
            Int32.TryParse(cell.Text, out id);
            if (id == 0)
            {
                return;
            }
            BusinessLogicLayer.Entity.PPM.ExamCenterRequiredExam exCenter = new BusinessLogicLayer.Entity.PPM.ExamCenterRequiredExam(id);
            if (exCenter == null)
            {
                return;
            }
            BusinessLogicLayer.Entity.PPM.ExamCenter center = new BusinessLogicLayer.Entity.PPM.ExamCenter(exCenter.ExamCenterID.Value);
            if (center == null)
            {
                return;
            }
            BusinessLogicLayer.Entity.Persons.City city = new BusinessLogicLayer.Entity.Persons.City(center.CityID.Value);
            if (city == null)
            {
                return;
            }

            cell.Text = city.Name + " - " + center.Name;
            //BusinessLogicLayer.Entity.PPM.ExamPeriod gender = new BusinessLogicLayer.Entity.PPM.ExamPeriod(exCenter.ExamPeriodID.Value);
            //if (gender == null)
            //    return;
        }