public function actionWrite()
 {
     parent::actionWrite();
     if (isset($_POST['Religion'])) {
         $messages = $this->ValidateData(array(array($_POST['Religion']['religionname'], 'emptyreligionname', 'emptystring')));
         if ($messages == '') {
             if ((int) $_POST['Religion']['religionid'] > 0) {
                 $model = $this->loadModel($_POST['Religion']['religionid']);
                 $model->religionname = $_POST['Religion']['religionname'];
                 $model->recordstatus = $_POST['Religion']['recordstatus'];
             } else {
                 $model = new Religion();
                 $model->attributes = $_POST['Religion'];
             }
             try {
                 if ($model->save()) {
                     $this->DeleteLock($this->menuname, $_POST['Religion']['religionid']);
                     $this->GetSMessage('hmreinsertsuccess');
                 } else {
                     $this->GetMessage($model->getErrors());
                 }
             } catch (Exception $e) {
                 $this->GetMessage($e->getMessage());
             }
         }
     }
 }