// PUT api/TipoPlan/5 public IHttpActionResult PutTipoPlan(int Id, TipoPlan tipoplan) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (Id != tipoplan.TipoPlanId) { return(BadRequest()); } db.Entry(tipoplan).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!TipoPlanExists(Id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
private void TryEditPlan(Etiqueta et, TipoPlan tp, bool emf, double m) { plan.Etiqueta = et; plan.Tipo = tp; plan.EsMesFijo = emf; plan.Meta = m; }
public void Update(TipoPlan tipoPlan) { SqlConnection sqlConnection = new SqlConnection(Utilities.GetConnectionString()); SqlCommand sqlCommand = new SqlCommand(SpTipoPlan.RUD, sqlConnection) { CommandType = System.Data.CommandType.StoredProcedure }; sqlCommand.Parameters.Add(new SqlParameter("@CODIGO", tipoPlan.Codigo)); sqlCommand.Parameters.Add(new SqlParameter("@TDCCODIGO", tipoPlan.TipoDescuento.Codigo)); sqlCommand.Parameters.Add(new SqlParameter("@DESCRIPCION", tipoPlan.Descripcion)); sqlCommand.Parameters.Add(new SqlParameter("@PORCENTAJE", tipoPlan.Porcentaje)); sqlCommand.Parameters.Add(new SqlParameter("@ESTADO", tipoPlan.Estado)); sqlCommand.Parameters.Add(new SqlParameter("@SECUENCIA", tipoPlan.Secuencia)); sqlCommand.Parameters.Add(new SqlParameter("@ACTION", 'U')); try { sqlConnection.Open(); sqlCommand.ExecuteNonQuery(); } catch (SqlException exc) { Console.WriteLine(exc.ToString()); } finally { sqlConnection.Close(); } }
public ActionResult DeleteConfirmed(int id) { TipoPlan tipoplan = db.TipoPlan.Get(id); db.TipoPlan.Delete(tipoplan); db.SaveChanges(); return(RedirectToAction("Index")); }
private void TryAddPlan(Etiqueta et, TipoPlan tp, bool emf, double m) { if (!planAdded) { container.PlanDAO.Add(et, tp, emf, m); planAdded = true; } }
public ActionResult DeleteConfirmed(int id) { TipoPlan tipoPlan = _UnityOfWork.TipoPlan1.Get(id); _UnityOfWork.TipoPlan1.Delete(tipoPlan); _UnityOfWork.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult DeleteConfirmed(int Id) { TipoPlan tipoPlan = db.TipoPlan.Find(Id); db.TipoPlan.Remove(tipoPlan); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult DeleteConfirmed(int id) { //AdministradorEquipo administradorEquipo = db.AdministradorEquipos.Find(id); TipoPlan TipoPlanes = unityOfWork.TipoPlanes.Get(id); unityOfWork.TipoPlanes.Delete(TipoPlanes); //db.SaveChanges(); unityOfWork.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "TipoPlanID")] TipoPlan tipoplan) { if (ModelState.IsValid) { db.StateModified(tipoplan); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tipoplan)); }
public Plan Add(Etiqueta etiqueta, TipoPlan tipo, bool esMesFijo, double meta) { return(Add(new Plan() { Etiqueta = etiqueta, Tipo = tipo, Meta = meta, EsMesFijo = esMesFijo })); }
public ActionResult Edit([Bind(Include = "TipoPlanId,NombreTipoPlan")] TipoPlan tipoPlan) { if (ModelState.IsValid) { db.Entry(tipoPlan).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tipoPlan)); }
public ActionResult Edit([Bind(Include = "TipoPlan_id,TipoPlan_caracteristica")] TipoPlan tipoPlan) { if (ModelState.IsValid) { // _UnityOfWork.Entry(tipoPlan).State = EntityState.Modified; _UnityOfWork.StateModified(tipoPlan); _UnityOfWork.SaveChanges(); return(RedirectToAction("Index")); } return(View(tipoPlan)); }
public ActionResult Create([Bind(Include = "TipoPlan_id,TipoPlan_caracteristica")] TipoPlan tipoPlan) { if (ModelState.IsValid) { _UnityOfWork.TipoPlan1.Add(tipoPlan); _UnityOfWork.SaveChanges(); return(RedirectToAction("Index")); } return(View(tipoPlan)); }
public List <TipoPlan> FindByDescription(string description) { List <TipoPlan> tipoPlans = new List <TipoPlan>(); SqlConnection sqlConnection = new SqlConnection(Utilities.GetConnectionString()); SqlCommand sqlCommand = new SqlCommand(SpTipoPlan.FIND_BY_DESCRIPCION, sqlConnection) { CommandType = System.Data.CommandType.StoredProcedure }; sqlCommand.Parameters.Add(new SqlParameter("@DESCRIPCION", description)); try { sqlConnection.Open(); SqlDataReader sqlDataReader = sqlCommand.ExecuteReader(); while (sqlDataReader.Read()) { TipoId tipoId = new TipoId( sqlDataReader.GetInt32(12), sqlDataReader.GetString(13), sqlDataReader.GetString(14), Convert.ToChar(sqlDataReader.GetString(15)) ); TipoDescuento tipoDescuento = new TipoDescuento( sqlDataReader.GetInt32(6), sqlDataReader.GetString(7), tipoId, sqlDataReader.GetString(9), sqlDataReader.GetInt32(10), Convert.ToChar(sqlDataReader.GetString(11)) ); TipoPlan tipoPlan = new TipoPlan( sqlDataReader.GetInt32(0), sqlDataReader.GetString(1), tipoDescuento, sqlDataReader.GetString(3), sqlDataReader.GetInt32(4), Convert.ToChar(sqlDataReader.GetString(5)) ); tipoPlans.Add(tipoPlan); } } catch (SqlException exc) { Console.WriteLine(exc.ToString()); } finally { sqlConnection.Close(); } return(tipoPlans); }
public IHttpActionResult GetTipoPlan(int Id) { TipoPlan tipoplan = db.TipoPlan.Find(Id); if (tipoplan == null) { return(NotFound()); } return(Ok(tipoplan)); }
public ActionResult Create([Bind(Include = "TipoPlanId")] TipoPlan tipoPlan) { if (ModelState.IsValid) { db.TipoPlan.Add(tipoPlan); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tipoPlan)); }
public ActionResult Edit([Bind(Include = "TipoPlanId")] TipoPlan TipoPlanes) { if (ModelState.IsValid) { //db.Entry(administradorEquipo).State = EntityState.Modified; unityOfWork.StateModified(TipoPlanes); //db.SaveChanges(); unityOfWork.SaveChanges(); return(RedirectToAction("Index")); } return(View(TipoPlanes)); }
public IHttpActionResult PostTipoPlan(TipoPlan tipoplan) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.TipoPlan.Add(tipoplan); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { Id = tipoplan.TipoPlanId }, tipoplan)); }
public ActionResult Create([Bind(Include = "TipoPlanId")] TipoPlan TipoPlanes) { if (ModelState.IsValid) { //db.AdministradorEquipos.Add(administradorEquipo); unityOfWork.TipoPlanes.Add(TipoPlanes); unityOfWork.SaveChanges(); return(RedirectToAction("Index")); } return(View(TipoPlanes)); }
/// <summary> /// actualiza un registro /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void ASPxGridView1_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e) { try { using (var conexion = new DataModelFE()) { // se declara el objeto a insertar TipoPlan dato = new TipoPlan(); //llena el objeto con los valores de la pantalla dato.codigo = e.NewValues["codigo"] != null ? e.NewValues["codigo"].ToString().ToUpper() : null; //busca el objeto dato = conexion.TipoPlan.Find(dato.codigo); dato.cantidad = int.Parse(e.NewValues["cantidad"].ToString()); dato.descripcion = e.NewValues["descripcion"] != null ? e.NewValues["descripcion"].ToString().ToUpper() : null; dato.estado = e.NewValues["estado"].ToString(); dato.usuarioModificacion = Session["usuario"].ToString(); dato.fechaModificacion = Date.DateTimeNow(); //modifica objeto conexion.Entry(dato).State = EntityState.Modified; conexion.SaveChanges(); //esto es para el manero del devexpress e.Cancel = true; this.ASPxGridView1.CancelEdit(); } } catch (DbEntityValidationException ex) { // Retrieve the error messages as a list of strings. var errorMessages = ex.EntityValidationErrors .SelectMany(x => x.ValidationErrors) .Select(x => x.ErrorMessage); // Join the list to a single string. var fullErrorMessage = string.Join("; ", errorMessages); // Throw a new DbEntityValidationException with the improved exception message. throw new DbEntityValidationException(fullErrorMessage, ex.EntityValidationErrors); } catch (Exception ex) { throw new Exception(Utilidades.validarExepcionSQL(ex), ex.InnerException); } finally { //refescar los datos this.refreshData(); } }
// GET: TipoPlans/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TipoPlan tipoPlan = _UnityOfWork.TipoPlan1.Get(id); if (tipoPlan == null) { return(HttpNotFound()); } return(View(tipoPlan)); }
public IHttpActionResult DeleteTipoPlan(int Id) { TipoPlan tipoplan = db.TipoPlan.Find(Id); if (tipoplan == null) { return(NotFound()); } db.TipoPlan.Remove(tipoplan); db.SaveChanges(); return(Ok(tipoplan)); }
// GET: /TipoPlan/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TipoPlan tipoplan = db.TipoPlan.Get(id); if (tipoplan == null) { return(HttpNotFound()); } return(View(tipoplan)); }
// GET: TipoPlans/Delete/5 public ActionResult Delete(int?Id) { if (Id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TipoPlan tipoPlan = db.TipoPlan.Find(Id); if (tipoPlan == null) { return(HttpNotFound()); } return(View(tipoPlan)); }
// GET: AdministradorEquipoes/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TipoPlan TipoPlanes = unityOfWork.TipoPlanes.Get(id.Value); if (TipoPlanes == null) { return(HttpNotFound()); } return(View(TipoPlanes)); }
// GET: AdministradorEquipoes/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } //AdministradorEquipo administradorEquipo = db.AdministradorEquipos.Find(id); TipoPlan TipoPlanes = unityOfWork.TipoPlanes.Get(id.Value); if (TipoPlanes == null) { return(HttpNotFound()); } return(View(TipoPlanes)); }
private void CB_TipoPlan_SelectionChanged(object sender, SelectionChangedEventArgs e) { CheckSePuedeAnadir(); TipoPlan selected = (TipoPlan)CB_TipoPlan.SelectedIndex; switch (selected) { case TipoPlan.Diario: TS_EsMesFijo.Visibility = Windows.UI.Xaml.Visibility.Visible; break; case TipoPlan.Mensual: TS_EsMesFijo.Visibility = Windows.UI.Xaml.Visibility.Collapsed; break; default: TS_EsMesFijo.Visibility = Windows.UI.Xaml.Visibility.Collapsed; break; } }
private void TryProcessTransaction() { if (CheckSePuedeAnadir()) { Etiqueta et = CB_Etiqueta.SelectedItem as Etiqueta; TipoPlan tp = (TipoPlan)CB_TipoPlan.SelectedIndex; bool emf = TS_EsMesFijo.IsOn; double m = NB_Meta.Value is double.NaN ? 0 : NB_Meta.Value; if (parameters.IsEditMode) { TryEditPlan(et, tp, emf, m); } else { TryAddPlan(et, tp, emf, m); } if (((this.Parent as Frame)?.Parent as FlyoutPresenter)?.Parent is Popup) { (((this.Parent as Frame)?.Parent as FlyoutPresenter)?.Parent as Popup).IsOpen = false; } } }
public void Delete(TipoPlan tipoPlan) { SqlConnection sqlConnection = new SqlConnection(Utilities.GetConnectionString()); SqlCommand sqlCommand = new SqlCommand(SpTipoPlan.RUD, sqlConnection) { CommandType = System.Data.CommandType.StoredProcedure }; sqlCommand.Parameters.Add(new SqlParameter("@SECUENCIA", tipoPlan.Secuencia)); sqlCommand.Parameters.Add(new SqlParameter("@ACTION", 'D')); try { sqlConnection.Open(); sqlCommand.ExecuteNonQuery(); } catch (SqlException exc) { Console.WriteLine(exc.ToString()); } finally { sqlConnection.Close(); } }
public Plan(TipoPlan tipoplan, String restricciones) { this.tipoplan = tipoplan; this.restricciones = restricciones; }