Esempio n. 1
0
        //批量删除
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            ChkAdminLevel("sys_rewardmoney", DTEnums.ActionEnum.Delete.ToString()); //检查权限
            int sucCount   = 0;
            int errorCount = 0;

            BLL.t_reward_goods bll = new BLL.t_reward_goods();
            for (int i = 0; i < rptList.Items.Count; i++)
            {
                int      id = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidId")).Value);
                CheckBox cb = (CheckBox)rptList.Items[i].FindControl("chkId");
                if (cb.Checked)
                {
                    if (bll.Delete(id))
                    {
                        sucCount += 1;
                    }
                    else
                    {
                        errorCount += 1;
                    }
                }
            }
            AddAdminLog(DTEnums.ActionEnum.Delete.ToString(), "删除方案" + sucCount + "条,失败" + errorCount + "条"); //记录日志
            JscriptMsg("删除成功" + sucCount + "条,失败" + errorCount + "条!", Utils.CombUrlTxt("t_reward_plan_list.aspx", "keywords={0}", ""));
        }
Esempio n. 2
0
        private void RptBind(string _strWhere, string _orderby)
        {
            //this.page = DTRequest.GetQueryInt("page", 1);
            //txtKeywords.Text = this.keywords;
            BLL.t_reward_goods bll = new BLL.t_reward_goods();
            this.rptList.DataSource = bll.GetList("PlanId = " + id);
            this.rptList.DataBind();

            //绑定页码
            //txtPageNum.Text = this.pageSize.ToString();
            //string pageUrl = Utils.CombUrlTxt("t_reward_plan_list.aspx", "keywords={0}&page={1}", this.keywords, "__id__");
            //PageContent.InnerHtml = Utils.OutPageList(this.pageSize, this.page, this.totalCount, pageUrl, 8);
        }
        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 void ShowInfo(int _id)
 {
     BLL.t_reward_goods   bll   = new BLL.t_reward_goods();
     Model.t_reward_goods model = bll.GetModel(_id);
     txt_PlanId.Text = model.PlanId.ToString();
     //planid = planid;
     //txt_GoodsImgUrl.Text = model.GoodsImgUrl;
     img_GoodsImgUrl.ImageUrl = model.GoodsImgUrl;
     txt_GoodsName.Text       = model.GoodsName;
     txt_Money.Text           = model.Money.ToString();
     if (model.IsDeleted == 1)
     {
         rad_IsDeleted02.Checked = true;
     }
     else
     {
         rad_IsDeleted01.Checked = true;
     }
 }
        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);
                }
            }
        }