/// <summary> /// Update the record. /// </summary> public static int Update(Staj staj, Database pDb = null) { Database db; if (pDb == null) { db = new Database(); db.Connect(); } else { db = (Database)pDb; } SqlCommand command = db.CreateCommand(SQL_UPDATE); PrepareCommand(command, staj); int ret = db.ExecuteNonQuery(command); if (pDb == null) { db.Close(); } return(ret); }
public StajPrihlasen(Form parent, Staj staj) { this.parent = parent; model = new StajFormModel(staj); InitializeComponent(); }
/// <summary> /// Insert the record. /// </summary> public static int Insert(Staj staj, Database pDb = null) { Database db; if (pDb == null) { db = new Database(); db.Connect(); } else { db = (Database)pDb; } SqlCommand command = db.CreateCommand(SQL_SELECT_MAX); SqlDataReader reader = db.Select(command); reader.Read(); staj.sid = reader.GetInt32(0) + 1; reader.Close(); command = db.CreateCommand(SQL_INSERT); PrepareCommand(command, staj); int ret = db.ExecuteNonQuery(command); if (pDb == null) { db.Close(); } return(ret); }
private static Collection <Staj> Read(SqlDataReader reader) { Collection <Staj> staje = new Collection <Staj>(); while (reader.Read()) { int i = -1; Staj staj = new Staj(); staj.sid = reader.GetInt32(++i); staj.nazev = reader.GetString(++i); staj.majitel = reader.GetInt32(++i); if (!reader.IsDBNull(++i)) { staj.telefon = reader.GetString(i); } else { staj.telefon = ""; } staj.heslo = reader.GetString(++i); staj.adresa = reader.GetInt32(++i); staje.Add(staj); } return(staje); }
/// <summary> /// Select the record. /// </summary> /// <param name="id">staj id</param> public static Staj Select(int id, Database pDb = null) { Database db; if (pDb == null) { db = new Database(); db.Connect(); } else { db = (Database)pDb; } SqlCommand command = db.CreateCommand(SQL_SELECT_ID); command.Parameters.AddWithValue("@id", id); SqlDataReader reader = db.Select(command); Collection <Staj> Staje = Read(reader); Staj staj = null; if (Staje.Count == 1) { staj = Staje[0]; } reader.Close(); if (pDb == null) { db.Close(); } return(staj); }
public StajFormModel(Staj staj) { this.staj = staj; adresa = AdresaTable.getInstance().getByID(staj.adresa); maj = OsobaTable.Select(staj.majitel).prijmeni + " " + OsobaTable.Select(staj.majitel).jmeno; kone = KunTable.Select(staj.sid); zavodyStaj = ZavodyTable.SelectAllFromStaj(staj.sid); }
/// <summary> /// Prepare a command. /// </summary> private static void PrepareCommand(SqlCommand command, Staj staj) { command.Parameters.AddWithValue("@sid", staj.sid); command.Parameters.AddWithValue("@nazev", staj.nazev); command.Parameters.AddWithValue("@majitel", staj.majitel); command.Parameters.AddWithValue("@telefon", staj.telefon); command.Parameters.AddWithValue("@heslo", staj.heslo); command.Parameters.AddWithValue("@adresa", staj.adresa); }
private void button1_Click(object sender, EventArgs e) { int id; if (int.TryParse(textID.Text, out id)) { Staj staj = StajTable.Select(id); if (staj.heslo == textHeslo.Text) { StajPrihlasen form = new StajPrihlasen(this, staj); form.Show(); this.Hide(); } else { errorProvider.SetError(textHeslo, "Špatné ID nebo heslo."); } } else if (textID.Text.Equals("Admin") && textHeslo.Text.Equals("AdminHeslo")) { AdminForm form = new AdminForm(this); form.Show(); this.Hide(); } else { Jezdec jezdec = JezdecTable.Select(textID.Text); if (jezdec == null) { errorProvider.SetError(textHeslo, "Špatné ID"); } if (jezdec.heslo == textHeslo.Text) { JezdecPrihlasen form = new JezdecPrihlasen(this, jezdec); form.Show(); this.Hide(); } else { errorProvider.SetError(textHeslo, "Špatné ID nebo heslo."); } } }
protected void btnNotVer_Click(object sender, EventArgs e) { Staj blStaj = new Staj(); eskiS = blStaj.ListeGetir2(staj_id).FirstOrDefault(); yeniS = blStaj.ListeGetir2(staj_id).FirstOrDefault(); yeniS.staj_sonuc = Convert.ToInt16(finalnotu.Text); yeniS.staj_yorum = yorum.Text; if (blStaj.Duzenle(eskiS, yeniS)) { Response.Write("<script>alert('Not verme işlemi Başarılı!');</script>"); System.Threading.Thread.Sleep(1000); Server.Transfer("H_StajBasvurulari.aspx"); } else { Response.Write("<script>alert('Not verme işlemi başarısız!');</script>"); } //Response.Write("<script>alert('"+staj_id+"');</script>"); }