Пример #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Osiris.Model.Coordinate model)
        {
            Osiris.Model.Coordinate m = GetModel(model.Id);
            if (m == null)
            {
                return(false);
            }

            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Coordinate set ");
            strSql.Append("Eare=@Eare,");
            strSql.Append("Lon=@Lon,");
            strSql.Append("Lat=@Lat,");
            strSql.Append("LogoName=@LogoName,");
            strSql.Append("UpdateTime=@UpdateTime,");
            strSql.Append("Creator=@Creator,");
            strSql.Append("Remark=@Remark");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Eare",       SqlDbType.NVarChar,   5),
                new SqlParameter("@Lon",        SqlDbType.VarChar,   20),
                new SqlParameter("@Lat",        SqlDbType.VarChar,   20),
                new SqlParameter("@LogoName",   SqlDbType.NVarChar,  30),
                new SqlParameter("@UpdateTime", SqlDbType.DateTime),
                new SqlParameter("@Creator",    SqlDbType.VarChar,   20),
                new SqlParameter("@Remark",     SqlDbType.NVarChar,  50),
                new SqlParameter("@Id",         SqlDbType.Int, 4)
            };
            parameters[0].Value = model.Eare == null ? m.Eare : model.Eare;
            parameters[1].Value = model.Lon == null ? m.Lon : model.Lon;
            parameters[2].Value = model.Lat == null ? m.Lat : model.Lat;
            parameters[3].Value = model.LogoName == null ? m.LogoName : model.LogoName;
            parameters[4].Value = DateTime.Now;
            parameters[5].Value = model.Creator == null ? m.Creator : model.Creator;
            parameters[6].Value = model.Remark == null ? m.Remark : model.Remark;
            parameters[7].Value = model.Id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Osiris.Model.Coordinate DataRowToModel(DataRow row)
 {
     Osiris.Model.Coordinate model = new Osiris.Model.Coordinate();
     if (row != null)
     {
         if (row["Id"] != null && row["Id"].ToString() != "")
         {
             model.Id = int.Parse(row["Id"].ToString());
         }
         if (row["Eare"] != null)
         {
             model.Eare = row["Eare"].ToString();
         }
         if (row["Lon"] != null)
         {
             model.Lon = row["Lon"].ToString();
         }
         if (row["Lat"] != null)
         {
             model.Lat = row["Lat"].ToString();
         }
         if (row["LogoName"] != null)
         {
             model.LogoName = row["LogoName"].ToString();
         }
         if (row["CreateTime"] != null && row["CreateTime"].ToString() != "")
         {
             model.CreateTime = DateTime.Parse(row["CreateTime"].ToString());
         }
         if (row["UpdateTime"] != null && row["UpdateTime"].ToString() != "")
         {
             model.UpdateTime = DateTime.Parse(row["UpdateTime"].ToString());
         }
         if (row["Creator"] != null)
         {
             model.Creator = row["Creator"].ToString();
         }
         if (row["Remark"] != null)
         {
             model.Remark = row["Remark"].ToString();
         }
     }
     return(model);
 }
Пример #3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Osiris.Model.Coordinate model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Coordinate(");
            strSql.Append("Eare,Lon,Lat,LogoName,Creator,Remark)");
            strSql.Append(" values (");
            strSql.Append("@Eare,@Lon,@lat,@LogoName,@Creator,@Remark)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Eare",     SqlDbType.NVarChar,  5),
                new SqlParameter("@Lon",      SqlDbType.VarChar,  20),
                new SqlParameter("@Lat",      SqlDbType.VarChar,  20),
                new SqlParameter("@LogoName", SqlDbType.NVarChar, 30),
                new SqlParameter("@Creator",  SqlDbType.VarChar,  20),
                new SqlParameter("@Remark",   SqlDbType.NVarChar, 50)
            };
            parameters[0].Value = model.Eare;
            parameters[1].Value = model.Lon;
            parameters[2].Value = model.Lat;
            parameters[3].Value = model.LogoName;
            parameters[4].Value = model.Creator;
            parameters[5].Value = model.Remark;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Пример #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Osiris.Model.Coordinate GetModel(int Id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 Id,Eare,Lon,Lat,LogoName,CreateTime,UpdateTime,Creator,Remark from Coordinate ");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Id", SqlDbType.Int, 4)
            };
            parameters[0].Value = Id;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Пример #5
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(Osiris.Model.Coordinate model)
 {
     return(dal.Update(model));
 }
Пример #6
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(Osiris.Model.Coordinate model)
 {
     return(dal.Add(model));
 }