Exemplo n.º 1
0
        private async Task ProductSelectionChanged()
        {
            if (m_dgvProductList.SelectedRows.Count == 1)
            {
                int productId = Convert.ToInt32(m_dgvProductList.SelectedRows[0].Cells["ProductId"].Value);

                try
                {
                    Response response = await APIUtilities.Get("services/products/" + productId + "/existences");

                    if (response != null)
                    {
                        if (response.Success)
                        {
                            m_dtExistences            = (DataTable)JsonConvert.DeserializeObject(response.Component.ToString(), (typeof(DataTable)));
                            m_dtExistences.PrimaryKey = new DataColumn[] { m_dtExistences.Columns["StoreId"], m_dtExistences.Columns["ProductId"] };

                            m_dgvExistencesList.DataSource = m_dtExistences;
                        }
                        else
                        {
                            MessageBox.Show(response.ErrorMessage, "ERROR");
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "ERROR DE SISTEMA");
                }
            }
        }
Exemplo n.º 2
0
        private async Task Retrieve()
        {
            try
            {
                Response response = await APIUtilities.Get("services/products");

                if (response != null)
                {
                    if (response.Success)
                    {
                        m_dtProducts            = (DataTable)JsonConvert.DeserializeObject(response.Component.ToString(), (typeof(DataTable)));
                        m_dtProducts.PrimaryKey = new DataColumn[] { m_dtProducts.Columns["ProductId"] };

                        m_dgvProductList.DataSource = m_dtProducts;
                    }
                    else
                    {
                        MessageBox.Show(response.ErrorMessage, "ERROR");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "ERROR DE SISTEMA");
            }
        }
Exemplo n.º 3
0
        private void DetailExistence_Load(object sender, EventArgs e)
        {
            Task.Run(async() =>
            {
                try
                {
                    Response response = await APIUtilities.Get("services/stores");
                    if (response != null)
                    {
                        if (response.Success)
                        {
                            List <Store> stores = (List <Store>)JsonConvert.DeserializeObject(response.Component.ToString(), (typeof(IEnumerable <Store>)));
                            m_cbStores.BeginInvoke(new Action(() =>
                            {
                                stores.Insert(0, new Store {
                                    StoreId = 0, Name = "SELECCIONE"
                                });

                                m_cbStores.DataSource    = stores;
                                m_cbStores.DisplayMember = "name";
                                m_cbStores.ValueMember   = "storeId";

                                if (ProductExistence != null)
                                {
                                    m_cbStores.SelectedValue = ProductExistence.StoreId;
                                }
                            }));
                        }
                        else
                        {
                            MessageBox.Show(response.ErrorMessage, "ERROR");
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "ERROR DE SISTEMA");
                }
            });

            if (ProductExistence != null)
            {
                m_tbTotalInShelf.Text = ProductExistence.TotalInShelf.ToString();
                m_tbTotalInVault.Text = ProductExistence.TotalInVault.ToString();
            }
            else
            {
                IsNew = true;
            }

            m_cbStores.Focus();
        }
Exemplo n.º 4
0
        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");
            }
        }
Exemplo n.º 5
0
        private async void m_btnEdit_Click(object sender, EventArgs e)
        {
            try
            {
                if (m_dgvProductList.SelectedRows.Count == 0)
                {
                    MessageBox.Show("No hay un producto seleccionado", "AVISO");
                    return;
                }

                int productId = Convert.ToInt32(m_dgvProductList.SelectedRows[0].Cells["ProductId"].Value);

                Response response = await APIUtilities.Get("services/products/" + productId);

                if (response != null)
                {
                    if (response.Success)
                    {
                        Product       product       = (Product)JsonConvert.DeserializeObject(response.Component.ToString(), (typeof(Product)));
                        DetailProduct detailProduct = new DetailProduct(product);

                        if (detailProduct.ShowDialog() == DialogResult.OK)
                        {
                            DataRow productRow = m_dtProducts.Rows.Find(productId);

                            productRow["Code"]        = detailProduct.Product.Code;
                            productRow["Name"]        = detailProduct.Product.Name;
                            productRow["Description"] = detailProduct.Product.Description;
                            productRow["Price"]       = detailProduct.Product.Price;

                            detailProduct.Dispose();
                        }
                    }
                    else
                    {
                        MessageBox.Show(response.ErrorMessage, "ERROR");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "ERROR DE SISTEMA");
            }
        }
Exemplo n.º 6
0
        private async void m_btnEdit_Click(object sender, EventArgs e)
        {
            try
            {
                if (m_dgvStoreList.SelectedRows.Count == 0)
                {
                    MessageBox.Show("No hay una tienda seleccionada", "AVISO");
                    return;
                }

                int StoreId = Convert.ToInt32(m_dgvStoreList.SelectedRows[0].Cells["StoreId"].Value);

                Response response = await APIUtilities.Get("services/stores/" + StoreId);

                if (response != null)
                {
                    if (response.Success)
                    {
                        Store       store       = (Store)JsonConvert.DeserializeObject(response.Component.ToString(), (typeof(Store)));
                        DetailStore detailStore = new DetailStore(store);

                        if (detailStore.ShowDialog() == DialogResult.OK)
                        {
                            DataRow StoreRow = m_dtStores.Rows.Find(StoreId);

                            StoreRow["Name"]    = detailStore.Store.Name;
                            StoreRow["Address"] = detailStore.Store.Address;

                            detailStore.Dispose();
                        }
                    }
                    else
                    {
                        MessageBox.Show(response.ErrorMessage, "ERROR");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "ERROR DE SISTEMA");
            }
        }
Exemplo n.º 7
0
        private async void m_btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                if (m_dgvExistencesList.SelectedRows.Count == 0)
                {
                    MessageBox.Show("No hay un inventario seleccionado", "AVISO");
                    return;
                }

                if (MessageBox.Show("¿Realmente desea eliminar el inventario seleccionado", "PRECAUCIÓN", MessageBoxButtons.YesNoCancel) != DialogResult.Yes)
                {
                    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.Delete("services/existences/" + storeId + "/" + productId);

                if (response != null)
                {
                    if (response.Success)
                    {
                        DataRow productRow = m_dtExistences.Rows.Find(new object[] { storeId, productId });

                        m_dtExistences.Rows.Remove(productRow);
                    }
                    else
                    {
                        MessageBox.Show(response.ErrorMessage, "ERROR");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "ERROR DE SISTEMA");
            }
        }
Exemplo n.º 8
0
        private async void m_btnOK_Click(object sender, EventArgs e)
        {
            // Check for valid data
            if (string.IsNullOrEmpty(m_tbCode.Text))
            {
                MessageBox.Show("Especifique el Código", "AVISO");
                m_tbCode.Focus();
                return;
            }
            if (string.IsNullOrEmpty(m_tbName.Text))
            {
                MessageBox.Show("Especifique el Nombre", "AVISO");
                m_tbName.Focus();
                return;
            }
            if (string.IsNullOrEmpty(m_tbDescription.Text))
            {
                MessageBox.Show("Especifique la Descripción", "AVISO");
                m_tbDescription.Focus();
                return;
            }
            if (string.IsNullOrEmpty(m_tbPrice.Text))
            {
                MessageBox.Show("Especifique el Precio", "AVISO");
                m_tbPrice.Focus();
                return;
            }
            if (!decimal.TryParse(m_tbPrice.Text, out _))
            {
                MessageBox.Show("Verifique que el precio sea un número válido", "AVISO");
                m_tbPrice.Focus();
                return;
            }

            if (Product == null)
            {
                Product = new Product
                {
                    Code        = m_tbCode.Text,
                    Name        = m_tbName.Text,
                    Description = m_tbDescription.Text,
                    Price       = Convert.ToDecimal(m_tbPrice.Text)
                };
            }
            else
            {
                Product.Code        = m_tbCode.Text;
                Product.Name        = m_tbName.Text;
                Product.Description = m_tbDescription.Text;
                Product.Price       = Convert.ToDecimal(m_tbPrice.Text);
            }

            try
            {
                Response response = null;

                if (IsNew)
                {
                    response = await APIUtilities.Post("services/products/", Product);
                }
                else
                {
                    response = await APIUtilities.Put("services/products/" + Product.ProductId, Product);
                }

                if (response != null)
                {
                    if (response.Success)
                    {
                        Product = (Product)JsonConvert.DeserializeObject(response.Component.ToString(), (typeof(Product)));

                        DialogResult = DialogResult.OK;
                        Close();
                    }
                    else
                    {
                        MessageBox.Show(response.ErrorMessage, "AVISO");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "ERROR DE SISTEMA");
            }
        }
Exemplo n.º 9
0
        private async void m_btnOK_Click(object sender, EventArgs e)
        {
            // Check for valid data
            if (string.IsNullOrEmpty(m_tbName.Text))
            {
                MessageBox.Show("Especifique el Nombre", "AVISO");
                m_tbName.Focus();
                return;
            }
            if (string.IsNullOrEmpty(m_tbAddress.Text))
            {
                MessageBox.Show("Especifique la Dirección", "AVISO");
                m_tbAddress.Focus();
                return;
            }

            if (Store == null)
            {
                Store = new Store
                {
                    Name    = m_tbName.Text,
                    Address = m_tbAddress.Text
                };
            }
            else
            {
                Store.Name    = m_tbName.Text;
                Store.Address = m_tbAddress.Text;
            }

            try
            {
                Response response = null;

                if (IsNew)
                {
                    response = await APIUtilities.Post("services/Stores/", Store);
                }
                else
                {
                    response = await APIUtilities.Put("services/Stores/" + Store.StoreId, Store);
                }

                if (response != null)
                {
                    if (response.Success)
                    {
                        Store = (Store)JsonConvert.DeserializeObject(response.Component.ToString(), (typeof(Store)));

                        DialogResult = DialogResult.OK;
                        Close();
                    }
                    else
                    {
                        MessageBox.Show(response.ErrorMessage, "AVISO");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "ERROR DE SISTEMA");
            }
        }
Exemplo n.º 10
0
        private async void m_btnOK_Click(object sender, EventArgs e)
        {
            // Check for valid data
            if (m_cbStores.SelectedIndex == 0)
            {
                MessageBox.Show("Seleccione una tienda", "AVISO");
                m_cbStores.Focus();
                return;
            }
            if (string.IsNullOrEmpty(m_tbTotalInShelf.Text))
            {
                MessageBox.Show("Especifique el total en estante", "AVISO");
                m_tbTotalInShelf.Focus();
                return;
            }
            if (!decimal.TryParse(m_tbTotalInShelf.Text, out _))
            {
                MessageBox.Show("Verifique que el total en estante sea un número válido", "AVISO");
                m_tbTotalInShelf.Focus();
                return;
            }
            if (string.IsNullOrEmpty(m_tbTotalInVault.Text))
            {
                MessageBox.Show("Especifique el total en bodega", "AVISO");
                m_tbTotalInVault.Focus();
                return;
            }
            if (!decimal.TryParse(m_tbTotalInVault.Text, out _))
            {
                MessageBox.Show("Verifique que el total en bodega sea un número válido", "AVISO");
                m_tbTotalInVault.Focus();
                return;
            }

            ProductExistence productExistence = new ProductExistence
            {
                StoreId      = (int)m_cbStores.SelectedValue,
                ProductId    = ProductId,
                TotalInShelf = Convert.ToInt32(m_tbTotalInShelf.Text),
                TotalInVault = Convert.ToInt32(m_tbTotalInVault.Text)
            };

            try
            {
                Response response = null;

                if (IsNew)
                {
                    response = await APIUtilities.Post("services/existences/", productExistence);
                }
                else
                {
                    response = await APIUtilities.Put("services/existences/" + ProductExistence.StoreId + "/" + productExistence.ProductId, productExistence);
                }

                if (response != null)
                {
                    if (response.Success)
                    {
                        ProductExistence = (ProductExistenceDTO)JsonConvert.DeserializeObject(response.Component.ToString(), (typeof(ProductExistenceDTO)));

                        DialogResult = DialogResult.OK;
                        Close();
                    }
                    else
                    {
                        MessageBox.Show(response.ErrorMessage, "AVISO");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "ERROR DE SISTEMA");
            }
        }