Ejemplo n.º 1
0
        private void BtnsaveComp_Click(object sender, EventArgs e)
        {
            if (txtCantComp.Text == "")
            {
                MessageBox.Show("Ingrese la cantidad");
            }
            else
            {
                if (Convert.ToInt32(txtCantComp.Text) < 1)
                {
                    MessageBox.Show("Ingrese un cantidad mayor a 0");
                }
                else
                {
                    purchase.State          = EntityState.Added;
                    purchase.IdProd_CompMod = Convert.ToInt32(txtIdProd_Comp.Text);
                    purchase.Prod_CodeMod   = txtCodProdComp.Text;
                    purchase.Prod_NameMod   = txtNameProdComp.Text;
                    purchase.Comp_DateMod   = Convert.ToDateTime(txtDateComp.Text);
                    purchase.Comp_CantMod   = Convert.ToInt32(txtCantComp.Text);

                    bool valid = new Helps.DataValidation(purchase).Validate();

                    if (valid == true)
                    {
                        string result = purchase.SaveChanges();
                        MessageBox.Show(result);
                        Restart();
                        Close();
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void DelPur_Click(object sender, EventArgs e)
        {
            if (dataPur.SelectedRows.Count > 0)
            {
                DialogResult deluser = MessageBox.Show("Eliminar los datos de la compra " + dataPur.CurrentRow.Cells[3].Value.ToString() + "? ", "Eliminar datos", MessageBoxButtons.YesNo);
                if (deluser == DialogResult.Yes)
                {
                    purchase.State     = EntityState.Deleted;
                    purchase.IdCompMod = Convert.ToInt32(dataPur.CurrentRow.Cells[0].Value);

                    string result = purchase.SaveChanges();
                    MessageBox.Show(result);
                    ListPurchases();
                }
            }
            else
            {
                MessageBox.Show("Select Row");
            }
        }