private void frm_Racun_rpt_Load(object sender, EventArgs e)
        {
            PEPBazaDataSet ds = new PEPBazaDataSet();

            SelectRacun(ds.usp_Select_Racun, narudzbaID);

            bindingSource1.DataSource = ds.usp_Select_Racun;

            ReportDataSource rds = new ReportDataSource("DS_Racun", bindingSource1);

            reportViewer1.LocalReport.DataSources.Add(rds);
            this.reportViewer1.RefreshReport();
        }
예제 #2
0
        private void procesirajButton_Click(object sender, EventArgs e)
        {
            if (this.ValidateChildren())
            {
                HttpResponseMessage       responseSkladista = skladistaProizvodiServis.GetResponse();
                List <SkladisteProizvodi> skl = responseSkladista.Content.ReadAsAsync <List <SkladisteProizvodi> >().Result;

                string message  = "";
                bool   dostupan = true;
                foreach (var item in skl)
                {
                    foreach (var item2 in stavkeNarudzbe)
                    {
                        if (item.ProizvodID != item2.ProizvodID && item.SkladisteID != Convert.ToInt32(skladistaList.SelectedValue))
                        {
                            dostupan = false;
                            message  = "Na odabranom skladištu nema proizvoda: " + item2.Naziv;
                        }

                        else
                        {
                            foreach (var item3 in stavkeNarudzbe)
                            {
                                if (item.Kolicina > 0 && item.Kolicina > item3.Kolicina)
                                {
                                    item.Kolicina    -= item2.Kolicina;
                                    responseSkladista = skladistaProizvodiServis.PutResponse(item.SkladisteProizvodiID, item);
                                    dostupan          = true;
                                }
                                else
                                {
                                    dostupan = false;
                                    message  = "Na odabranom skladištu nema dovoljno proizvoda: " + item2.Naziv;
                                }
                            }
                        }
                    }
                }

                if (dostupan == true)
                {
                    ////////////
                    Izlazi izlaz = new Izlazi();

                    izlaz.NarudzbaID  = narudzba.NarudzbaID;
                    izlaz.SkladisteID = Convert.ToInt32(skladistaList.SelectedValue);
                    izlaz.KorisnikID  = Global.prijavljeniKorisnik.KorisnikID;



                    HttpResponseMessage response = narudzbeService.PostActionResponse("ProcesirajNarudzbu", izlaz);

                    if (response.IsSuccessStatusCode)
                    {
                        MessageBox.Show("Narudžba uspješno procesirana.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.Close();
                        PEPBazaDataSet ds  = new PEPBazaDataSet();
                        Račun          rpt = new Račun(narudzba.NarudzbaID);
                        rpt.Show();
                    }
                    else
                    {
                        MessageBox.Show("Greska." + izlaz.IzlazID, "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                else
                {
                    MessageBox.Show(message);
                }
            }
        }