public void Delete(object sender, EventArgs e) { if (this.UltraGridUstanove.ActiveRow != null) { int id = Convert.ToInt32(this.UltraGridUstanove.ActiveRow.Cells["ID"].Value); if (MessageBox.Show(string.Format("Obrisati ustanovu '{0}-{1}'?", id, this.UltraGridUstanove.ActiveRow.Cells["Naziv"].Value), "Brisanje ustanove", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { BusinessLogic.Ustanove ustanove = new BusinessLogic.Ustanove(); ustanove.Delete(id); if (ustanove.IsValid) { ustanove.Persist(); LoadGridUstanove(); } else { ustanove.DisplayValidationMessages(); } } } }
private bool SaveData() { this.lblValidationMessages.ResetText(); BusinessLogic.Ustanove ustanove = new BusinessLogic.Ustanove(); if (TextBoxLogotip.Text == TextBoxLogotip.Tag.ToString()) { TextBoxLogotip.Text = string.Empty; } byte?model = null; if (rbrPrva.Checked) { model = 1; } else if (rbrDruga.Checked) { model = 2; } else if (rbrTreci.Checked) { model = 3; } else { MessageBox.Show("Odaberite po kojem modelu će se raditi!!!"); return(false); } if (this.FormEditMode == Enums.FormEditMode.Insert || this.FormEditMode == Enums.FormEditMode.Copy) { ustanove.Add(this.TextBoxNaziv.Text.Trim(), this.TextBoxSkraceniNaziv.Text.Trim(), this.TextBoxOIB.Text.Trim(), this.TextBoxUlicaKucniBroj.Text.Trim(), (this.ComboBoxPostanskiBroj.Value != null ? this.ComboBoxPostanskiBroj.Value.ToString() : null), this.TextBoxKontaktPodaci.Text.Trim(), this.TextBoxLogotip.Text.Trim(), cbkMaticnaPodrucnaUstanova.Checked, (int?)ucbUstanoveKorisnik.Value, (string)uteUstanoveSifraUstanove.Value.ToString(), txtModel.Text.Trim(), txtPozivNaBroj01.Text.Trim(), txtModel2.Text.Trim(), (byte)model, txtModel3.Text.Trim(), utePozivNaBro03.Text.Trim(), cbkPDVNapomena.Checked, cbkOtvorneStavke.Checked); } else if (this.FormEditMode == Enums.FormEditMode.Update) { ustanove.Update(this.ID.Value, this.TextBoxNaziv.Text.Trim(), this.TextBoxSkraceniNaziv.Text.Trim(), this.TextBoxOIB.Text.Trim(), this.TextBoxUlicaKucniBroj.Text.Trim(), (this.ComboBoxPostanskiBroj.Value != null ? this.ComboBoxPostanskiBroj.Value.ToString() : null), this.TextBoxKontaktPodaci.Text.Trim(), this.TextBoxLogotip.Text.Trim(), cbkMaticnaPodrucnaUstanova.Checked, (int?)ucbUstanoveKorisnik.Value, (string)uteUstanoveSifraUstanove.Value.ToString(), txtModel.Text.Trim(), txtPozivNaBroj01.Text.Trim(), txtModel2.Text.Trim(), (byte)model, txtModel3.Text.Trim(), utePozivNaBro03.Text.Trim(), cbkPDVNapomena.Checked, cbkOtvorneStavke.Checked); } if (ustanove.IsValid) { return(ustanove.Persist()); } else { ustanove.DisplayValidationMessages(this); } return(false); }