public frmSastanciDetalji(int?sastanakId = null, frmSastanci frm1 = null)
 {
     InitializeComponent();
     _id  = sastanakId;
     frm2 = frm1;
     this.AutoValidate = AutoValidate.Disable;
 }
        private void btnRezervacije_Click(object sender, EventArgs e)
        {
            frmSastanci frm = new frmSastanci();

            frm.TopLevel        = false;
            frm.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
            pnlMjesto.Controls.Clear();
            pnlMjesto.Controls.Add(frm);
            frm.Dock = DockStyle.Fill;
            frm.Show();
        }
        private async void BtnSacuvaj_Click(object sender, EventArgs e)
        {
            bool odrzano = false;

            if (radioButtonDA.Checked)
            {
                odrzano = true;
            }
            else
            {
                odrzano = false;
            }

            bool odobreno;

            if (checkBox1.Checked)
            {
                odobreno = true;
            }
            else
            {
                odobreno = false;
            }



            if (this.ValidateChildren())
            {
                int.Parse(cmbVrstaUsluge.SelectedValue.ToString());



                var request = new SastanciInsertRequest()
                {
                    ZaposleniciId    = int.Parse(cbZaposlenik.SelectedValue.ToString()),
                    KlijentId        = int.Parse(cbKlijent.SelectedValue.ToString()),
                    DatumSastanka    = dtpDatumSastanka.Value,
                    MjestoOdrzavanja = txtMjestoOdrzavanja.Text,
                    Poruka           = txtPoruka.Text,
                    Odrzan           = odrzano,
                    IsDeleted        = false,
                    Odobreno         = odobreno,
                    VrstaId          = int.Parse(cmbVrstaUsluge.SelectedValue.ToString())
                };

                if (_id.HasValue)
                {
                    await _aPIServiceSastanci.Update <Model.Sastanci>(_id, request);

                    MessageBox.Show(Properties.Resources.MessageBoxForSave);
                    this.Hide();
                    frm2.RefreshData();
                }
                else
                {
                    await _aPIServiceSastanci.Insert <Model.Sastanci>(request);

                    MessageBox.Show(Properties.Resources.MessageBoxForSave);
                    this.Hide();
                    frmSastanci frm = new frmSastanci();
                    frm.Show();


                    if (request.Odobreno == true)
                    {
                        var klijent = await _serviceZaposlenici.GetById <Model.Korisnici>(request.KlijentId);

                        var zaposlenik = await _serviceZaposlenici.GetById <Model.Korisnici>(request.ZaposleniciId);

                        string subject  = "Sastanak";
                        string body     = "Odobren vam je sastanak";
                        string FromMail = "*****@*****.**";

                        string tempKlijent    = klijent.Email;
                        string tempZaposlenik = zaposlenik.Email;

                        MailMessage mail       = new MailMessage();
                        SmtpClient  SmtpServer = new SmtpClient("smtp.gmail.com");
                        mail.From = new MailAddress(FromMail);
                        mail.To.Add(tempKlijent);
                        mail.To.Add(tempZaposlenik);
                        mail.Subject    = subject;
                        mail.Body       = body;
                        SmtpServer.Port = 587;
                        SmtpServer.UseDefaultCredentials = false;
                        SmtpServer.Credentials           = new System.Net.NetworkCredential("*****@*****.**", "Rstest123456");
                        SmtpServer.EnableSsl             = true;
                        SmtpServer.Send(mail);
                    }
                }
            }
        }