Exemplo n.º 1
0
 public bool agregarmaterialI(MATERIAL_I nuevo)
 {
     try
     {
         modelo.MATERIAL_I.Add(nuevo);
         return(modelo.SaveChanges() > 0);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Exemplo n.º 2
0
        protected void btnconfirmarmaterial_Click(object sender, EventArgs e)
        {
            if (txtcmc.Text.Equals("") || txtcmv.Text.Equals(""))
            {
                lbmaterial.Text = "rellene campos";
                mm1.Show();
            }
            else
            {
                int      canta = Convert.ToInt32(lbcantidad.Text);
                int      cantn = Convert.ToInt32(txtcmc.Text);
                int      valor = Convert.ToInt32(txtcmv.Text);
                int      s     = canta + cantn;
                DateTime fecha = DateTime.Now;

                if (cantn != 0)
                {
                    MATERIAL nuevo = new MATERIAL
                    {
                        ID_MATERIAL = Convert.ToInt32(lbid.Text),
                        NOMBRE      = txtcmn.Text,
                        TIPO        = txtcmt.Text,
                        MEDIDA      = txtcmm.Text,
                        CANTIDAD    = s
                    };
                    if (con.Actualizarmaterial(nuevo))
                    {
                        MATERIAL_I nuevoi = new MATERIAL_I
                        {
                            ID_MATERIAL = Convert.ToInt32(lbid.Text),
                            FECHA       = fecha,
                            VALOR       = valor,
                            CANTIDAD_IM = cantn
                        };

                        if (con.agregarmaterialI(nuevoi))
                        {
                            lbmaterial.Text = "compra agregada";
                            txtcmn.Visible  = false;
                            txtcmn.Text     = "";
                            txtcmt.Visible  = false;
                            txtcmt.Text     = "";
                            txtcmm.Visible  = false;
                            txtcmm.Text     = "";
                            txtcmc.Visible  = false;
                            txtcmc.Text     = "";
                            txtcmv.Visible  = false;
                            txtcmv.Text     = "";
                            btnconfirmarmaterial.Visible = false;
                            gvmaterial.DataSource        = con.buscarmaterial(txtbuscarm.Text, txtbuscart.Text);
                            gvmaterial.DataBind();
                            gvmaterial.Visible = true;

                            mm1.Show();
                        }
                    }
                }
                else
                {
                    lbmaterial.Text = "la cantidad no puede ser 0";
                    txtcmc.Text     = "";
                    mm1.Show();
                }
            }
        }