private void btnNapravi_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) // KREIRANJE NOVOG IDENTA { try { using (var kreirajArtikal = new InterakcijaArtikal()) { kreirajArtikal.BringToFront(); kreirajArtikal.Activate(); var result = kreirajArtikal.ShowDialog(); if (result == DialogResult.OK) { ucitajTabelu(); } } } catch (DbUpdateException ex) { if (ex.InnerException != null) { if (ex.InnerException.ToString().Contains("The DELETE statement conflicted with the REFERENCE constraint")) { MessageBox.Show("Došlo je do greške prilikom brisanja. \nNije moguće obrsati elemnt koji se već koristi u drugoj tabeli.", "Greška", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { MainForm.logger.Error("Naziv klase: " + this.GetType().Name + "\n Funkcija: " + System.Reflection.MethodBase.GetCurrentMethod().Name + "\n\"" + ex.InnerException.ToString().Trim().Substring(0, Math.Min(ex.InnerException.ToString().Trim().Length, 350)) + "\""); } } } catch (Exception ex) { MainForm.logger.Error("Naziv klase: " + this.GetType().Name + "\n Funkcija: " + System.Reflection.MethodBase.GetCurrentMethod().Name + "\n\"" + ex.Message.ToString().Trim().Substring(0, Math.Min(ex.Message.ToString().Trim().Length, 350)) + "\""); } }
private void izmeniIdent() //FUNCKIJA IZMENI IDENT { try { if (gridView.SelectedRowsCount > 0 && gridView.GetFocusedRowCellValue("Artikal_ID") != null) { var Artikal_ID = gridView.GetFocusedRowCellValue("Artikal_ID"); var Aktivan = gridView.GetFocusedRowCellValue("Aktivan"); var Artikal = gridView.GetFocusedRowCellValue("Artikal"); var Usluga = gridView.GetFocusedRowCellValue("Usluga"); var Sifra = gridView.GetFocusedRowCellValue("Sifra"); var Naziv = gridView.GetFocusedRowCellValue("Naziv"); var Opis = gridView.GetFocusedRowCellValue("Opis"); var Cena = gridView.GetFocusedRowCellValue("Cena"); var JM_ID = gridView.GetFocusedRowCellValue("JM_ID"); var JM = gridView.GetFocusedRowCellValue("JM_Kod"); var PS_ID = gridView.GetFocusedRowCellValue("PS_ID"); var PoreskaStopa = gridView.GetFocusedRowCellValue("PS_Naziv"); Artikal art = new Artikal() { Artikal_ID = Convert.ToInt32(gridView.GetFocusedRowCellValue("Artikal_ID")), Aktivan = gridView.GetFocusedRowCellValue("Aktivan").ToString(), Vrsta = gridView.GetFocusedRowCellValue("Artikal").ToString(), Sifra = gridView.GetFocusedRowCellValue("Sifra").ToString(), Naziv = gridView.GetFocusedRowCellValue("Naziv").ToString(), Opis = gridView.GetFocusedRowCellValue("Opis").ToString(), Cena = Convert.ToDecimal(gridView.GetFocusedRowCellValue("Cena")), JM_ID = Convert.ToInt32(gridView.GetFocusedRowCellValue("JM_ID")), PS_ID = Convert.ToInt32(gridView.GetFocusedRowCellValue("PS_ID")) }; using (var izmeniArtikal = new InterakcijaArtikal(art)) { izmeniArtikal.BringToFront(); izmeniArtikal.Activate(); var result = izmeniArtikal.ShowDialog(); if (result == DialogResult.OK) { ucitajTabelu(); } } } else { MessageBox.Show("Morate prvo da izaberete ident iz tabele!", "Upozorenje", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (DbUpdateException ex) { if (ex.InnerException != null) { if (ex.InnerException.ToString().Contains("The DELETE statement conflicted with the REFERENCE constraint")) { MessageBox.Show("Došlo je do greške prilikom brisanja. \nNije moguće obrsati elemnt koji se već koristi u drugoj tabeli.", "Greška", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { MainForm.logger.Error("Naziv klase: " + this.GetType().Name + "\n Funkcija: " + System.Reflection.MethodBase.GetCurrentMethod().Name + "\n\"" + ex.InnerException.ToString().Trim().Substring(0, Math.Min(ex.InnerException.ToString().Trim().Length, 350)) + "\""); } } } catch (Exception ex) { MainForm.logger.Error("Naziv klase: " + this.GetType().Name + "\n Funkcija: " + System.Reflection.MethodBase.GetCurrentMethod().Name + "\n\"" + ex.Message.ToString().Trim().Substring(0, Math.Min(ex.Message.ToString().Trim().Length, 350)) + "\""); } }