Пример #1
0
        //修改文件信息
        protected void BtnUpdate_Click(object sender, EventArgs e) {
            //验证日期
            DateTime sDate = new DateTime();
            DateTime eDate = new DateTime();
            DateTime shotDate = new DateTime();
            if (this.Calendar_ShotDate.Text == "") {
                this.Label2.Text = "拍摄时间不能为空!";
                return;
            }
            else {
                shotDate = Convert.ToDateTime(this.Calendar_ShotDate.Text);
                if (shotDate > Convert.ToDateTime(this.lb_uploadDate.Text)) {
                    this.Label2.Text = "拍摄时间应比图片上传日期早!";
                    return;
                }
            }
            if (this.Calendar_StartDate.Text != "") {
                sDate = Convert.ToDateTime(this.Calendar_StartDate.Text);
            }
            else {
                sDate = Convert.ToDateTime("1900-01-01");
            }
            if (this.Calendar_EndDate.Text != "") {
                eDate = Convert.ToDateTime(this.Calendar_EndDate.Text);

                if (sDate != Convert.ToDateTime("1900-01-01") && eDate < sDate) {
                    this.Label2.Text = "有效结束日期应比有效开始日期晚";
                    return;
                }
            }
            else {
                eDate = Convert.ToDateTime("1900-01-01");
            }

            ResourceEntity re = null;
            Resource r = new Resource();
            if (ViewState["model"] != null) {
                re = ViewState["model"] as ResourceEntity;
            }
            else {
                re = r.GetResourceInfoByItemId(this.Hidden_ItemId.Value);
            }

            re.Caption = this.txt_Caption.Text;
            re.Description = this.TxtDescription.Text;
            re.Keyword = this.TxtKeyword.Text;
            re.shotDate = shotDate;
            re.StartDate = sDate;
            re.EndDate = eDate;

            string editResult = "";
            try {
                r.Update(re);

                ShowMessage("修改文件信息成功!");
                editResult = "成功";
            }
            catch (Exception e1) {
                ShowMessage("修改文件信息失败!" + e1.Message);
                editResult = "失败";
            }


            LogEntity model = new LogEntity();
            model.id = Guid.NewGuid();
            model.userId = CurrentUser.UserId;
            model.userName = CurrentUser.UserLoginName;
            model.EventType = ((int)LogType.EditResource).ToString();
            model.EventResult = editResult;
            model.EventContent = "图片序号:" + re.ItemSerialNum;
            model.IP = HttpContext.Current.Request.UserHostAddress;
            model.AddDate = DateTime.Now;
            new Logs().Add(model);



        }
Пример #2
0
        //修改文件信息
        protected void BtnUpdate_Click(object sender, EventArgs e)
        {

            string ids = Request.QueryString["ids"];
            if (string.IsNullOrEmpty(ids))
            {
                return;
            }

            ids = ids.TrimEnd(";".ToCharArray());
            string[] arrIds = ids.Split(";".ToCharArray());



            ResourceEntity re = null;
            Resource r = new Resource();



            foreach (string id in arrIds)
            {

                re = r.GetResourceInfoByItemId(id);
                re.Caption = this.txt_Caption.Text;
                re.Description = this.TxtDescription.Text;
                re.Keyword = this.TxtKeyword.Text;
                try
                {
                    r.Update(re);

                  
                    LogEntity model = new LogEntity();
                    model.id = Guid.NewGuid();
                    model.userId = CurrentUser.UserId;
                    model.userName = CurrentUser.UserLoginName;
                    model.EventType = ((int)LogType.EditResource).ToString();
                    model.EventResult = "成功";
                    model.EventContent = "图片序号:"+re.ItemSerialNum ;
                    model.IP = HttpContext.Current.Request.UserHostAddress;
                    model.AddDate = DateTime.Now;
                    new Logs().Add(model);


                    ShowMessage("修改文件信息成功!");


                }
                catch (Exception e1)
                {
                    ShowMessage("修改文件信息失败!" + e1.Message);
                }
            }





            //ResourceEntity re = null;
            //Resource r = new Resource();
            //if (ViewState["model"] != null)
            //{
            //    re = ViewState["model"] as ResourceEntity;
            //}
            //else
            //{
            //    re = r.GetResourceInfoByItemId(this.Hidden_ItemId.Value);
            //}

            //re.Caption = this.txt_Caption.Text;
            //re.Description = this.TxtDescription.Text;
            //re.Keyword = this.TxtKeyword.Text;
            //re.shotDate = shotDate;
            //re.StartDate = sDate;
            //re.EndDate = eDate;

            //string editResult = "";
            //try
            //{
            //    r.Update(re);

            //    ShowMessage("修改文件信息成功!");
            //    editResult = "成功";
            //}
            //catch (Exception e1)
            //{
            //    ShowMessage("修改文件信息失败!" + e1.Message);
            //    editResult = "失败";
            //}


            //LogEntity model = new LogEntity();
            //model.id = Guid.NewGuid();
            //model.userId = CurrentUser.UserId;
            //model.userName = CurrentUser.UserLoginName;
            //model.EventType = ((int)LogType.EditResource).ToString();
            //model.EventResult = editResult;
            //model.EventContent = "图片序号:" + re.ItemSerialNum;
            //model.IP = HttpContext.Current.Request.UserHostAddress;
            //model.AddDate = DateTime.Now;
            //new Logs().Add(model);



        }