private void btnAddStavka_Click(object sender, EventArgs e) { try { if (!UserControlHelpers.ComboBoxValidation(cbAutomobil, lblAutomobil) | !UserControlHelpers.ComboBoxValidation(cbPolisa, lblPolisa) | !UserControlHelpers.DateRentiranjeValidation(dtpDatumDo, dtpDatumOd, lblDatumDo) ) { return; } stavkaRentiranja = new StavkaRentiranja { RedniBroj = redniBroj, DatumOd = dtpDatumOd.Value, DatumDo = dtpDatumDo.Value, Automobil = (Automobil)cbAutomobil.SelectedItem, Polisa = (Polisa)cbPolisa.SelectedItem }; this.DialogResult = DialogResult.OK; this.Dispose(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
internal void Save(UCProduct ucProduct) { if (!UserControlHelpers.EmptyFieldValidation(ucProduct.TxtName) | !UserControlHelpers.EmptyFieldValidation(ucProduct.TxtPrice) | !UserControlHelpers.EmptyFieldValidation(ucProduct.TxtVAT) | !UserControlHelpers.EmptyFieldValidationCB(ucProduct.CbType) | !UserControlHelpers.EmptyFieldValidationCB(ucProduct.CbCurrency)) { MessageBox.Show("Sva polja su obavezna!"); return; } if (!UserControlHelpers.CheckDoubleType(ucProduct.TxtPrice) | !UserControlHelpers.CheckDoubleType(ucProduct.TxtVAT)) { MessageBox.Show("Pogrešan unos!"); return; } try { Product p = new Product(); p.Name = ucProduct.TxtName.Text; p.PriceWithoutVAT = Math.Ceiling(Double.Parse(ucProduct.TxtPrice.Text)); p.VAT = Math.Ceiling(Double.Parse(ucProduct.TxtVAT.Text)); p.Currency = (Currency)ucProduct.CbCurrency.SelectedItem; p.Type = (ProductType)ucProduct.CbType.SelectedItem; Communication.Communication.Instance.SaveProduct(p); MessageBox.Show("Sistem je zapamtio proizvod!"); ucProduct.Visible = false; } catch (Exception) { MessageBox.Show("Sistem ne može da zapamti proizvod!"); } }
private void btnLogin_Click(object sender, EventArgs e) { main.Connect(); if (UserControlHelpers.EmptyFieldValidation(txtUsername) | UserControlHelpers.EmptyFieldValidation(txtPassword)) { return; } Korisnik korisnik = Communication.Communication.Instance.Login(txtUsername.Text, txtPassword.Text); if (korisnik != null) { if (korisnik.KorisnikId != -1) { MessageBox.Show("Uspesno ste se ulogovali"); FormMain frmMain = new FormMain(); this.Visible = false; frmMain.ShowDialog(); this.Visible = true; } else { MessageBox.Show("Korisnik sa datim usernamom je vec prijavljen"); } } else { MessageBox.Show("Korisnik sa datim username-om i password-om ne postoji!"); return; } }
internal void SaveOrder(UCOrder uCOrder) { if (!UserControlHelpers.EmptyFieldValidationCB(uCOrder.CbTable)) { MessageBox.Show("Polje 'Broj stola' je obavezno!"); return; } DateTime dateTime = DateTime.Now; uCOrder.TxtDate.Text = dateTime.ToString("dd/MM/yyyy HH:mm:ss"); try { Order order = new Order { DateTime = dateTime, Table = (Table)uCOrder.CbTable.SelectedItem, TotalWithoutVAT = double.Parse(uCOrder.TxtTotal.Text), TotalWithVAT = double.Parse(uCOrder.TxtTotalVAT.Text), Currency = currency, State = "Nije placeno", User = MainCoordinator.Instance.User, OrderItems = bindingItems.ToList() }; Communication.Communication.Instance.SaveOrder(order); MessageBox.Show("Sistem je zapamtio porudžbinu!"); uCOrder.Visible = false; } catch (Exception) { MessageBox.Show("Sistem ne može da zapamti porudžbinu!"); } }
private void btnZakazi_Click(object sender, EventArgs e) { bool popunjeno = true; List <Termin> termini = new List <Termin>(); foreach (DataGridViewRow row in dgvTermini.Rows) { Termin termin = (Termin)row.DataBoundItem; if (termin.Pacijent == null || termin.VrstaPregleda == null) { popunjeno = false; } termini.Add(termin); } if (popunjeno) { if (Communication.Communication.Instance.SacuvajTermine(termini)) { MessageBox.Show($"Upseno ste zakazali termine za {Lekar}"); } else { MessageBox.Show($"{Lekar} ima vec taj termin zakazan za datog pacijenta"); } UserControlHelpers.KreirajUC(new ZakazivanjeTermina(), this); } else { MessageBox.Show("Unesite sve informacije o pregledu!"); } }
internal void SaveRentiranje() { if (stavkeRentiranja.Count == 0) { MessageBox.Show("Niste uneli nijednu stavku"); return; } if (!UserControlHelpers.ComboBoxValidation(uCAddRentiranje.CbMusterija, uCAddRentiranje.LblMusterija)) { return; } try { string k = CommaConversion(GetUkupnaCena().ToString()); Musterija m = (Musterija)uCAddRentiranje.CbMusterija.SelectedItem; Rentiranje r = new Rentiranje { Musterija = m, Datum = DateTime.Now, //StavkeRentiranja = stavkeRentiranja.ToList(), UkupnaCena = GetUkupnaCena(), StavkeRentiranja = stavkeRentiranja.ToList(), InsertValues = $"'{m.JMBG}','{DateTime.Now.ToString("MM/dd/yyyy")}',{k}" }; Communication.Communication.Instance.SaveRentiranje(r); MessageBox.Show("Rentiranje je uspesno sacuvano"); stavkeRentiranja.Clear(); InitUCAddRentiranje(uCAddRentiranje); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
internal void Login(TextBox txtUsername, TextBox txtPassword, FrmLogin frmLogin) { if (!UserControlHelpers.EmptyFieldValidation(txtUsername) | !UserControlHelpers.EmptyFieldValidation(txtPassword)) { return; } try { Zaposleni z = new Zaposleni { KorisnickoIme = txtUsername.Text, Sifra = txtPassword.Text }; z = Communication.Communication.Instance.Login(z); if (z != null) { MainCoordinator.Instance.Zaposleni = z; MessageBox.Show($"Korisnik {z.ImePrezime} se uspesno prijavio!"); MainCoordinator.Instance.OpenMainForm(); frmLogin.Dispose(); } else { MessageBox.Show("Ne postoji ovakav korisnik"); } } catch (SystemOperationsException ex) { MessageBox.Show(ex.Message); } }
internal void Pay(UCInvoice uCInvoice) { if (!UserControlHelpers.EmptyFieldValidationCB(uCInvoice.CbPayment)) { MessageBox.Show("Odaberite način plaćanja"); return; } if (uCInvoice.CbPayment.SelectedItem.Equals(PaymentType.Gotovina)) { uCInvoice.TxtCache.Text = uCInvoice.TxtTotalToPay.Text; uCInvoice.TxtCard.Text = string.Empty; uCInvoice.TxtCardNumber.Text = string.Empty; uCInvoice.CbCardType.SelectedIndex = -1; uCInvoice.TxtCache.Enabled = false; uCInvoice.TxtCard.Enabled = false; uCInvoice.CbCardType.Enabled = false; uCInvoice.TxtCardNumber.Enabled = false; } if (uCInvoice.CbPayment.SelectedItem.Equals(PaymentType.Kartica)) { uCInvoice.TxtCard.Text = uCInvoice.TxtTotalToPay.Text; uCInvoice.TxtCache.Text = string.Empty; uCInvoice.TxtCardNumber.Text = string.Empty; uCInvoice.CbCardType.SelectedIndex = -1; uCInvoice.TxtCache.Enabled = false; uCInvoice.TxtCard.Enabled = false; uCInvoice.CbCardType.Enabled = true; uCInvoice.CbCardType.DataSource = Enum.GetValues(typeof(CardType)); uCInvoice.CbCardType.SelectedIndex = -1; uCInvoice.CbCardType.DropDownStyle = ComboBoxStyle.DropDownList; uCInvoice.TxtCardNumber.Enabled = true; } if (uCInvoice.CbPayment.SelectedItem.Equals(PaymentType.Kombinovano)) { uCInvoice.TxtCache.Text = string.Empty; uCInvoice.TxtCard.Text = string.Empty; uCInvoice.TxtCardNumber.Text = string.Empty; uCInvoice.CbCardType.SelectedIndex = -1; uCInvoice.TxtCache.Enabled = true; uCInvoice.TxtCard.Enabled = true; uCInvoice.CbCardType.Enabled = true; uCInvoice.CbCardType.DataSource = Enum.GetValues(typeof(CardType)); uCInvoice.CbCardType.SelectedIndex = -1; uCInvoice.CbCardType.DropDownStyle = ComboBoxStyle.DropDownList; uCInvoice.TxtCardNumber.Enabled = true; } uCInvoice.BtnSave.Enabled = true; }
internal void dodajUsluguUListu(DataGridView dgvusluge, TextBox txtNaziv, TextBox txtCena, TextBox txtOpis, System.Windows.Forms.ComboBox cbTipUsluge, System.Windows.Forms.Button btnSacuvaj, System.Windows.Forms.Button btnObrisi) { if (!UserControlHelpers.EmptyFieldValidation(txtNaziv) | !UserControlHelpers.EmptyFieldValidation(txtOpis) | !UserControlHelpers.EmptyFieldValidation(txtCena)) { return; } Usluga u = new Usluga() { NazivUsluge1 = txtNaziv.Text.ToString(), OpisUsluge1 = txtOpis.Text.ToString() }; try { u.CenaUsluge1 = Convert.ToInt32(txtCena.Text.ToString()); } catch (Exception) { MessageBox.Show("Nesto nije okej sa cenom, mora biti ceo broj"); return; } if (Convert.ToInt32(txtCena.Text.ToString()) <= 0) { MessageBox.Show("Cena mora biti veca od 0"); return; } // TipUsluge tip = (TipUsluge)cbTipUsluge.SelectedItem; if ((TipUsluge)cbTipUsluge.SelectedItem == null) { MessageBox.Show("Niste selektovali tip usluge"); return; } TipUsluge tip = (TipUsluge)cbTipUsluge.SelectedItem; u.Tip = tip; foreach (Usluga us in usluge) { if (us.NazivUsluge1 == u.NazivUsluge1) { MessageBox.Show("Ne mogu postojati usluge sa istim nazivom"); return; } } if (usluge.ToList().Contains(u) == false) { usluge.Add(u); dgvusluge.DataSource = usluge; btnSacuvaj.Enabled = true; btnObrisi.Enabled = true; } }
private void btnSacuvaj_Click(object sender, EventArgs e) { if (!UserControlHelpers.EmptyFieldValidation(txtIme) & !UserControlHelpers.EmptyFieldValidation(txtPrezime) & cbBolnica.SelectedIndex != -1) { if (!UserControlHelpers.HasNumberOrSymbol(txtIme) && !UserControlHelpers.HasNumberOrSymbol(txtPrezime)) { bool hitan = true; if (rbHitanNe.Checked == true) { hitan = false; } Pacijent pacijent = new Pacijent() { Ime = (string)txtIme.Text, Prezime = (string)txtPrezime.Text, DaumRodjenja = (DateTime)dtpDatum.Value, Hitan = hitan, Anamneza = (string)rtbAnamneza.Text, Bolnica = (Bolnica)cbBolnica.SelectedItem }; if (Communication.Communication.Instance.SacuvajPacijenta(pacijent)) { MessageBox.Show("Pacijent je uspesno sacuvan!"); } else { MessageBox.Show("Pacijent vec postoji u bazi!"); } DialogResult result = MessageBox.Show("", "Da li zelite da uneste jos pacijenata?", MessageBoxButtons.YesNo); if (result == DialogResult.Yes) { UserControlHelpers.KreirajUC(new UCUnosPacijenta(), this); } else if (result == DialogResult.No) { this.Visible = false; } } else { MessageBox.Show("Ime i prezime ne smeju da sadrze cifre"); } } else { MessageBox.Show("Unesite sva potrebna polja"); } }
internal void UpdateRentiranje() { if (uCUpdateRentiranje.CbPretraga.SelectedItem == null) { MessageBox.Show("Niste izabrali rentiranje koje zelite da izmenite"); } if (stavkeRentiranja.Count == 0) { MessageBox.Show("Niste dodali nijednu stavku"); return; } if (!UserControlHelpers.ComboBoxValidation(uCUpdateRentiranje.CbMusterijaUpdate, uCUpdateRentiranje.LblMusterija)) { return; } try { Musterija m = (Musterija)uCUpdateRentiranje.CbMusterijaUpdate.SelectedItem; string k = CommaConversion(GetUkupnaCena().ToString()); Rentiranje r = new Rentiranje { Id = RentiranjeId, Musterija = (Musterija)uCUpdateRentiranje.CbMusterijaUpdate.SelectedItem, Datum = DateTime.Now, UkupnaCena = GetUkupnaCena(), StavkeRentiranja = stavkeRentiranja.ToList(), WhereCondition = "ID=", WhereValue = $"{RentiranjeId}", UpdateText = $"JMBG='{m.JMBG}',Datum='{DateTime.Now.ToString("MM/dd/yyyy")}',UkupnaCena={k}" }; //Communication.Communication.Instance.UpdateRentiranje(r); if (stavkeRentiranjaUpdateDeletion.Count > 0) { for (int i = 0; i < stavkeRentiranjaUpdateDeletion.Count; i++) { stavkeRentiranjaUpdateDeletion[i].WhereCondition = "ID="; stavkeRentiranjaUpdateDeletion[i].WhereValue = $"{stavkeRentiranjaUpdateDeletion[i].Id}"; Communication.Communication.Instance.DeleteStavkaRentiranja(stavkeRentiranjaUpdateDeletion[i]); } } Communication.Communication.Instance.UpdateRentiranje(r); MessageBox.Show("Rentiranje je uspesno azurirano"); stavkeRentiranja.Clear(); uCUpdateRentiranje.CbPretraga.DataSource = null; uCUpdateRentiranje.TxtPretragaImePrezime.Text = ""; InitUCUpdateRentiranje(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
internal void Save(UCAddAutomobil uCAddAutomobil) { if (!UserControlHelpers.RegistrationValidation(uCAddAutomobil.TxtRegistracija, uCAddAutomobil.LblRegistracija) | !UserControlHelpers.VINNumberValidation(uCAddAutomobil.TxtBrojSasije, uCAddAutomobil.LblBrojSasije) | !UserControlHelpers.ComboBoxValidation(uCAddAutomobil.CbMarka, uCAddAutomobil.LblMarka) | !UserControlHelpers.ComboBoxValidation(uCAddAutomobil.CbModel, uCAddAutomobil.LblModel) ) { return; } try { string k = CommaConversion(uCAddAutomobil.TxtCenaPoDanu.Text); Model model = (Model)uCAddAutomobil.CbModel.SelectedItem; Automobil a = new Automobil { /*BrojSasije = uCAddAutomobil.TxtBrojSasije.Text, * Registracija = uCAddAutomobil.TxtRegistracija.Text, * Model = (Model)uCAddAutomobil.CbModel.SelectedItem, * GodinaProizvodnje = (int)uCAddAutomobil.CbGodiste.SelectedItem,*/ WhereCondition = "a.BrojSasije=", WhereValue = uCAddAutomobil.TxtBrojSasije.Text, InsertValues = $"'{uCAddAutomobil.TxtBrojSasije.Text}','{uCAddAutomobil.TxtRegistracija.Text}',{(int)uCAddAutomobil.CbGodiste.SelectedItem},{k},{model.Id}" }; /*List<Automobil> automobilBrSasije; * if (Communication.Communication.Instance.SearchAutomobilBrSasije(a)) * { * Communication.Communication.Instance.SaveAutomobil(a); * System.Windows.Forms.MessageBox.Show("Automobil je uspesno sacuvan"); * ResetForm(uCAddAutomobil); * } * else * { * automobilBrSasije = Communication.Communication.Instance.SearchAutomobil(a); * System.Windows.Forms.MessageBox.Show("Vec postoji automobil sa ovim brojem sasije"); * return; * }*/ Communication.Communication.Instance.SaveAutomobil(a); System.Windows.Forms.MessageBox.Show("Automobil je uspesno sacuvan"); ResetForm(uCAddAutomobil); } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message); } }
internal void Save(UCAddMusterija UCAddMusterija) { if (!UserControlHelpers.JMBGFieldValidation(UCAddMusterija.TxtJMBG, UCAddMusterija.LblJMBG) | !UserControlHelpers.CapitalLetterValidation(UCAddMusterija.TxtIme, UCAddMusterija.LblIme) | !UserControlHelpers.CapitalLetterValidation(UCAddMusterija.TxtPrezime, UCAddMusterija.LblPrezime) | !UserControlHelpers.PhoneNumberValidation(UCAddMusterija.TxtBrojTelefona, UCAddMusterija.LblBrojTelefona) | !UserControlHelpers.DateValidation(UCAddMusterija.DtpDatumRodjenja, UCAddMusterija.LblDatum) ) { return; } try { Musterija m = new Musterija { JMBG = UCAddMusterija.TxtJMBG.Text, Ime = UCAddMusterija.TxtIme.Text, Prezime = UCAddMusterija.TxtPrezime.Text, BrojTelefona = UCAddMusterija.TxtBrojTelefona.Text, DatumRodjenja = UCAddMusterija.DtpDatumRodjenja.Value, WhereCondition = "m.JMBG=", WhereValue = UCAddMusterija.TxtJMBG.Text }; /*List<Musterija> musterijaJMBG; * if (Communication.Communication.Instance.SearchMusterijaJMBG(m)) * { * Communication.Communication.Instance.SaveMusterija(m); * System.Windows.Forms.MessageBox.Show("Musterija uspesno sacuvana"); * ResetForm(UCAddMusterija); * } * else * { * musterijaJMBG = Communication.Communication.Instance.SearchMusterija(m); * System.Windows.Forms.MessageBox.Show("Musterija vec postoji u bazi"); * return; * }*/ Communication.Communication.Instance.SaveMusterija(m); System.Windows.Forms.MessageBox.Show("Musterija uspesno sacuvana"); ResetForm(UCAddMusterija); } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message); } }
private void btnDodaj_Click(object sender, EventArgs e) { if (!UserControlHelpers.EmptyFieldValidation(txtDate) && DateTime.TryParseExact(txtDate.Text, "dd.MM.yyyy HH:mm", CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime date)) { if (SlobodanTerminLekara((Lekar)cbLekari.SelectedItem, date)) { trenutniTermini.Add(date); listaTermina.Add(new Termin { DateTime = DateTime.ParseExact(txtDate.Text, "dd.MM.yyyy HH:mm", CultureInfo.InvariantCulture) }); } } else { MessageBox.Show("Unesite datum u formatu dd.MM.yyyy HH:mm"); } }
internal void AddItem(UCOrder uCOrder) { if (!UserControlHelpers.EmptyFieldValidationCB(uCOrder.CbProduct) | !UserControlHelpers.EmptyFieldValidation(uCOrder.TxtPieces)) { MessageBox.Show("Polja 'Proizvod' i 'Količina' su obavezna!"); return; } if (!int.TryParse(uCOrder.TxtPieces.Text, out _)) { MessageBox.Show("Pogrešan unos u polje 'Količina'! Neophodno uneti ceo broj!"); return; } Product p = new Product(); p = (Product)uCOrder.CbProduct.SelectedItem; currency = p.Currency; OrderItem orderItem = new OrderItem { Number = bindingItems.Count + 1, Product = p, Pieces = int.Parse(uCOrder.TxtPieces.Text), PriceWithoutVAT = p.PriceWithoutVAT, PriceWithVAT = p.PriceWithVAT, Currency = p.Currency, TotalWithoutVAT = p.PriceWithoutVAT * int.Parse(uCOrder.TxtPieces.Text), TotalWithVAT = p.PriceWithVAT * int.Parse(uCOrder.TxtPieces.Text) }; bindingItems.Add(orderItem); total += orderItem.TotalWithoutVAT; totalVAT += orderItem.TotalWithVAT; uCOrder.TxtTotal.Text = total.ToString(); uCOrder.TxtTotalVAT.Text = totalVAT.ToString(); uCOrder.CbProduct.SelectedIndex = -1; uCOrder.TxtPieces.Clear(); uCOrder.TxtCurrency.Text = currency.ToString(); }
private void btnSacuvaj_Click(object sender, EventArgs e) { if (!UserControlHelpers.EmptyFieldValidation(txtNaziv) & !UserControlHelpers.EmptyFieldValidation(txtOblast) && dgvLekari.SelectedRows.Count == 1) { if (!UserControlHelpers.HasNumberOrSymbol(txtIme) && !UserControlHelpers.HasNumberOrSymbol(txtPrezime)) { VrstaPregleda pregled = new VrstaPregleda() { Naziv = txtNaziv.Text, Oblast = txtOblast.Text, Lekar = (Lekar)dgvLekari.SelectedRows[0].DataBoundItem }; if (Communication.Communication.Instance.SacuvajVrstuPregleda(pregled)) { MessageBox.Show("Novi pregled je uspesno sacuvan"); } else { MessageBox.Show("Dati tip pregleda vec postoji"); } DialogResult result = MessageBox.Show("", "Da li zelite da uneste jos pregleda?", MessageBoxButtons.YesNo); if (result == DialogResult.Yes) { UserControlHelpers.KreirajUC(new UCUnosPregleda(), this); } else if (result == DialogResult.No) { this.Visible = false; } } else { MessageBox.Show("Naziv i oblast ne smeju da sadrze cifre"); } } else { MessageBox.Show("Popunite sva polja i izaberite jednog lekara!"); } }
internal void Login(TextBox txtKorisnickoIme, TextBox txtLozinka, FrmLogin frmLogin) { if (!UserControlHelpers.EmptyFieldValidation(txtKorisnickoIme) | !UserControlHelpers.EmptyFieldValidation(txtLozinka)) { return; } try { Zaposleni z = Communication.Communication.Instance.Login(txtKorisnickoIme.Text, txtLozinka.Text); MainCoordinator.Instance.Zaposleni = z; MessageBox.Show($"Zaposleni: {z.Ime} {z.Prezime} se ulogovao"); MainCoordinator.Instance.OpenMainForm(); frmLogin.Dispose(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
internal void Login(TextBox txtUsername, TextBox txtPassword, FrmLogin frmLogin) { if (!UserControlHelpers. EmptyFieldValidation(txtUsername) | !UserControlHelpers.EmptyFieldValidation(txtPassword)) { MessageBox.Show("Oba polja su obavezna!"); return; } try { User k = Communication.Communication.Instance.Login(txtUsername.Text, txtPassword.Text); MainCoordinator.Instance.User = k; MessageBox.Show($"Korisnik {k.FirstName} {k.LastName} se uspesno prijavio!"); MainCoordinator.Instance.OpenMainForm(); frmLogin.Dispose(); } catch (SystemOperationException) { MessageBox.Show("Sistem ne može da prepozna radnika!"); } }
internal void UpdateAutomobil(UCUpdateAutomobil uCUpdateAutomobil) { if (uCUpdateAutomobil.ComboBox.SelectedItem == null) { System.Windows.Forms.MessageBox.Show("Niste izabrali automobil koji zelite da izmenite"); return; } if (!UserControlHelpers.ComboBoxValidation(uCUpdateAutomobil.CbMarka, uCUpdateAutomobil.LblMarka) | !UserControlHelpers.ComboBoxValidation(uCUpdateAutomobil.CbModel, uCUpdateAutomobil.LblModel) | !UserControlHelpers.RegistrationValidation(uCUpdateAutomobil.TxtRegistracijaUpdate, uCUpdateAutomobil.LblRegistracija) ) { return; } try { string k = CommaConversion(uCUpdateAutomobil.TxtCenaUpdate.Text); Model model = (Model)uCUpdateAutomobil.CbModel.SelectedItem; Automobil a = new Automobil { /*BrojSasije=uCUpdateAutomobil.BrojSasije, * Registracija=uCUpdateAutomobil.TxtRegistracijaUpdate.Text, * CenaPoDanu=double.Parse(uCUpdateAutomobil.TxtCenaUpdate.Text), * GodinaProizvodnje=(int)uCUpdateAutomobil.CbGodiste.SelectedItem, * Model=(Model)uCUpdateAutomobil.CbModel.SelectedItem*/ WhereCondition = "BrojSasije=", WhereValue = $"'{uCUpdateAutomobil.BrojSasije}'", UpdateText = $"Registracija='{uCUpdateAutomobil.TxtRegistracijaUpdate.Text}',GodinaProizvodnje={(int)uCUpdateAutomobil.CbGodiste.SelectedItem},CenaPoDanu={k},ModelID={model.Id}" }; Communication.Communication.Instance.UpdateAutomobil(a); System.Windows.Forms.MessageBox.Show("Automobil uspesno sacuvan"); ResetForm(uCUpdateAutomobil); } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message); } }
internal void Update(UCUpdateMusterija uCUpdateMusterija) { if (uCUpdateMusterija.CbMusterije.SelectedItem == null) { System.Windows.Forms.MessageBox.Show("Niste izabrali musteriju koju zelite da izmenite"); return; } if (!UserControlHelpers.CapitalLetterValidation(uCUpdateMusterija.TxtImeUpdate, uCUpdateMusterija.LblIme) | !UserControlHelpers.CapitalLetterValidation(uCUpdateMusterija.TxtPrezimeUpdate, uCUpdateMusterija.LblPrezime) | !UserControlHelpers.PhoneNumberValidation(uCUpdateMusterija.TxtBrojTelefonaUpdate, uCUpdateMusterija.LblBrojTelefona) | !UserControlHelpers.DateValidation(uCUpdateMusterija.DtpDatumUpdate, uCUpdateMusterija.LblDatum) ) { return; } try { Musterija m = new Musterija { /*JMBG = uCUpdateMusterija.JMBG, * Ime = uCUpdateMusterija.TxtImeUpdate.Text, * Prezime = uCUpdateMusterija.TxtPrezimeUpdate.Text, * BrojTelefona = uCUpdateMusterija.TxtBrojTelefonaUpdate.Text, * DatumRodjenja = uCUpdateMusterija.DtpDatumUpdate.Value*/ WhereCondition = "JMBG=", WhereValue = $"'{uCUpdateMusterija.JMBG}'", UpdateText = $"Ime='{uCUpdateMusterija.TxtImeUpdate.Text}',Prezime='{uCUpdateMusterija.TxtPrezimeUpdate.Text}', BrojTelefona='{uCUpdateMusterija.TxtBrojTelefonaUpdate.Text}', DatumRodjenja='{uCUpdateMusterija.DtpDatumUpdate.Value.ToString("MM/dd/yyyy")}'" }; Communication.Communication.Instance.UpdateMusterija(m); System.Windows.Forms.MessageBox.Show("Musterija uspesno izmenjena"); ResetForm(uCUpdateMusterija); } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message); } }
internal void unesiNovogKorisnika(TextBox txtImePrezime, TextBox txtBrojTelefona, TextBox txtAdresa) { if (!UserControlHelpers.EmptyFieldValidation(txtImePrezime) | !UserControlHelpers.EmptyFieldValidation(txtBrojTelefona) | !UserControlHelpers.EmptyFieldValidation(txtAdresa)) { MessageBox.Show("Sva polja su obavezna!"); return; } if (txtImePrezime.Text.Contains(' ') == false) { MessageBox.Show("Morate uneti i ime i prezime"); return; } if (txtBrojTelefona.Text.Length != 10) { MessageBox.Show("Broj telefona mora sadrzati 10 cifara"); return; } if (txtBrojTelefona.Text[0] != '0') { MessageBox.Show("Broj telefona mora pocinjati sa 0"); return; } if (txtBrojTelefona.Text[1] != '6') { MessageBox.Show("Broj telefona na drugom mestu mora imati 6!"); return; } foreach (char c in txtImePrezime.Text) { if (char.IsDigit(c)) { MessageBox.Show("Ima i prezime korisnika sadrze cifru,a to nije dozvoljeno"); return; } } foreach (char c in txtBrojTelefona.Text) { if (char.IsLetter(c)) { MessageBox.Show("Broj telefona sadrzi slovo,a to nije dozvoljeno"); return; } } Korisnik k = new Korisnik() { ImePrezime = txtImePrezime.Text.ToString(), BrojTelefona = txtBrojTelefona.Text.ToString(), Adresa = txtAdresa.Text.ToString() }; try { int rez = Communication.Communication.Instance.ZapamtiKorisnika(k); if (rez == 1) { MessageBox.Show("Sistem je uspešno zapamtio podatke o korisniku!"); txtImePrezime.Focus(); txtAdresa.Text = ""; txtImePrezime.Text = ""; txtBrojTelefona.Text = ""; } else { MessageBox.Show("Sistem nije uspeo da zapamti korisnika"); txtImePrezime.Focus(); txtAdresa.Text = ""; txtImePrezime.Text = ""; txtBrojTelefona.Text = ""; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
internal void IzmeniKorisnika(TextBox txtimeiprezime, TextBox txtbrojtelefona, TextBox txtadresa, DataGridView dataGridView1, TextBox txtImePrezime) { if (!UserControlHelpers.EmptyFieldValidation(txtimeiprezime) | !UserControlHelpers.EmptyFieldValidation(txtbrojtelefona) | !UserControlHelpers.EmptyFieldValidation(txtadresa)) { return; } if (dataGridView1.CurrentRow.DataBoundItem == null) { MessageBox.Show("Niste izabrali korisnika za izmenu"); return; } Korisnik k = (Korisnik)dataGridView1.CurrentRow.DataBoundItem; Korisnik novi = new Korisnik(); if (txtimeiprezime.Text.Contains(' ') == false) { MessageBox.Show("Morate uneti i ime i prezime"); return; } if (txtbrojtelefona.Text.Length != 10) { MessageBox.Show("Broj telefona mora sadrzati 10 cifara"); return; } if (txtbrojtelefona.Text[0] != '0') { MessageBox.Show("Broj telefona mora pocinjati sa 0"); return; } if (txtbrojtelefona.Text[1] != '6') { MessageBox.Show("Broj telefona na drugom mestu mora imati 6!"); return; } foreach (char c in txtimeiprezime.Text) { if (char.IsDigit(c)) { MessageBox.Show("Ima i prezime korisnika sadrze cifru,a to nije dozvoljeno"); return; } } foreach (char c in txtbrojtelefona.Text) { if (char.IsLetter(c)) { MessageBox.Show("Broj telefona sadrzi slovo,a to nije dozvoljeno"); return; } } novi.IDKorisnika = k.IDKorisnika; novi.ImePrezime = txtimeiprezime.Text; novi.BrojTelefona = txtbrojtelefona.Text; novi.Adresa = txtadresa.Text; novi.USLOVINT = k.IDKorisnika; try { int rez = Communication.Communication.Instance.IzmeniKorisnika(novi); if (rez == 1) { MessageBox.Show("Sistem je uspesno izmenio podatke o korisniku"); txtimeiprezime.Text = ""; txtbrojtelefona.Text = ""; txtadresa.Text = ""; lista.Clear(); dataGridView1.DataSource = lista; txtImePrezime.Text = ""; } else { MessageBox.Show("Sistem ne moze da izmeni korisnika"); } } catch (Exception) { MessageBox.Show("Sistem ne moze da izmeni korisnika"); } }
internal void SaveInvoice(UCInvoice uCInvoice) { if (uCInvoice.CbPayment.SelectedItem.Equals(PaymentType.Kartica) || uCInvoice.CbPayment.SelectedItem.Equals(PaymentType.Kombinovano)) { if (!UserControlHelpers.EmptyFieldValidationCB(uCInvoice.CbCardType) | !UserControlHelpers.EmptyFieldValidation(uCInvoice.TxtCardNumber)) { MessageBox.Show("Neophodno je uneti 'tip kartice' i broj kartice'"); return; } if (!UserControlHelpers.CheckLongIntType(uCInvoice.TxtCardNumber)) { MessageBox.Show("Broj kartice nije ispravano unet."); return; } } double totalToPay = int.Parse(uCInvoice.TxtTotalToPay.Text); double card; double cache; if (uCInvoice.CbPayment.SelectedItem.Equals(PaymentType.Kombinovano)) { if (string.IsNullOrEmpty(uCInvoice.TxtCache.Text) | string.IsNullOrEmpty(uCInvoice.TxtCard.Text)) { MessageBox.Show("Neophodno je popuniti polja: 'Iznos koji se plaća gotovinom', 'Iznos koji se plaća karticom'"); return; } if (!UserControlHelpers.CheckDoubleType(uCInvoice.TxtCache) | !UserControlHelpers.CheckDoubleType(uCInvoice.TxtCard)) { MessageBox.Show("Neispravan unos iznosa za plaćanje. Unete vrednosti moraju biti brojevi."); return; } cache = double.Parse(uCInvoice.TxtCache.Text); card = double.Parse(uCInvoice.TxtCard.Text); if ((card + cache) != totalToPay) { MessageBox.Show($"Neispravan unos iznosa za plaćanje. Ukupan iznos za plaćanje iznosi {totalToPay}."); return; } } Cache cache1 = null; Card card1 = null; DateTime dateTime = DateTime.Now; uCInvoice.TxtDate.Text = dateTime.ToString("dd/MM/yyyy HH:mm:ss"); Table table = new Table { TableNumber = int.Parse(uCInvoice.TxtTable.Text) }; try { if (uCInvoice.CbPayment.SelectedItem.Equals(PaymentType.Gotovina)) { cache = totalToPay; cache1 = new Cache { OrderId = order.OrderId, TotalInCache = cache }; } if (uCInvoice.CbPayment.SelectedItem.Equals(PaymentType.Kartica)) { card = totalToPay; card1 = new Card { OrderId = order.OrderId, CardType = (CardType)uCInvoice.CbCardType.SelectedItem, CardNumber = long.Parse(uCInvoice.TxtCardNumber.Text), TotalByCard = card }; } if (uCInvoice.CbPayment.SelectedItem.Equals(PaymentType.Kombinovano)) { card = double.Parse(uCInvoice.TxtCard.Text); cache = double.Parse(uCInvoice.TxtCache.Text); card1 = new Card { OrderId = order.OrderId, CardType = (CardType)uCInvoice.CbCardType.SelectedItem, CardNumber = long.Parse(uCInvoice.TxtCardNumber.Text), TotalByCard = card }; cache1 = new Cache { OrderId = order.OrderId, TotalInCache = cache }; } Payment payment = new Payment { OrderId = order.OrderId, Total = totalToPay, Currency = currency, PaymentType = (PaymentType)uCInvoice.CbPayment.SelectedItem, Cache = cache1, Card = card1 }; Invoice invoice = new Invoice { DateTime = dateTime, User = MainCoordinator.Instance.User, Table = table, Currency = currency, TotalWithoutVAT = double.Parse(uCInvoice.TxtTotal.Text), TotalWithVAT = double.Parse(uCInvoice.TxtTotalVAT.Text), TotalToPay = double.Parse(uCInvoice.TxtTotalToPay.Text), InvoiceItems = invoiceItems, OrderId = order.OrderId, Payment = payment }; Communication.Communication.Instance.SaveInvoice(invoice); order.State = "Placeno"; Communication.Communication.Instance.UpdateOrder(order); MessageBox.Show("Sistem je zapamtio račun!"); uCInvoice.Visible = false; } catch (Exception) { MessageBox.Show("Sistem ne može da zapamti račun!"); } }