/// <summary> /// 获得数据列表 /// </summary> public List <Tunnel.Model.Tunnel_MingXing> DataTableToList(DataTable dt) { List <Tunnel.Model.Tunnel_MingXing> modelList = new List <Tunnel.Model.Tunnel_MingXing>(); int rowsCount = dt.Rows.Count; if (rowsCount > 0) { Tunnel.Model.Tunnel_MingXing model; for (int n = 0; n < rowsCount; n++) { model = new Tunnel.Model.Tunnel_MingXing(); if (dt.Rows[n]["m_id"].ToString() != "") { model.m_id = int.Parse(dt.Rows[n]["m_id"].ToString()); } if (dt.Rows[n]["m_uid"].ToString() != "") { model.m_uid = int.Parse(dt.Rows[n]["m_uid"].ToString()); } model.m_img = dt.Rows[n]["m_img"].ToString(); model.m_content = dt.Rows[n]["m_content"].ToString(); model.Title = dt.Rows[n]["m_title"].ToString(); if (dt.Rows[n]["m_year"].ToString() != "") { model.m_year = int.Parse(dt.Rows[n]["m_year"].ToString()); } if (dt.Rows[n]["m_moon"].ToString() != "") { model.m_moon = int.Parse(dt.Rows[n]["m_moon"].ToString()); } modelList.Add(model); } } return(modelList); }
protected void btnSave_Click(object sender, EventArgs e) { //if (FileUpload1.HasFile) //{ // string ext = System.IO.Path.GetExtension(FileUpload1.FileName); // ext = ext.ToLower(); // if (ext == ".jpg" || ext == ".bmp" || ext == ".gif") // { if (FreeTextBox1.Value.Length > 0) { string tempdel = string.Empty; Tunnel.BLL.Tunnel_MingXing tmx = new Tunnel.BLL.Tunnel_MingXing(); Tunnel.Model.Tunnel_MingXing tmxx = new Tunnel.Model.Tunnel_MingXing(); //if (tmx.GetModelList("m_year=" + text1.Value.Split('-')[0] + " and m_moon=" + text1.Value.Split('-')[1] + "").Count > 0) //{ // tempdel = tmx.GetModelList("m_year=" + text1.Value.Split('-')[0] + " and m_moon=" + text1.Value.Split('-')[1] + "")[0].m_id.ToString(); //} tmxx.Title = txtUser.Text.Trim(); tmxx.m_year = Convert.ToInt32(text1.Value.Split('-')[0]); tmxx.m_moon = Convert.ToInt32(text1.Value.Split('-')[1]); tmxx.m_content = FreeTextBox1.Value; tmxx.m_uid = ul.LoginID; string date = DateTime.Now.ToFileTime().ToString(); //if (!Directory.Exists(Server.MapPath("mx"))) //{ // Directory.CreateDirectory(Server.MapPath("mx")); //} //FileUpload1.SaveAs(Server.MapPath("mx/" + date + ".jpg")); tmxx.m_img = ""; //"mx/" + date + ".jpg"; try { if (tmx.Add(tmxx) > 0) { Tunnel.Common.Message.Show("添加成功!", "StarManage.aspx"); } } catch (Exception) { } //if (tempdel.Length > 0) //{ // Del(Convert.ToInt32(tempdel)); //} } //else //{ // Tunnel.Common.Message.Show("请输入内容!", "StarAdd.aspx"); //} //} //else //{ // Tunnel.Common.Message.Show("请上传JPG、BMP、GIF图片!", "StarAdd.aspx"); //} //} }
public void PageBind() { Tunnel.BLL.Tunnel_MingXing tmx = new Tunnel.BLL.Tunnel_MingXing(); Tunnel.Model.Tunnel_MingXing tmxx = new Tunnel.Model.Tunnel_MingXing(); List <Tunnel.Model.Tunnel_MingXing> tmxxList = new List <Tunnel.Model.Tunnel_MingXing>(); tmxxList = tmx.GetModelList("1=1 order by m_id desc"); Repeater1.DataSource = tmxxList; Repeater1.DataBind(); }
public void PageBind() { string tmpUid = string.Empty; tmxx = tmx.GetModel(Convert.ToInt32(id)); if (tmxx != null) { txtTitle.Text = tmxx.Title.ToString(); tmpUid = tmxx.m_uid.ToString(); Label2.Text = tmxx.m_year.ToString(); Label3.Text = tmxx.m_moon.ToString(); FreeTextBox1.Value = tmxx.m_content; } //Tunnel.BLL.Tunnel_menber tm = new Tunnel.BLL.Tunnel_menber(); //Tunnel.Model.Tunnel_menber tmm = new Tunnel.Model.Tunnel_menber(); //tmm = tm.GetModel(Convert.ToInt64(tmpUid)); //if (tmm != null) //{ // Label1.Text = tmm.m_name; //} }
public void showHtml(int d) { Tunnel.BLL.Tunnel_MingXing tmx = new Tunnel.BLL.Tunnel_MingXing(); Tunnel.Model.Tunnel_MingXing tmxx = new Tunnel.Model.Tunnel_MingXing(); List <Tunnel.Model.Tunnel_MingXing> tmxxList = new List <Tunnel.Model.Tunnel_MingXing>(); if (d == -1) { tmxxList = tmx.GetModelList(" 1=1 order by Convert(datetime,str(m_year)+'-'+str(M_moon)+'-'+'01') desc"); if (tmxxList.Count > 0) { d = tmxxList[0].m_id; } } tmxxList = tmx.GetModelList("m_id = " + d + ""); for (int i = 0; i < tmxxList.Count; i++) { Tunnel.BLL.Tunnel_menber tm = new Tunnel.BLL.Tunnel_menber(); Tunnel.Model.Tunnel_menber tmm = new Tunnel.Model.Tunnel_menber(); tmm = tm.GetModel(Convert.ToInt64(tmxxList[i].m_uid)); if (tmm != null) { name = tmm.m_name; Tunnel.BLL.Tunnel_bum tb = new Tunnel.BLL.Tunnel_bum(); Tunnel.Model.Tunnel_bum tbb = new Tunnel.Model.Tunnel_bum(); tbb = tb.GetModel(Convert.ToInt64(tmm.m_bum)); if (tbb != null) { bum = tbb.b_name; } } title = tmxxList[i].Title.ToString(); year = tmxxList[i].m_year.ToString(); moon = tmxxList[i].m_moon.ToString(); img = "../N_MyWork/N_Star/" + tmxxList[i].m_img; content = tmxxList[i].m_content; } lblcontent.Text = content; string dateStr = string.Empty; string tempYear = year; string tempMoon = moon; string tempSql = @" select * from (select top 4 * from (select top 4 * from tunnel_mingxing where Convert(datetime,lTRIM(str(m_year))+'-'+ltrim(str(m_moon))+'-'+'01') <substring(Convert(varchar,'" + year + "-" + (moon.Length == 1 ? "0" + moon : moon) + "-01" + @"',20),0,8)+'-01' order by Convert(datetime,lTRIM(str(m_year))+'-'+ltrim(str(m_moon))+'-'+'01') desc) as bb order by Convert(datetime,lTRIM(str(m_year))+'-'+ltrim(str(m_moon))+'-'+'01')) as tunnel_mingxing union all select * from (select top 1 * from tunnel_mingxing where Convert(datetime,lTRIM(str(m_year))+'-'+ltrim(str(m_moon))+'-'+'01') =substring(Convert(varchar,'" + year + "-" + (moon.Length == 1 ? "0" + moon : moon) + "-01" + @"',20),0,8)+'-01' ) as tunnel_mingxing union all select * from (select top 4 * from tunnel_mingxing where Convert(datetime,lTRIM(str(m_year))+'-'+ltrim(str(m_moon))+'-'+'01') >substring(Convert(varchar,'" + year + "-" + (moon.Length == 1 ? "0" + moon : moon) + "-01" + @"',20),0,8)+'-01' ) as tunnel_mingxing "; DataSet ds = Tunnel.Data.DbHelperSQL.Query(tempSql); tmxxList = tmx.DataTableToList(ds.Tables[0]); foreach (Tunnel.Model.Tunnel_MingXing item in tmxxList) { if (item.m_year == Convert.ToInt32(year) && Convert.ToInt32(item.m_moon) == Convert.ToInt32(moon)) { dateStr += "<a href=?id=" + item.m_id + "><font color=\"red\" style=\"14px\" >" + item.m_year + "-" + item.m_moon + "</font></a> "; } else { dateStr += "<a href=?id=" + item.m_id + "><font color=\"black\" style=\"12px\" >" + item.m_year + "-" + item.m_moon + "</font></a> "; } } //Label1.Text = dateStr; }
/// <summary> /// 更新一条数据 /// </summary> public void Update(Tunnel.Model.Tunnel_MingXing model) { dal.Update(model); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Tunnel.Model.Tunnel_MingXing model) { return(dal.Add(model)); }
/// <summary> /// 明星员工 /// </summary> /// <param name="d"></param> public void showHtml(int d) { Tunnel.BLL.Tunnel_MingXing tmx = new Tunnel.BLL.Tunnel_MingXing(); Tunnel.Model.Tunnel_MingXing tmxx = new Tunnel.Model.Tunnel_MingXing(); List <Tunnel.Model.Tunnel_MingXing> tmxxList = new List <Tunnel.Model.Tunnel_MingXing>(); if (d == -1) { tmxxList = tmx.GetModelList(" 1=1 order by Convert(datetime,str(m_year)+'-'+str(M_moon)+'-'+'01') desc"); if (tmxxList.Count > 0) { d = tmxxList[0].m_id; } } tmxxList = tmx.GetModelList("m_id = " + d + ""); for (int i = 0; i < tmxxList.Count; i++) { Tunnel.BLL.Tunnel_menber tm = new Tunnel.BLL.Tunnel_menber(); Tunnel.Model.Tunnel_menber tmm = new Tunnel.Model.Tunnel_menber(); tmm = tm.GetModel(Convert.ToInt64(tmxxList[i].m_uid)); if (tmm != null) { name = tmm.m_name; Tunnel.BLL.Tunnel_bum tb = new Tunnel.BLL.Tunnel_bum(); Tunnel.Model.Tunnel_bum tbb = new Tunnel.Model.Tunnel_bum(); tbb = tb.GetModel(Convert.ToInt64(tmm.m_bum)); if (tbb != null) { bum = tbb.b_name; if (!string.IsNullOrEmpty(bum)) { if (bum.Length > 8) { bum = bum.Substring(0, 8); } } } Tunnel.BLL.Tunnel_duty td = new Tunnel.BLL.Tunnel_duty(); Tunnel.Model.Tunnel_duty tdd = new Tunnel.Model.Tunnel_duty(); tdd = td.GetModel(Convert.ToInt64(tmm.m_duty)); if (tdd != null) { duty = tdd.d_name; } } year = tmxxList[i].m_year.ToString(); moon = tmxxList[i].m_moon.ToString(); img = "N_MyWork/N_Star/" + tmxxList[i].m_img; mxId = tmxxList[i].m_id.ToString(); } string tempYear = DateTime.Now.AddMonths(-12).Year.ToString(); string tempMoon = DateTime.Now.AddMonths(-12).Month.ToString(); tmxxList = tmx.GetModelList("m_year >= " + tempYear + " order by Convert(datetime,str(m_year)+'-'+str(M_moon)+'-'+'01') asc"); int count = 0; foreach (Tunnel.Model.Tunnel_MingXing item in tmxxList) { if (item.m_moon >= Convert.ToInt32(tempMoon) || item.m_year != DateTime.Now.Year) { content += "<a href=?id=" + item.m_id + ">" + item.m_year + "-" + item.m_moon + "</a> "; count++; } if (count > 1) { break; } } }
/// <summary> /// 喜报 /// </summary> /// <param name="d"></param> public void showHtml(int d) { Tunnel.BLL.Tunnel_MingXing tmx = new Tunnel.BLL.Tunnel_MingXing(); Tunnel.Model.Tunnel_MingXing tmxx = new Tunnel.Model.Tunnel_MingXing(); List <Tunnel.Model.Tunnel_MingXing> tmxxList = new List <Tunnel.Model.Tunnel_MingXing>(); #region 无用 //if (d == -1) //{ // //tmxxList = tmx.GetModelList(" 1=1 order by Convert(datetime,str(m_year)+'-'+str(M_moon)+'-'+'01') desc"); // tmxxList = tmx.GetModelList(" 1=1 order by m_id desc"); // if (tmxxList.Count > 0) // { // d = tmxxList[0].m_id; // } //} //tmxxList = tmx.GetModelList("m_id = " + d + ""); #endregion tmxxList = tmx.GetModelMingXIng(" 1=1 order by m_id desc"); //Title = "<Table><tr>"; for (int i = 0; i < tmxxList.Count; i++) { Tunnel.BLL.Tunnel_menber tm = new Tunnel.BLL.Tunnel_menber(); Tunnel.Model.Tunnel_menber tmm = new Tunnel.Model.Tunnel_menber(); #region 无用 //tmm = tm.GetModel(Convert.ToInt64(tmxxList[i].m_uid)); //if (tmm != null) //{ // name = tmm.m_name; // Tunnel.BLL.Tunnel_bum tb = new Tunnel.BLL.Tunnel_bum(); // Tunnel.Model.Tunnel_bum tbb = new Tunnel.Model.Tunnel_bum(); // tbb = tb.GetModel(Convert.ToInt64(tmm.m_bum)); // if (tbb != null) // { // bum = tbb.b_name; // if (!string.IsNullOrEmpty(bum)) // { // if (bum.Length > 8) // { // bum = bum.Substring(0, 8); // } // } // } // Tunnel.BLL.Tunnel_duty td = new Tunnel.BLL.Tunnel_duty(); // Tunnel.Model.Tunnel_duty tdd = new Tunnel.Model.Tunnel_duty(); // tdd = td.GetModel(Convert.ToInt64(tmm.m_duty)); // if (tdd != null) // { // duty = tdd.d_name; // } //} #endregion string sTitle = tmxxList[i].Title.ToString() + " "; year = tmxxList[i].m_year.ToString(); moon = tmxxList[i].m_moon.ToString(); img = "N_MyWork/N_Star/" + tmxxList[i].m_img; mxId = tmxxList[i].m_id.ToString(); string str = "/N_Right/XiBao.aspx?id=" + mxId; //Title += string.Format("<td><a href='{0}'> <font color='#003300' size='4'><center>{1}</center></font></a></td>", str, sTitle); Title += string.Format("<a href='{0}'> <font color='#003300' size='4'><center>{1}</center></font></a>", str, sTitle); } //Title += "</tr></table>"; #region 无用 //string tempYear = DateTime.Now.AddMonths(-12).Year.ToString(); //string tempMoon = DateTime.Now.AddMonths(-12).Month.ToString(); //tmxxList = tmx.GetModelList("m_year >= " + tempYear + " order by Convert(datetime,str(m_year)+'-'+str(M_moon)+'-'+'01') asc"); //int count = 0; //foreach (Tunnel.Model.Tunnel_MingXing item in tmxxList) //{ // if (item.m_moon >= Convert.ToInt32(tempMoon) || item.m_year != DateTime.Now.Year) // { // content += "<a href=?id=" + item.m_id + ">" + item.m_year + "-" + item.m_moon + "</a> "; // count++; // } // if (count > 1) // break; //} #endregion }