Exemplo n.º 1
0
        public bool Add_Paragraph(String Text, int id)
        {
            try
            {
                Text_Model Paragraph = new Text_Model
                {
                    Text         = Text,
                    Ownership_Id = "VesterGade_543v92_sjdhs_Para_7jdh45d_Graph"
                };

                if (id == 2)
                {
                    Paragraph.Ownership_Id = "Follow_7fdkf67-6467-gade_076470-45h4a-e14dh5kjd5445even";
                }

                _Data.Text_Model.Add(Paragraph);
                _Data.SaveChanges();

                return(true);
            }
            catch
            {
                return(false);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Text_Model model)
        {
            StringBuilder strSql  = new StringBuilder();
            StringBuilder strSql1 = new StringBuilder();
            StringBuilder strSql2 = new StringBuilder();

            if (model.TEXT_TITLE != null)
            {
                strSql1.Append("TEXT_TITLE,");
                strSql2.Append("'" + model.TEXT_TITLE + "',");
            }
            if (model.TEXT_DESCRIPT != null)
            {
                strSql1.Append("TEXT_DESCRIPT,");
                strSql2.Append("'" + model.TEXT_DESCRIPT + "',");
            }
            if (model.TEXT_CONTENT != null)
            {
                strSql1.Append("TEXT_CONTENT,");
                strSql2.Append("'" + model.TEXT_CONTENT + "',");
            }
            if (model.IMGPATH != null)
            {
                strSql1.Append("IMGPATH,");
                strSql2.Append("'" + model.IMGPATH + "',");
            }
            if (model.TEXT_AUTHOR != null)
            {
                strSql1.Append("TEXT_AUTHOR,");
                strSql2.Append("'" + model.TEXT_AUTHOR + "',");
            }
            if (model.CREATE_TIME != null)
            {
                strSql1.Append("CREATE_TIME,");
                strSql2.Append("'" + model.CREATE_TIME + "',");
            }
            if (model.CATEGORY_ID != null)
            {
                strSql1.Append("CATEGORY_ID,");
                strSql2.Append("" + model.CATEGORY_ID + ",");
            }
            strSql.Append("insert into COM_TEXT(");
            strSql.Append(strSql1.ToString().Remove(strSql1.Length - 1));
            strSql.Append(")");
            strSql.Append(" values (");
            strSql.Append(strSql2.ToString().Remove(strSql2.Length - 1));
            strSql.Append(")");
            strSql.Append(";select @@IDENTITY");
            object obj = DbHelperSQL.GetSingle(strSql.ToString());

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Exemplo n.º 3
0
        //添加
        protected void Button1_Click(object sender, EventArgs e)
        {
            //string uppath = "";//用于保存图片上传路径
            //获取上传图片的文件名
            string fileFullname = this.FileUpload1.FileName;
            //获取图片上传的时间,以时间作为图片的名字可以防止图片重名
            //string dataName = DateTime.Now.ToString("yyMMddhhmmss");
            //获取图片的文件名(不含扩展名)
            string fileName = fileFullname.Substring(fileFullname.LastIndexOf("\\") + 1);
            //获取图片扩展名
            string type    = fileFullname.Substring(fileFullname.LastIndexOf(".") + 1);
            string picName = DateTime.Now.ToString("yyyyMMddhhssmmfff");

            //判断是否为要求的格式
            if (type == "bmp" || type == "jpg" || type == "jpeg" || type == "gif" || type == "JPG" || type == "JPEG" ||
                type == "BMP" || type == "GIF" || type == "png" || type == "PNG")
            {
                //将图片上传到指定路径的文件夹
                FileUpload1.SaveAs(Server.MapPath("../NewsImage") + "\\" + picName + "." + type);
                //将路径保存到变量,将该变量的值保存到数据库相应字段即可
                txtpath.Text = "../NewsImage/" + picName + "." + type;
                //txtpath.Text = uppath;
            }

            string TEXT_TITLE    = this.textitle.Text;
            string TEXT_DESCRIPT = this.textdesc.Text;
            string TEXT_AUTHOR   = this.textauthor.Text;
            string TEXT_CONTENT  = this.txtEditorContents.Value.ToString();
            string CATEGORY_ID   = this.ddlTypeList.SelectedValue;

            Text_Model model = new Text_Model();

            model.TEXT_TITLE    = TEXT_TITLE;
            model.TEXT_DESCRIPT = TEXT_DESCRIPT;
            model.TEXT_AUTHOR   = TEXT_AUTHOR;
            model.IMGPATH       = txtpath.Text.ToString();//图片路径
            model.TEXT_CONTENT  = TEXT_CONTENT;
            model.CREATE_TIME   = DateTime.Now;
            model.CATEGORY_ID   = Convert.ToInt32(CATEGORY_ID);

            Text_Bll bll = new Text_Bll();
            int      i   = bll.Add(model);

            if (i > 0)
            {
                Response.Write("<script>alert('新增成功!');window.location.href='com_text_list.aspx';</script>");
            }
            else
            {
                Response.Write("<script>alert('新增失败!');window.location.href='com_text_list.aspx';</script>");
            }
        }
Exemplo n.º 4
0
        public bool Add_Paragraph(String Text)
        {
            try
            {
                Text_Model Paragraph = new Text_Model();
                Paragraph.Text         = Text;
                Paragraph.Ownership_Id = "Text_23792_sjdhs_Para_745nfd_Graph";

                _Data.Text_Model.Add(Paragraph);
                _Data.SaveChanges();

                return(true);
            }
            catch
            {
                return(false);
            }
        }
Exemplo n.º 5
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            int    TEXT_ID       = Convert.ToInt32(Request.Params["text_id"]);
            string TEXT_TITLE    = this.textitle.Text;
            string TEXT_DESCRIPT = this.textdesc.Text;
            string TEXT_AUTHOR   = this.textauthor.Text;
            string TEXT_CONTENT  = this.txtEditorContents.Value.ToString();
            string CATEGORY_ID   = this.ddlTypeList.SelectedValue;


            Text_Model model = new Text_Model();

            model.TEXT_ID       = TEXT_ID;
            model.TEXT_TITLE    = TEXT_TITLE;
            model.TEXT_DESCRIPT = TEXT_DESCRIPT;
            model.TEXT_AUTHOR   = TEXT_AUTHOR;
            model.TEXT_CONTENT  = TEXT_CONTENT;
            model.CATEGORY_ID   = Convert.ToInt32(CATEGORY_ID);
            model.CREATE_TIME   = DateTime.Now;

            string fileFullname = this.FileUpload1.FileName;
            string fileName     = fileFullname.Substring(fileFullname.LastIndexOf("\\") + 1);
            string type         = fileFullname.Substring(fileFullname.LastIndexOf(".") + 1);
            string picName      = DateTime.Now.ToString("yyyyMMddhhssmmfff");

            if (type == "bmp" || type == "jpg" || type == "jpeg" || type == "gif" || type == "JPG" || type == "JPEG" || type == "BMP" || type == "GIF" || type == "png" || type == "PNG")
            {
                FileUpload1.SaveAs(Server.MapPath("../NewsImage") + "\\" + picName + "." + type);
                Text = "../NewsImage/" + picName + "." + type;
            }
            if (lj.Value == Text)//值相等
            {
                model.IMGPATH = lj.Value.ToString();
            }
            else if (fileFullname == null || fileFullname == "")//值等于空
            {
                model.IMGPATH = lj.Value.ToString();
            }
            else if (lj.Value == "")
            {
                model.IMGPATH = Text.ToString();
            }
            else if (Text != "")
            {
                model.IMGPATH = Text.ToString();
            }
            else
            {
                model.IMGPATH = lj.Value;
            }
            //更改选择状态,如果添加,则此设备状态改为,已经使用
            bool i = bll.Update(model);

            if (i)
            {
                Response.Write("<script>alert('保存成功!');window.location.href='com_text_list.aspx';</script>");
            }
            else
            {
                Response.Write("<script>alert(保存失败!');window.location.href='com_text_list.aspx';</script>");
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Text_Model model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update COM_TEXT set ");
            if (model.TEXT_TITLE != null)
            {
                strSql.Append("TEXT_TITLE='" + model.TEXT_TITLE + "',");
            }
            else
            {
                strSql.Append("TEXT_TITLE= null ,");
            }
            if (model.TEXT_DESCRIPT != null)
            {
                strSql.Append("TEXT_DESCRIPT='" + model.TEXT_DESCRIPT + "',");
            }
            else
            {
                strSql.Append("TEXT_DESCRIPT= null ,");
            }
            if (model.TEXT_CONTENT != null)
            {
                strSql.Append("TEXT_CONTENT='" + model.TEXT_CONTENT + "',");
            }
            else
            {
                strSql.Append("TEXT_CONTENT= null ,");
            }
            if (model.IMGPATH != null)
            {
                strSql.Append("IMGPATH='" + model.IMGPATH + "',");
            }
            else
            {
                strSql.Append("IMGPATH= null ,");
            }
            if (model.TEXT_AUTHOR != null)
            {
                strSql.Append("TEXT_AUTHOR='" + model.TEXT_AUTHOR + "',");
            }
            else
            {
                strSql.Append("TEXT_AUTHOR= null ,");
            }
            if (model.CREATE_TIME != null)
            {
                strSql.Append("CREATE_TIME='" + model.CREATE_TIME + "',");
            }
            else
            {
                strSql.Append("CREATE_TIME= null ,");
            }
            if (model.CATEGORY_ID != null)
            {
                strSql.Append("CATEGORY_ID=" + model.CATEGORY_ID + ",");
            }
            int n = strSql.ToString().LastIndexOf(",");

            strSql.Remove(n, 1);
            strSql.Append(" where TEXT_ID=" + model.TEXT_ID + "");
            int rowsAffected = DbHelperSQL.ExecuteSql(strSql.ToString());

            if (rowsAffected > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 7
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(Text_Model model)
 {
     return(dal.Update(model));
 }
Exemplo n.º 8
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int  Add(Text_Model model)
 {
     return(dal.Add(model));
 }