Пример #1
0
        public string Insertar(classNac mt)
        {
            SqlCommand cmd = new SqlCommand("spo_InsertarNacionalidades", conn);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@Id", mt.Id);
            cmd.Parameters.AddWithValue("@Descripcion", mt.Descripcion);
            cmd.Parameters.AddWithValue("@fechaReg", mt.fechaReg);
            cmd.Parameters.AddWithValue("@Usr", mt.Usr);
            cmd.Parameters.AddWithValue("@accion", 1);
            try
            {
                if (conn.State == ConnectionState.Closed)
                {
                    conn.Open();
                }

                cmd.ExecuteNonQuery();
            }
            catch (Exception)
            {
                return("Se ha producido un error...");
            }
            finally
            {
                if (conn.State == ConnectionState.Open)
                {
                    conn.Close();
                }
            }

            return("Operacion realizada exitosamente...");
        }
Пример #2
0
        protected void btnGuardar_Click(object sender, EventArgs e)
        {
            if (txtDescripcion.Text.Trim().Length == 0)
            {
                //Msg.Text = "Datos incompletos...";
                return;
            }

            classNac mt = new classNac();

            mt.Id          = txtId.Text.Trim().Length == 0 ? 0 : Convert.ToInt32(txtId.Text);
            mt.Descripcion = txtDescripcion.Text;

            mt.fechaReg = DateTime.Now;
            mt.Usr      = "******";
            string result = Insertar(mt);

            //Msg.Text = result;
            fillGV();
            txtId.Text          = "";
            txtDescripcion.Text = "";
            txtDescripcion.Focus();
        }