public void add(MainPageBackgroundPicModel mainpagebackgroundpic)
        {
            SqlConnection cn = null;
            SqlTransaction tc = null;
            try
            {
                cn = DbHelperSQL.getConnection();
                tc = DbHelperSQL.startTransaction(cn);

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

                DbHelperSQL.commitTransaction(tc);
            }
            catch (Exception dalEx)
            {
                DbHelperSQL.rollBackTransaction(tc);
                throw new MakeException(ExpSort.数据库, dalEx.Message);
            }
            finally
            {
                DbHelperSQL.closeConnection(cn);
            }
        }
    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
            {
                IList<QueryModel> qmList = new List<QueryModel>();
                qmList.Add(MakeUtil.getQueryModel("SchoolNo", "'", SqlWhere.WhereOperator.Equal, ImgType));
                if (_backgroundImageEbi.getModelList(qmList, 1).Any())
                {
                    this.Label1.Text = "主页的背景图只能上传一张图";
                    return;
                }
                FileUpload1.SaveAs(path);
                //压缩图片,覆盖原图
                Helper.ImageMakeSmaller(wpath);

                var img = new MainPageBackgroundPicModel();
                img.SchoolNo = ImgType;
                img.ImgPath = imageName + type;
                _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;
        }
    }
 public bool update(SqlConnection cn, SqlTransaction tc, MainPageBackgroundPicModel model)
 {
     return DbHelperSQL.updateModel<MainPageBackgroundPicModel>(model, "MainPageBackgroundPic", "Evenid", model.Evenid.ToString(), "'", cn, tc);
 }
 public bool add(SqlConnection cn, SqlTransaction tc, MainPageBackgroundPicModel model)
 {
     return DbHelperSQL.insertModel<MainPageBackgroundPicModel>(model, "MainPageBackgroundPic", cn, tc);
 }