public bool UpdateDV(DonViDTO DV) { bool table = false; if (ConnectionSQL.ExecuteNonQuery(DV_DAO.QueryUpdateDV(DV)) > 0) { table = true; } return(table); }
protected void Page_Load(object sender, EventArgs e) { cn = new ConnectionSQL(); TBusuario.Attributes.Add("placeholder", "Usuario"); TBcontrasena.Attributes.Add("placeholder", "Contraseña"); if (!Page.IsPostBack) { Response.AppendHeader("Cache-Control", "no-store"); } }
protected void Page_Load(object sender, EventArgs e) { TBBuscarMedico.Attributes.Add("placeholder", "Cedula..."); cn = new ConnectionSQL(); manager = new ManagerFiles(); if (!IsPostBack) { cargarDepartamento(); cargarGrupos(); } }
public void LogGame(int[,] mas, string status) { ConnectionSQL sql = new ConnectionSQL(); int idGame = sql.AddGame(status, 2);; for (int i = 0; i < MainWindow.FIELD_X; i++) { for (int j = 0; j < MainWindow.FIELD_Y; j++) { sql.AddMap(idGame, i, j, mas[i, j], 2); } } }
/// <summary> /// Executar comando. /// </summary> /// <returns>Resposta do banco de dados.</returns> public object Execute(bool closeConnection = true) { object db = CommandSQL.ExecuteScalar(); if (ConnectionSQL.State == System.Data.ConnectionState.Open) { if (closeConnection) { ConnectionSQL.Close(); } } return(db); }
public ActionResult Index() { ApercuViewModel model; try { ConnectionSQL csql = new ConnectionSQL(); LigneHistorique data = csql.DerniereEntreeHistorique(); Profil profil = gp.Selectionner(data.Id_profil) ?? new Profil(); Reglage reglage = profil.SelectionnerReglage(data.Id_reglage) ?? new Reglage(); model = new ApercuViewModel(gpa, data, reglage); } catch (Exception ex) { ModelState.AddModelError("", "Erreur : " + ex.Message); model = new ApercuViewModel(); } return(View(model)); }
public T Read <T>(T obj) { try { SqlDataReader readDataBase = CommandSQL.ExecuteReader(); while (readDataBase.Read()) { if (obj == null) { obj = Activator.CreateInstance <T>(); } var keys = obj.GetType().GetProperties(); for (int i = 0; i < keys.Length; i++) { PropertyInfo key = keys[i]; string keyName = key.Name; PropertyInfo prop = obj.GetType().GetProperty(keyName); Type propType = key.PropertyType; ColumnNameAttribute attr = key.GetCustomAttribute <ColumnNameAttribute>(); if (attr != null) { keyName = attr.ColumnName; } var db = readDataBase[keyName].ToString(); object value = null; // Números: if (propType == typeof(int)) { value = Convert.ToInt32(db); } if (propType == typeof(decimal)) { value = decimal.Parse(db); } if (propType == typeof(double)) { value = double.Parse(db); } if (propType == typeof(float)) { value = float.Parse(db); } if (propType == typeof(long)) { value = long.Parse(db); } // Texto: if (propType == typeof(char)) { value = char.Parse(db); } if (propType == typeof(string)) { value = db.ToString(); } // Data: if (propType == typeof(DateTime)) { value = DateTime.Parse(db); } // Boleano: if (propType == typeof(bool)) { value = bool.Parse(db); } // Enum: if (propType == typeof(Enum)) { value = null; } prop.SetValue(obj, value, null); } } return(obj); } catch (SqlException Ex) { throw Ex; } catch (Exception Ex) { throw Ex; } finally { if (ConnectionSQL.State == System.Data.ConnectionState.Open) { ConnectionSQL.Close(); } } }