Exemplo n.º 1
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public BWJSLog.Model.MachineLocationLog GetModel(int MachineLocationLogId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select MachineLocationLogId, CreateDate, IsDeleted, Remark, UserId, MachineId, IP, MAC, Latitude, Longitude, LocationAddress, LocationData  ");
            strSql.Append("  from dbo.[MachineLocationLog] ");
            strSql.Append(" where MachineLocationLogId=@MachineLocationLogId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@MachineLocationLogId", SqlDbType.Int, 4)
            };
            parameters[0].Value = MachineLocationLogId;


            BWJSLog.Model.MachineLocationLog model = new BWJSLog.Model.MachineLocationLog();
            DataSet ds = BWJSLogHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(BWJSLog.Model.MachineLocationLog model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update dbo.[MachineLocationLog] set ");

            strSql.Append(" CreateDate = @CreateDate , ");
            strSql.Append(" IsDeleted = @IsDeleted , ");
            strSql.Append(" Remark = @Remark , ");
            strSql.Append(" UserId = @UserId , ");
            strSql.Append(" MachineId = @MachineId , ");
            strSql.Append(" IP = @IP , ");
            strSql.Append(" MAC = @MAC , ");
            strSql.Append(" Latitude = @Latitude , ");
            strSql.Append(" Longitude = @Longitude , ");
            strSql.Append(" LocationAddress = @LocationAddress , ");
            strSql.Append(" LocationData = @LocationData  ");
            strSql.Append(" where MachineLocationLogId=@MachineLocationLogId ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@MachineLocationLogId", model.MachineLocationLogId),
                new SqlParameter("@CreateDate",           model.CreateDate),
                new SqlParameter("@IsDeleted",            model.IsDeleted),
                new SqlParameter("@Remark",               model.Remark),
                new SqlParameter("@UserId",               model.UserId),
                new SqlParameter("@MachineId",            model.MachineId),
                new SqlParameter("@IP",                   model.IP),
                new SqlParameter("@MAC",                  model.MAC),
                new SqlParameter("@Latitude",             model.Latitude),
                new SqlParameter("@Longitude",            model.Longitude),
                new SqlParameter("@LocationAddress",      model.LocationAddress),
                new SqlParameter("@LocationData",         model.LocationData)
            };

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// datarow转成对象实体
        /// </summary>
        public BWJSLog.Model.MachineLocationLog DataRowToModel(DataRow row)
        {
            BWJSLog.Model.MachineLocationLog model = new BWJSLog.Model.MachineLocationLog();

            if (row != null)
            {
                if (row["MachineLocationLogId"].ToString() != "")
                {
                    model.MachineLocationLogId = int.Parse(row["MachineLocationLogId"].ToString());
                }
                if (row["CreateDate"].ToString() != "")
                {
                    model.CreateDate = DateTime.Parse(row["CreateDate"].ToString());
                }
                if (row["IsDeleted"].ToString() != "")
                {
                    model.IsDeleted = int.Parse(row["IsDeleted"].ToString());
                }
                model.Remark = row["Remark"].ToString();
                if (row["UserId"].ToString() != "")
                {
                    model.UserId = int.Parse(row["UserId"].ToString());
                }
                if (row["MachineId"].ToString() != "")
                {
                    model.MachineId = int.Parse(row["MachineId"].ToString());
                }
                model.IP              = row["IP"].ToString();
                model.MAC             = row["MAC"].ToString();
                model.Latitude        = row["Latitude"].ToString();
                model.Longitude       = row["Longitude"].ToString();
                model.LocationAddress = row["LocationAddress"].ToString();

                return(model);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(BWJSLog.Model.MachineLocationLog model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into dbo.[MachineLocationLog](");
            strSql.Append("CreateDate,IsDeleted,Remark,UserId,MachineId,IP,MAC,Latitude,Longitude,LocationAddress,LocationData");
            strSql.Append(") values (");
            strSql.Append("@CreateDate,@IsDeleted,@Remark,@UserId,@MachineId,@IP,@MAC,@Latitude,@Longitude,@LocationAddress,@LocationData");
            strSql.Append(") ");
            strSql.Append(";select SCOPE_IDENTITY()");
            SqlParameter[] parameters =
            {
                new SqlParameter("@CreateDate",      model.CreateDate),
                new SqlParameter("@IsDeleted",       model.IsDeleted),
                new SqlParameter("@Remark",          model.Remark),
                new SqlParameter("@UserId",          model.UserId),
                new SqlParameter("@MachineId",       model.MachineId),
                new SqlParameter("@IP",              model.IP),
                new SqlParameter("@MAC",             model.MAC),
                new SqlParameter("@Latitude",        model.Latitude),
                new SqlParameter("@Longitude",       model.Longitude),
                new SqlParameter("@LocationAddress", model.LocationAddress),
                new SqlParameter("@LocationData",    model.LocationData)
            };


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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }