Exemplo n.º 1
0
        public int Update(BasicInfoModel model)
        {
            string sql = "update BasicInfo set Name=@name,Gender=@gender,Age=@age,Email=@email  where PersonID=@id";

            SqlParameter[] p = new SqlParameter[] {
                new SqlParameter("@name", SqlDbType.NVarChar, 100)
                {
                    Value = model.Name
                },
                new SqlParameter("@gender", SqlDbType.NChar, 1)
                {
                    Value = model.Gender
                },
                new SqlParameter("@age", SqlDbType.Int)
                {
                    Value = model.Age
                },
                new SqlParameter("@email", SqlDbType.NVarChar, 50)
                {
                    Value = model.Email
                },
                new SqlParameter("@id", SqlDbType.Int)
                {
                    Value = model.PersonID
                }
            };
            return(SqlHelper.ExecuteNoneQuery(sql, CommandType.Text, p));
        }
Exemplo n.º 2
0
        public BasicInfoModel SelectModelById(int id)
        {
            BasicInfoModel model = new BasicInfoModel();
            string         sql   = "select * from BasicInfo where PersonID=@id";
            SqlParameter   p     = new SqlParameter("@id", SqlDbType.Int)
            {
                Value = id
            };

            using (SqlDataReader reader = SqlHelper.ExecuteReader(sql, CommandType.Text, p))
            {
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        //PersonID, Name, Gender, Age, Email
                        model          = new BasicInfoModel();
                        model.PersonID = reader.GetInt32(0);
                        model.Name     = reader.GetString(1);
                        model.Gender   = reader.GetString(2);
                        model.Age      = reader.GetInt32(3);
                        model.Email    = reader.GetString(4);
                    }
                }
            }
            return(model);
        }
Exemplo n.º 3
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            BasicInfoBll         bll   = new BasicInfoBll();
            int                  id    = int.Parse(context.Request["personId"]);
            BasicInfoModel       model = bll.SelectModelById(id);
            JavaScriptSerializer jss   = new JavaScriptSerializer();

            if (model != null)
            {
                string jsonData = jss.Serialize(model);
                context.Response.Write(jsonData);
            }
        }
Exemplo n.º 4
0
        public List <BasicInfoModel> SelectByRow(int pagesize, int pageindex, out int pagecount, out int recordcount)
        {
            // @pagesize int,
            //@pageindex int,
            //@pagecount int output,
            //@recordcount int output
            List <BasicInfoModel> ls = new List <BasicInfoModel>();
            string sql = "usp_basicInfoByRow";

            SqlParameter[] p = new SqlParameter[] {
                new SqlParameter("@pagesize", SqlDbType.Int)
                {
                    Value = pagesize
                },
                new SqlParameter("@pageindex", SqlDbType.Int)
                {
                    Value = pageindex
                },
                new SqlParameter("@pagecount", SqlDbType.Int)
                {
                    Direction = ParameterDirection.Output
                },
                new SqlParameter("@recordcount", SqlDbType.Int)
                {
                    Direction = ParameterDirection.Output
                },
            };
            using (SqlDataReader reader = SqlHelper.ExecuteReader(sql, CommandType.StoredProcedure, p))
            {
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        //PersonID, Name, Gender, Age, Email
                        BasicInfoModel model = new BasicInfoModel();
                        model.PersonID = reader.GetInt32(0);
                        model.Name     = reader.GetString(1);
                        model.Gender   = reader.GetString(2);
                        model.Age      = reader.GetInt32(3);
                        model.Email    = reader.GetString(4);
                        ls.Add(model);
                    }
                }
            }
            pagecount   = (int)p[2].Value;
            recordcount = (int)p[3].Value;
            return(ls);
        }
Exemplo n.º 5
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            BasicInfoBll   bll   = new BasicInfoBll();
            BasicInfoModel model = new BasicInfoModel();

            model.Name   = context.Request["name"];
            model.Gender = context.Request["gender"];
            model.Age    = int.Parse(context.Request["age"]);
            model.Email  = context.Request["email"];
            if (bll.Insert(model))
            {
                context.Response.Write("ok");
            }
            else
            {
                context.Response.Write("notok");
            }
        }
Exemplo n.º 6
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            BasicInfoModel model = new BasicInfoModel();

            model.Name     = context.Request["txtName"];
            model.Age      = int.Parse(context.Request["txtAge"]);
            model.Gender   = context.Request["gender"];
            model.Email    = context.Request["txtEmail"];
            model.PersonID = int.Parse(context.Request["hidId"]);
            BasicInfoBll bll = new BasicInfoBll();

            if (bll.Update(model))
            {
                context.Response.Redirect("ok");
            }
            else
            {
                context.Response.Write("notok");
            }
        }
Exemplo n.º 7
0
        public int Insert(BasicInfoModel model)
        {
            string sql = "insert into BasicInfo values(@name,@gender,@age,@email)";

            SqlParameter[] p = new SqlParameter[] {
                new SqlParameter("@name", SqlDbType.NVarChar, 100)
                {
                    Value = model.Name
                },
                new SqlParameter("@gender", SqlDbType.NChar, 1)
                {
                    Value = model.Gender
                },
                new SqlParameter("@age", SqlDbType.Int)
                {
                    Value = model.Age
                },
                new SqlParameter("@email", SqlDbType.NVarChar, 50)
                {
                    Value = model.Email
                }
            };
            return(SqlHelper.ExecuteNoneQuery(sql, CommandType.Text, p));
        }
Exemplo n.º 8
0
 public IActionResult Index(BasicInfoModel model)
 {
     return(View("Display", model));
 }
Exemplo n.º 9
0
 public bool Update(BasicInfoModel model)
 {
     return(dal.Update(model) > 0);
 }
Exemplo n.º 10
0
 public bool Insert(BasicInfoModel model)
 {
     return(dal.Insert(model) > 0);
 }