Ejemplo n.º 1
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List <Tunnel.Model.Tunnel_CView> DataTableToList(DataTable dt)
        {
            List <Tunnel.Model.Tunnel_CView> modelList = new List <Tunnel.Model.Tunnel_CView>();
            int rowsCount = dt.Rows.Count;

            if (rowsCount > 0)
            {
                Tunnel.Model.Tunnel_CView model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new Tunnel.Model.Tunnel_CView();
                    //model.c_id=dt.Rows[n]["c_id"].ToString();
                    //model.c_fid=dt.Rows[n]["c_fid"].ToString();
                    //model.c_uid=dt.Rows[n]["c_uid"].ToString();
                    if (dt.Rows[n]["c_read"].ToString() != "")
                    {
                        model.c_read = int.Parse(dt.Rows[n]["c_read"].ToString());
                    }
                    if (dt.Rows[n]["c_readdate"].ToString() != "")
                    {
                        model.c_readdate = DateTime.Parse(dt.Rows[n]["c_readdate"].ToString());
                    }
                    model.c_content = dt.Rows[n]["c_content"].ToString();
                    modelList.Add(model);
                }
            }
            return(modelList);
        }
Ejemplo n.º 2
0
    /// <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("系统故障,请与管理员联系");
        }
    }
Ejemplo n.º 3
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public void Update(Tunnel.Model.Tunnel_CView model)
 {
     dal.Update(model);
 }
Ejemplo n.º 4
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int  Add(Tunnel.Model.Tunnel_CView model)
 {
     return(dal.Add(model));
 }