コード例 #1
0
 public frmUgovoriDetalji(int?ugovorId = null, frmUgovori frm1 = null)
 {
     InitializeComponent();
     _id  = ugovorId;
     frm2 = frm1;
     this.AutoValidate = AutoValidate.Disable;
 }
コード例 #2
0
        private async void BtnSacuvaj_Click(object sender, EventArgs e)
        {
            bool zavrsen = false;

            if (rbZavrsenDa.Checked)
            {
                zavrsen = true;
            }
            else
            {
                zavrsen = false;
            }

            DateTime?datumRaskida = null;


            if (this.ValidateChildren())
            {
                var request = new UgovoriInsertRequest()
                {
                    ZaposleniciId     = int.Parse(cbZaposlenik.SelectedValue.ToString()),
                    Naslov            = txtNaslov.Text,
                    DatumPotpisivanja = dtpDatumPotpisivanja.Value,
                    DatumRaskida      = datumRaskida,
                    Napomena          = txtNapomena.Text,
                    Zavrsen           = zavrsen,
                    IsDeleted         = false
                };

                if (_id.HasValue)
                {
                    var entity1 = await _aPIServiceUgovori.GetById <Model.Ugovori>(_id);

                    request.DatumRaskida = entity1.DatumRaskida;
                    await _aPIServiceUgovori.Update <Model.Ugovori>(_id, request);

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

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