/// <summary> /// 更新一条数据 /// </summary> public bool Update(Model.province model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update td_province set "); strSql.Append(" ProvinceID = @ProvinceID , "); strSql.Append(" ProvinceName = @ProvinceName , "); strSql.Append(" DateCreated = @DateCreated , "); strSql.Append(" DateUpdated = @DateUpdated "); strSql.Append(" where ProvinceID=@ProvinceID "); SqlParameter[] parameters = { new SqlParameter("@ProvinceID", SqlDbType.BigInt, 8), new SqlParameter("@ProvinceName", SqlDbType.VarChar, 50), new SqlParameter("@DateCreated", SqlDbType.DateTime), new SqlParameter("@DateUpdated", SqlDbType.DateTime) }; parameters[0].Value = model.ProvinceID; parameters[1].Value = model.ProvinceName; parameters[2].Value = model.DateCreated; parameters[3].Value = model.DateUpdated; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 获取省名称 /// </summary> /// <param name="id"></param> /// <returns></returns> public string get_province_title(int id) { BLL.province bll = new BLL.province(); Model.province model = bll.GetModel(id); if (model != null) { return(model.ProvinceName); } else { return(""); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Model.province GetModel(long ProvinceID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select ProvinceID, ProvinceName, DateCreated, DateUpdated "); strSql.Append(" from td_province "); strSql.Append(" where ProvinceID=@ProvinceID "); SqlParameter[] parameters = { new SqlParameter("@ProvinceID", SqlDbType.BigInt, 8) }; parameters[0].Value = ProvinceID; Model.province model = new Model.province(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["ProvinceID"].ToString() != "") { model.ProvinceID = long.Parse(ds.Tables[0].Rows[0]["ProvinceID"].ToString()); } model.ProvinceName = ds.Tables[0].Rows[0]["ProvinceName"].ToString(); if (ds.Tables[0].Rows[0]["DateCreated"].ToString() != "") { model.DateCreated = DateTime.Parse(ds.Tables[0].Rows[0]["DateCreated"].ToString()); } if (ds.Tables[0].Rows[0]["DateUpdated"].ToString() != "") { model.DateUpdated = DateTime.Parse(ds.Tables[0].Rows[0]["DateUpdated"].ToString()); } return(model); } else { return(null); } }
/// <summary> /// 增加一条数据 /// </summary> public void Add(Model.province model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into td_province("); strSql.Append("ProvinceID,ProvinceName,DateCreated,DateUpdated"); strSql.Append(") values ("); strSql.Append("@ProvinceID,@ProvinceName,@DateCreated,@DateUpdated"); strSql.Append(") "); SqlParameter[] parameters = { new SqlParameter("@ProvinceID", SqlDbType.BigInt, 8), new SqlParameter("@ProvinceName", SqlDbType.VarChar, 50), new SqlParameter("@DateCreated", SqlDbType.DateTime), new SqlParameter("@DateUpdated", SqlDbType.DateTime) }; parameters[0].Value = model.ProvinceID; parameters[1].Value = model.ProvinceName; parameters[2].Value = model.DateCreated; parameters[3].Value = model.DateUpdated; DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Model.province model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public void Add(Model.province model) { dal.Add(model); }
/// <summary> /// 得到一个对象实体 /// </summary> public Model.province GetModel(long ProvinceID) { StringBuilder strSql=new StringBuilder(); strSql.Append("select ProvinceID, ProvinceName, DateCreated, DateUpdated "); strSql.Append(" from td_province "); strSql.Append(" where ProvinceID=@ProvinceID "); SqlParameter[] parameters = { new SqlParameter("@ProvinceID", SqlDbType.BigInt,8) }; parameters[0].Value = ProvinceID; Model.province model=new Model.province(); DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters); if(ds.Tables[0].Rows.Count>0) { if(ds.Tables[0].Rows[0]["ProvinceID"].ToString()!="") { model.ProvinceID=long.Parse(ds.Tables[0].Rows[0]["ProvinceID"].ToString()); } model.ProvinceName= ds.Tables[0].Rows[0]["ProvinceName"].ToString(); if(ds.Tables[0].Rows[0]["DateCreated"].ToString()!="") { model.DateCreated=DateTime.Parse(ds.Tables[0].Rows[0]["DateCreated"].ToString()); } if(ds.Tables[0].Rows[0]["DateUpdated"].ToString()!="") { model.DateUpdated=DateTime.Parse(ds.Tables[0].Rows[0]["DateUpdated"].ToString()); } return model; } else { return null; } }