private async void btn_Inventar_Click(object sender, EventArgs e) { if (tb_Inventar.Text.Length > 2 && !string.IsNullOrEmpty(tb_Inventar.Text)) { InventarModel request = new InventarModel { Naziv = tb_Inventar.Text, SobaId = _SobaId, InventarSobaId = 0 }; await _InventarService.Insert <InventarInsertRequest>(request); InventarSearchRequest request2 = new InventarSearchRequest { SobaId = _SobaId }; var lista = await _InventarService.Get <List <InventarModel> >(request2); dgv_Inventar.DataSource = lista; } else { lbl_inventarError.Visible = true; lbl_inventarError.Text = "Naziv mora biti najmanje 2 karaktera!"; } }
private async void dgv_Inventar_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (dgv_Inventar.CurrentCell.ColumnIndex.Equals(2) && e.RowIndex != -1) { if (dgv_Inventar.CurrentCell != null) { var id = int.Parse(dgv_Inventar[e.ColumnIndex + 1, e.RowIndex].Value.ToString()); await _InventarService.Delete <InventarModel>(id); InventarSearchRequest request2 = new InventarSearchRequest { SobaId = _SobaId }; var lista = await _InventarService.Get <List <InventarModel> >(request2); dgv_Inventar.DataSource = lista; } } }
private async void frm_UrediSobe_Load(object sender, EventArgs e) { var result = await _SobaService.GetById <SobaModel>(_SobaId); tb_BrojKreveta.Text = result.BrojKreveta.ToString(); tb_Cijena.Text = result.Cijena.ToString(); tb_Opis.Text = result.Opis; tb_Velicina.Text = result.VelicinaSobe.ToString(); tb_VrstaSmjestaja.Text = result.VrstaSmjestaja; cb_Kupaonica.Checked = result.VlastitaKupoanica; InventarSearchRequest request = new InventarSearchRequest { SobaId = _SobaId }; var lista = await _InventarService.Get <List <InventarModel> >(request); dgv_Inventar.AutoGenerateColumns = false; dgv_Inventar.DataSource = lista; }