//Funkcija za popunjavanje kontrole u Input formi private void PopunjavanjeKontrola(PropertyInfo item) { if (item.GetCustomAttributes <BrowsableAttribute>().Count() > 0) { //f-ja koja provjerava da li ima BrowsableAttribute ako ima da se ne prikazuje na input formi return; } //Dodavanje kontrole za datum if (item.PropertyType.Name == "DateTime") { InputDateControl uc = new InputDateControl(); uc.Name = item.Name; uc.SetLabel(item.GetCustomAttributes <DisplayNameAttribute>().FirstOrDefault().DisplayName); if (state == StateEnum.Update) { try { uc.SetValueInDateBox(item.GetValue(myInterface).ToString()); } catch { } } //provjera da li smo kliknuli na detalje ako jesmo da polje bude samo read only if (Detalji == "detalji") { uc.ReadOnly(); } flowPanel.Controls.Add(uc); } //Dodavanje kontrole za Lookup else if (item.GetCustomAttributes <Attributes.ForeignKeyAttribute>() != null && item.Name.Contains("ID")) { PropertyInterface foreignKeyInterface = Assembly.GetExecutingAssembly(). CreateInstance(item.GetCustomAttribute <ForeignKeyAttribute>().ClassName) as PropertyInterface; LookUpControl uc = new LookUpControl(foreignKeyInterface, userEmail, Id); uc.Name = item.Name; uc.SetLabel(item.GetCustomAttributes <DisplayNameAttribute>().FirstOrDefault().DisplayName); if (uc.GetLabelValue() == "Radnik ID") { uc.SetValueTextBox(Id, userEmail); } //provjera da li smo kliknuli na detalje ako jesmo da polje bude samo read only if (Detalji == "detalji") { uc.ReadOnly(); } if (state == StateEnum.Update) { try { string broj = item.GetValue(myInterface).ToString(); string red = ""; SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.GetConnectionString(), CommandType.Text, foreignKeyInterface.GetSelectQueryZaJedanItem(broj)); DataTable dt = new DataTable(); dt.Load(reader); if (uc.GetLabelValue() == "Radnik ID") { PropertyOsoba pom = new PropertyOsoba(); broj = dt.Rows[0][1].ToString(); reader = SqlHelper.ExecuteReader(SqlHelper.GetConnectionString(), CommandType.Text, pom.GetSelectQueryZaJedanItem(broj)); dt = new DataTable(); dt.Load(reader); } //treba dodati i za ostale property-e sta treba da se prikaze u lookup polju if (myInterface.GetType() == typeof(PropertyKlijent)) { red = dt.Rows[0].ItemArray[1].ToString() + " " + dt.Rows[0].ItemArray[2].ToString(); } else if (myInterface.GetType() == typeof(PropertyFaktura) && item.Name == "KlijentID") { DataTable dtpom = new DataTable(); bool prop = true; foreach (PropertyInfo itemPom in foreignKeyInterface.GetType().GetProperties()) { //Izbacivanje prikaza primarnog kljuca if (prop == false) { if (itemPom.Name.Contains("ID")) { string klasa = itemPom.GetCustomAttributes <ForeignKeyAttribute>().FirstOrDefault().ClassName; foreignKeyInterface = Assembly.GetExecutingAssembly(). CreateInstance(klasa) as PropertyInterface; reader = SqlHelper.ExecuteReader(SqlHelper.GetConnectionString(), CommandType.Text, foreignKeyInterface.GetLookupQuery(dt.Rows[0].ItemArray[1].ToString())); dtpom.Load(reader); } } prop = false; } red = dtpom.Rows[0].ItemArray[0].ToString(); } else if (uc.GetLabelValue() == "Model ID") { PropertyProizvodjac pom = new PropertyProizvodjac(); broj = dt.Rows[0][2].ToString(); red = dt.Rows[0].ItemArray[1].ToString(); reader = SqlHelper.ExecuteReader(SqlHelper.GetConnectionString(), CommandType.Text, pom.GetSelectQueryZaJedanItem(broj)); dt = new DataTable(); dt.Load(reader); red += " " + dt.Rows[0].ItemArray[1].ToString(); } else if (myInterface.GetType() == typeof(PropertyCijena) && item.Name == "VoziloID") { DataTable dtpom = new DataTable(); bool prop = true; foreach (PropertyInfo itemPom in foreignKeyInterface.GetType().GetProperties()) { //Izbacivanje prikaza primarnog kljuca if (prop == false) { if (itemPom.Name.Contains("ID")) { string klasa = itemPom.GetCustomAttributes <ForeignKeyAttribute>().FirstOrDefault().ClassName; foreignKeyInterface = Assembly.GetExecutingAssembly(). CreateInstance(klasa) as PropertyInterface; reader = SqlHelper.ExecuteReader(SqlHelper.GetConnectionString(), CommandType.Text, foreignKeyInterface.GetLookupQuery(dt.Rows[0].ItemArray[1].ToString())); dtpom.Load(reader); reader.Close(); red = dtpom.Rows[0].ItemArray[0].ToString(); bool prop1 = true; foreach (PropertyInfo itemPom1 in foreignKeyInterface.GetType().GetProperties()) { //Izbacivanje prikaza primarnog kljuca if (prop1 == false) { if (itemPom1.Name.Contains("ID")) { string klasa1 = itemPom1.GetCustomAttributes <ForeignKeyAttribute>().FirstOrDefault().ClassName; foreignKeyInterface = Assembly.GetExecutingAssembly(). CreateInstance(klasa1) as PropertyInterface; reader = SqlHelper.ExecuteReader(SqlHelper.GetConnectionString(), CommandType.Text, foreignKeyInterface.GetLookupQuery(dtpom.Rows[0].ItemArray[1].ToString())); dtpom = new DataTable(); dtpom.Load(reader); red += " " + dtpom.Rows[0].ItemArray[0].ToString(); break; } } prop1 = false; } break; } } prop = false; } } else { red = dt.Rows[0].ItemArray[1].ToString(); try { red += " " + dt.Rows[0].ItemArray[2].ToString(); } catch { } } reader.Close(); uc.SetValueTextBox(item.GetValue(myInterface).ToString(), red); } catch { } } flowPanel.Controls.Add(uc); } //Dodavanje kontrole za 2 radio dugmica else if (item.GetCustomAttribute <TwoRadioButtonsAttribute>() != null) { TwoRadioButtonsControl uc = new TwoRadioButtonsControl(); uc.Name = item.Name; uc.SetLabel(item.GetCustomAttributes <DisplayNameAttribute>().FirstOrDefault().DisplayName); uc.SetRadioButtons(item.GetCustomAttribute <TwoRadioButtonsAttribute>().Value1, item.GetCustomAttribute <TwoRadioButtonsAttribute>().Value2); //provjera da li smo kliknuli na detalje ako jesmo da polje bude samo read only if (Detalji == "detalji") { uc.ReadOnly(); } if (state == StateEnum.Update) { try { uc.SetChecked(item.GetValue(myInterface).ToString()); } catch { } } flowPanel.Controls.Add(uc); } else if (item.GetCustomAttribute <ComboBoxAttribute>() != null) { ComboBoxControl uc = new ComboBoxControl(); uc.Name = item.Name; uc.SetLabel(item.GetCustomAttributes <DisplayNameAttribute>().FirstOrDefault().DisplayName); uc.FillComboBox(item.GetCustomAttribute <ComboBoxAttribute>().vrijednosti); if (Detalji == "detalji") { uc.ReadOnly(); } if (state == StateEnum.Update) { try { uc.SetComboBox(item.GetValue(myInterface).ToString()); } catch { } } flowPanel.Controls.Add(uc); } //Dodavanje kontrole za TextBox else { InputControl uc = new InputControl(); uc.Name = item.Name; if (uc.Name == "Napomena") { uc.SetValueInTextBox(" "); } uc.SetLabel(item.GetCustomAttributes <DisplayNameAttribute>().FirstOrDefault().DisplayName); if (Detalji == "detalji") { uc.ReadOnly(); } if (state == StateEnum.Update) { try { uc.SetValueInTextBox(item.GetValue(myInterface).ToString()); } catch { } } flowPanel.Controls.Add(uc); } }