Example #1
0
 public function actionUpdate($id)
 {
     //                $model=$this->loadModel($id);
     $member = new Detallecompra();
     if (isset($_POST['Detallecompra'])) {
         $cantidad_inicial = $member->Cantidad;
         $member->attributes = $_POST['Detallecompra'];
         //$cantidadinicial = $model->Cantidad;
         //SaldoAct = salcdo actua;l - cantidad incial
         if ($member->save()) {
             $criteria = new CDbCriteria();
             $criteria->condition = 'CodProducto=:CodProducto';
             $criteria->params = array(':CodProducto' => $model->CodProducto);
             $objProducto = Productos::model()->find($criteria);
             $objProducto->CanExistencia = $objProducto->CanExistencia + $member->Cantidad;
             $objProducto->save();
             //                                        $this->redirect(array('view', 'id' => $model->Id));
         }
     }
     $this->render('update', array('model' => $model));
 }
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer $id the ID of the model to be loaded
  * @return Detallecompra the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Detallecompra::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }