private bool DoAdd()
        {
            Model.t_reward_goods model = new Model.t_reward_goods();
            BLL.t_reward_goods   bll   = new BLL.t_reward_goods();
            model.PlanId               = Convert.ToInt32(txt_PlanId.Text);
            model.Money                = Convert.ToDecimal(txt_Money.Text);
            model.IsDeleted            = Convert.ToInt32(model.IsDeleted);
            model.GoodsName            = txt_GoodsName.Text;
            model.LastModifierUserId   = managermodel.id;
            model.LastModificationTime = DateTime.Now;

            model.CreatorUserId = managermodel.id;
            model.CreationTime  = DateTime.Now;
            return(bll.Add(model));
        }
        private bool DoEdit(int _id)
        {
            if (id > 0)
            {
                string filename = string.Empty, fileExtension = string.Empty;
                if (pic_upload.HasFile)//验证是否包含文件
                {
                    //取得文件的扩展名,并转换成小写
                    fileExtension = Path.GetExtension(pic_upload.FileName).ToLower();

                    if (IsImage(fileExtension))
                    {
                        //对上传文件的大小进行检测,限定文件最大不超过8M
                        if (pic_upload.PostedFile.ContentLength < 8192000)
                        {
                            string filepath = "C:/WebSite/PublishOutput/Imges/linglong/";
                            if (Directory.Exists(Server.MapPath("/images/")) == false)//如果不存在就创建file文件夹
                            {
                                Directory.CreateDirectory(Server.MapPath("/images/"));
                            }
                            filename = Guid.NewGuid().ToString();
                            string virpath = filepath + filename + fileExtension;                   //+ "business_banner.png";//CreatePasswordHash(pic_upload.FileName, 4) + fileExtension;//这是存到服务器上的虚拟路径

                            string mappath = Server.MapPath("/images/" + filename + fileExtension); //转换成服务器上的物理路径
                            pic_upload.PostedFile.SaveAs(mappath);                                  //保存图片

                            if (File.Exists(virpath))
                            {
                                File.Delete(virpath);
                            }
                            File.Copy(mappath, virpath, true);
                        }
                        else
                        {
                            img_GoodsImgUrl.ImageUrl = "";
                            lbl_pic.Text             = "文件大小超出8M!请重新选择!";
                        }
                    }
                    else
                    {
                        img_GoodsImgUrl.ImageUrl = "";
                        lbl_pic.Text             = "要上传的文件类型不对!请重新选择!";
                    }
                }
                // 写数据库
                Model.t_reward_goods model    = new Model.t_reward_goods();
                BLL.t_reward_goods   bll      = new BLL.t_reward_goods();
                Model.t_reward_goods oldmodel = bll.GetModel(_id);

                model.PlanId               = Convert.ToInt32(txt_PlanId.Text);
                model.Money                = Convert.ToDecimal(txt_Money.Text);
                model.IsDeleted            = Convert.ToInt32(model.IsDeleted);
                model.GoodsName            = txt_GoodsName.Text;
                model.LastModifierUserId   = managermodel.id;
                model.LastModificationTime = DateTime.Now;
                model.GoodsImgUrl          = pic_upload.HasFile ? ConfigHelper.GetConfigAppSettings("ApiWebUrl") + "Imges/linglong/" + filename + fileExtension : oldmodel.GoodsImgUrl;
                model.ID = _id;

                lbl_pic.Text             = "";
                img_GoodsImgUrl.ImageUrl = pic_upload.HasFile ? ConfigHelper.GetConfigAppSettings("ApiWebUrl") + "Imges/linglong/" + filename + fileExtension : oldmodel.GoodsImgUrl;
                return(bll.Update(model));
            }
            else
            {
                if (pic_upload.HasFile)//验证是否包含文件
                {
                    //取得文件的扩展名,并转换成小写
                    string fileExtension = Path.GetExtension(pic_upload.FileName).ToLower();
                    //验证上传文件是否图片格式
                    //fileOk = IsImage(fileExtension);

                    if (IsImage(fileExtension))
                    {
                        //对上传文件的大小进行检测,限定文件最大不超过8M
                        if (pic_upload.PostedFile.ContentLength < 8192000)
                        {
                            string filepath = "C:/WebSite/PublishOutput/Imges/linglong/";
                            if (Directory.Exists(Server.MapPath("/images/")) == false)//如果不存在就创建file文件夹
                            {
                                Directory.CreateDirectory(Server.MapPath("/images/"));
                            }
                            string filename = Guid.NewGuid().ToString();
                            string virpath  = filepath + filename + fileExtension;                  //+ "business_banner.png";//CreatePasswordHash(pic_upload.FileName, 4) + fileExtension;//这是存到服务器上的虚拟路径

                            string mappath = Server.MapPath("/images/" + filename + fileExtension); //转换成服务器上的物理路径
                            pic_upload.PostedFile.SaveAs(mappath);                                  //保存图片

                            if (File.Exists(virpath))
                            {
                                File.Delete(virpath);
                            }
                            File.Copy(mappath, virpath, true);

                            // 写数据库
                            Model.t_reward_goods model = new Model.t_reward_goods();
                            BLL.t_reward_goods   bll   = new BLL.t_reward_goods();
                            model.PlanId               = Convert.ToInt32(txt_PlanId.Text);
                            model.Money                = Convert.ToDecimal(txt_Money.Text);
                            model.IsDeleted            = Convert.ToInt32(model.IsDeleted);
                            model.GoodsName            = txt_GoodsName.Text;
                            model.LastModifierUserId   = managermodel.id;
                            model.LastModificationTime = DateTime.Now;
                            model.GoodsImgUrl          = ConfigHelper.GetConfigAppSettings("ApiWebUrl") + "Imges/linglong/" + filename + fileExtension;
                            model.CreatorUserId        = managermodel.id;
                            model.CreationTime         = DateTime.Now;

                            lbl_pic.Text             = "";
                            img_GoodsImgUrl.ImageUrl = ConfigHelper.GetConfigAppSettings("ApiWebUrl") + "Imges/linglong/" + filename + fileExtension;
                            return(bll.Add(model));
                        }
                        else
                        {
                            img_GoodsImgUrl.ImageUrl = "";
                            lbl_pic.Text             = "文件大小超出8M!请重新选择!";
                            return(false);
                        }
                    }
                    else
                    {
                        img_GoodsImgUrl.ImageUrl = "";
                        lbl_pic.Text             = "要上传的文件类型不对!请重新选择!";
                        return(false);
                    }
                }
                else
                {
                    img_GoodsImgUrl.ImageUrl = "";
                    lbl_pic.Text             = "请选择要上传的图片!";
                    return(false);
                }
            }
        }