Пример #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (cmb_artikal.Text == "")
            {
                MessageBox.Show("Izabrite artikal");
            }
            else
            {
                string[] arr = new string[4];
                arr[0] = cmb_artikal.SelectedItem.ToString();
                arr[1] = txt_cena.Text;
                arr[2] = textBox2.Text;
                arr[3] = txt_ukupno1.Text;


                if (!string.IsNullOrEmpty(arr[0]) && !string.IsNullOrEmpty(arr[1]) && !string.IsNullOrEmpty(arr[2]) &&
                    !string.IsNullOrEmpty(arr[3]))
                {
                    ListViewItem lv1 = new ListViewItem(arr);
                    listView1.Items.Add(lv1);
                    try { txt_ukupno.Text = (Convert.ToInt16(txt_ukupno.Text) + Convert.ToInt16(txt_ukupno1.Text)).ToString(); }
                    catch (Exception ex) { txt_ukupno.Text = ""; }
                    var novi = new Narudzbina
                    {
                        naziv = cmb_artikal.Text,
                        cena  = int.Parse(txt_cena.Text),

                        kolicina = int.Parse(textBox2.Text),
                        datum    = DateTime.Today
                    };
                    this.unit.Narudzbinaa.AddNarudzbinas(novi);
                    this.unit.Complete();
                }
                else
                {
                    MessageBox.Show("Popunite sva polja.");
                    return;
                }
            }
        }
Пример #2
0
 public void DeleteNarudzbina(Narudzbina narudzbina)
 {
     this.context.Narudzbinaa.Remove(narudzbina);
 }
Пример #3
0
 public void AddNarudzbinas(Narudzbina narudzbina)
 {
     this.context.Narudzbinaa.Add(narudzbina);
 }
Пример #4
0
        private void button3_Click(object sender, EventArgs e)
        {
            try
            {
                //var hemikalije = this.unit.Hemikalijee.GetAllHemikalijes();
                //foreach (var h in hemikalije)
                //{
                //    if (h.kolicina > 0)
                //    {
                //        cmb_artikal.Items.Add(h.ToString());
                //        h.kolicina = h.kolicina - int.Parse(textBox2.Text);
                //        }
                //    else
                //        MessageBox.Show("Artikal nemamo na stanju");
                //}
                double        ukupno  = double.Parse(txt_neto.Text);
                int           placeno = int.Parse(txt_placeno.Text);
                double        kusur   = double.Parse(txt_balans.Text);
                string        r       = "Račun :";
                string        u       = "Sve ukupno :" + ukupno;
                string        pl      = "Placeno :" + placeno;
                string        k       = "Kusur :" + kusur;
                string        na      = "Naziv artikla :";
                string        c       = "Cena";
                string        kol     = "Količina";
                string        uk      = "Ukupno";
                string        nl      = "\n";
                PrintDocument p       = new PrintDocument();
                p.PrintPage += delegate(object sender1, PrintPageEventArgs e1)
                {
                    e1.Graphics.DrawString("  " + u + "\n  " + pl + "\n  " + k + nl, new Font("Arial Bold", 11), new SolidBrush(Color.Black), new RectangleF(0, 0, 0, 0));
                    e1.Graphics.DrawString(" ____________________________________________________________________", new Font("Arial Bold", 11), new SolidBrush(Color.Black), new RectangleF(0, 5, 0, 10));

                    // e1.Graphics.DrawString(" \t" +na+ "\t" +c+"\t"+kol+"\t"+uk+"\t"+"\n"+"\n", new Font("Arial Bold", 11), new SolidBrush(Color.Black), new RectangleF(0, 0, 0,300));

                    e1.Graphics.DrawString(" " + r + " ", new Font("Times New Roman", 12), new SolidBrush(Color.Black), new RectangleF(0, 55, 0, 0));
                    e1.Graphics.DrawString("\n " + nl + nl + "\n" + "\b" + nl, new Font("Arial Bold", 11), new SolidBrush(Color.Black), new RectangleF(0, 0, p.DefaultPageSettings.PrintableArea.Width, p.DefaultPageSettings.PrintableArea.Height));
                    e1.Graphics.DrawString("\t" + na + "\t \t" + c + "\t \t" + kol + "\t \t" + uk + "\t \t" + "\n", new Font("Arial Bold", 11), new SolidBrush(Color.Black), new RectangleF(0, 55, 0, 0));


                    var startX = 0;
                    var startY = 35;
                    var Offset = 0;

                    for (int i = 0; i < listView1.Items.Count; i++)
                    {
                        int ii = 1;
                        ii++;
                        string prvi    = listView1.Items[i].SubItems[0].Text;
                        string drugi   = listView1.Items[i].SubItems[1].Text;
                        string treci   = listView1.Items[i].SubItems[2].Text;
                        string cetvrti = listView1.Items[i].SubItems[3].Text;



                        e1.Graphics.DrawString(" " + nl + nl + "\t " + prvi + "\t" + "\t" + drugi + "\t" + "\t" + treci + "\t" + "\t" + cetvrti + "\n" + "\n" + nl, new Font("Arial Bold", 11), new SolidBrush(Color.Black), startX, startY + Offset);

                        Offset = Offset + 15;
                    }

                    //    e1.Graphics.DrawString("\n " +nl+ "\n", new Font("Arial Bold", 11), new SolidBrush(Color.Black), new RectangleF(0, 0, p.DefaultPageSettings.PrintableArea.Width, p.DefaultPageSettings.PrintableArea.Height));
                    //e1.Graphics.DrawString(nl+"  " +nl+nl+ u + "\n" +nl+ nl+pl+ "\n" + " " +nl+ k+nl, new Font("Arial Bold", 11), new SolidBrush(Color.Black), new RectangleF(0, 0, p.DefaultPageSettings.PrintableArea.Width, p.DefaultPageSettings.PrintableArea.Height));
                };
                try
                {
                    p.Print();
                }
                catch (Exception ex)
                {
                    throw new Exception("Exception Occured While Printing", ex);
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Exception Occured While Printing", ex);
            }
            for (int i = 0; i < listView1.Items.Count; i++)
            {
                string prvi    = listView1.Items[i].SubItems[0].Text;
                string drugi   = listView1.Items[i].SubItems[1].Text;
                string treci   = listView1.Items[i].SubItems[2].Text;
                string cetvrti = listView1.Items[i].SubItems[3].Text;

                var novi = new Narudzbina
                {
                    naziv = prvi,
                    cena  = int.Parse(drugi),

                    kolicina = int.Parse(treci),
                    datum    = DateTime.Today
                };
                this.unit.Narudzbinaa.AddNarudzbinas(novi);
                this.unit.Complete();
            }
        }