public List <Tunnel.Model.Tunnel_Cfile> GetList(PageBase pb, ref int count) { DataTable dt = dal.GetList(pb, ref count).Tables[0]; List <Tunnel.Model.Tunnel_Cfile> modelList = new List <Tunnel.Model.Tunnel_Cfile>(); int rowsCount = dt.Rows.Count; if (rowsCount > 0 && pb.DoCount == 0) { Tunnel.Model.Tunnel_Cfile model; for (int n = 0; n < rowsCount; n++) { model = new Tunnel.Model.Tunnel_Cfile(); model.f_id = Convert.ToInt64(dt.Rows[n]["f_id"].ToString()); model.f_title = dt.Rows[n]["f_title"].ToString(); model.f_file = dt.Rows[n]["f_file"].ToString(); model.f_type = Convert.ToInt32(dt.Rows[n]["f_type"].ToString()); if (dt.Rows[n]["f_date"].ToString() != "") { model.f_date = DateTime.Parse(dt.Rows[n]["f_date"].ToString()); } if (dt.Rows[n]["f_user"].ToString() != "") { model.f_user = int.Parse(dt.Rows[n]["f_user"].ToString()); } modelList.Add(model); } } return(modelList); }
/// <summary> /// 获得数据列表 /// </summary> public List <Tunnel.Model.Tunnel_Cfile> DataTableToList(DataTable dt) { List <Tunnel.Model.Tunnel_Cfile> modelList = new List <Tunnel.Model.Tunnel_Cfile>(); int rowsCount = dt.Rows.Count; if (rowsCount > 0) { Tunnel.Model.Tunnel_Cfile model; for (int n = 0; n < rowsCount; n++) { model = new Tunnel.Model.Tunnel_Cfile(); //model.f_id=dt.Rows[n]["f_id"].ToString(); model.f_title = dt.Rows[n]["f_title"].ToString(); if (dt.Rows[n]["f_type"].ToString() != "") { model.f_type = int.Parse(dt.Rows[n]["f_type"].ToString()); } model.f_content = dt.Rows[n]["f_content"].ToString(); model.f_file = dt.Rows[n]["f_file"].ToString(); //model.f_first=dt.Rows[n]["f_first"].ToString(); model.f_other = dt.Rows[n]["f_other"].ToString(); if (dt.Rows[n]["f_date"].ToString() != "") { model.f_date = DateTime.Parse(dt.Rows[n]["f_date"].ToString()); } modelList.Add(model); } } return(modelList); }
/// <summary> /// 获得数据列表 /// </summary> //public DataSet GetList(int PageSize,int PageIndex,string strWhere) //{ //return dal.GetList(PageSize,PageIndex,strWhere); //} #endregion 成员方法 public List <Tunnel.Model.Tunnel_Cfile> GetList(PageBase pb, int uid, ref int count) { DataTable dt = dal.GetList(pb, ref count).Tables[0]; List <Tunnel.Model.Tunnel_Cfile> modelList = new List <Tunnel.Model.Tunnel_Cfile>(); int rowsCount = dt.Rows.Count; if (rowsCount > 0 && pb.DoCount == 0) { Tunnel.Model.Tunnel_Cfile model; for (int n = 0; n < rowsCount; n++) { bool isreaed = false; model = new Tunnel.Model.Tunnel_Cfile(); model.f_id = Convert.ToInt64(dt.Rows[n]["f_id"].ToString()); model.f_title = dt.Rows[n]["f_title"].ToString(); model.f_file = dt.Rows[n]["f_file"].ToString(); model.f_type = Convert.ToInt32(dt.Rows[n]["f_type"].ToString()); if (dt.Rows[n]["f_date"].ToString() != "") { model.f_date = DateTime.Parse(dt.Rows[n]["f_date"].ToString()); } if (dt.Rows[n]["f_user"].ToString() != "") { model.f_user = int.Parse(dt.Rows[n]["f_user"].ToString()); } if (dt.Rows[n]["f_first"].ToString() != "") { model.f_first = int.Parse(dt.Rows[n]["f_first"].ToString()); } if ((uid != model.f_first || model.f_first == 0)) { DataSet ds = Tunnel.Data.DbHelperSQL.Query("select * from Tunnel_cView where c_fid=" + model.f_id); foreach (DataRow dr in ds.Tables[0].Rows) { if (model.f_first.ToString().Equals(dr["c_uid"].ToString())) { if (dr["c_read"].ToString() == "1") { isreaed = true; } } if (isreaed || model.f_first == 0) { if (uid.ToString() == dr["c_uid"].ToString()) { modelList.Add(model); } } } } else { modelList.Add(model); } } } return(modelList); }
void ShowInit() { if (!string.IsNullOrEmpty(Request.Params["File_Id"])) { Tunnel.BLL.Tunnel_Cfile tf = new Tunnel.BLL.Tunnel_Cfile(); Tunnel.Model.Tunnel_Cfile mf = new Tunnel.Model.Tunnel_Cfile(); mf = tf.GetModel(Convert.ToInt32(Request.Params["File_Id"])); Label1.Text = mf.f_title; Label2.Text = mf.f_content; ul.UsbnLogin = ul.getUserModel(mf.f_user); Label3.Text = "发布人:" + ul.UsbnLogin.m_name + " 发布时间:" + mf.f_date.ToString(); file = getFile(mf.f_file); DataSet ds = tc.GetList("c_fid=" + mf.f_id + " order by c_id asc"); Repeater1.DataSource = ds; Repeater1.DataBind(); } }
/// <summary> /// 更新一条数据 /// </summary> public void Update(Tunnel.Model.Tunnel_Cfile model) { dal.Update(model); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Tunnel.Model.Tunnel_Cfile model) { return(dal.Add(model)); }
/// <summary> /// 上传文件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Button1_Click(object sender, EventArgs e) { try { //获得所需参数 string strTitle = tb_Title.Text.Trim(); HttpPostedFile hpf = file1.PostedFile; if (Convert.ToDouble(hpf.ContentLength) / 1024 / 1024 > 10) { Response.Write("<script>alert('附件大小不能大于10MB');</script>"); return; } else { CreateMdAndFilePaht(hpf); } Tunnel.BLL.Tunnel_Cfile tc = new Tunnel.BLL.Tunnel_Cfile(); Tunnel.BLL.Tunnel_CView tv = new Tunnel.BLL.Tunnel_CView(); Tunnel.Model.Tunnel_Cfile mc = new Tunnel.Model.Tunnel_Cfile(); Tunnel.Model.Tunnel_CView mv = new Tunnel.Model.Tunnel_CView(); mc.f_title = tb_Title.Text.Trim(); mc.f_type = Convert.ToInt32(DropDownList1.SelectedValue); mc.f_date = DateTime.Now; mc.f_content = tb_content.Value; mc.f_file = filePaht; mc.f_user = ul.LoginID; if (!string.IsNullOrEmpty(first_value.Value)) { mc.f_first = Convert.ToInt32(first_value.Value); } else { mc.f_first = 0; } string userlist = m_value.Value; mc.f_other = userlist; int s = tc.Add(mc); if (!string.IsNullOrEmpty(first_value.Value)) { mv.c_fid = s; mv.c_read = 0; mv.c_uid = Convert.ToInt32(first_value.Value); mv.c_content = ""; tv.Add(mv); } string[] users = userlist.Split(','); foreach (string user in users) { if (!string.IsNullOrEmpty(user)) { mv.c_fid = s; mv.c_read = 0; mv.c_uid = Convert.ToInt32(user); mv.c_content = ""; tv.Add(mv); } } Tunnel.Common.Message.Show("保存成功"); } catch { Tunnel.Common.Message.back("系统故障,请与管理员联系"); } }