Example #1
0
    //添加至信息表
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (titleId == 1)
        {
            if (!"0".Equals(Request.Form["DropDownList1"]))
            {
                string title       = this.tb_Title.Text.Trim();
                int    typeid      = Convert.ToInt32(this.DropDownList1.SelectedValue);
                string htmlsourcce = this.FCKeditor.Value; // Request.Form["content1"];  //this.FCKeditor.Value;
                string imagepaht   = stringFormat(From_Content(htmlsourcce)).Trim();
                string content     = FCKeditor.Value;      //Request.Form["content1"]; //FreeTextBox1.HtmlStrippedText;
                int    userid      = ul.LoginID;
                if (!string.IsNullOrEmpty(imagepaht))
                {
                    if (imagepaht.Substring(0, 1) == "/")
                    {
                        imagepaht = imagepaht.Substring(1, imagepaht.Length - 1);
                    }
                    imagepaht = imagepaht.Replace("src=/sdoa/", "");
                }

                Tunnel.Model.Tunnel_index model = new Tunnel.Model.Tunnel_index();
                model.Id         = indexId;
                model.Title      = title;
                model.TypeId     = typeid;
                model.HtmlSource = htmlsourcce;
                model.ImagePaht  = imagepaht;
                model.Content    = content;
                model.UserId     = userid;
                HttpPostedFile hpf = file1.PostedFile;
                if (Convert.ToDouble(hpf.ContentLength) / 1024 / 1024 > 10)
                {
                    Response.Write("<script>alert('附件大小不能大于10MB');</script>");

                    return;
                }
                else
                {
                    CreateMdAndFilePaht(hpf);
                }
                model.Files = filePaht; //infofiles


                //string str = titleName;

                Tunnel.BLL.Tunnel_information bllf  = new Tunnel.BLL.Tunnel_information();
                Tunnel.BLL.Tunnel_Index       index = new Tunnel.BLL.Tunnel_Index();
                int relt = -1;
                relt = index.Update(model);
                if (relt > 0)
                {
                    Tunnel.Common.Message.Show("修改成功!", "N_InformationManage.aspx?type=" + Request.QueryString["type"]);
                }
                else
                {
                    Tunnel.Common.Message.Show("修改失败!", "N_InformationManage.aspx?type=" + Request.QueryString["type"]);
                }

                // MessageBox(str, url);
            }
            else
            {
                Tunnel.Common.Message.Show("请选择子栏目!");
            }
        }
        else
        {
            if (!"0".Equals(Request.Form["DropDownList1"]))
            {
                string title       = this.tb_Title.Text.Trim();
                int    typeid      = Convert.ToInt32(this.DropDownList1.SelectedValue);
                string htmlsourcce = this.FCKeditor.Value; // Request.Form["content1"];  //this.FCKeditor.Value;
                string imagepaht   = stringFormat(From_Content(htmlsourcce)).Trim();
                string content     = FCKeditor.Value;      //Request.Form["content1"]; //FreeTextBox1.HtmlStrippedText;
                int    userid      = ul.LoginID;
                if (!string.IsNullOrEmpty(imagepaht))
                {
                    if (imagepaht.Substring(0, 1) == "/")
                    {
                        imagepaht = imagepaht.Substring(1, imagepaht.Length - 1);
                    }
                    imagepaht = imagepaht.Replace("src=/sdoa/", "");
                }

                Tunnel.Model.Tunnel_index model = new Tunnel.Model.Tunnel_index();
                model.Title      = title;
                model.TypeId     = typeid;
                model.HtmlSource = htmlsourcce;
                model.ImagePaht  = imagepaht;
                model.Content    = content;
                model.UserId     = userid;
                HttpPostedFile hpf = file1.PostedFile;
                if (Convert.ToDouble(hpf.ContentLength) / 1024 / 1024 > 10)
                {
                    Response.Write("<script>alert('附件大小不能大于10MB');</script>");

                    return;
                }
                else
                {
                    CreateMdAndFilePaht(hpf);
                }
                model.Files = filePaht; //infofiles


                //string str = titleName;

                Tunnel.BLL.Tunnel_information bllf = new Tunnel.BLL.Tunnel_information();
                int relt = -1;
                relt = bllf.Add(model);
                if (relt > 0)
                {
                    Tunnel.Common.Message.Show("增加成功!", "N_InformationManage.aspx?type=" + Request.QueryString["type"]);
                    string strsql = "";
                    strsql = "insert into tunnel_log(l_user,l_time,l_content,l_ip,l_sort) values(" + ul.LoginID + ",'" + DateTime.Now + "','公司事务>>党工团信息>>修改党工团信息。标题:" + model.Title + "','" + Tunnel.Common.Common.GetIp() + "',1)";
                    Tunnel.Data.DbHelperSQL.ExecuteSql(strsql);
                }
                else
                {
                    Tunnel.Common.Message.Show("增加失败!", "N_InformationManage.aspx?type=" + Request.QueryString["type"]);
                }

                // MessageBox(str, url);
            }
            else
            {
                Tunnel.Common.Message.Show("请选择子栏目!");
            }
        }
    }