public ActionResult Nuevo(TablaViewModel model) { try { if (ModelState.IsValid) { using (pruebaEntities1 db = new pruebaEntities1()) { var tabla = new tabla() { nombre = model.Nombre, correo = model.Correo, fecha_nacimiento = model.Fecha_Nacimiento }; db.tabla.Add(tabla); db.SaveChanges(); } return(Redirect("~/Tabla/")); } return(View(model)); } catch (Exception exc) { throw new Exception(exc.Message); } }
public ActionResult Nuevo(TablaViewModel model) { try { if (ModelState.IsValid) { using (CrudEntities db = new CrudEntities()) { var oTabla = new tabla(); oTabla.Dueño = model.Dueño; oTabla.Puertas = model.Puertas; oTabla.Modelo = model.Modelo; oTabla.Marca = model.Marca; oTabla.Patente = model.Patente; db.tabla.Add(oTabla); db.SaveChanges(); } return(Redirect("~/Tabla/")); } return(View(model)); } catch (Exception ex) { throw new Exception(ex.Message); } }
public ActionResult Nuevo(TableViewModel model) { try { if (ModelState.IsValid)//validar los formatos en los data annotations { using (var db = new CrudEntities()) { var oTabla = new tabla() { correo = model.Correo, fecha_nacimiento = model.Fecha_Nacimiento, nombre = model.Nombre }; db.tablas.Add(oTabla); db.SaveChanges(); } return(Redirect("~/Tabla")); } return(View(model)); } catch (Exception ex) { throw new Exception(ex.Message); } }
private void button1_Click(object sender, EventArgs e) { using (CrudEntities db = new CrudEntities()) { if (id == null) { oTabla = new tabla(); } oTabla.nombre = txtNombre.Text; oTabla.correo = txtCorreo.Text; oTabla.fecha_nacimiento = dtpFechaNacimiento.Value; if (id == null) { db.tabla.Add(oTabla); } else { db.Entry(oTabla).State = System.Data.Entity.EntityState.Modified; } db.SaveChanges(); this.Close(); } }
public ActionResult Nuevo(TablaViewModel model) { try { if (ModelState.IsValid) { using (CrudEntities db = new CrudEntities()) { var oTabla = new tabla(); oTabla.correo = model.Correo; oTabla.fecha_nacimiento = model.Fecha_Nacimiento; oTabla.nombre = model.Nombre; db.tabla.Add(oTabla); db.SaveChanges(); } return(Redirect("~/Tabla/")); } return(View(model)); } catch (Exception ex) { throw new Exception(ex.Message); } }
private void cmdGuardar_Click(object sender, EventArgs e) { using (TallerORM_Ejemplo_1Entities db = new TallerORM_Ejemplo_1Entities()) { if (!editar) { this.objPersona = new tabla(); } objPersona.nombre = txtNombre.Text; objPersona.direccion = txtDireccion.Text; objPersona.email = txtEmail.Text; objPersona.fecha_nacimiento = dtpFecha.Value; if (editar) { db.Entry(objPersona).State = System.Data.Entity.EntityState.Modified; } else { db.tabla.Add(objPersona); //Solo lo agrega al modelo edmx } db.SaveChanges(); //Persiste en la base de datos según el caso (modificar o agregar) this.Close(); } }
public ActionResult Nuevo(TablaaViewModel model) { try { //validacion if (ModelState.IsValid) { using (TablaEntities1 db = new TablaEntities1()) { var oTabla = new tabla(); oTabla.correo = model.correo; oTabla.sueldo = model.sueldo; oTabla.nombre = model.nombre; //oTabla.fecha_nacimiento = model.fecha_nacimiento; db.tabla.Add(oTabla); db.SaveChanges(); } return(Redirect("~/tabla/")); } return(View(model)); } catch (Exception ex) { throw new Exception(ex.Message); } }
private void CargaDatos() { using (CrudEntities db = new CrudEntities()) { oTabla = db.tabla.Find(id); txtCorreo.Text = oTabla.correo; txtNombre.Text = oTabla.nombre; dtpFechaNacimiento.Value = oTabla.fecha_nacimiento; } }
private void cargarDatos() { using (TallerORM_Ejemplo_1Entities db = new TallerORM_Ejemplo_1Entities()) { this.objPersona = db.tabla.Find(this.id); txtNombre.Text = objPersona.nombre; txtDireccion.Text = objPersona.direccion; txtEmail.Text = objPersona.email; dtpFecha.Value = objPersona.fecha_nacimiento.Value; } }
public ActionResult Editar(int Id) { tabla model = new tabla(); using (TablaEntities1 db = new TablaEntities1()) { var oTabla = db.tabla.Find(Id); model.Id = oTabla.Id; model.sueldo = oTabla.sueldo; model.nombre = oTabla.nombre; model.correo = oTabla.correo; } return(View()); }
private void button3_Click(object sender, EventArgs e) { int?id = GetId(); if (id != null) { using (CrudEntities db = new CrudEntities()) { tabla oTabla = db.tabla.Find(id); db.tabla.Remove(oTabla); db.SaveChanges(); } Refrescar(); } }
private void cmdEliminar_Click(object sender, EventArgs e) { if (dgvPersona.Rows.Count > 0) { int id = int.Parse(dgvPersona.Rows[dgvPersona.CurrentRow.Index].Cells[0].Value.ToString()); using (TallerORM_Ejemplo_1Entities db = new TallerORM_Ejemplo_1Entities()) { tabla objPersona = db.tabla.Find(id); db.tabla.Remove(objPersona); db.SaveChanges(); } this.cargarGrilla(); } }
public ActionResult Nuevo(Persona per) { try { using (DBEntities db = new DBEntities()) { var oTabla = new tabla(); oTabla.id = per.Id; oTabla.nombre = per.Nombre; oTabla.correo = per.Correo; oTabla.fecha_nacimiento = per.Fecha_Nacimiento; db.tabla.Add(oTabla); db.SaveChanges(); } return(Json(new { success = true, html = GlobalClass.RenderRazorViewToString(this, "Listar", obtenerLista()), message = "Guardado exitosamente" }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { success = false, message = ex.Message }, JsonRequestBehavior.AllowGet)); } }
private String Homologar(tabla.proceso procesoManual) { String procesoHomologado = null; switch (procesoManual) { case tabla.proceso.ContactoComercial: procesoHomologado = Procesos.Comercial.ToString(); break; case tabla.proceso.ContactoSeleccion: procesoHomologado = Procesos.Seleccion.ToString(); break; case tabla.proceso.ContactoContratacion: procesoHomologado = Procesos.Contratacion.ToString(); break; case tabla.proceso.Nomina: procesoHomologado = Procesos.Nomina.ToString(); break; case tabla.proceso.ContactoFinanciera: procesoHomologado = Procesos.Financiera.ToString(); break; case tabla.proceso.ContactoJuridica: procesoHomologado = Procesos.Juridica.ToString(); break; case tabla.proceso.ContactoSaludIntegral: procesoHomologado = Procesos.SaludIntegral.ToString(); break; case tabla.proceso.ContactoOperaciones: procesoHomologado = Procesos.Operaciones.ToString(); break; case tabla.proceso.ContactoBienestarSocial: procesoHomologado = Procesos.BienestarSocial.ToString(); break; case tabla.proceso.ContactoRse: procesoHomologado = Procesos.Rse.ToString(); break; case tabla.proceso.ContactoComprasEInventario: procesoHomologado = Procesos.ComprasEInventario.ToString(); break; case tabla.proceso.ContactoContabilidad: procesoHomologado = Procesos.Contabilidad.ToString(); break; } return procesoHomologado; }
public Button refresher; //Button used for JSON refreshing // Use this for initialization void Start() { string json = File.ReadAllText(Application.dataPath + "/StreamingAssets/JsonChallenge.json"); //Loads JSON File from specified path /*SPECIFICATIONS FOR JSON CREATION * * JSON FILE Requires the following to work with the table: * * Title String that holds chart title * * ColumnHeaders string array that holds column headers title and amount (It's not limited by any means, it can hold as many columns as needed) * * Data: Array of "person" class objects * * Person class is a class that contain a string array that holds person (or item/entity) data (It's not limited by any means, it can hold as many data as needed) * * Data and column count mismatching is not a problem. Chart script will handle by showing as much data as there are columns * * * Example of a JSON FILE that works: * * * {"Title":"Chart title","ColumnHeaders":["columnA","columnB","columnC"],"Data":[{"dataFields":["data1","data2","data3"]},{"dataFields":["data4","data5","data6"]},{"dataFields":["data7","data8","data9"]}]} * */ tabla tablaCargada = JsonUtility.FromJson <tabla>(json); //Deserialize JSON file into "tabla" class title.text = tablaCargada.Title; gridSpace.GetComponent <GridLayoutGroup>().constraintCount = tablaCargada.ColumnHeaders.Length; //Assign number of columns based on number of columns given in JSON file for (int i = 0; i < tablaCargada.ColumnHeaders.Length; i++) //First for cycle instantiate columnHeaders UI elements with their assigned text from JSON file { GameObject prefab; prefab = Instantiate(columnPrefab, new Vector3(0, 0, 0), Quaternion.identity); prefab.transform.parent = gridSpace.transform; prefab.transform.localScale = new Vector3(1, 1, 1); prefab.name = "Columna " + i + " : " + tablaCargada.ColumnHeaders[i]; prefab.GetComponent <Text>().text = tablaCargada.ColumnHeaders[i]; } for (int i = 0; i < tablaCargada.Data.Length; i++) //Second for cycle instantiate cells of data with their assigned data from daraFields array in JSON { for (int j = 0; j < tablaCargada.ColumnHeaders.Length; j++) //Data instantiation is limited to columnHeaders count, in order to avoid spawning more data than there are columns and thus unbalance the table { GameObject prefabCell; prefabCell = Instantiate(cellPrefab, new Vector3(0, 0, 0), Quaternion.identity); prefabCell.transform.parent = gridSpace.transform; prefabCell.transform.localScale = new Vector3(1, 1, 1); prefabCell.name = "Fila " + i + " Data " + j + " : " + tablaCargada.Data[i].dataFields[j]; prefabCell.GetComponent <Text>().text = tablaCargada.Data[i].dataFields[j]; } } refresher.onClick.AddListener(refreshJSON); }
public void verifyFormula_with_ListFormula() { var Fecha_inicial = DateTime.Now.AddDays(-2); var Fecha_final = DateTime.Now; var tabla_Contratos = new tabla(1, "contratos", new List <Campo>() { new Campo(1, "Cantidad_Contratos"), new Campo(1, "Cantidad_x") }); var tabla_Persistencia = new tabla(1, "persistencia", new List <Campo>() { new Campo(1, "Porcentaje"), new Campo(1, "OtroCampo") }); var tabla_SegundoPago = new tabla(1, "segundopago", new List <Campo>() { new Campo(1, "Porcentaje"), new Campo(1, "OtroCampo") }); var listatablas = new List <tabla>() { tabla_Contratos, tabla_Persistencia, tabla_SegundoPago }; var pedro = new Persona(1, "pedro", "garcias", "asesor", 1); var alexander = new Persona(2, "alexander", "garcias", "asesor", 1); var gerald = new Persona(3, "gerald", "garcias", "asesor", 1); var carlos = new Persona(4, "carlos", "garcias", "asesor", 2); var maria = new Persona(5, "maria", "garcias", "asesor", 2); var pedro_antiguedad = new Antiguedad(1, "descripcion1", 10, pedro); var alexander_antiguedad = new Antiguedad(2, "descripcion1", 0, alexander); var gerald_antiguedad = new Antiguedad(3, "descripcion1", 5, gerald); var carlos_antiguedad = new Antiguedad(4, "descripcion1", 2, carlos); var cmaria_antiguedad = new Antiguedad(5, "descripcion1", 7, maria); var persistencia_pedro = new Persistencia(1, pedro, 0.1M, 1, 2021, Fecha_inicial, Fecha_final, 5, 5); var persistencia_alexander = new Persistencia(1, alexander, 0.8M, 1, 2021, Fecha_inicial, Fecha_final, 2, 1); var persistencia_gerald = new Persistencia(1, gerald, 0.5M, 1, 2021, Fecha_inicial, Fecha_final, 10, 5); var persistencia_carlos = new Persistencia(1, carlos, 0.2M, 1, 2021, Fecha_inicial, Fecha_final, 2, 2); var persistencia_maria = new Persistencia(1, maria, 0.9M, 1, 2021, Fecha_inicial, Fecha_final, 10, 9); var segundo_pedro = new SegundoPago(1, pedro, 0.2M, 1, 2021, Fecha_inicial, Fecha_final, 5, 5); var segundo_alexander = new SegundoPago(1, alexander, 0.7M, 1, 2021, Fecha_inicial, Fecha_final, 2, 1); var segundo_gerald = new SegundoPago(1, gerald, 0.3M, 1, 2021, Fecha_inicial, Fecha_final, 10, 5); var segundo_carlos = new SegundoPago(1, carlos, 0.5M, 1, 2021, Fecha_inicial, Fecha_final, 2, 2); var psegundo_maria = new SegundoPago(1, maria, 0.4M, 1, 2021, Fecha_inicial, Fecha_final, 10, 9); var Lista_Antiguedad = new List <Antiguedad>() { pedro_antiguedad, alexander_antiguedad, gerald_antiguedad, carlos_antiguedad, cmaria_antiguedad }; var Lista_Persistencia = new List <Persistencia>() { persistencia_pedro, persistencia_alexander, persistencia_gerald, persistencia_carlos, persistencia_maria }; var Lista_SegundoPago = new List <SegundoPago>() { segundo_pedro, segundo_alexander, segundo_gerald, segundo_carlos, psegundo_maria }; _Listformula.ForEach(x => { x.setMathResolve(new MathXParserResolve()); }); var Listdata = (from a in Lista_Antiguedad join p in Lista_Persistencia on a.persona.Id equals p.persona.Id join s in Lista_SegundoPago on p.persona.Id equals s.persona.Id select new DataRepositorio { nombre = a.persona.Nombre, CargoId = a.persona.IdCargo, Porcentaje_Persistencia = p.Porcentaje, porcentaje_segundoPago = s.Porcentaje, Cantidad_Contratos = s.Cantidad_Contratos, Cantidad_Solventes = s.Contratos_Solventes } ).ToList(); var result = (from x in Listdata select new DataRepositorio { nombre = x.nombre, CargoId = x.CargoId, Porcentaje_Persistencia = x.Porcentaje_Persistencia, porcentaje_segundoPago = x.porcentaje_segundoPago, Cantidad_Contratos = x.Cantidad_Contratos, Cantidad_Solventes = x.Cantidad_Solventes, comision = x.Cantidad_Solventes * (_Listformula.FirstOrDefault(f => f.PositionId == x.CargoId).calculateFormula(x)), formula = _Listformula.FirstOrDefault(f => f.PositionId == x.CargoId).getFormula() } ).ToList(); }
public Proceso ObteneroPorId(tabla.proceso procesoManualDeServicio, String empresa) { Conexion datos = new Conexion(empresa); DataSet dataSet = new DataSet(); DataView dataView = new DataView(); DataTable dataTable = new DataTable(); String sql = null; String proceso = Homologar(procesoManualDeServicio); sql = "usp_oper_permisos_obtenerPorProceso "; sql += "'" + proceso + "'"; try { dataSet = datos.ExecuteReader(sql); dataView = dataSet.Tables[0].DefaultView; dataTable = dataView.Table; } catch (Exception e) { throw new Exception(e.Message); } finally { Cargar(dataTable); if (dataTable != null) dataTable.Dispose(); if (dataView != null) dataView.Dispose(); if (dataSet != null) dataSet.Dispose(); datos.Desconectar(); } return this; }