public bool agregarconsumibleG(CONSUMIBLE_G nuevo) { try { modelo.CONSUMIBLE_G.Add(nuevo); return(modelo.SaveChanges() > 0); } catch (Exception) { return(false); } }
protected void btnconfirmarG_Click(object sender, EventArgs e) { int id = Convert.ToInt32(lbcid.Text); string nombre = txtccn.Text; int cantidada = Convert.ToInt32(txtccc.Text); string medida = txtccd.Text; if (txtccd2.Text.Equals("") || txtccc2.Text.Equals("")) { lbconsumible.Text = "rellene los campos"; mc1.Show(); } else { string comentario = txtccd2.Text; int cantidadn = Convert.ToInt32(txtccc2.Text); DateTime fecha = DateTime.Now; int s = cantidada - cantidadn; if (cantidadn == 0) { lbconsumible.Text = "un gasto debe ser mallor a 0"; mc1.Show(); } else { if (s < 0) { lbconsumible.Text = "no se cuenta con tanto consumible"; mc1.Show(); } else { CONSUMIBLE nuevo = new CONSUMIBLE { ID_CONSUMIBLE = id, NOMBRE = nombre, CANTIDAD = s, DETALLE = medida }; if (con.Actualizarconsumible(nuevo)) { CONSUMIBLE_G nuevog = new CONSUMIBLE_G { ID_CONSUMIBLE = id, FECHA = fecha, DETALLE = comentario, CANTIDAD_SC = cantidadn }; if (con.agregarconsumibleG(nuevog)) { lbconsumible.Text = "gasto realizado"; mc1.Show(); lbid.Text = ""; txtccn.Visible = false; txtccn.Text = ""; txtccc.Text = ""; txtccd.Visible = false; txtccd.Enabled = true; txtccd.Text = ""; txtccd2.Visible = false; txtccd2.Text = ""; txtccc2.Visible = false; txtccc2.Text = ""; btnconfirmarG.Visible = false; gvconsumible.Visible = true; gvconsumible.DataBind(); } } } } } }