public ActionResult Create(CuentaAbono CuentaAbono_) { try { if (!ModelState.IsValid) { return(View(CuentaAbono_)); } DBMysql dBMysql1 = new DBMysql(); dBMysql1.OpenConnection(); CuentaAbono_.SetConnection(dBMysql1); int Result = CuentaAbono_.Create(); dBMysql1.CloseConnection(); if (Result == 0) { return(RedirectToAction("Index")); } else { ModelState.AddModelError(string.Empty, string.Format("No se ha podido registrar")); return(View(CuentaAbono_)); } } catch (DBException ex) { ModelState.AddModelError(string.Empty, string.Format("System Error: {0}", ex.Message)); return(View(CuentaAbono_)); } catch (MySqlException ex) { ModelState.AddModelError(string.Empty, string.Format("System Error: {0}", ex.Message)); return(View(CuentaAbono_)); } catch (Exception ex) { ModelState.AddModelError(string.Empty, string.Format("System Error: {0}", ex.Message)); return(View(CuentaAbono_)); } }
public ActionResult Edit(CuentaAbono CuentaAbono_) { try { if (!ModelState.IsValid) { throw new Exception("Campos vacios"); } DBMysql dBMysql1 = new DBMysql(); dBMysql1.OpenConnection(); CuentaAbono_.SetConnection(dBMysql1); int Result = CuentaAbono_.Update(); dBMysql1.CloseConnection(); if (Result == 0) { return(RedirectToAction("Index")); } else { return(View()); } } catch (DBException ex) { ModelState.AddModelError(string.Empty, string.Format("System Error: {0}", ex.Message)); return(View(CuentaAbono_)); } catch (MySqlException ex) { ModelState.AddModelError(string.Empty, string.Format("System Error: {0}", ex.Message)); return(View(CuentaAbono_)); } catch (Exception ex) { ModelState.AddModelError(string.Empty, string.Format("System Error: {0}", ex.Message)); return(View(CuentaAbono_)); } }