Beispiel #1
0
        //更新用户要编辑的数据
        public int UpdateData(TblArea ta)
        {
            string sql = "update TblArea set contactName=@name,cellPhone=@phone,email=@email,groupId=@gId where contactId=@id";

            SqlParameter[] pms = new SqlParameter[] {
                new SqlParameter("@name", SqlDbType.NVarChar, 10)
                {
                    Value = ta.ContactName
                },
                new SqlParameter("@phone", SqlDbType.NChar, 50)
                {
                    Value = ta.CellPhone
                },
                new SqlParameter("@email", SqlDbType.NChar, 50)
                {
                    Value = ta.Email
                },
                new SqlParameter("@gId", SqlDbType.Int)
                {
                    Value = ta.GroupId.GroupId
                },
                new SqlParameter("@id", SqlDbType.Int)
                {
                    Value = ta.ContactId
                }
            };
            return(SqlHelper.ExecuteNonquery(sql, CommandType.Text, pms));
        }
Beispiel #2
0
        //根据id查询编辑的内容
        public TblArea GetDataById(int id)
        {
            TblArea      area = new TblArea();
            string       sql  = "select * from TblArea where contactId=@id";
            SqlParameter pms  = new SqlParameter("@id", SqlDbType.Int)
            {
                Value = id
            };

            using (SqlDataReader reader = SqlHelper.ExecuteReader(sql, CommandType.Text, pms))
            {
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        area.ContactId       = reader.GetInt32(0);
                        area.ContactName     = reader.GetString(1);
                        area.CellPhone       = reader.GetString(2);
                        area.Email           = reader.GetString(3);
                        area.GroupId         = new ContactGroup();
                        area.GroupId.GroupId = reader.GetInt32(4);
                    }
                }
            }
            return(area);
        }
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            //将修改的数据进行保存
            //首先根据键值对获要更新的数据
            TblArea tbl = new TblArea();

            tbl.ContactId       = int.Parse(context.Request.Form["hidenId"]);
            tbl.ContactName     = context.Request.Form["txtName"];
            tbl.CellPhone       = context.Request.Form["txtPhone"];
            tbl.Email           = context.Request.Form["txtEmail"];
            tbl.GroupId         = new ContactGroup();
            tbl.GroupId.GroupId = int.Parse(context.Request.Form["sel2"]);
            UserHandlerBLL bll = new UserHandlerBLL();
            int            rec = bll.UpdateData(tbl);

            context.Response.Clear();
            if (rec > 0)
            {
                context.Response.Write("1");
            }
            else
            {
                context.Response.Write("0");
            }

            context.Response.End();
        }
        public async Task <bool> DeleteAreaAsync(int id)
        {
            TblArea area = await Context.TblAreas.Where(x => x.Id == id).FirstOrDefaultAsync();

            Context.TblAreas.Remove(area);
            return(await Context.SaveChangesAsync() == 1 ? true : false);
        }
        public async Task <bool> UpdateAreaAsync(AreaViewModel entity)
        {
            TblArea existingArea = await Context.TblAreas.Where(x => x.Id == entity.Id).FirstOrDefaultAsync();

            if (existingArea.Id > 0)
            {
                existingArea.Name      = entity.AreaName;
                existingArea.UpdatedOn = DateTime.UtcNow;
                existingArea.UpdatedBy = 1;
            }
            return(await Context.SaveChangesAsync() > 0 ? true : false);
        }
        public async Task <bool> CreateAreaAsync(AreaViewModel model)
        {
            var entity = new TblArea
            {
                Name      = model.AreaName,
                CreatedOn = DateTime.UtcNow,
                CreatedBy = 1
            };
            await Context.TblAreas.AddAsync(entity);

            int saved = await Context.SaveChangesAsync();

            return(saved > 0 ? true : false);
        }
Beispiel #7
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            //根据id获取用户要编辑的内容 并显示到前端
            int            id   = int.Parse(context.Request.QueryString["id"]);
            UserHandlerBLL bll  = new UserHandlerBLL();
            TblArea        area = bll.GetDataById(id);
            //转换为json字符串
            JavaScriptSerializer jss = new JavaScriptSerializer();
            string strJson           = jss.Serialize(area);

            context.Response.Clear();
            context.Response.Write(strJson);
            context.Response.End();
        }
Beispiel #8
0
        //显示查询到的数据
        public List <TblArea> GetData(int pageindex, int pagesize, out int pagecount, out int recordcount)
        {
            List <TblArea> list = new List <TblArea>();
            string         sql  = "usp_FenYe";

            SqlParameter[] pms = new SqlParameter[] {
                new SqlParameter("@pageindex", SqlDbType.Int)
                {
                    Value = pageindex
                },
                new SqlParameter("@pagesize", SqlDbType.Int)
                {
                    Value = pagesize
                },
                new SqlParameter("@pagecount", SqlDbType.Int)
                {
                    Direction = ParameterDirection.Output
                },
                new SqlParameter("@recordcount", SqlDbType.Int)
                {
                    Direction = ParameterDirection.Output
                }
            };
            using (SqlDataReader reader = SqlHelper.ExecuteReader(sql, CommandType.StoredProcedure, pms))
            {
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        TblArea area = new TblArea();
                        area.ContactId         = reader.GetInt32(0);
                        area.ContactName       = reader.GetString(1);
                        area.CellPhone         = reader.GetString(2);
                        area.Email             = reader.GetString(3);
                        area.GroupId           = new ContactGroup();
                        area.GroupId.GroupId   = reader.GetInt32(4);
                        area.GroupId.GroupName = reader.GetString(5);
                        list.Add(area);
                    }
                }
            }
            pagecount   = int.Parse(pms[2].Value.ToString());
            recordcount = int.Parse(pms[3].Value.ToString());
            return(list);
        }
Beispiel #9
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            //获取用户发送过来的数据
            TblArea area = new TblArea();

            area.ContactName     = context.Request.Form["txtName"];
            area.CellPhone       = context.Request.Form["txtPhone"];
            area.Email           = context.Request.Form["txtEmail"];
            area.GroupId         = new ContactGroup();
            area.GroupId.GroupId = int.Parse(context.Request.Form["sel1"]);
            UserHandlerBLL bll = new UserHandlerBLL();
            int            rec = bll.InsertData(area);

            context.Response.Clear();
            context.Response.Write(rec);
            context.Response.End();
        }
Beispiel #10
0
        //向数据库中插入数据
        public int InsertData(TblArea tbl)
        {
            string sql = "insert into TblArea values(@name,@phone,@email,@groupId)";

            SqlParameter[] pms = new SqlParameter[] {
                new SqlParameter("@name", SqlDbType.NVarChar, 10)
                {
                    Value = tbl.ContactName
                },
                new SqlParameter("@phone", SqlDbType.NChar, 50)
                {
                    Value = tbl.CellPhone
                },
                new SqlParameter("@email", SqlDbType.NChar, 50)
                {
                    Value = tbl.Email
                },
                new SqlParameter("@groupId", SqlDbType.Int)
                {
                    Value = tbl.GroupId.GroupId
                }
            };
            return(SqlHelper.ExecuteNonquery(sql, CommandType.Text, pms));
        }
Beispiel #11
0
 //更新用户要编辑的数据
 public int UpdateData(TblArea ta)
 {
     return(dal.UpdateData(ta));
 }
Beispiel #12
0
 //向数据库中插入数据
 public int InsertData(TblArea tbl)
 {
     return(dal.InsertData(tbl));
 }