/// <summary> /// 根据条件得到列表 /// </summary> /// <param name="strWhere"></param> /// <returns></returns> public List<ShowShop.Model.SystemInfo.ArticleChannel> GetAllByWhere(string strWhere) { List<ShowShop.Model.SystemInfo.ArticleChannel> list = new List<ShowShop.Model.SystemInfo.ArticleChannel>(); StringBuilder strSql = new StringBuilder(); strSql.Append("select Id,Name,Shop,Users,Description,Type,ProjectName,ProjectUtil,Target,ExternalLink,MeteKey,MeteDescription,Power from yxs_articlechannel "); if (strWhere != null && strWhere != "") { strSql.Append("where " + strWhere + " "); } using (SqlDataReader reader = ChangeHope.DataBase.SQLServerHelper.ExecuteReader(strSql.ToString())) { while (reader.Read()) { ShowShop.Model.SystemInfo.ArticleChannel model = new ShowShop.Model.SystemInfo.ArticleChannel(); model.Id = reader["Id"].ToString(); model.Name = reader["Name"].ToString(); model.Shop = reader["Shop"].ToString(); model.Users = reader["Users"].ToString(); model.Description = reader["Description"].ToString(); model.Type = reader["Type"].ToString(); model.ProjectName = reader["ProjectName"].ToString(); model.ProjectUtil = reader["ProjectUtil"].ToString(); model.Target = reader["Target"].ToString(); model.ExternalLink = reader["ExternalLink"].ToString(); model.MeteKey = reader["MeteKey"].ToString(); model.MeteDescription = reader["MeteDescription"].ToString(); model.Power = reader["Power"].ToString(); list.Add(model); } } return list; }
/// <summary> /// 得到一个对象实体 /// </summary> public ShowShop.Model.SystemInfo.ArticleChannel GetModel(string Id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 Id,Name,Shop,Users,Description,Type,ProjectName,ProjectUtil,Target,ExternalLink,MeteKey,MeteDescription,Power,[DefaultTemplate], [ListTemplate], [ContentTemplate] from yxs_articlechannel "); strSql.Append(" where Id=@Id "); SqlParameter[] parameters = { new SqlParameter("@Id", SqlDbType.VarChar,50)}; parameters[0].Value = Id; ShowShop.Model.SystemInfo.ArticleChannel model = new ShowShop.Model.SystemInfo.ArticleChannel(); DataSet ds = ChangeHope.DataBase.SQLServerHelper.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { model.Id = ds.Tables[0].Rows[0]["Id"].ToString(); model.Name = ds.Tables[0].Rows[0]["Name"].ToString(); model.Shop = ds.Tables[0].Rows[0]["Shop"].ToString(); model.Users = ds.Tables[0].Rows[0]["Users"].ToString(); model.Description = ds.Tables[0].Rows[0]["Description"].ToString(); model.Type = ds.Tables[0].Rows[0]["Type"].ToString(); model.ProjectName = ds.Tables[0].Rows[0]["ProjectName"].ToString(); model.ProjectUtil = ds.Tables[0].Rows[0]["ProjectUtil"].ToString(); model.Target = ds.Tables[0].Rows[0]["Target"].ToString(); model.ExternalLink = ds.Tables[0].Rows[0]["ExternalLink"].ToString(); model.MeteKey = ds.Tables[0].Rows[0]["MeteKey"].ToString(); model.MeteDescription = ds.Tables[0].Rows[0]["MeteDescription"].ToString(); model.Power = ds.Tables[0].Rows[0]["Power"].ToString(); model.DefaultTemplate = ds.Tables[0].Rows[0]["DefaultTemplate"].ToString(); model.ListTemplate = ds.Tables[0].Rows[0]["ListTemplate"].ToString(); model.ContentTemplate = ds.Tables[0].Rows[0]["ContentTemplate"].ToString(); return model; } else { return null; } }
private void Save() { ShowShop.BLL.SystemInfo.ArticleChannel bll = new ShowShop.BLL.SystemInfo.ArticleChannel(); Model.SystemInfo.ArticleChannel model = new ShowShop.Model.SystemInfo.ArticleChannel(); model.Description = this.txtDescription.Text; model.Name = this.txtName.Text; model.Shop = this.txtShop.SelectedValue; model.Type = this.ckbType.SelectedValue; model.ProjectName = this.txtProjectName.Text; model.ProjectUtil = this.txtProjectUtil.Text; model.Target = this.ckbTarget.SelectedValue; model.ExternalLink = this.txtAddress.Text.Trim().ToString(); model.MeteKey = this.txtMeteKey.Text; model.MeteDescription = this.txtMeteDescription.Text; model.DefaultTemplate = this.txtWebPagePath.Text; model.ListTemplate = this.txtListPageTemplate.Text; model.ContentTemplate = this.txtContentPageTemplate.Text; model.Power = ""; foreach (ListItem item in this.ckbPower.Items) { if (item.Selected) { model.Power = model.Power + item.Value+ ","; } } if(this.txtId.Value.Equals("")) { this.txtId.Value = bll.GetMaxId(this.txtParentId.Value); } model.Id = txtId.Value; ShowShop.Model.Admin.AdminInfo adminInfo = (ShowShop.Model.Admin.AdminInfo)ShowShop.Common.AdministrorManager.Get(); if (adminInfo != null) { model.Users = adminInfo.AdminName; } if (bll.Exists(model.Id)) { bll.Update(model); } else { bll.Add(model); } model = null; bll = null; }