コード例 #1
0
        public void add(BackgroundImageModel backgroundimage)
        {
            SqlConnection cn = null;
            SqlTransaction tc = null;
            try
            {
                cn = DbHelperSQL.getConnection();
                tc = DbHelperSQL.startTransaction(cn);

                //执行新增写进数据库
            backgroundimageDal.add(cn, tc, backgroundimage);

                DbHelperSQL.commitTransaction(tc);
            }
            catch (Exception dalEx)
            {
                DbHelperSQL.rollBackTransaction(tc);
                throw new MakeException(ExpSort.数据库, dalEx.Message);
            }
            finally
            {
                DbHelperSQL.closeConnection(cn);
            }
        }
コード例 #2
0
 public bool add(SqlConnection cn, SqlTransaction tc, BackgroundImageModel model)
 {
     return DbHelperSQL.insertModel<BackgroundImageModel>(model, "BackgroundImage", cn, tc);
 }
コード例 #3
0
 public bool update(SqlConnection cn, SqlTransaction tc, BackgroundImageModel model)
 {
     return DbHelperSQL.updateModel<BackgroundImageModel>(model, "BackgroundImage", "Evenid", model.Evenid.ToString(), "'", cn, tc);
 }
コード例 #4
0
    protected void UpPicCmd_Click(object sender, EventArgs e)
    {
        string name = FileUpload1.FileName;
        if ((name.Trim() == ""))
        {
            this.Label1.Text = "请选择要上传的文件";
            return;
        }
        else
        {
            this.Label1.Text = "";
        }
        string type = name.Substring(name.LastIndexOf("."));
        //            if (type != ".jpg")
        //            {
        //                this.Label1.Text = "请上传jpg格式文件";
        //                return;
        //            }
        //            string fileName = DateTime.Now.GetHashCode().ToString();
        string imageName = Guid.NewGuid().ToString();
        string path = Server.MapPath(Helper.ImagePath) + imageName + type;
        string wpath = Helper.ImagePath + imageName + type;
        if (FileUpload1.PostedFile.ContentType.Substring(0, 5) == "image")
        {
            if (FileUpload1.PostedFile.ContentLength > Helper.ImageLimit)
            {
                this.Label1.Text = Helper.ImageLimitWraning;
                return;
            }
            try
            {
                FileUpload1.SaveAs(path);
                //压缩图片,覆盖原图
                Helper.ImageMakeSmaller(wpath);
                var img = new BackgroundImageModel();
                img.SchoolNo = ImgType;
                img.ImgPath = imageName + type;
                img.SortNo = Convert.ToInt32(ReqSortNo);
                _backgroundImageEbi.add(img);

                this.Image1.ImageUrl = wpath + "?" + MakeRandom();
                Script.RunJS(Page, "SuccessCallBack", "SuccessCallBack();");
            }
            catch
            {
                Script.alertMsg("发生错误", Page);
            }
            //                    imgBytes = SetImgToByte(path);
            //                    Session["PhotoImage"] = imgBytes;
        }
        else
        {
            this.Label1.Text = "请上传图片格式文件";
            return;
        }
    }