Пример #1
0
        /// <summary>
        ///  增加一条数据
        /// </summary>
        public int Add(Tunnel.Model.Tunnel_report model)
        {
            int rowsAffected;

            SqlParameter[] parameters =
            {
                new SqlParameter("@r_id",      SqlDbType.Int,          8),
                new SqlParameter("@r_title",   SqlDbType.VarChar,    200),
                new SqlParameter("@r_file",    SqlDbType.VarChar,    100),
                new SqlParameter("@r_time",    SqlDbType.DateTime),
                new SqlParameter("@r_from",    SqlDbType.Int,          4),
                new SqlParameter("@r_user",    SqlDbType.Int,          4),
                new SqlParameter("@r_content", SqlDbType.VarChar,   2000),
                new SqlParameter("@r_toemail", SqlDbType.VarChar,    200),
                new SqlParameter("@r_ip",      SqlDbType.VarChar, 20)
            };
            parameters[0].Direction = ParameterDirection.Output;
            parameters[1].Value     = model.r_title;
            parameters[2].Value     = model.r_file;
            parameters[3].Value     = model.r_time;
            parameters[4].Value     = model.r_from;
            parameters[5].Value     = model.r_user;
            parameters[6].Value     = model.r_Content;
            parameters[7].Value     = model.r_toEmail;
            parameters[8].Value     = model.r_Ip;


            DbHelperSQL.RunProcedure("Tunnel_report_ADD", parameters, out rowsAffected);
            return((int)parameters[0].Value);
        }
Пример #2
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List <Tunnel.Model.Tunnel_report> DataTableToList(DataTable dt)
        {
            List <Tunnel.Model.Tunnel_report> modelList = new List <Tunnel.Model.Tunnel_report>();
            int rowsCount = dt.Rows.Count;

            if (rowsCount > 0)
            {
                Tunnel.Model.Tunnel_report model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model         = new Tunnel.Model.Tunnel_report();
                    model.r_id    = Convert.ToInt64(dt.Rows[n]["r_id"].ToString());
                    model.r_title = dt.Rows[n]["r_title"].ToString();
                    model.r_file  = dt.Rows[n]["r_file"].ToString();
                    if (dt.Rows[n]["r_time"].ToString() != "")
                    {
                        model.r_time = DateTime.Parse(dt.Rows[n]["r_time"].ToString());
                    }
                    if (dt.Rows[n]["r_from"].ToString() != "")
                    {
                        model.r_from = int.Parse(dt.Rows[n]["r_from"].ToString());
                    }
                    if (dt.Rows[n]["r_user"].ToString() != "")
                    {
                        model.r_user = int.Parse(dt.Rows[n]["r_user"].ToString());
                    }
                    modelList.Add(model);
                }
            }
            return(modelList);
        }
Пример #3
0
    /// <summary>
    /// 页面数据绑定
    /// </summary>
    public void PageBind()
    {
        if (Id == 0)
        {
            return;
        }
        Tunnel.Model.Tunnel_report        model     = new Tunnel.Model.Tunnel_report();
        List <Tunnel.Model.Tunnel_report> modelList = new List <Tunnel.Model.Tunnel_report>();

        model = tbll.GetModel(Id);
        modelList.Add(model);
        Repeater1.DataSource = modelList;
        Repeater1.DataBind();
    }
Пример #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Tunnel.Model.Tunnel_report GetModel(long r_id)
        {
            SqlParameter[] parameters =
            {
                new SqlParameter("@r_id", SqlDbType.BigInt)
            };
            parameters[0].Value = r_id;

            Tunnel.Model.Tunnel_report model = new Tunnel.Model.Tunnel_report();
            DataSet ds = DbHelperSQL.RunProcedure("Tunnel_report_GetModel", parameters, "ds");

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["r_id"].ToString() != "")
                {
                    model.r_id = long.Parse(ds.Tables[0].Rows[0]["r_id"].ToString());
                }
                model.r_title = ds.Tables[0].Rows[0]["r_title"].ToString();
                model.r_file  = ds.Tables[0].Rows[0]["r_file"].ToString();
                if (ds.Tables[0].Rows[0]["r_time"].ToString() != "")
                {
                    model.r_time = DateTime.Parse(ds.Tables[0].Rows[0]["r_time"].ToString());
                }
                if (ds.Tables[0].Rows[0]["r_from"].ToString() != "")
                {
                    model.r_from = int.Parse(ds.Tables[0].Rows[0]["r_from"].ToString());
                }
                if (ds.Tables[0].Rows[0]["r_user"].ToString() != "")
                {
                    model.r_user = int.Parse(ds.Tables[0].Rows[0]["r_user"].ToString());
                }
                model.r_Content = ds.Tables[0].Rows[0]["r_content"].ToString();
                model.r_toEmail = ds.Tables[0].Rows[0]["r_toemail"].ToString();
                return(model);
            }
            else
            {
                return(null);
            }
        }
Пример #5
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        /// <param name="pb">分页基本信息</param>
        /// <param name="count">返回总数</param>
        /// <returns></returns>
        public List <Tunnel.Model.Tunnel_report> GetList(PageBase pb, ref int count)
        {
            DataSet ds = dal.GetList(pb, ref count);
            List <Tunnel.Model.Tunnel_report> modelList = new List <Tunnel.Model.Tunnel_report>();
            int rowsCount = ds.Tables[0].Rows.Count;

            if (rowsCount > 0 && pb.DoCount == 0)
            {
                Tunnel.Model.Tunnel_report model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new Tunnel.Model.Tunnel_report();
                    if (ds.Tables[0].Rows[n]["r_id"].ToString() != "")
                    {
                        model.r_id = long.Parse(ds.Tables[0].Rows[n]["r_id"].ToString());
                    }
                    model.r_title = ds.Tables[0].Rows[n]["r_title"].ToString();
                    model.r_file  = ds.Tables[0].Rows[n]["r_file"].ToString();
                    if (ds.Tables[0].Rows[n]["r_time"].ToString() != "")
                    {
                        model.r_time = DateTime.Parse(ds.Tables[0].Rows[n]["r_time"].ToString());
                    }
                    if (ds.Tables[0].Rows[n]["r_from"].ToString() != "")
                    {
                        model.r_from = int.Parse(ds.Tables[0].Rows[n]["r_from"].ToString());
                    }
                    if (ds.Tables[0].Rows[n]["r_user"].ToString() != "")
                    {
                        model.r_user = int.Parse(ds.Tables[0].Rows[n]["r_user"].ToString());
                    }
                    model.r_Content = ds.Tables[0].Rows[n]["r_content"].ToString();
                    model.r_toEmail = ds.Tables[0].Rows[n]["r_toemail"].ToString();
                    modelList.Add(model);
                }
            }
            return(modelList);
        }
Пример #6
0
        /// <summary>
        ///  更新一条数据
        /// </summary>
        public void Update(Tunnel.Model.Tunnel_report model)
        {
            int rowsAffected;

            SqlParameter[] parameters =
            {
                new SqlParameter("@r_id",    SqlDbType.BigInt,      8),
                new SqlParameter("@r_title", SqlDbType.VarChar,   200),
                new SqlParameter("@r_file",  SqlDbType.VarChar,   100),
                new SqlParameter("@r_time",  SqlDbType.DateTime),
                new SqlParameter("@r_from",  SqlDbType.Int,         4),
                new SqlParameter("@r_user",  SqlDbType.Int,         4),
                new SqlParameter("@r_ip",    SqlDbType.VarChar, 20)
            };
            parameters[0].Value = model.r_id;
            parameters[1].Value = model.r_title;
            parameters[2].Value = model.r_file;
            parameters[3].Value = model.r_time;
            parameters[4].Value = model.r_from;
            parameters[5].Value = model.r_user;
            parameters[6].Value = model.r_Ip;

            DbHelperSQL.RunProcedure("Tunnel_report_Update", parameters, out rowsAffected);
        }
Пример #7
0
    /// <summary>
    /// 发送邮件并保存到服务器
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Button1_Click(object sender, EventArgs e)
    {
        //获得所需参数
        string str2 = tb_Email.Text.Trim();

        //把;替换为;
        str2 = str2.Replace(";", ";");
        //如果不是;结尾就加上

        if (!str2.EndsWith(";"))
        {
            str2 += ";";
        }
        //去除地址中的用户名

        for (int i = 0; i >= 0; i++)
        {
            int startstr = str2.IndexOf("[");
            int endstr   = str2.IndexOf("];") + 1;
            if (startstr >= 0)
            {
                str2 = str2.Remove(startstr, (endstr - startstr));
            }
            else
            {
                break;
            }
        }
        string        str3     = str2;
        List <string> strlist  = new List <string>();
        List <string> strlist2 = new List <string>();
        //根据样式获取正确的邮箱地址
        Regex           rx      = new Regex(@"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*");
        MatchCollection matches = rx.Matches(str2);

        foreach (Match var in matches)
        {
            strlist2.Add(var.Value);
        }
        for (int i = 0; i >= 0; i++)
        {
            int endstr = str3.IndexOf(";");
            if (endstr >= 0)
            {
                //截取邮箱地址
                strlist.Add(str3.Substring(0, endstr));
                str3 = str3.Remove(0, (str3.Substring(0, endstr)).Length + 1);
                if (strlist.Count <= strlist2.Count)
                {
                    //如果地址不同就代表格式不正确
                    if (strlist[i] != strlist2[i])
                    {
                        Response.Write("<script type='text/javascript'>alert('" + strlist[i] + "的格式错误')</script>");
                        return;
                    }
                    else
                    {
                        continue;
                    }
                }
            }
            else
            {
                break;
            }
        }
        string         strTitle   = "隧道OA办公系统:" + tb_Title.Text.Trim();
        string         strContent = tb_content.Text.Trim();
        HttpPostedFile hpf        = file1.PostedFile;

        if (Convert.ToDouble(hpf.ContentLength) / 1024 / 1024 > 10)
        {
            Response.Write("<script>alert('附件大小不能大于10MB');</script>");

            return;
        }
        else
        {
            CreateMdAndFilePaht();
        }
        string[] arr = new string[1];
        if (hpf.ContentLength > 0)
        {
            if (!string.IsNullOrEmpty(hpf.FileName))
            {
                fileName = fileName + System.IO.Path.GetExtension(hpf.FileName);
            }
            else
            {
                fileName = fileName + hpf.ContentType;
            }
            filePaht      = upDbFilePaht + fileName;
            fileDirectory = fileDirectory + fileName;
            arr[0]        = fileDirectory;
            hpf.SaveAs(fileDirectory);
        }
        else
        {
            filePaht = string.Empty;
        }
        int relt1 = 0;

        for (int i = 0; i < strlist.Count; i++)
        {
            //发送邮件

            SendEamil se   = new SendEamil();
            int       relt = -1;

            relt = se.SendEmail(se.NcUserEmail, strlist[i], strTitle, strContent, arr);

            //写入数据库

            Tunnel.BLL.Tunnel_report   rbll  = new Tunnel.BLL.Tunnel_report();
            Tunnel.Model.Tunnel_report model = new Tunnel.Model.Tunnel_report();
            model.r_title   = strTitle;
            model.r_Content = strContent;
            model.r_file    = filePaht;
            model.r_time    = DateTime.Now;
            model.r_user    = ul.LoginID;
            model.r_toEmail = strlist[i];
            model.r_Ip      = Tunnel.Common.Common.GetIp();
            rbll.Add(model);
            relt1++;
        }
        if (relt1 == strlist.Count)
        {
            string str = "邮件";
            string url = "N_MailManage.aspx";
            if (relt1 > 0)
            {
                str += "发送成功!";
            }
            else
            {
                str += "发送失败!";
            }

            MessageBox(str, url);
        }
    }
Пример #8
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public void Update(Tunnel.Model.Tunnel_report model)
 {
     dal.Update(model);
 }
Пример #9
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(Tunnel.Model.Tunnel_report model)
 {
     return(dal.Add(model));
 }