コード例 #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(AMS.Model.AMS_Campus model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update AMS_Campus set ");
            strSql.Append("Number=@Number,");
            strSql.Append("SchoolId=@SchoolId,");
            strSql.Append("Name=@Name,");
            strSql.Append("Describe=@Describe");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Number",   SqlDbType.NVarChar,  50),
                new SqlParameter("@SchoolId", SqlDbType.Int,        4),
                new SqlParameter("@Name",     SqlDbType.NVarChar,  50),
                new SqlParameter("@Describe", SqlDbType.NVarChar, 500),
                new SqlParameter("@Id",       SqlDbType.Int, 4)
            };
            parameters[0].Value = model.Number;
            parameters[1].Value = model.SchoolId;
            parameters[2].Value = model.Name;
            parameters[3].Value = model.Describe;
            parameters[4].Value = model.Id;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(AMS.Model.AMS_Campus model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into AMS_Campus(");
            strSql.Append("Number,SchoolId,Name,Describe)");
            strSql.Append(" values (");
            strSql.Append("@Number,@SchoolId,@Name,@Describe)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Number",   SqlDbType.NVarChar, 50),
                new SqlParameter("@SchoolId", SqlDbType.Int,       4),
                new SqlParameter("@Name",     SqlDbType.NVarChar, 50),
                new SqlParameter("@Describe", SqlDbType.NVarChar, 500)
            };
            parameters[0].Value = model.Number;
            parameters[1].Value = model.SchoolId;
            parameters[2].Value = model.Name;
            parameters[3].Value = model.Describe;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
        /// <summary>
        /// 把学校信息转换为可以显示的信息
        /// </summary>
        /// <param name="campus"></param>
        public void ShowCampusDetail(AMS.Model.AMS_Campus campus)
        {
            CampusInfo campusDetail = new CampusInfo();

            campusDetail.Id          = campus.Id;
            campusDetail.Name        = campus.Name;
            campusDetail.Number      = campus.Number;
            campusDetail.Address     = campus.Address;
            campusDetail.DeviceCount = campus.Device.Count;
            this.CampusDetail        = campusDetail;
        }
        /// <summary>
        /// 显示设备list信息
        /// </summary>
        /// <param name="campus"></param>
        public void ShowDeviceList(AMS.Model.AMS_Campus campus)
        {
            List <DeviceInfo> devices = new List <DeviceInfo>();

            foreach (AMS.Model.AMS_Device d in campus.Device)
            {
                DeviceInfo di = new DeviceInfo();
                di.Id          = d.Id;
                di.IsDelete    = d.IsDel == true ? "停用" : "启用";
                di.Number      = d.Number;
                di.Status      = d.Flag == true ? "未获取" : "已更新";
                di.Describe    = d.Describe;
                di.CaputrePath = d.CaputrePath;
                di.CaputreTime = d.CaputreTime;
                devices.Add(di);
            }
            DeviceList = devices;
        }
コード例 #5
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public AMS.Model.AMS_Campus GetModel(int Id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 Id,Number,SchoolId,Name,Describe from AMS_Campus ");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Id", SqlDbType.Int, 4)
            };
            parameters[0].Value = Id;

            AMS.Model.AMS_Campus model = new AMS.Model.AMS_Campus();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["Id"] != null && ds.Tables[0].Rows[0]["Id"].ToString() != "")
                {
                    model.Id = int.Parse(ds.Tables[0].Rows[0]["Id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Number"] != null && ds.Tables[0].Rows[0]["Number"].ToString() != "")
                {
                    model.Number = ds.Tables[0].Rows[0]["Number"].ToString();
                }
                if (ds.Tables[0].Rows[0]["SchoolId"] != null && ds.Tables[0].Rows[0]["SchoolId"].ToString() != "")
                {
                    model.SchoolId = int.Parse(ds.Tables[0].Rows[0]["SchoolId"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Name"] != null && ds.Tables[0].Rows[0]["Name"].ToString() != "")
                {
                    model.Name = ds.Tables[0].Rows[0]["Name"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Describe"] != null && ds.Tables[0].Rows[0]["Describe"].ToString() != "")
                {
                    model.Describe = ds.Tables[0].Rows[0]["Describe"].ToString();
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
コード例 #6
0
        /// <summary>
        /// 获取实体对象
        /// </summary>
        /// <param name="strWhere"></param>
        /// <returns></returns>
        public Model.AMS_Campus GetModel(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 Id,Number,SchoolId,Name,Describe from AMS_Campus ");
            if (!string.IsNullOrEmpty(strWhere) && strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            AMS.Model.AMS_Campus model = new AMS.Model.AMS_Campus();
            DataSet ds = DbHelperSQL.Query(strSql.ToString());

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["Id"] != null && ds.Tables[0].Rows[0]["Id"].ToString() != "")
                {
                    model.Id = int.Parse(ds.Tables[0].Rows[0]["Id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Number"] != null && ds.Tables[0].Rows[0]["Number"].ToString() != "")
                {
                    model.Number = ds.Tables[0].Rows[0]["Number"].ToString();
                }
                if (ds.Tables[0].Rows[0]["SchoolId"] != null && ds.Tables[0].Rows[0]["SchoolId"].ToString() != "")
                {
                    model.SchoolId = int.Parse(ds.Tables[0].Rows[0]["SchoolId"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Name"] != null && ds.Tables[0].Rows[0]["Name"].ToString() != "")
                {
                    model.Name = ds.Tables[0].Rows[0]["Name"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Describe"] != null && ds.Tables[0].Rows[0]["Describe"].ToString() != "")
                {
                    model.Describe = ds.Tables[0].Rows[0]["Describe"].ToString();
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
 /// <summary>
 /// 删除校区信息
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public static string DeleteCampusInfo(AMS.Model.AMS_Campus model)
 {
     AMS.IBllService.IAdvertManageBllService bllService = AMS.ServiceConnectChannel.AdvertManageBllServiceChannel.CreateServiceChannel();
     try
     {
         return(bllService.DeleteCampusInfo(model));
     }
     catch (EndpointNotFoundException ex)
     {
         throw new AMS.Model.CustomerException("连接服务器失败");
     }
     catch (CommunicationException ex)
     {
         throw ex;
     }
     catch (Exception ex)
     {
         throw ex;
     }
     finally
     {
         ICommunicationObject ICommObjectService = bllService as ICommunicationObject;
         try
         {
             if (ICommObjectService.State == CommunicationState.Faulted)
             {
                 ICommObjectService.Abort();
             }
             else
             {
                 ICommObjectService.Close();
             }
         }
         catch
         {
             ICommObjectService.Abort();
         }
     }
 }
 public ViewModelDeviceEditWindow(AMS.Model.AMS_Campus campusModel, AMS.Model.AMS_School schoolModel)
 {
     CampusModel = campusModel;
     SchoolModel = schoolModel;
 }