public Maticsoft.Model.SNS.PhotoTags DataRowToModel(DataRow row) { Maticsoft.Model.SNS.PhotoTags tags = new Maticsoft.Model.SNS.PhotoTags(); if (row != null) { if ((row["TagID"] != null) && (row["TagID"].ToString() != "")) { tags.TagID = int.Parse(row["TagID"].ToString()); } if ((row["TagName"] != null) && (row["TagName"].ToString() != "")) { tags.TagName = row["TagName"].ToString(); } if ((row["IsRecommand"] != null) && (row["IsRecommand"].ToString() != "")) { tags.IsRecommand = new int?(int.Parse(row["IsRecommand"].ToString())); } if ((row["Status"] != null) && (row["Status"].ToString() != "")) { tags.Status = new int?(int.Parse(row["Status"].ToString())); } if ((row["CreatedDate"] != null) && (row["CreatedDate"].ToString() != "")) { tags.CreatedDate = new DateTime?(DateTime.Parse(row["CreatedDate"].ToString())); } if ((row["Remark"] != null) && (row["Remark"].ToString() != "")) { tags.Remark = row["Remark"].ToString(); } } return tags; }
protected void btnSave_Click(object sender, EventArgs e) { string tagName = this.txtTagName.Text.Trim(); if (tagName.Length == 0) { MessageBox.ShowServerBusyTip(this, "名称不能为空!"); } else { Maticsoft.BLL.SNS.PhotoTags tags = new Maticsoft.BLL.SNS.PhotoTags(); Maticsoft.Model.SNS.PhotoTags model = null; if (this.TagID > 0) { model = tags.GetModel(this.TagID); if (model != null) { if (tags.Exists(model.TagID, tagName)) { MessageBox.ShowServerBusyTip(this, "标签已存在!"); } else { model.TagName = tagName; model.IsRecommand = new int?(Globals.SafeInt(this.radlIsRecommand.SelectedValue, 0)); model.Status = new int?(Globals.SafeInt(this.radlStatus.SelectedValue, 0)); model.CreatedDate = new DateTime?(DateTime.Now); if (tags.Update(model)) { this.txtTagName.Text = ""; this.gridView.OnBind(); MessageBox.ShowSuccessTip(this, Site.TooltipUpdateOK, "PhotoTags.aspx"); } else { MessageBox.ShowFailTip(this, Site.TooltipUpdateError); } } } } else if (tags.Exists(tagName)) { MessageBox.ShowServerBusyTip(this, "标签已存在!"); } else { model = new Maticsoft.Model.SNS.PhotoTags { TagName = tagName, IsRecommand = new int?(Globals.SafeInt(this.radlIsRecommand.SelectedValue, 0)), Status = new int?(Globals.SafeInt(this.radlStatus.SelectedValue, 0)), CreatedDate = new DateTime?(DateTime.Now) }; if (tags.Add(model) > 0) { LogHelp.AddUserLog(base.CurrentUser.UserName, base.CurrentUser.UserType, "增加图片标签成功", this); this.txtTagName.Text = ""; MessageBox.ShowSuccessTip(this, Site.TooltipSaveOK); this.gridView.OnBind(); } else { MessageBox.ShowFailTip(this, Site.TooltipSaveError); } } } }