public ActionResult PromjeniStatus(int id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Racuni r = db.RacuniDbSet.Find(id); if (r == null) { return(HttpNotFound()); } r.Placen = !r.Placen; db.SaveChanges(); string status; if (r.Placen) { status = "plaćen"; } else { status = "nije plaćen"; } TempData["Message"] = "Račun " + r.Sifra + " je označen kao <b>" + status + "</b>"; TempData["code"] = "info"; return(RedirectToAction("Detalji", new { id = id })); }
public RacuniViewModel(DAL dal) { _dal = dal; RevRobas = new RevRobasViewModel(new List <RevRobaViewModel>()); Datum = DateTime.Now; _model = new Racuni(); }
public IHttpActionResult PutRacuni(int id, Racuni racuni) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != racuni.RacunId) { return(BadRequest()); } db.Entry(racuni).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!RacuniExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
private void procesirajButton_Click(object sender, EventArgs e) { if (Convert.ToUInt32(statusNarudzbeComboBox.SelectedValue) == 0) { MessageBox.Show("Odaberi status!"); } else if (Convert.ToUInt32(statusNarudzbeComboBox.SelectedValue) == 3) { Racuni r = new Racuni(); r.Datum = DateTime.Now; r.NarudzbaId = narudzba.NarudzbaId; r.KorisnikId = narudzba.KorisnikId; r.CijenaSaPDV = (decimal)narudzba.UkupnaCijena; r.CijenaBezPDV = (decimal)narudzba.UkupnaCijena / (decimal)1.17; HttpResponseMessage responser = racuniService.PostResponse(r); if (responser.IsSuccessStatusCode) { MessageBox.Show("Narudzba procesirana!"); this.Close(); } } else if (Convert.ToUInt32(statusNarudzbeComboBox.SelectedValue) == 4) { HttpResponseMessage response = narudzbeService.GetActionResponse("UpdateNarudzbe", narudzba.NarudzbaId.ToString()); if (response.IsSuccessStatusCode) { MessageBox.Show("Narudzba procesirana!"); this.Close(); } } }
public void Storno(object sender, EventArgs e) { if (ugdData.ActiveRow != null) { try { foreach (Infragistics.Win.UltraWinGrid.UltraGridRow row in ugdData.Rows) { if (row.Cells["Ozn"].Value.ToString() == "True") { BusinessLogic.Racuni.pIDRacun = Convert.ToInt32(row.Cells["IDRACUN"].Value); BusinessLogic.Racuni.pIDGodina = Convert.ToInt16(row.Cells["RACUNGODINAIDGODINE"].Value); using (BusinessLogic.Racuni objekt = new Racuni()) { if (objekt.IsStorniran()) { if (objekt.Storno()) { } else { MessageBox.Show("Dogodila se greška prilikom storniranja dokumenta.\n\rJavite se u T4S."); } } } } } LoadGridData(); } catch { } } }
private void LoadGodina() { using (BusinessLogic.Racuni objekt = new Racuni()) { ucbGodina.DataSource = objekt.LoadGodina(); } }
public async Task KorpaRacun(List <Artikal> la, User u) { Baza NB = new Baza(); var rac = new Racuni(); var lisart = new List <Artikal>(); foreach (Artikal a in la) { lisart.Add(NB.Artikals.Find(a.SKU)); } NB.Racunis.Add(rac); foreach (Artikal a in lisart) { NB.ArtikalRacunis.Add(new ArtikalRacuni(a, rac)); } var kor = NB.Users.Find(u.Username); rac.korID = kor.Username; rac.kor = kor; NB.SaveChanges(); }
public void LoadGridData() { Racuni objekt = new Racuni(); ugdData.DataSource = objekt.GetGridData(); ugdData.DataBind(); ugdData.UpdateData(); if (ugdData.DisplayLayout.Bands.Count > 0) { //ugdData.DisplayLayout.Bands[0].Columns["RACUNGODINAIDGODINE"].Hidden = true; ugdData.DisplayLayout.Bands[0].Columns["NAZIVPARTNER"].Header.Caption = "Učenik"; ugdData.DisplayLayout.Bands[0].Columns["IDRACUN"].Header.Caption = "Broj"; ugdData.DisplayLayout.Bands[0].Columns["DATUM"].Header.Caption = "Datum"; ugdData.DisplayLayout.Bands[0].Columns["NAPOMENA"].Header.Caption = "Napomena"; ugdData.DisplayLayout.Bands[0].Columns["UkupanIznos"].Header.Caption = "Ukupan iznos"; ugdData.DisplayLayout.Bands[0].Columns["UkupanIznos"].Format = "F2"; ugdData.DisplayLayout.Bands[0].Columns["Ozn"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.CheckBox; ugdData.DisplayLayout.Bands[0].Columns["Ozn"].CellActivation = Infragistics.Win.UltraWinGrid.Activation.AllowEdit; ugdData.DisplayLayout.Bands[0].Columns["Ozn"].Width = 20; ugdData.DisplayLayout.Bands[0].Columns["IDRACUN"].Width = 50; ugdData.DisplayLayout.Bands[0].Columns["Napomena"].Width = 250; ugdData.DisplayLayout.Bands[0].Columns["UkupanIznos"].Width = 100; ugdData.DisplayLayout.Bands[0].Columns["NAZIVPARTNER"].Width = 200; ugdData.DisplayLayout.Bands[0].Columns["VezaRacunID"].Hidden = true; ugdData.DisplayLayout.Bands[0].Columns["VezaObracun"].Hidden = true; ugdData.DisplayLayout.Bands[0].Columns["Vrsta"].Hidden = true; ugdData.DisplayLayout.Bands[0].Columns["RACUNGODINAIDGODINE"].Header.Caption = "Godina"; ugdData.DisplayLayout.Bands[0].Columns["RACUNGODINAIDGODINE"].Width = 50; ugdData.DisplayLayout.Bands[1].Columns["None"].Header.Caption = " "; ugdData.DisplayLayout.Bands[1].Columns["IDRACUN"].Hidden = true; ugdData.DisplayLayout.Bands[1].Columns["RACUNGODINAIDGODINE"].Hidden = true; ugdData.DisplayLayout.Bands[1].Columns["BROJSTAVKE"].Hidden = true; ugdData.DisplayLayout.Bands[1].Columns["NAZIVPROIZVODRACUN"].Header.Caption = "Proizvod"; ugdData.DisplayLayout.Bands[1].Columns["CIJENARACUN"].Header.Caption = "Neto"; ugdData.DisplayLayout.Bands[1].Columns["RABAT"].Header.Caption = "Rabat"; ugdData.DisplayLayout.Bands[1].Columns["KOLICINA"].Header.Caption = "Količina"; ugdData.DisplayLayout.Bands[1].Columns["FINPOREZSTOPARACUN"].Header.Caption = "Stopa PDV-a"; ugdData.DisplayLayout.Bands[1].Columns["CijenaPDV"].Header.Caption = "Ukupan iznos"; ugdData.DisplayLayout.Bands[1].Columns["CIJENARACUN"].Format = "F2"; ugdData.DisplayLayout.Bands[1].Columns["RABAT"].Format = "F2"; ugdData.DisplayLayout.Bands[1].Columns["KOLICINA"].Format = "F2"; ugdData.DisplayLayout.Bands[1].Columns["FINPOREZSTOPARACUN"].Format = "F2"; ugdData.DisplayLayout.Bands[1].Columns["CijenaPDV"].Format = "F2"; } // Utils.Tools.UltraGridStyling(ugdData); foreach (UltraGridRow row in ugdData.Rows) { if (row.Index == BusinessLogic.Obracuni.pSelectedIndex) { ugdData.ActiveRow = row; } } }
private void frmProdaja_Load(object sender, EventArgs e) { OsvijeziStavke(); stavke = new Stavka_racuna(); lblBrRacuna.Text = (int.Parse(Racuni.DohvatiBrRacuna().ToString()) + 1).ToString(); sifraRacuna = int.Parse(lblBrRacuna.Text); btnBrisi.Enabled = false; btnOcistiRacun.Enabled = false; }
private void frmRacuni_Load(object sender, EventArgs e) { listaDatuma = Racuni.DohvatiDisDatum(); cmbDatum.DataSource = listaDatuma; string datum = cmbDatum.SelectedValue.ToString(); // TODO: This line of code loads data into the '_16027_DBDataSet2.Racuni' table. You can move, or remove it, as needed. this.racuniTableAdapter1.FillByDatum(this._16027_DBDataSet2.Racuni, datum); }
public IHttpActionResult GetRacuni(int id) { Racuni racuni = db.Racuni.Find(id); if (racuni == null) { return(NotFound()); } return(Ok(racuni)); }
public IHttpActionResult PostRacuni(Racuni racuni) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.myPizza_Racun_Insert(racuni.Datum, racuni.NarudzbaId, racuni.KorisnikId, racuni.CijenaSaPDV, racuni.CijenaBezPDV); return(CreatedAtRoute("DefaultApi", new { id = racuni.RacunId }, racuni)); }
public void DeleteRacuni(Racuni racuni) { if (racuni.RacuniID == 0) { return; } _context.RevRobas.RemoveRange(_context.RevRobas.Where(f => f.RacuniID == racuni.RacuniID)); _context.Racunis.Remove(racuni); SaveChanges(); }
public RacuniViewModel(DAL dal, Racuni k, IEnumerable <KupciViewModel> kupcis, RevRobasViewModel revRobas) { _dal = dal; _model = k; Brev = k.Brev; RevRobas = revRobas; RevRobas.Items.ListChanged += CurrentPriceHandler; Datum = k.Datum; Kupci = kupcis.FirstOrDefault(r => r.Idbroj == k.KupciID); Changed = false; }
public IHttpActionResult DeleteRacuni(int id) { Racuni racuni = db.Racuni.Find(id); if (racuni == null) { return(NotFound()); } db.Racuni.Remove(racuni); db.SaveChanges(); return(Ok(racuni)); }
public async Task Neplaceni() { Racuni trazi = new Racuni(); trazi.Placen = false; var list = await _racuniService.Get <IEnumerable <Racuni> >(trazi); PlaceniRacuniList.Clear(); foreach (var racuni in list) { if (racuni.Placen == false) { PlaceniRacuniList.Add(racuni); } } }
public void PrijenosGK(object sender, EventArgs e) { if (ugdData.ActiveRow != null) { using (BusinessLogic.Racuni objekt = new Racuni()) { objekt.pOdabraniRacuni = VratiOznaceneRacune(ugdData.Rows); if (objekt.pOdabraniRacuni.Count > 0) { if (objekt.GetIDShema() != 0) { int id_shema = 0; if (objekt.InsertGlavnaKnjiga(ref id_shema)) { if (id_shema != 0) { MessageBox.Show("Uspješno je preneseno računa u GK: " + objekt.pCounter); if (objekt.InsertIRA()) { MessageBox.Show("Uspješno je preneseno računa u IRA: " + objekt.pCounter); objekt.SetPreneseniObracuni(); if (objekt.SetZatvaranja()) { LoadGridData(); } } } } else { MessageBox.Show("Dogodila se greška prilikom financijskog zaduživanja!\nJavite se u T4S."); } } else { MessageBox.Show("potrebno je napraviti shemu knjiženja\nda bi se računi mogli zadužiti."); } } } } }
private void btnOdobrenje_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { try { Cursor = Cursors.WaitCursor; Racuni racun = new Racuni("02"); racun.MdiParent = this; racun.Show(); } catch (Exception ex) { MainForm.logger.Error("Naziv klase: " + this.GetType().Name + "\n Funkcija: " + System.Reflection.MethodBase.GetCurrentMethod().Name + "\n\"" + ex.Message.ToString().Trim().Substring(0, Math.Min(ex.Message.ToString().Trim().Length, 350)) + "\""); } finally { Cursor = Cursors.Default; } }
public ActionResult Edit(Racun vm) { Racuni a = new Racuni(); if (ModelState.IsValid) { a = db.Racunii.Find(vm.Id); a.Id = vm.Id; a.Naziv = vm.Naziv; a.Datum = vm.Datum; a.IznosZaPlatiti = vm.IznosZaPlatiti; a.IsDeleted = false; db.SaveChanges(); TempData["Message"] = "Uspješna izmjena!"; return(RedirectToAction("Edit")); } return(View(vm)); }
public ActionResult Create(Racun vm) { Racuni p = new Racuni(); if (ModelState.IsValid) { p.Id = vm.Id; p.Naziv = vm.Naziv; p.Datum = vm.Datum; p.IznosZaPlatiti = vm.IznosZaPlatiti; p.IsDeleted = false; db.Racunii.Add(p); db.SaveChanges(); TempData["Message"] = "Uspješno dodavanje!"; return(RedirectToAction("Create")); } return(View(vm)); }
public async Task Pretraga() { var list = await _service.Get <IEnumerable <Racuni> >(null); RacuniList.Clear(); _suma = 0; foreach (var item in list) { if (Convert.ToDecimal(item.Napomena) >= Od && Convert.ToDecimal(item.Napomena) <= Do) { _suma += Convert.ToDecimal(item.Napomena); RacuniList.Add(item); } } Racuni zadnji = new Racuni(); zadnji.RacunId = 500; zadnji.Napomena = Convert.ToDecimal(_suma).ToString(); zadnji.Referenca = "Iznos: "; RacuniList.Add(zadnji); }
public Evidencija_Racuna(bool dodajNoviRacun, DataGridViewRow racun = null) { InitializeComponent(); UnesiProdavaceUPadajuciIzbornik(); UnesiKupceUPadajuciIzbornik(); this.DodajNoviRacun = dodajNoviRacun; if (dodajNoviRacun == false) { this.idRacuna = racun.Cells["idRacuna"].Value.ToString(); } //Ovisno o tome dodajemo li novi račun ili ažuriramo postojeći račun, popunjavaju se polja i/ili datagrid sa stavkama računa if (dodajNoviRacun == true) { PodaciORacunu.Text = "Dodaj novi račun"; EvidencijaRacuna_btn.Text = "Dodaj"; //upisujemo zaglavlje u datagrid sa stavkama računa StavkeRacuna_datagrid.DataSource = Racuni.IspisiStavkeRacuna(); UrediPostavkeDatagrida(); } else { PodaciORacunu.Text = "Promijeni postojeću primku"; EvidencijaRacuna_btn.Text = "Ažuriraj"; //popunjavamo polja s informacijama Prodavaci_combobox.SelectedValue = int.Parse(racun.Cells["prodao"].Value.ToString()); Kupci_combobox.SelectedValue = int.Parse(racun.Cells["kupio"].Value.ToString()); DatumProdaje_datepicker.Text = racun.Cells["Datum prodaje"].Value.ToString(); //popunjavamo datagrid sa stavkama primke StavkeRacuna_datagrid.DataSource = Racuni.IspisiStavkeRacuna(idRacuna); UrediPostavkeDatagrida(); } }
public ActionResult Detalji(int id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Racuni r = db.RacuniDbSet.Find(id); if (r == null) { return(HttpNotFound()); } RacunDetaljiVM model = db.RacuniDbSet .Where(x => x.Id == id) .Select(f => new RacunDetaljiVM { Id = f.Id, Placen = f.Placen ? "DA" : "NE", DatumIzdavanja = f.DatumIzdavanja, KorisnikId = f.KorisnikId, PeriodDo = f.ObracunskiPeriodDO, PeriodOd = f.ObracunskiPeriodOD, RokPlacanja = f.RokPlacanja, Sifra = f.Sifra, Ukupno = f.UkupnoBezPDV.ToString(), PDF = (f.UkupnoSaPDV - f.UkupnoBezPDV).ToString(), UkupnoPDV = f.UkupnoSaPDV.ToString(), }).Single(); model.Korisnik = db.KorisnikDbSet.Find(model.KorisnikId); model.ListaStavki = db.RacuniStavkeDbSet.Where(g => g.RacunId == model.Id).ToList(); return(View(model)); }
private void StornirajExecute(object obj) { if (SelektovaniIndeks > -1) { if (!Racuni.ElementAt(selektovaniIndeks).Storniran) { Racuni.ElementAt(selektovaniIndeks).Storniran = true; if (DataSourceUtil.Instance.WriteChecks(Racuni, Racuni.ElementAt(selektovaniIndeks).DateTime)) { Console.WriteLine("Uspesno serijalizovani racuni"); MessageBox.Show("Racun je uspesno storniran!"); } else { Console.WriteLine("Greska prilikom serijalizacije racuna - storno"); } } else { MessageBox.Show("Račun je već storniran!"); } } }
public ActionResult Kreiraj(RacunKreirajVM model) { if (!string.IsNullOrEmpty(model.Mjesec)) { if (!Regex.IsMatch(model.Mjesec, @"^\d+$")) { ModelState.AddModelError(string.Empty, "Niste unijeli ispravan mjesec!"); return(View(model)); } } if (!string.IsNullOrEmpty(model.Godina)) { if (!Regex.IsMatch(model.Mjesec, @"^\d+$")) { ModelState.AddModelError(string.Empty, "Niste unijeli ispravnu godinu!"); return(View(model)); } } int mjesec = Int32.Parse(model.Mjesec); if (DateTime.Now.Month == mjesec) { ModelState.AddModelError(string.Empty, "Racuni se mogu generisati samo za prethodni mjesec!"); return(View(model)); } if (db.RacuniDbSet.Where(c => c.ObracunskiPeriodOD.Month == mjesec).Count() > 0) { ModelState.AddModelError(string.Empty, "Već ste generisali račune za mjesec " + model.Mjesec + "!"); return(View(model)); } int brojRacuna = 0; var korisnici = db.KorisnikDbSet.ToList(); foreach (var x in korisnici) { var datum = new DateTime(Int32.Parse(model.Godina), Int32.Parse(model.Mjesec), 1); var datumdo = datum.AddMonths(1).AddDays(-1); var aktivne = db.AktivneUslugeDbSet.Where(c => c.KorisnikId == x.Id && c.DatumAktivacije < datumdo).ToList(); if (aktivne != null && aktivne.Count() > 0) { Racuni racun = new Racuni(); racun.KorisnikId = x.Id; racun.ObracunskiPeriodOD = new DateTime(Int32.Parse(model.Godina), Int32.Parse(model.Mjesec), 1); racun.ObracunskiPeriodDO = racun.ObracunskiPeriodOD.AddMonths(1).AddDays(-1); racun.RokPlacanja = DateTime.Now.AddDays(20); racun.DatumIzdavanja = DateTime.Now; racun.Placen = false; db.RacuniDbSet.Add(racun); db.SaveChanges(); double sumPDV = 0, sumBEZPDV = 0; foreach (var stavka in aktivne) { RacuniStavke rs = new RacuniStavke(); rs.RacunId = racun.Id; bool temp = false; rs.AktivneUslugeId = stavka.Id; rs.DatumPocetka = racun.ObracunskiPeriodOD; rs.DatumKraja = racun.ObracunskiPeriodDO; rs.IznosBezPDV = Math.Round(stavka.Paket.CijenaBezPdv, 2); rs.IznosSaPDV = Math.Round(stavka.Paket.CijenaSaPdv, 2); // ako je usluga aktivirana u toku mjeseca, pocetni datum promjeniti if (stavka.DatumAktivacije > rs.DatumPocetka) { rs.DatumPocetka = stavka.DatumAktivacije; temp = true; } if (stavka.DatumZatvaranja < rs.DatumKraja) { rs.DatumKraja = stavka.DatumZatvaranja ?? rs.DatumKraja; } if (temp) { rs.IznosBezPDV = Math.Round(stavka.Paket.CijenaBezPdv / 30 * (rs.DatumKraja - rs.DatumPocetka).TotalDays, 2); rs.IznosSaPDV = Math.Round(rs.IznosBezPDV * 1.17, 2); } db.RacuniStavkeDbSet.Add(rs); db.SaveChanges(); sumPDV += rs.IznosSaPDV; sumBEZPDV += rs.IznosBezPDV; } racun.UkupnoBezPDV = Math.Round(sumBEZPDV, 2); racun.UkupnoSaPDV = Math.Round(sumPDV, 2); racun.Sifra = racun.Id.ToString() + model.Mjesec + "/" + model.Godina.Substring(model.Godina.Length - 2); db.SaveChanges(); sumPDV = sumBEZPDV = 0; brojRacuna++; } } TempData["Message"] = "Generisemo racune za mjesec " + model.Mjesec + " i godinu " + model.Godina + "<br><br> Generisano je ukupno: " + brojRacuna + " racuna!"; TempData["code"] = "info"; return(RedirectToAction("Index")); }
private void EvidencijaRacuna_btn_Click(object sender, EventArgs e) { //prvo provjeravamo imamo li duplikata u stavkama računa List <string> duplikati = new List <string>(); bool imaDuplikata = false; foreach (DataGridViewRow redak in StavkeRacuna_datagrid.Rows) { if (duplikati.IndexOf(redak.Cells[0].Value.ToString()) == -1) { duplikati.Add(redak.Cells[0].Value.ToString()); } else { imaDuplikata = true; } } duplikati.Clear(); //potom provjerimo imamo li dovoljno stavki na skladištu za isporučiti List <string> prekoraceni = new List <string>(); foreach (DataGridViewRow redak in StavkeRacuna_datagrid.Rows) { string idStavke = redak.Cells["id"].Value.ToString(); string naziv = redak.Cells["Naziv"].Value.ToString(); string kolicinaZaProdaju = redak.Cells["Količina"].Value.ToString(); string popravakIliDio = redak.Cells["popravci_ili_dijelovibicikli"].Value.ToString(); if (popravakIliDio == "D") { string upit = "SELECT kolicina, \"minimalnaKolicina\" FROM \"DijeloviBicikli\" WHERE \"idDijelaBicikla\" = " + idStavke; string trenutnaPravaKolicina; using (NpgsqlDataReader dr = DB.Instance.dohvati_podatke(upit)) { dr.Read(); trenutnaPravaKolicina = dr["kolicina"].ToString(); } if (DodajNoviRacun == true) { if (int.Parse(trenutnaPravaKolicina) - int.Parse(kolicinaZaProdaju) < 0) { prekoraceni.Add(naziv); } } else { string staraKolicinaStavke; upit = string.Format("SELECT kolicina FROM \"StavkeRacuna\" WHERE \"idRacuna\" = {0} AND \"idPopravciDijeloviBicikli\" = {1}", idRacuna, idStavke); using (NpgsqlDataReader dr = DB.Instance.dohvati_podatke(upit)) { dr.Read(); staraKolicinaStavke = dr[0].ToString(); } if (int.Parse(trenutnaPravaKolicina) - int.Parse(kolicinaZaProdaju) + int.Parse(staraKolicinaStavke) < 0) { prekoraceni.Add(naziv); } } } } if (prekoraceni.Count > 0) { string poruka = "Navedene stavke je nemoguće prodati zbog manjka na skladištu:\n\n"; foreach (string proizvod in prekoraceni) { poruka += proizvod + ", "; } MessageBox.Show(poruka); } else { if (imaDuplikata == true) { MessageBox.Show("Među stavkama računa postoje duplikati! Potrebno ih je ukloniti."); } else { if (DodajNoviRacun == true) { DodajRacunUBazu(); } else { //najprije smanjujemo količine na skladištu za sve stavke računa koje će se obrisati Racuni.PovecajKolicinuNaSkladistu(idRacuna); //potom brišemo postojeći račun iz baze podataka (kaskadno se brišu i stavke računa) string upit = "DELETE FROM \"Racuni\" WHERE \"idRacuna\" = " + idRacuna; DB.Instance.izvrsi_upit(upit); //na kraju umećemo novu primku zadanu obrascem DodajRacunUBazu(); } //javljamo informaciju o tome kojih proizvoda je na skladištu ostalo malo string upitZaProizvode = "SELECT naziv, kolicina, \"minimalnaKolicina\" FROM \"DijeloviBicikli\""; using (NpgsqlDataReader dr = DB.Instance.dohvati_podatke(upitZaProizvode)) { string poruka = ""; while (dr.Read()) { if (int.Parse(dr[1].ToString()) - int.Parse(dr[2].ToString()) <= 0) { poruka += dr[0].ToString() + " (minimalna količina: " + int.Parse(dr[2].ToString()) + ", stvarna količina: " + int.Parse(dr[1].ToString()) + ")\n"; } } //ako postoje takvi proizvodi, tj ako string poruke nije ostao prazan if (poruka != "") { poruka = "Sljedeće stavke je potrebno naručiti:\n" + poruka; MessageBox.Show(poruka); } } this.Close(); } } }
public void AddRacuni(Racuni model) { _context.Racunis.Add(model); }
private void btnGotovo_Click_1(object sender, EventArgs e) { Racuni racun = new Racuni(); datum = DateTime.Now; racun.Unos(sifraRacuna, datum); listaStavke = Stavka_racuna.DohvatiSveStavke(); stavke.PopuniTablicuRacuni(listaStavke); Document doc = new Document(PageSize.LETTER, 10, 10, 42, 35); PdfWriter wri = PdfWriter.GetInstance(doc, new FileStream("Racun'" + sifraRacuna.ToString() + "'.pdf", FileMode.Create)); doc.Open(); var naslovFont = FontFactory.GetFont("Arial", 20, BaseColor.BLACK); var tablicaFont = FontFactory.GetFont("Arial", 12, BaseColor.BLACK); var textFont = FontFactory.GetFont("Arial", 10, BaseColor.BLACK); Paragraph firma = new Paragraph("Cvjecarna Mak d.o.o.", textFont); Paragraph ulica = new Paragraph("Koprivnicka 7", textFont); Paragraph grad = new Paragraph("Varazdin", textFont); Paragraph oib = new Paragraph("2873467382912", textFont); Paragraph crta = new Paragraph(new Chunk(new LineSeparator(0.0F, 100.0F, BaseColor.BLACK, Element.ALIGN_LEFT, 1))); iTextSharp.text.Image slika = iTextSharp.text.Image.GetInstance("C:/Users/INSITE/Documents/GitHub/r16027/PICvjecara/Slike/logo.png"); slika.ScalePercent(25f); slika.Alignment = 2; slika.SetAbsolutePosition(500, 690); doc.Add(firma); doc.Add(slika); doc.Add(ulica); doc.Add(grad); doc.Add(oib); doc.Add(crta); Paragraph ime = new Paragraph("\n\nIme izdavaca: " + korisnik.Ime, textFont); ime.Alignment = 2; Paragraph prezime = new Paragraph("Prezime izdavaca: " + korisnik.Prezime, textFont); prezime.Alignment = 2; Paragraph datumPar = new Paragraph("Datum: " + datum.ToString(), textFont); datumPar.Alignment = 2; Paragraph placanje = new Paragraph("Način placanja: " + "Gotovina", textFont); placanje.Alignment = 2; doc.Add(ime); doc.Add(prezime); doc.Add(datumPar); doc.Add(placanje); Paragraph paragraph = new Paragraph("\n\nRacun br: " + sifraRacuna.ToString(), naslovFont); paragraph.Alignment = 1; paragraph.Font.SetStyle("bold"); doc.Add(paragraph); Paragraph noviRed = new Paragraph("\n\n"); doc.Add(noviRed); PdfPTable tablica = new PdfPTable(7); tablica.DefaultCell.HorizontalAlignment = 1; tablica.AddCell(new Phrase("Redni broj", tablicaFont)); tablica.AddCell(new Phrase("Broj stavke", tablicaFont)); tablica.AddCell(new Phrase("Broj artikla", tablicaFont)); tablica.AddCell(new Phrase("Naziv", tablicaFont)); tablica.AddCell(new Phrase("Kolicina", tablicaFont)); tablica.AddCell(new Phrase("PDV", tablicaFont)); tablica.AddCell(new Phrase("Iznos", tablicaFont)); int brojac = 0; double pdv = 0; for (int i = 0; i < listaStavke.Count; i++) { brojac++; PdfPCell cell1 = new PdfPCell(new Phrase(brojac.ToString(), textFont)); cell1.HorizontalAlignment = 2; PdfPCell cell2 = new PdfPCell(new Phrase(listaStavke[i].ID_stavke_racuna.ToString(), textFont)); cell2.HorizontalAlignment = 1; PdfPCell cell3 = new PdfPCell(new Phrase(listaStavke[i].ID_artikli.ToString(), textFont)); cell3.HorizontalAlignment = 1; PdfPCell cell4 = new PdfPCell(new Phrase(listaStavke[i].Naziv, textFont)); cell4.HorizontalAlignment = 0; PdfPCell cell5 = new PdfPCell(new Phrase(listaStavke[i].Kolicina.ToString(), textFont)); cell5.HorizontalAlignment = 2; PdfPCell cell6 = new PdfPCell(new Phrase("25%", textFont)); cell6.HorizontalAlignment = 1; PdfPCell cell7 = new PdfPCell(new Phrase(listaStavke[i].Iznos.ToString() + " kn", textFont)); cell7.HorizontalAlignment = 2; tablica.AddCell(cell1); tablica.AddCell(cell2); tablica.AddCell(cell3); tablica.AddCell(cell4); tablica.AddCell(cell5); tablica.AddCell(cell6); tablica.AddCell(cell7); pdv = pdv + (int.Parse(listaStavke[i].Iznos.ToString()) * 0.25); } tablica.HorizontalAlignment = 1; PdfPCell cellPDV = new PdfPCell(new Phrase("PDV:")); cellPDV.Colspan = 6; cellPDV.HorizontalAlignment = 2; tablica.AddCell(cellPDV); tablica.AddCell(pdv.ToString() + " kn"); PdfPCell cellUkupno = new PdfPCell(new Phrase("Ukupno:")); cellUkupno.Colspan = 6; cellUkupno.HorizontalAlignment = 2; tablica.AddCell(cellUkupno); tablica.AddCell((int.Parse(lblIznos.Text) + pdv).ToString() + " kn"); doc.Add(tablica); Chunk razmak = new Chunk(new VerticalPositionMark()); PdfPTable ispodTablice = new PdfPTable(3); PdfPCell potpisP = new PdfPCell(new Phrase("\n\n\n\nPotpis prodavaca:")); potpisP.Border = 0; PdfPCell potpisK = new PdfPCell(new Phrase("\n\n\n\nPotpis kupca:")); potpisK.Border = 0; potpisK.Colspan = 2; potpisK.HorizontalAlignment = 2; PdfPCell crta1 = new PdfPCell(new Phrase("\n_______________")); crta1.Border = 0; PdfPCell crta2 = new PdfPCell(new Phrase("\n____________")); crta2.Border = 0; crta2.Colspan = 2; crta2.HorizontalAlignment = 2; ispodTablice.AddCell(potpisP); ispodTablice.AddCell(potpisK); ispodTablice.AddCell(crta1); ispodTablice.AddCell(crta2); doc.Add(ispodTablice); doc.Close(); stavke.ObrisiSve(); OsvijeziStavke(); lblIznos.Text = "0,00"; sifraRacuna++; MessageBox.Show("Račun uspiješno kreiran"); }
/// <summary> /// Invoked when this page is about to be displayed in a Frame. /// </summary> /// <param name="e">Event data that describes how this page was reached. /// This parameter is typically used to configure the page.</param> protected override void OnNavigatedTo(NavigationEventArgs e) { n = (Racuni)e.Parameter; BindNarudzbeDetails(n.NarudzbaId); }
public ActionResult Printaj(int id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Racuni r = db.RacuniDbSet.Find(id); if (r == null) { return(HttpNotFound()); } RacunPrintajVM model = db.RacuniDbSet .Where(x => x.Id == id) .Select(f => new RacunPrintajVM { Id = f.Id, Placen = f.Placen ? "DA" : "NE", DatumIzdavanja = f.DatumIzdavanja, KorisnikId = f.KorisnikId, PeriodDo = f.ObracunskiPeriodDO, PeriodOd = f.ObracunskiPeriodOD, RokPlacanja = f.RokPlacanja, Sifra = f.Sifra, Ukupno = f.UkupnoBezPDV.ToString(), PDF = (f.UkupnoSaPDV - f.UkupnoBezPDV).ToString(), UkupnoPDV = f.UkupnoSaPDV.ToString(), }).Single(); model.Korisnik = db.KorisnikDbSet.Find(model.KorisnikId); model.ListaStavki = db.RacuniStavkeDbSet.Where(g => g.RacunId == model.Id).ToList(); PdfPTable pdftabela = new PdfPTable(2); PdfPTable tabela3 = new PdfPTable(3); PdfPTable tabelaUsluge = new PdfPTable(7); PdfPTable tabelaTotal = new PdfPTable(5); PdfPCell celija; string FONT = "c:/Windows/Fonts/arial.ttf"; Font font = FontFactory.GetFont(FONT, BaseFont.IDENTITY_H, true); using (MemoryStream ms = new MemoryStream()) { Document document = new Document(); document.SetPageSize(PageSize.A4); document.SetMargins(50f, 50f, 20f, 20f); pdftabela.WidthPercentage = 100; pdftabela.HorizontalAlignment = Element.ALIGN_LEFT; tabela3.WidthPercentage = 100; tabela3.HorizontalAlignment = Element.ALIGN_LEFT; tabelaUsluge.WidthPercentage = 100; tabelaUsluge.HorizontalAlignment = Element.ALIGN_LEFT; tabelaTotal.WidthPercentage = 100; tabelaTotal.HorizontalAlignment = Element.ALIGN_LEFT; PdfWriter writer = PdfWriter.GetInstance(document, ms); document.Open(); BaseFont nf = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.CP1250, false); BaseFont bf = BaseFont.CreateFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1250, false); var Sivaboja = new BaseColor(25, 25, 25); Font fontsadrzaj = new Font(nf, 11); Font font8 = new Font(nf, 8); Font font8bold = new Font(bf, 8); Font font11 = new Font(nf, 11); Font font9 = new Font(nf, 9); Font font10 = new Font(nf, 10); Font font11bold = new Font(bf, 11); Font font16Bold = new Font(bf, 16); Font font16 = new Font(nf, 16); Font font20 = new Font(nf, 18); string putanja = Server.MapPath("~/Slike/"); Image header = Image.GetInstance(putanja + "header.png"); ////////////////////////////////////////////////////////////////////////// header.ScaleToFit(PageSize.A4.Width - 90f, 80f); header.SpacingBefore = 10f; header.SpacingAfter = 10f; header.Alignment = Element.ALIGN_LEFT; document.Add(header); ////////////////////////////////////////////////////////////////////////// pdftabela.SetWidths(new float[] { 160f, 100f }); tabela3.SetWidths(new float[] { 50, 40, 50 }); tabelaUsluge.SetWidths(new float[] { 35, 35, 35, 35, 35, 35, 35 }); tabelaTotal.SetWidths(new float[] { 50, 50, 50, 50, 50 }); #region tijelo pdftabela.SpacingBefore = 50f; celija = new PdfPCell(new Phrase("RAČUN - " + model.Sifra, font20)); celija.HorizontalAlignment = Element.ALIGN_LEFT; celija.VerticalAlignment = Element.ALIGN_MIDDLE; celija.BackgroundColor = BaseColor.WHITE; celija.Border = Rectangle.NO_BORDER; pdftabela.AddCell(celija); celija = new PdfPCell(); celija.Border = Rectangle.NO_BORDER; pdftabela.AddCell(celija); //celija = new PdfPCell(new Phrase("Sifra " + model.Sifra, font11)); //celija.HorizontalAlignment = Element.ALIGN_RIGHT; //celija.VerticalAlignment = Element.ALIGN_MIDDLE; //celija.BackgroundColor = BaseColor.WHITE; //celija.Border = Rectangle.NO_BORDER; //pdftabela.AddCell(celija); tabela3.SpacingBefore = 50f; #endregion document.Add(pdftabela); celija = new PdfPCell(new Phrase("Klijent: ", font11bold)); celija.HorizontalAlignment = Element.ALIGN_LEFT; celija.VerticalAlignment = Element.ALIGN_MIDDLE; celija.BackgroundColor = BaseColor.WHITE; celija.Border = Rectangle.NO_BORDER; celija.MinimumHeight = 25f; tabela3.AddCell(celija); celija = new PdfPCell(); celija.Border = Rectangle.NO_BORDER; tabela3.AddCell(celija); celija = new PdfPCell(new Phrase("Detalji o računu: ", font11bold)); celija.HorizontalAlignment = Element.ALIGN_LEFT; celija.VerticalAlignment = Element.ALIGN_MIDDLE; celija.BackgroundColor = BaseColor.WHITE; celija.MinimumHeight = 25f; celija.PaddingLeft = 20; celija.Border = Rectangle.NO_BORDER; tabela3.AddCell(celija); tabela3.CompleteRow(); celija = new PdfPCell(new Phrase(model.Korisnik.Ime + " " + model.Korisnik.Prezime, font11)); celija.HorizontalAlignment = Element.ALIGN_LEFT; celija.VerticalAlignment = Element.ALIGN_MIDDLE; celija.BackgroundColor = BaseColor.WHITE; celija.Border = Rectangle.NO_BORDER; celija.MinimumHeight = 16f; tabela3.AddCell(celija); celija = new PdfPCell(); celija.Border = Rectangle.NO_BORDER; tabela3.AddCell(celija); celija = new PdfPCell(new Phrase("Datum izdavanja: " + model.DatumIzdavanja.ToShortDateString(), font11)); celija.HorizontalAlignment = Element.ALIGN_RIGHT; celija.VerticalAlignment = Element.ALIGN_MIDDLE; celija.BackgroundColor = BaseColor.WHITE; celija.MinimumHeight = 16f; celija.PaddingLeft = 20; celija.Border = Rectangle.NO_BORDER; tabela3.AddCell(celija); tabela3.CompleteRow(); celija = new PdfPCell(new Phrase(model.Korisnik.Adresa + " ", font11)); celija.HorizontalAlignment = Element.ALIGN_LEFT; celija.VerticalAlignment = Element.ALIGN_MIDDLE; celija.BackgroundColor = BaseColor.WHITE; celija.Border = Rectangle.NO_BORDER; celija.MinimumHeight = 16f; tabela3.AddCell(celija); celija = new PdfPCell(); celija.Border = Rectangle.NO_BORDER; tabela3.AddCell(celija); celija = new PdfPCell(new Phrase("Period od: " + model.PeriodOd.ToShortDateString(), font11)); celija.HorizontalAlignment = Element.ALIGN_RIGHT; celija.VerticalAlignment = Element.ALIGN_MIDDLE; celija.BackgroundColor = BaseColor.WHITE; celija.PaddingLeft = 20; celija.Border = Rectangle.NO_BORDER; tabela3.AddCell(celija); tabela3.CompleteRow(); celija = new PdfPCell(new Phrase(model.Korisnik.Opcina.NazivOpcine, font11)); celija.HorizontalAlignment = Element.ALIGN_LEFT; celija.VerticalAlignment = Element.ALIGN_MIDDLE; celija.BackgroundColor = BaseColor.WHITE; celija.Border = Rectangle.NO_BORDER; celija.MinimumHeight = 16f; tabela3.AddCell(celija); celija = new PdfPCell(); celija.Border = Rectangle.NO_BORDER; tabela3.AddCell(celija); celija = new PdfPCell(new Phrase("Period od: " + model.PeriodDo.ToShortDateString(), font11)); celija.HorizontalAlignment = Element.ALIGN_RIGHT; celija.VerticalAlignment = Element.ALIGN_MIDDLE; celija.BackgroundColor = BaseColor.WHITE; celija.PaddingLeft = 20; celija.Border = Rectangle.NO_BORDER; tabela3.AddCell(celija); tabela3.CompleteRow(); document.Add(tabela3); tabelaUsluge.SpacingBefore = 50f; celija = new PdfPCell(new Phrase("USLUGA ", font10)); celija.HorizontalAlignment = Element.ALIGN_CENTER; celija.VerticalAlignment = Element.ALIGN_MIDDLE; celija.BackgroundColor = BaseColor.WHITE; celija.Border = Rectangle.NO_BORDER; celija.MinimumHeight = 20f; tabelaUsluge.AddCell(celija); celija = new PdfPCell(new Phrase("NAZIV ", font10)); celija.HorizontalAlignment = Element.ALIGN_CENTER; celija.VerticalAlignment = Element.ALIGN_MIDDLE; celija.BackgroundColor = BaseColor.WHITE; celija.Border = Rectangle.NO_BORDER; celija.MinimumHeight = 20f; tabelaUsluge.AddCell(celija); celija = new PdfPCell(new Phrase("DATUM OD ", font10)); celija.HorizontalAlignment = Element.ALIGN_CENTER; celija.VerticalAlignment = Element.ALIGN_MIDDLE; celija.BackgroundColor = BaseColor.WHITE; celija.Border = Rectangle.NO_BORDER; celija.MinimumHeight = 20f; tabelaUsluge.AddCell(celija); celija = new PdfPCell(new Phrase("DATUM DO ", font10)); celija.HorizontalAlignment = Element.ALIGN_CENTER; celija.VerticalAlignment = Element.ALIGN_MIDDLE; celija.BackgroundColor = BaseColor.WHITE; celija.Border = Rectangle.NO_BORDER; celija.MinimumHeight = 20f; tabelaUsluge.AddCell(celija); celija = new PdfPCell(new Phrase("CIJENA ", font10)); celija.HorizontalAlignment = Element.ALIGN_CENTER; celija.VerticalAlignment = Element.ALIGN_MIDDLE; celija.BackgroundColor = BaseColor.WHITE; celija.Border = Rectangle.NO_BORDER; celija.MinimumHeight = 20f; tabelaUsluge.AddCell(celija); celija = new PdfPCell(new Phrase("PDV ", font10)); celija.HorizontalAlignment = Element.ALIGN_CENTER; celija.VerticalAlignment = Element.ALIGN_MIDDLE; celija.BackgroundColor = BaseColor.WHITE; celija.Border = Rectangle.NO_BORDER; celija.MinimumHeight = 20f; tabelaUsluge.AddCell(celija); celija = new PdfPCell(new Phrase("UKUPNO ", font10)); celija.HorizontalAlignment = Element.ALIGN_CENTER; celija.VerticalAlignment = Element.ALIGN_MIDDLE; celija.BackgroundColor = BaseColor.WHITE; celija.Border = Rectangle.NO_BORDER; celija.MinimumHeight = 20f; tabelaUsluge.AddCell(celija); ///////////////////////////////////////////////////////////////// tabelaUsluge.CompleteRow(); ///////////////////////////////////////////////////////////////// foreach (var item in model.ListaStavki) { celija = new PdfPCell(new Phrase(item.AktivnaUsluga.Paket.Naziv, font11)); celija.HorizontalAlignment = Element.ALIGN_CENTER; celija.VerticalAlignment = Element.ALIGN_MIDDLE; celija.BackgroundColor = BaseColor.WHITE; celija.Border = Rectangle.NO_BORDER; celija.MinimumHeight = 20f; tabelaUsluge.AddCell(celija); celija = new PdfPCell(new Phrase(item.AktivnaUsluga.Paket.TipUsluga.Naziv, font11)); celija.HorizontalAlignment = Element.ALIGN_CENTER; celija.VerticalAlignment = Element.ALIGN_MIDDLE; celija.BackgroundColor = BaseColor.WHITE; celija.Border = Rectangle.NO_BORDER; celija.MinimumHeight = 20f; tabelaUsluge.AddCell(celija); celija = new PdfPCell(new Phrase(item.DatumPocetka.ToShortDateString(), font11)); celija.HorizontalAlignment = Element.ALIGN_CENTER; celija.VerticalAlignment = Element.ALIGN_MIDDLE; celija.BackgroundColor = BaseColor.WHITE; celija.Border = Rectangle.NO_BORDER; celija.MinimumHeight = 20f; tabelaUsluge.AddCell(celija); celija = new PdfPCell(new Phrase(item.DatumKraja.ToShortDateString(), font11)); celija.HorizontalAlignment = Element.ALIGN_CENTER; celija.VerticalAlignment = Element.ALIGN_MIDDLE; celija.BackgroundColor = BaseColor.WHITE; celija.Border = Rectangle.NO_BORDER; celija.MinimumHeight = 20f; tabelaUsluge.AddCell(celija); celija = new PdfPCell(new Phrase(item.IznosBezPDV.ToString(), font11)); celija.HorizontalAlignment = Element.ALIGN_CENTER; celija.VerticalAlignment = Element.ALIGN_MIDDLE; celija.BackgroundColor = BaseColor.WHITE; celija.Border = Rectangle.NO_BORDER; celija.MinimumHeight = 20f; tabelaUsluge.AddCell(celija); celija = new PdfPCell(new Phrase((item.IznosSaPDV - item.IznosBezPDV).ToString(), font11)); celija.HorizontalAlignment = Element.ALIGN_CENTER; celija.VerticalAlignment = Element.ALIGN_MIDDLE; celija.BackgroundColor = BaseColor.WHITE; celija.Border = Rectangle.NO_BORDER; celija.MinimumHeight = 20f; tabelaUsluge.AddCell(celija); celija = new PdfPCell(new Phrase(item.IznosSaPDV.ToString(), font11)); celija.HorizontalAlignment = Element.ALIGN_CENTER; celija.VerticalAlignment = Element.ALIGN_MIDDLE; celija.BackgroundColor = BaseColor.WHITE; celija.Border = Rectangle.NO_BORDER; celija.MinimumHeight = 20f; tabelaUsluge.AddCell(celija); //////////////////////////////////////////////////////////////////////// tabelaUsluge.CompleteRow(); /////////////////////////////////////////////////////////////////////////// } tabelaUsluge.CompleteRow(); document.Add(tabelaUsluge); //////////////////////////////////////////////////////////////////////// tabelaTotal.SpacingBefore = 100f; celija = new PdfPCell(); celija.Border = Rectangle.NO_BORDER; tabelaTotal.AddCell(celija); celija = new PdfPCell(); celija.Border = Rectangle.NO_BORDER; tabelaTotal.AddCell(celija); celija = new PdfPCell(new Phrase("Ukupno bez PDV", font11)); celija.HorizontalAlignment = Element.ALIGN_RIGHT; celija.VerticalAlignment = Element.ALIGN_MIDDLE; celija.BackgroundColor = BaseColor.WHITE; celija.Border = Rectangle.NO_BORDER; tabelaTotal.AddCell(celija); celija = new PdfPCell(new Phrase("PDV 17%", font11)); celija.HorizontalAlignment = Element.ALIGN_RIGHT; celija.VerticalAlignment = Element.ALIGN_MIDDLE; celija.BackgroundColor = BaseColor.WHITE; celija.Border = Rectangle.NO_BORDER; tabelaTotal.AddCell(celija); celija = new PdfPCell(new Phrase("Ukupno sa PDV", font11)); celija.HorizontalAlignment = Element.ALIGN_RIGHT; celija.VerticalAlignment = Element.ALIGN_MIDDLE; celija.BackgroundColor = BaseColor.WHITE; celija.Border = Rectangle.NO_BORDER; tabelaTotal.AddCell(celija); tabelaTotal.CompleteRow(); celija = new PdfPCell(); celija.Border = Rectangle.NO_BORDER; tabelaTotal.AddCell(celija); celija = new PdfPCell(); celija.Border = Rectangle.NO_BORDER; tabelaTotal.AddCell(celija); celija = new PdfPCell(new Phrase(model.Ukupno.ToString(), font16)); celija.HorizontalAlignment = Element.ALIGN_RIGHT; celija.VerticalAlignment = Element.ALIGN_MIDDLE; celija.BackgroundColor = BaseColor.WHITE; celija.Border = Rectangle.NO_BORDER; tabelaTotal.AddCell(celija); celija = new PdfPCell(new Phrase(model.PDF, font16)); celija.HorizontalAlignment = Element.ALIGN_RIGHT; celija.VerticalAlignment = Element.ALIGN_MIDDLE; celija.BackgroundColor = BaseColor.WHITE; celija.Border = Rectangle.NO_BORDER; tabelaTotal.AddCell(celija); celija = new PdfPCell(new Phrase(model.UkupnoPDV, font16Bold)); celija.HorizontalAlignment = Element.ALIGN_RIGHT; celija.VerticalAlignment = Element.ALIGN_MIDDLE; celija.BackgroundColor = BaseColor.WHITE; celija.Border = Rectangle.NO_BORDER; tabelaTotal.AddCell(celija); tabelaTotal.CompleteRow(); document.Add(tabelaTotal); document.Close(); byte[] bytes = ms.ToArray(); ms.Close(); return(File(bytes, "application/pdf")); } }