} = false; // Flag to indicate is new or exists public DetailExistence(ProductExistenceDTO productExistence, int productId, string productName = "") { InitializeComponent(); ProductExistence = productExistence; ProductId = productId; if (!string.IsNullOrEmpty(productName)) { Text = productName; } }
private async void m_btnEdit_Click(object sender, EventArgs e) { try { if (m_dgvExistencesList.SelectedRows.Count == 0) { MessageBox.Show("No hay un inventario seleccionado", "AVISO"); return; } int storeId = Convert.ToInt32(m_dgvExistencesList.SelectedRows[0].Cells["StoreId"].Value); int productId = Convert.ToInt32(m_dgvExistencesList.SelectedRows[0].Cells["ProductId"].Value); Response response = await APIUtilities.Get("services/existences/" + storeId + "/" + productId); if (response != null) { if (response.Success) { ProductExistenceDTO productExistence = (ProductExistenceDTO)JsonConvert.DeserializeObject(response.Component.ToString(), (typeof(ProductExistenceDTO))); DetailExistence detailExistence = new DetailExistence(productExistence, productId); if (detailExistence.ShowDialog() == DialogResult.OK) { DataRow productRow = m_dtExistences.Rows.Find(new object[] { storeId, productId }); productRow["StoreId"] = detailExistence.ProductExistence.StoreId; productRow["StoreName"] = detailExistence.ProductExistence.StoreName; productRow["ProductId"] = detailExistence.ProductExistence.ProductId; productRow["ProductName"] = detailExistence.ProductExistence.ProductName; productRow["TotalInShelf"] = detailExistence.ProductExistence.TotalInShelf; productRow["TotalInVault"] = detailExistence.ProductExistence.TotalInVault; detailExistence.Dispose(); } } else { MessageBox.Show(response.ErrorMessage, "ERROR"); } } } catch (Exception ex) { MessageBox.Show(ex.Message, "ERROR DE SISTEMA"); } }