public void Insert(PropertyInterface myProperty) { this.myProperty = myProperty; InputForma pom = new InputForma(myProperty, StateEnum.Create, UserEmail, UserID); pom.ShowDialog(); pom.Close(); }
public void Update(PropertyInterface myProperty, string ID, Bunifu.Framework.UI.BunifuCustomDataGrid dgv) { //Pretraga SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.GetConnectionString(), CommandType.Text, myProperty.GetSelectQueryZaJedanItem(ID)); DataTable dt = new DataTable(); dt.Load(reader); reader.Close(); dgv.DataSource = dt; var type = myProperty.GetType(); var properties = type.GetProperties(); PropertyInterface pom = myProperty; int i = 0; try { foreach (DataGridViewCell cell in dgv.Rows[0].Cells) { String value = cell.Value.ToString(); PropertyInfo property = properties.Where(x => dgv.Columns[i].HeaderText == x.GetCustomAttribute <DisplayNameAttribute>().DisplayName).FirstOrDefault(); property.SetValue(myProperty, Convert.ChangeType(value, property.PropertyType)); i++; } } catch { } InputForma inputForma = null; if (DetaljiUpdate != "detalji") { inputForma = new InputForma(myProperty, StateEnum.Update, UserEmail, UserID); } else { inputForma = new InputForma("detalji", myProperty, StateEnum.Update, UserEmail, UserID); } inputForma.ShowDialog(); if (inputForma.DialogResult == DialogResult.Cancel) { return; } }