private void btnSave_Click(object sender, EventArgs e) { User korisnik = new User(); try { if (tboxUsername.Text == String.Empty || tboxPassword.Text == String.Empty) { MessageBox.Show("Polja Korisničko ime i Lozinka moraju biti popunjena!"); } else { using (DBBL data = new DBBL()) { if (data.checkDoubleUsername(tboxUsername.Text) == true && frmUsers.korisnik.Username != tboxUsername.Text) { MessageBox.Show("Korisnik sa korisničkim imenom: " + tboxUsername.Text + " već postoji."); tboxUsername.Focus(); tboxUsername.SelectAll(); } else { data.updateUser(frmUsers.korisnik, tboxIme.Text, tboxPrezime.Text, tboxUsername.Text, FormsAuthentication.HashPasswordForStoringInConfigFile(tboxPassword.Text, "sha1")); MessageBox.Show("Uspješno ste editovali podatke o korisniku."); } } } } catch (Exception ee) { MessageBox.Show(ee.ToString()); } }
private void btnSave_Click(object sender, EventArgs e) { News vijest = new News(); try { vijest.Text = tboxNewsText.Text; vijest.Created = DateTime.Now; vijest.Expiry = dtpExpire.Value; vijest.Expired = false; vijest.IsDeleted = false; if (dtpExpire.Value <= DateTime.Now) { MessageBox.Show("Datum i vrijeme isteka objave vijesti mora biti veće od današnjeg!"); } else { using (DBBL data = new DBBL()) { data.InsertNews(vijest); MessageBox.Show("Uspješno ste dodali vijest."); clearFields(); } } } catch (Exception ee) { MessageBox.Show(ee.ToString()); } }
private void btnSave_Click(object sender, EventArgs e) { if (dtpExpire.Value <= DateTime.Now || tboxAnnouncementText.Text == String.Empty || tboxTitle.Text == String.Empty) { MessageBox.Show("Datum i vrijeme isteka objave vijesti mora biti veće od današnjeg.\nNaslov i tekst objave ne mogu biti prazni."); } else { using (DBBL data = new DBBL()) { Image img = null; Image icon = null; try { if (tboxImagePath.Text != "Izaberite sliku") { img = Image.FromFile(tboxImagePath.Text); } if (tboxIconPath.Text != "Izaberite ikonu") { icon = Image.FromFile(tboxIconPath.Text); } } catch (Exception) { } data.updateAnnouncement(frmAnnouncements.announcement, tboxTitle.Text, tboxAnnouncementText.Text, dtpExpire.Value, img, icon); MessageBox.Show("Uspješno ste editovali podatke o objavi."); } } }
private void LoadAnnouncements() { using (DBBL data = new DBBL()) { announcements = data.getActiveAnnouncement(); } }
private void btnDelete_Click(object sender, EventArgs e) { if (dtvKorisnici.Rows.Count < 1) { MessageBox.Show("Izaberite red u tabeli."); } else { int id = Convert.ToInt32(dtvKorisnici.CurrentRow.Cells[0].Value); using (DBBL data = new DBBL()) { try { data.removeKorisnik(data.getKorisnikByID(id)); } catch (Exception err) { MessageBox.Show(err.ToString()); } MessageBox.Show("Uspješno ste izbrisali korisnika"); dtvKorisnici.DataSource = null; dtvKorisnici.DataSource = data.getKorisnikByAnyParameter(tboxPretraga.Text); } KorisniciTableWidth(); } }
private void btnRefresh_Click(object sender, EventArgs e) { using (DBBL data = new DBBL()) { dtvAnnouncements.DataSource = data.getActiveAnnouncement(); } AnnouncementTableWidth(); }
private void btnSearch_Click(object sender, EventArgs e) { using (DBBL data = new DBBL()) { dtvKorisnici.DataSource = data.getKorisnikByAnyParameter(tboxPretraga.Text); } KorisniciTableWidth(); }
private void btnSearch_Click(object sender, EventArgs e) { using (DBBL data = new DBBL()) { dtvAnnouncements.DataSource = data.getAnnouncementByAnyParameter(tboxPretraga.Text); } AnnouncementTableWidth(); }
private void lblClear_Click(object sender, EventArgs e) { tboxPretraga.Text = String.Empty; using (DBBL data = new DBBL()) { dtvAnnouncements.DataSource = data.getAnnouncementByAnyParameter(tboxPretraga.Text); } AnnouncementTableWidth(); }
private void dodajToolStripMenuItem2_Click(object sender, EventArgs e) { frmAddAnnouncement frm = new frmAddAnnouncement(); frm.ShowDialog(); using (DBBL data = new DBBL()) { dtvAnnouncements.DataSource = data.getActiveAnnouncement(); } AnnouncementTableWidth(); }
private void tboxPretraga_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == 13) { using (DBBL data = new DBBL()) { dtvAnnouncements.DataSource = data.getAnnouncementByAnyParameter(tboxPretraga.Text); } AnnouncementTableWidth(); } }
public int AddPitanja(DBBL.DAL.Pitanja pt) { context.Pitanja.AddObject(pt); context.SaveChanges(); DBBL.DAL.Pitanja temp = context.Pitanja.ToList().LastOrDefault(); if (temp != null) { return temp.PitanjeID; } return 0; }
private void btnSave_Click(object sender, EventArgs e) { if (tboxTitle.Text == String.Empty || tboxNewsText.Text == String.Empty || tboxIconPath.Text == "" || tboxIconPath.Text == "Izaberite ikonu") { MessageBox.Show("Upišite naslov, tekst i ikonu objave."); tboxTitle.Focus(); } else { Announcement objava = new Announcement(); try { objava.Title = tboxTitle.Text; objava.Text = tboxNewsText.Text; objava.Expiry = dtpExpire.Value; objava.Expired = false; objava.IsDeleted = false; objava.Created = DateTime.Now; if (dtpExpire.Value <= DateTime.Now) { MessageBox.Show("Datum i vrijeme isteka objave mora biti veće od današnjeg!"); } else { if (!String.IsNullOrEmpty(tboxImagePath.Text) && tboxImagePath.Text != "Izaberite sliku") { Image img = Image.FromFile(tboxImagePath.Text); //Image img = (Image)(new Bitmap(Image.FromFile(tboxImagePath.Text), new Size(80, 80))); MemoryStream ms = new MemoryStream(); img.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); objava.Image = ms.ToArray(); } if (!String.IsNullOrEmpty(tboxIconPath.Text) && tboxIconPath.Text != "Izaberite ikonu") { //byte[] img2 = System.IO.File.ReadAllBytes(tboxIconPath.Text); Image img2 = (Image)(new Bitmap(Image.FromFile(tboxIconPath.Text), new Size(80, 80))); MemoryStream ms = new MemoryStream(); img2.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); objava.Icon = ms.ToArray(); } using (DBBL data = new DBBL()) { data.InsertAnnouncement(objava); MessageBox.Show("Uspješno ste dodali objavu."); clearFields(); } } } catch (Exception ee) { MessageBox.Show(ee.ToString()); } } }
private void btnDodaj_Click(object sender, EventArgs e) { frmAddUser frm = new frmAddUser(); frm.ShowDialog(); using (DBBL data = new DBBL()) { dtvKorisnici.DataSource = null; dtvKorisnici.DataSource = data.getKorisnikByAnyParameter(tboxPretraga.Text); KorisniciTableWidth(); } }
private void frmAnnouncements_Load(object sender, EventArgs e) { using (DBBL data = new DBBL()) { dtvAnnouncements.DataSource = data.getAnnouncementByAnyParameter(tboxPretraga.Text); } AnnouncementTableWidth(); dtvAnnouncements.FirstDisplayedScrollingRowIndex = dtvAnnouncements.Rows[0].Index; dtvAnnouncements.Refresh(); dtvAnnouncements.CurrentCell = dtvAnnouncements.Rows[0].Cells[1]; dtvAnnouncements.Rows[0].Selected = true; }
private void frmMain_Load(object sender, EventArgs e) { lblLoggedInUser.Text = "Korisnik: " + Session.LoggedInUser.Name + " " + Session.LoggedInUser.Surname; using (DBBL data = new DBBL()) { dtvAnnouncements.DataSource = data.getActiveAnnouncement(); } AnnouncementTableWidth(); dtvAnnouncements.FirstDisplayedScrollingRowIndex = dtvAnnouncements.Rows[0].Index; dtvAnnouncements.Refresh(); dtvAnnouncements.CurrentCell = dtvAnnouncements.Rows[0].Cells[1]; dtvAnnouncements.Rows[0].Selected = true; }
private void btnSave_Click(object sender, EventArgs e) { if (dtpExpire.Value <= DateTime.Now || tboxNewsText.Text == String.Empty) { MessageBox.Show("Datum i vrijeme isteka objave vijesti mora biti veće od današnjeg.\nTekst vijesti ne može biti prazan."); } else { using (DBBL data = new DBBL()) { data.updateNews(frmNews.news, tboxNewsText.Text, dtpExpire.Value); MessageBox.Show("Uspješno ste editovali podatke o vijesti."); } } }
private bool CheckUserName() { try { using (DBBL data = new DBBL()) { ccounter = data.CheckUsernameValue(tboxUsername.Text, tboxPassword.Text); } } catch (Exception e) { MessageBox.Show(e.ToString()); } if (ccounter == 0) { AttemptCounter = AttemptCounter + 1; if (AttemptCounter > 5) { Application.Exit(); return(false); } else { WrongUsernameLabel.Text = "Pristup odbijen. Ovo je Vaš " + AttemptCounter + ". pokušaj."; WrongUsernameLabel.Visible = true; WrongUsernameLabel.Refresh(); return(false); } } else { try { using (DBBL data = new DBBL()) { User k = data.getKorisnikByParameter(tboxUsername.Text, tboxPassword.Text); Session.LoggedInUser = k; } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } return(true); } }
private void LoadNews() { using (DBBL data = new DBBL()) { fitVijesti = data.getActiveNews(); } if (fitVijesti.Count > 0) { lista = new List <FITNewsItem>(); foreach (var news in fitVijesti) { FITNewsItem fn = new FITNewsItem(); fn.Description = news.Text; lista.Add(fn); } } }
private void btnEdit_Click(object sender, EventArgs e) { if (dtvAnnouncements.Rows.Count < 1) { MessageBox.Show("Izaberite red u tabeli."); } else { using (DBBL data = new DBBL()) { announcement = data.getAnnouncementByID(Convert.ToInt32(dtvAnnouncements.CurrentRow.Cells[0].Value)); } frmEditAnnouncement frm = new frmEditAnnouncement(); frm.ShowDialog(); btnSearch_Click(sender, null); AnnouncementTableWidth(); } }
private void btnEdit_Click(object sender, EventArgs e) { if (dtvKorisnici.Rows.Count < 1) { MessageBox.Show("Izaberite red u tabeli."); } else { using (DBBL data = new DBBL()) { korisnik = data.getKorisnikByID(Convert.ToInt32(dtvKorisnici.CurrentRow.Cells[0].Value)); } frmEditUser frm = new frmEditUser(); frm.ShowDialog(); btnSearch_Click(sender, null); KorisniciTableWidth(); } }
private void btnSave_Click(object sender, EventArgs e) { User korisnik = new User(); try { korisnik.Name = tboxIme.Text; korisnik.Surname = tboxPrezime.Text; korisnik.Username = tboxUsername.Text; korisnik.Password = FormsAuthentication.HashPasswordForStoringInConfigFile(tboxPassword.Text, "sha1"); korisnik.IsDeleted = false; if (tboxUsername.Text == String.Empty || tboxPassword.Text == String.Empty) { MessageBox.Show("Polja Korisničko ime i Lozinka moraju biti popunjena!"); } else { using (DBBL data = new DBBL()) { if (data.checkDoubleUsername(tboxUsername.Text) == true) { MessageBox.Show("Korisnik sa korisničkim imenom: " + tboxUsername.Text + " već postoji."); tboxUsername.Focus(); tboxUsername.SelectAll(); } else { data.InsertKorisnikByAdmin(korisnik); MessageBox.Show("Uspješno ste dodali korisnika."); clearFields(); } } } } catch (Exception ee) { MessageBox.Show(ee.ToString()); } }
public HomeController(ApplicationDbContext applicationDbContext) { _DBBL = new DBBL(applicationDbContext); }