/// <summary> /// 更新一条数据 /// </summary> public bool Update(FlowGaugeEntity model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update FlowGauge set "); strSql.Append("FG_Name=@FG_Name,"); strSql.Append("FG_longitude=@FG_longitude,"); strSql.Append("FG_dimensionality=@FG_dimensionality,"); strSql.Append("FG_Description=@FG_Description,"); strSql.Append("Msc_ID=@Msc_ID,"); strSql.Append("FG_Brand=@FG_Brand,"); strSql.Append("FG_Specification=@FG_Specification,"); strSql.Append("FG_Manufacturer=@FG_Manufacturer"); strSql.Append(" where FlowGauge_ID=@FlowGauge_ID"); SqlParameter[] parameters = { new SqlParameter("@FG_Name", SqlDbType.NVarChar, 50), new SqlParameter("@FG_longitude", SqlDbType.Float, 8), new SqlParameter("@FG_dimensionality", SqlDbType.Float, 8), new SqlParameter("@FG_Description", SqlDbType.NVarChar, 50), new SqlParameter("@Msc_ID", SqlDbType.Int, 4), new SqlParameter("@FG_Brand", SqlDbType.NVarChar, 50), new SqlParameter("@FG_Specification", SqlDbType.NVarChar, 150), new SqlParameter("@FG_Manufacturer", SqlDbType.NChar, 10), new SqlParameter("@FlowGauge_ID", SqlDbType.Int, 4) }; parameters[0].Value = model.FG_Name; parameters[1].Value = model.FG_longitude; parameters[2].Value = model.FG_dimensionality; parameters[3].Value = model.FG_Description; parameters[4].Value = model.Msc_ID; parameters[5].Value = model.FG_Brand; parameters[6].Value = model.FG_Specification; parameters[7].Value = model.FG_Manufacturer; parameters[8].Value = model.FlowGauge_ID; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public FlowGaugeEntity DataRowToModel(DataRow row) { FlowGaugeEntity model = new FlowGaugeEntity(); if (row != null) { if (row["FlowGauge_ID"] != null && row["FlowGauge_ID"].ToString() != "") { model.FlowGauge_ID = int.Parse(row["FlowGauge_ID"].ToString()); } if (row["FG_Name"] != null) { model.FG_Name = row["FG_Name"].ToString(); } if (row["FG_longitude"] != null && row["FG_longitude"].ToString() != "") { model.FG_longitude = decimal.Parse(row["FG_longitude"].ToString()); } if (row["FG_dimensionality"] != null && row["FG_dimensionality"].ToString() != "") { model.FG_dimensionality = decimal.Parse(row["FG_dimensionality"].ToString()); } if (row["FG_Description"] != null) { model.FG_Description = row["FG_Description"].ToString(); } if (row["Msc_ID"] != null && row["Msc_ID"].ToString() != "") { model.Msc_ID = int.Parse(row["Msc_ID"].ToString()); } if (row["FG_Brand"] != null) { model.FG_Brand = row["FG_Brand"].ToString(); } if (row["FG_Specification"] != null) { model.FG_Specification = row["FG_Specification"].ToString(); } if (row["FG_Manufacturer"] != null) { model.FG_Manufacturer = row["FG_Manufacturer"].ToString(); } } return(model); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(FlowGaugeEntity model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into FlowGauge("); strSql.Append("FG_Name,FG_longitude,FG_dimensionality,FG_Description,Msc_ID,FG_Brand,FG_Specification,FG_Manufacturer)"); strSql.Append(" values ("); strSql.Append("@FG_Name,@FG_longitude,@FG_dimensionality,@FG_Description,@Msc_ID,@FG_Brand,@FG_Specification,@FG_Manufacturer)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@FG_Name", SqlDbType.NVarChar, 50), new SqlParameter("@FG_longitude", SqlDbType.Float, 8), new SqlParameter("@FG_dimensionality", SqlDbType.Float, 8), new SqlParameter("@FG_Description", SqlDbType.NVarChar, 50), new SqlParameter("@Msc_ID", SqlDbType.Int, 4), new SqlParameter("@FG_Brand", SqlDbType.NVarChar, 50), new SqlParameter("@FG_Specification", SqlDbType.NVarChar, 150), new SqlParameter("@FG_Manufacturer", SqlDbType.NChar, 10) }; parameters[0].Value = model.FG_Name; parameters[1].Value = model.FG_longitude; parameters[2].Value = model.FG_dimensionality; parameters[3].Value = model.FG_Description; parameters[4].Value = model.Msc_ID; parameters[5].Value = model.FG_Brand; parameters[6].Value = model.FG_Specification; parameters[7].Value = model.FG_Manufacturer; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public FlowGaugeEntity GetModel(int FlowGauge_ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 FlowGauge_ID,FG_Name,FG_longitude,FG_dimensionality,FG_Description,Msc_ID,FG_Brand,FG_Specification,FG_Manufacturer from FlowGauge "); strSql.Append(" where FlowGauge_ID=@FlowGauge_ID"); SqlParameter[] parameters = { new SqlParameter("@FlowGauge_ID", SqlDbType.Int, 4) }; parameters[0].Value = FlowGauge_ID; FlowGaugeEntity model = new FlowGaugeEntity(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(FlowGaugeEntity model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(FlowGaugeEntity model) { return(dal.Add(model)); }