示例#1
0
        public string UPDATEDATA(ListTablaViewModel objUsu)
        {
            SqlConnection con    = null;
            string        result = "";

            try
            {
                con = new SqlConnection(ConfigurationManager.ConnectionStrings["myConnectionString"].ToString());
                SqlCommand cmd = new SqlCommand("sp_Admin", con);
                cmd.CommandType = CommandType.StoredProcedure;
                con.Open();
                cmd.Parameters.AddWithValue("@nombre", objUsu.Nombre);
                cmd.Parameters.AddWithValue("@apellido_paterno", objUsu.Apellido_Paterno);
                cmd.Parameters.AddWithValue("@apellido_materno", objUsu.Apellido_Materno);
                cmd.Parameters.AddWithValue("@edad", objUsu.Edad);
                cmd.Parameters.AddWithValue("@isactve", objUsu.isactive);
                cmd.Parameters.AddWithValue("@userId", objUsu.Id);
                cmd.Parameters.AddWithValue("@Action", "UPDATE");

                result = cmd.ExecuteNonQuery().ToString();

                return(result);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                con.Close();
            }
        }
示例#2
0
 public ActionResult UpdateUser(ListTablaViewModel objUsu)
 {
     if (ModelState.IsValid)
     {
         DataAccessLayout objDB  = new DataAccessLayout();
         string           result = objDB.UPDATEDATA(objUsu);
         TempData["userOBJ"] = result;
         return(RedirectToAction("index"));
     }
     else
     {
         ModelState.AddModelError("", "Error en la Edicion de datos");
         return(View());
     }
 }
示例#3
0
        public List <ListTablaViewModel> GetData()
        {
            SqlConnection             con     = null;
            DataSet                   ds      = null;
            List <ListTablaViewModel> usuList = null;
            ListTablaViewModel        usuObj  = null;

            try
            {
                con = new SqlConnection(ConfigurationManager.ConnectionStrings["myConnectionString"].ToString());

                SqlCommand cmd = new SqlCommand("sp_Admin", con);
                con.Open();
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.AddWithValue("@Action", "READ");


                SqlDataAdapter da = new SqlDataAdapter();
                da.SelectCommand = cmd;
                ds = new DataSet();
                da.Fill(ds);
                usuList = new List <ListTablaViewModel>();
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    usuObj                  = new ListTablaViewModel();
                    usuObj.Id               = Convert.ToInt32(ds.Tables[0].Rows[i]["id"].ToString());
                    usuObj.Nombre           = ds.Tables[0].Rows[i]["nombre"].ToString();
                    usuObj.Apellido_Paterno = ds.Tables[0].Rows[i]["apellido_paterno"].ToString();
                    usuObj.Apellido_Materno = ds.Tables[0].Rows[i]["apellido_materno"].ToString();
                    usuObj.Edad             = ds.Tables[0].Rows[i]["edad"].ToString();
                    usuObj.isactive         = Convert.ToBoolean(ds.Tables[0].Rows[i]["isactve"]);
                    usuList.Add(usuObj);
                }
                return(usuList);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                con.Close();
            }
        }