//查询以发布的加盟信息 public List <JoininforModel> joininfors() { string sql = "select*from joininfor WHERE Jdelete is null"; SqlDataReader reader = SQLHelper.ExecuteReader(sql); List <JoininforModel> joininfors = new List <JoininforModel>(); if (reader.HasRows) { while (reader.Read()) { JoininforModel model = new JoininforModel(); model.JId = Convert.ToInt32(reader["JId"]); model.Jname = reader["Jname"].ToString(); model.Jprice = reader["Jprice"].ToString(); model.Jperson = Convert.ToInt32(reader["Jperson"]); model.Jclassification = reader["Jclassification"].ToString(); model.Jtime = Convert.ToDateTime(reader["Jtime"]); model.JToapplyfor = Convert.ToInt32(reader["JToapplyfor"]); model.Jshow = Convert.ToInt32(reader["Jshow"]); joininfors.Add(model); } reader.Close(); } return(joininfors); }
//添加加盟项目 public int Addjoininfor(JoininforModel model) { string sql = "insert into joininfor values(@Jname,@Jprice,@Jperson,@Jother,0,getdate(),@mId,'河南郑州',@Jintroduce,@Jsquare,@Jclassification,0,null,@Jlogo)"; SqlParameter[] Parameters = { new SqlParameter("@Jname", model.Jname), new SqlParameter("@Jprice", model.Jprice), new SqlParameter("@Jperson", model.Jperson), new SqlParameter("@Jother", model.Jother), new SqlParameter("@mId", model.mId), new SqlParameter("@Jintroduce", model.Jintroduce), new SqlParameter("@Jsquare", model.Jsquare), new SqlParameter("@Jclassification", model.Jclassification), new SqlParameter("@Jlogo", model.Jlogo) }; int count = SQLHelper.ExecuteNonQuery(sql, Parameters); return(count); }
//查询 public List <JoininforModel> Thequery(string Jname) { StringBuilder stringBuilder = new StringBuilder("SELECT * FROM dbo.joininfor WHERE Jdelete IS NULL "); List <SqlParameter> parameters = new List <SqlParameter>(); List <string> Wherelist = new List <string>(); if (!string.IsNullOrWhiteSpace(Jname)) { Wherelist.Add("Jname=@Jname"); parameters.Add(new SqlParameter("@Jname", Jname)); } if (Wherelist.Count > 0) { string pj = string.Join(" and ", Wherelist.ToArray()); stringBuilder.Append($" and {pj}"); } SqlDataReader reader = SQLHelper.ExecuteReader(stringBuilder.ToString(), parameters.ToArray()); List <JoininforModel> joininfors = new List <JoininforModel>(); if (reader.HasRows) { while (reader.Read()) { JoininforModel model = new JoininforModel(); model.JId = Convert.ToInt32(reader["JId"]); model.Jname = reader["Jname"].ToString(); model.Jprice = reader["Jprice"].ToString(); model.Jperson = Convert.ToInt32(reader["Jperson"]); model.Jclassification = reader["Jclassification"].ToString(); model.Jtime = Convert.ToDateTime(reader["Jtime"]); model.JToapplyfor = Convert.ToInt32(reader["JToapplyfor"]); model.Jshow = Convert.ToInt32(reader["Jshow"]); joininfors.Add(model); } reader.Close(); } return(joininfors); }
//protected void rptTruckList_ItemDataBound(object sender, RepeaterItemEventArgs e) //{ // if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) // { // HtmlTableCell cell = null; // LogisticsAdmin.Model.TruckListModel truck = new TruckListModel(); // truck = (TruckListModel)e.Item.DataItem; // cell = e.Item.FindControl("tbState") as HtmlTableCell; // switch (truck.State) // { // case 1: // cell.InnerHtml = "<font color='red'>承运中<font>"; // break; // case 2: // cell.InnerHtml = "空闲中"; // break; // default: // break; // } // } //} protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { HtmlTableCell cell = null; JoininforModel truck = new JoininforModel(); truck = (JoininforModel)e.Item.DataItem; cell = e.Item.FindControl("JshowId") as HtmlTableCell; switch (truck.Jshow) { case 1: cell.InnerHtml = "<font color='red'>展示<font>"; break; case 0: cell.InnerHtml = "关闭"; break; default: break; } } }
protected void Upload_Click(object sender, EventArgs e) { string filepath = Session["filename"].ToString(); JoininforModel model = new JoininforModel(); model.Jlogo = "\\images\\" + filepath; model.Jname = TxtJname.Value; model.Jintroduce = TxtJintroduce.Value; model.Jprice = TxtJprice.Value; model.Jperson = Convert.ToInt32(TxtJperson.Value); model.Jsquare = Convert.ToInt32(TxtJsquare.Value); model.Jclassification = TxtJclassification.Value; model.Jother = TxtJother.Value; model.mId = Convert.ToInt32(Session["Mid"]); JoinTheManagementBLL bLL = new JoinTheManagementBLL(); int count = bLL.Addjoininfor(model); if (count > 0) { JSHelper.Alert(this, "添加成功"); } }
//添加加盟项目 public int Addjoininfor(JoininforModel model) { JoinTheManagementDAL joinThe = new JoinTheManagementDAL(); return(joinThe.Addjoininfor(model)); }