Пример #1
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(Entity.GradeUpdateConfigEntity model)
 {
     return(dal.Add(model));
 }
Пример #2
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public void Update(Entity.GradeUpdateConfigEntity model)
 {
     dal.Update(model);
 }
Пример #3
0
        //添加
        protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
        {
            string cfidStr    = Request["configId"];
            string cfcurrCStr = Request["currClassGid"];
            string cffurCStr  = Request["furClassGid"];

            BLL.GradeUpdateConfigBLL gucBll = new BLL.GradeUpdateConfigBLL();
            if (string.IsNullOrEmpty(cfidStr) || string.IsNullOrEmpty(cfcurrCStr) || string.IsNullOrEmpty(cffurCStr))
            {
                FinalMessage("班级无效!", "GradeUpdateConfig_List.aspx", 0);
                return;
            }
            string[] idArr    = cfidStr.Split(',');
            string[] currCArr = cfcurrCStr.Split(',');
            string[] furCArr  = cffurCStr.Split(',');
            if (idArr.Length != currCArr.Length || currCArr.Length != furCArr.Length)
            {
                FinalMessage("班级选择数量不一致!", "GradeUpdateConfig_List.aspx", 0);
                return;
            }
            //验证数据
            for (int i = 0; i < currCArr.Length; i++)
            {
                if (currCArr[i] == furCArr[i])
                {
                    FinalMessage("选择了相同的班级!", "GradeUpdateConfig_List.aspx", 0);
                    return;
                }
            }
            //保存数据
            List <Entity.GradeUpdateConfigEntity> list = gucBll.GetModelList(" IsDeleted = 0");
            List <int> exsistIdList = new List <int>();

            Entity.GradeUpdateConfigEntity entity = null;
            for (int i = 0; i < idArr.Length; i++)
            {
                int id = Convert.ToInt32(idArr[i]);
                entity = list.Where(s => s.ID == id).FirstOrDefault();
                if (id != 0 && entity != null)
                {
                    entity.ModifyDate   = DateTime.Now;
                    entity.ModifyUserID = UserId;
                    entity.CurrGradeID  = Convert.ToInt32(currCArr[i]);
                    entity.UpGradeID    = Convert.ToInt32(furCArr[i]);
                    gucBll.Update(entity);
                    exsistIdList.Add(entity.ID);
                }
                if (0 == id)
                {
                    entity              = new Entity.GradeUpdateConfigEntity();
                    entity.CreateDate   = DateTime.Now;
                    entity.CreateUserID = UserId;
                    entity.ModifyDate   = DateTime.Now;
                    entity.ModifyUserID = 0;
                    entity.CurrGradeID  = Convert.ToInt32(currCArr[i]);
                    entity.UpGradeID    = Convert.ToInt32(furCArr[i]);
                    entity.IsDeleted    = 0;
                    gucBll.Add(entity);
                }
            }
            //更新用户删除的数据
            for (int i = 0; i < list.Count; i++)
            {
                int id = list[i].ID;
                if (!exsistIdList.Contains(id))
                {
                    list[i].IsDeleted    = 1;
                    list[i].DeleteDate   = DateTime.Now;
                    list[i].DeleteUserID = UserId;
                    gucBll.Update(list[i]);
                }
            }
        }