예제 #1
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            if (dgvProducts.SelectedRows.Count == 0)
            {
                MessageBox.Show("Selecione um produto para editar");
            }
            else
            {
                Product product = new Product();
                int     row     = dgvProducts.CurrentRow.Index;

                product.Id               = Convert.ToInt32(dgvProducts["id", row].Value);
                product.Barcode          = dgvProducts["barcode", row].Value.ToString();
                product.Description      = dgvProducts["product_description", row].Value.ToString();
                product.UnitType         = new UnitType();
                product.UnitType.Id      = Convert.ToInt32(dgvProducts["unit_type", row].Value);
                product.MinimumQuantity  = Convert.ToInt32(dgvProducts["minimum_quantity", row].Value);
                product.MaximumQuantity  = Convert.ToInt32(dgvProducts["maximum_quantity", row].Value);
                product.CurrentQuantity  = Convert.ToInt32(dgvProducts["current_quantity", row].Value);
                product.UnitCost         = Convert.ToDouble(dgvProducts["unit_cost", row].Value);
                product.PercentageProfit = Convert.ToDouble(dgvProducts["percentage_profit", row].Value);
                product.SalePrice        = Convert.ToDouble(dgvProducts["sale_price", row].Value);
                product.Active           = Convert.ToBoolean(dgvProducts["active", row].Value);

                FrmProduct   frmProduct = new FrmProduct(TypeAction.Update, product);
                DialogResult result     = frmProduct.ShowDialog();
                if (result == DialogResult.OK)
                {
                    LoadProducts();
                }
            }
        }
예제 #2
0
        private void btnNew_Click(object sender, EventArgs e)
        {
            FrmProduct frmProduct = new FrmProduct(TypeAction.Create, null);

            frmProduct.ShowDialog();
        }