/// <summary> /// 更新一条数据 /// </summary> public bool Update(CdHotelManage.Model.shopInfo model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update shopInfo set "); strSql.Append("shop_Name=@shop_Name,"); strSql.Append("shop_LxMan=@shop_LxMan,"); strSql.Append("Shop_Telphone=@Shop_Telphone,"); strSql.Append("Shop_chuanzen=@Shop_chuanzen,"); strSql.Append("Shop_Province=@Shop_Province,"); strSql.Append("Shop_City=@Shop_City,"); strSql.Append("Shop_Area=@Shop_Area,"); strSql.Append("Shop_Address=@Shop_Address,"); strSql.Append("Shop_x=@Shop_x,"); strSql.Append("Shop_y=@Shop_y,"); strSql.Append("Shop_Remaker=@Shop_Remaker,"); strSql.Append("Shop_date=@Shop_date"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@shop_Name", SqlDbType.NVarChar, 50), new SqlParameter("@shop_LxMan", SqlDbType.NVarChar, 50), new SqlParameter("@Shop_Telphone", SqlDbType.NVarChar, 50), new SqlParameter("@Shop_chuanzen", SqlDbType.NVarChar, 50), new SqlParameter("@Shop_Province", SqlDbType.NVarChar, 50), new SqlParameter("@Shop_City", SqlDbType.NVarChar, 50), new SqlParameter("@Shop_Area", SqlDbType.NVarChar, 50), new SqlParameter("@Shop_Address", SqlDbType.NVarChar), new SqlParameter("@Shop_x", SqlDbType.NVarChar, 50), new SqlParameter("@Shop_y", SqlDbType.NVarChar, 50), new SqlParameter("@Shop_Remaker", SqlDbType.NVarChar), new SqlParameter("@Shop_date", SqlDbType.DateTime), new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = model.shop_Name; parameters[1].Value = model.shop_LxMan; parameters[2].Value = model.Shop_Telphone; parameters[3].Value = model.Shop_chuanzen; parameters[4].Value = model.Shop_Province; parameters[5].Value = model.Shop_City; parameters[6].Value = model.Shop_Area; parameters[7].Value = model.Shop_Address; parameters[8].Value = model.Shop_x; parameters[9].Value = model.Shop_y; parameters[10].Value = model.Shop_Remaker; parameters[11].Value = model.Shop_date; parameters[12].Value = model.id; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(CdHotelManage.Model.shopInfo model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into shopInfo("); strSql.Append("shop_Name,shop_LxMan,Shop_Telphone,Shop_chuanzen,Shop_Province,Shop_City,Shop_Area,Shop_Address,Shop_x,Shop_y,Shop_Remaker,Shop_date)"); strSql.Append(" values ("); strSql.Append("@shop_Name,@shop_LxMan,@Shop_Telphone,@Shop_chuanzen,@Shop_Province,@Shop_City,@Shop_Area,@Shop_Address,@Shop_x,@Shop_y,@Shop_Remaker,@Shop_date)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@shop_Name", SqlDbType.NVarChar, 50), new SqlParameter("@shop_LxMan", SqlDbType.NVarChar, 50), new SqlParameter("@Shop_Telphone", SqlDbType.NVarChar, 50), new SqlParameter("@Shop_chuanzen", SqlDbType.NVarChar, 50), new SqlParameter("@Shop_Province", SqlDbType.NVarChar, 50), new SqlParameter("@Shop_City", SqlDbType.NVarChar, 50), new SqlParameter("@Shop_Area", SqlDbType.NVarChar, 50), new SqlParameter("@Shop_Address", SqlDbType.NVarChar), new SqlParameter("@Shop_x", SqlDbType.NVarChar, 50), new SqlParameter("@Shop_y", SqlDbType.NVarChar, 50), new SqlParameter("@Shop_Remaker", SqlDbType.NVarChar), new SqlParameter("@Shop_date", SqlDbType.DateTime) }; parameters[0].Value = model.shop_Name; parameters[1].Value = model.shop_LxMan; parameters[2].Value = model.Shop_Telphone; parameters[3].Value = model.Shop_chuanzen; parameters[4].Value = model.Shop_Province; parameters[5].Value = model.Shop_City; parameters[6].Value = model.Shop_Area; parameters[7].Value = model.Shop_Address; parameters[8].Value = model.Shop_x; parameters[9].Value = model.Shop_y; parameters[10].Value = model.Shop_Remaker; parameters[11].Value = model.Shop_date; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(CdHotelManage.Model.shopInfo model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(CdHotelManage.Model.shopInfo model) { return(dal.Add(model)); }
/// <summary> /// 获得数据列表 /// </summary> public List <CdHotelManage.Model.shopInfo> DataTableToList(DataTable dt) { List <CdHotelManage.Model.shopInfo> modelList = new List <CdHotelManage.Model.shopInfo>(); int rowsCount = dt.Rows.Count; if (rowsCount > 0) { CdHotelManage.Model.shopInfo model; for (int n = 0; n < rowsCount; n++) { model = new CdHotelManage.Model.shopInfo(); if (dt.Rows[n]["id"] != null && dt.Rows[n]["id"].ToString() != "") { model.id = dt.Rows[n]["id"].ToString(); } if (dt.Rows[n]["shop_Name"] != null && dt.Rows[n]["shop_Name"].ToString() != "") { model.shop_Name = dt.Rows[n]["shop_Name"].ToString(); } if (dt.Rows[n]["shop_LxMan"] != null && dt.Rows[n]["shop_LxMan"].ToString() != "") { model.shop_LxMan = dt.Rows[n]["shop_LxMan"].ToString(); } if (dt.Rows[n]["Shop_Telphone"] != null && dt.Rows[n]["Shop_Telphone"].ToString() != "") { model.Shop_Telphone = dt.Rows[n]["Shop_Telphone"].ToString(); } if (dt.Rows[n]["Shop_chuanzen"] != null && dt.Rows[n]["Shop_chuanzen"].ToString() != "") { model.Shop_chuanzen = dt.Rows[n]["Shop_chuanzen"].ToString(); } if (dt.Rows[n]["Shop_Province"] != null && dt.Rows[n]["Shop_Province"].ToString() != "") { model.Shop_Province = dt.Rows[n]["Shop_Province"].ToString(); } if (dt.Rows[n]["Shop_City"] != null && dt.Rows[n]["Shop_City"].ToString() != "") { model.Shop_City = dt.Rows[n]["Shop_City"].ToString(); } if (dt.Rows[n]["Shop_Area"] != null && dt.Rows[n]["Shop_Area"].ToString() != "") { model.Shop_Area = dt.Rows[n]["Shop_Area"].ToString(); } if (dt.Rows[n]["Shop_Address"] != null && dt.Rows[n]["Shop_Address"].ToString() != "") { model.Shop_Address = dt.Rows[n]["Shop_Address"].ToString(); } if (dt.Rows[n]["Shop_x"] != null && dt.Rows[n]["Shop_x"].ToString() != "") { model.Shop_x = dt.Rows[n]["Shop_x"].ToString(); } if (dt.Rows[n]["Shop_y"] != null && dt.Rows[n]["Shop_y"].ToString() != "") { model.Shop_y = dt.Rows[n]["Shop_y"].ToString(); } if (dt.Rows[n]["Shop_Remaker"] != null && dt.Rows[n]["Shop_Remaker"].ToString() != "") { model.Shop_Remaker = dt.Rows[n]["Shop_Remaker"].ToString(); } if (dt.Rows[n]["Shop_date"] != null && dt.Rows[n]["Shop_date"].ToString() != "") { model.Shop_date = DateTime.Parse(dt.Rows[n]["Shop_date"].ToString()); } modelList.Add(model); } } return(modelList); }
/// <summary> /// 得到一个对象实体 /// </summary> public CdHotelManage.Model.shopInfo GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 id,shop_Name,shop_LxMan,Shop_Telphone,Shop_chuanzen,Shop_Province,Shop_City,Shop_Area,Shop_Address,Shop_x,Shop_y,Shop_Remaker,Shop_date from shopInfo "); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = id; CdHotelManage.Model.shopInfo model = new CdHotelManage.Model.shopInfo(); 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 = ds.Tables[0].Rows[0]["id"].ToString(); } if (ds.Tables[0].Rows[0]["shop_Name"] != null && ds.Tables[0].Rows[0]["shop_Name"].ToString() != "") { model.shop_Name = ds.Tables[0].Rows[0]["shop_Name"].ToString(); } if (ds.Tables[0].Rows[0]["shop_LxMan"] != null && ds.Tables[0].Rows[0]["shop_LxMan"].ToString() != "") { model.shop_LxMan = ds.Tables[0].Rows[0]["shop_LxMan"].ToString(); } if (ds.Tables[0].Rows[0]["Shop_Telphone"] != null && ds.Tables[0].Rows[0]["Shop_Telphone"].ToString() != "") { model.Shop_Telphone = ds.Tables[0].Rows[0]["Shop_Telphone"].ToString(); } if (ds.Tables[0].Rows[0]["Shop_chuanzen"] != null && ds.Tables[0].Rows[0]["Shop_chuanzen"].ToString() != "") { model.Shop_chuanzen = ds.Tables[0].Rows[0]["Shop_chuanzen"].ToString(); } if (ds.Tables[0].Rows[0]["Shop_Province"] != null && ds.Tables[0].Rows[0]["Shop_Province"].ToString() != "") { model.Shop_Province = ds.Tables[0].Rows[0]["Shop_Province"].ToString(); } if (ds.Tables[0].Rows[0]["Shop_City"] != null && ds.Tables[0].Rows[0]["Shop_City"].ToString() != "") { model.Shop_City = ds.Tables[0].Rows[0]["Shop_City"].ToString(); } if (ds.Tables[0].Rows[0]["Shop_Area"] != null && ds.Tables[0].Rows[0]["Shop_Area"].ToString() != "") { model.Shop_Area = ds.Tables[0].Rows[0]["Shop_Area"].ToString(); } if (ds.Tables[0].Rows[0]["Shop_Address"] != null && ds.Tables[0].Rows[0]["Shop_Address"].ToString() != "") { model.Shop_Address = ds.Tables[0].Rows[0]["Shop_Address"].ToString(); } if (ds.Tables[0].Rows[0]["Shop_x"] != null && ds.Tables[0].Rows[0]["Shop_x"].ToString() != "") { model.Shop_x = ds.Tables[0].Rows[0]["Shop_x"].ToString(); } if (ds.Tables[0].Rows[0]["Shop_y"] != null && ds.Tables[0].Rows[0]["Shop_y"].ToString() != "") { model.Shop_y = ds.Tables[0].Rows[0]["Shop_y"].ToString(); } if (ds.Tables[0].Rows[0]["Shop_Remaker"] != null && ds.Tables[0].Rows[0]["Shop_Remaker"].ToString() != "") { model.Shop_Remaker = ds.Tables[0].Rows[0]["Shop_Remaker"].ToString(); } if (ds.Tables[0].Rows[0]["Shop_date"] != null && ds.Tables[0].Rows[0]["Shop_date"].ToString() != "") { model.Shop_date = DateTime.Parse(ds.Tables[0].Rows[0]["Shop_date"].ToString()); } return(model); } else { return(null); } }