Exemple #1
0
        /// <summary>
        ///添加修改校区
        /// </summary>
        public bool SaveCampus(W_Campus Model, int AccountID, int System_Station_ID)
        {
            ///判断数据是否存在
            W_Campus model = Orm.Single <W_Campus>(x => x.ID == Model.ID && x.System_Station_ID == System_Station_ID);

            if (Model.ID > 0)//修改
            {
                if (model.Name == Model.Name)
                {
                    throw new ApiException("校区已存在请重新添加");
                }
                if (model == null)
                {
                    throw new ApiException("操作失败,未找到对应的数据!");
                }
                Model.System_Station_ID = model.System_Station_ID;
                Model.AddPerson         = model.AddPerson;
                Model.AddTime           = model.AddTime;
                Model.Valid             = model.Valid;
                if (Orm.Update(Model) > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else//添加
            {
                Model.AddPerson         = AccountID;
                Model.AddTime           = DateTime.Now;
                Model.Valid             = 1;
                Model.System_Station_ID = System_Station_ID;
                if (Orm.Insert(Model) > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// 启用禁用校区
        /// </summary>
        /// <returns></returns>
        public dynamic UpdateValid(CampusModel Model, int System_Station_ID)
        {
            W_Campus campusmodel = Orm.Single <W_Campus>(x => x.ID == Model.ID && x.System_Station_ID == System_Station_ID);

            if (campusmodel == null)
            {
                throw new ApiException("操作失败,请稍后再试");
            }
            if (Model.Valid == 0)
            {
                W_ClassRoom roommodel = Orm.Single <W_ClassRoom>(x => x.CampusID == Model.ID && x.System_Station_ID == System_Station_ID);
                if (roommodel != null)
                {
                    throw new ApiException("该校区下面存在教室,不能禁用");
                }
            }
            campusmodel.Valid = Model.Valid;
            if (Orm.Update(campusmodel) <= 0)
            {
                throw new ApiException("修改失败");
            }
            return(true);
        }
Exemple #3
0
        /// <summary>
        /// 删除校区
        /// </summary>
        /// <returns></returns>
        public bool DeleteCampus(CampusModel Model, int System_Station_ID)
        {
            W_Campus campusmodel = Orm.Single <W_Campus>(x => x.ID == Model.ID && x.System_Station_ID == System_Station_ID);

            if (campusmodel == null)
            {
                throw new ApiException("操作失败,未找到要操作的数据,请刷新再试");
            }
            if (campusmodel.Valid == 1)
            {
                throw new ApiException("启用状态中,不能删除");
            }
            W_ClassRoom roommodel = Orm.Single <W_ClassRoom>(x => x.CampusID == Model.ID && x.System_Station_ID == System_Station_ID);

            if (roommodel != null)
            {
                throw new ApiException("该校区下面存在教室,不能删除");
            }
            if (Orm.Delete(campusmodel) <= 0)
            {
                throw new ApiException("删除失败,请重试");
            }
            return(true);
        }
Exemple #4
0
 public dynamic SaveCampus(W_Campus Model)
 {
     return(Success(mapper.SaveCampus(Model, this.AccountID, this.System_Station_ID)));
 }