protected void btnSave_Click(object sender, EventArgs e) { this.btnSave.Enabled = false; this.btnCancle.Enabled = false; if (string.IsNullOrWhiteSpace(this.txtKeyName.Text)) { this.btnSave.Enabled = true; this.btnCancle.Enabled = true; MessageBox.ShowFailTip(this, "链接文字不能为空!"); } else if (string.IsNullOrWhiteSpace(this.txtLinkURL.Text)) { this.btnSave.Enabled = true; this.btnCancle.Enabled = true; MessageBox.ShowFailTip(this, "链接地址不能为空!"); } else { string text = this.txtKeyName.Text; if (this.bll.Exists(text)) { this.btnSave.Enabled = true; this.btnCancle.Enabled = true; MessageBox.ShowFailTip(this, "链接文字已经存在!"); } else { string str2 = this.txtLinkURL.Text; bool flag = this.chkIsCMS.Checked; bool flag2 = this.chkIsShop.Checked; bool flag3 = this.chkIsSNS.Checked; bool flag4 = this.chkIsComment.Checked; bool flag5 = this.chkIsActive.Checked; Maticsoft.Model.Settings.SEORelation model = new Maticsoft.Model.Settings.SEORelation { KeyName = text, LinkURL = str2, IsCMS = flag, IsShop = flag2, IsSNS = flag3, IsComment = flag4, CreatedDate = new DateTime?(DateTime.Now), IsActive = flag5 }; this.bll.Add(model); if (this.chkIsAdd.Checked) { MessageBox.ShowSuccessTip(this, "添加成功", "add.aspx"); this.btnSave.Enabled = true; this.btnCancle.Enabled = true; } else { MessageBox.ShowSuccessTip(this, "添加成功,正在跳转...", "list.aspx"); } } } }
public List<Maticsoft.Model.Settings.SEORelation> DataTableToList(DataTable dt) { List<Maticsoft.Model.Settings.SEORelation> list = new List<Maticsoft.Model.Settings.SEORelation>(); int count = dt.Rows.Count; if (count > 0) { for (int i = 0; i < count; i++) { Maticsoft.Model.Settings.SEORelation item = new Maticsoft.Model.Settings.SEORelation(); if ((dt.Rows[i]["RelationID"] != null) && (dt.Rows[i]["RelationID"].ToString() != "")) { item.RelationID = int.Parse(dt.Rows[i]["RelationID"].ToString()); } if ((dt.Rows[i]["KeyName"] != null) && (dt.Rows[i]["KeyName"].ToString() != "")) { item.KeyName = dt.Rows[i]["KeyName"].ToString(); } if ((dt.Rows[i]["LinkURL"] != null) && (dt.Rows[i]["LinkURL"].ToString() != "")) { item.LinkURL = dt.Rows[i]["LinkURL"].ToString(); } if ((dt.Rows[i]["IsCMS"] != null) && (dt.Rows[i]["IsCMS"].ToString() != "")) { if ((dt.Rows[i]["IsCMS"].ToString() == "1") || (dt.Rows[i]["IsCMS"].ToString().ToLower() == "true")) { item.IsCMS = true; } else { item.IsCMS = false; } } if ((dt.Rows[i]["IsShop"] != null) && (dt.Rows[i]["IsShop"].ToString() != "")) { if ((dt.Rows[i]["IsShop"].ToString() == "1") || (dt.Rows[i]["IsShop"].ToString().ToLower() == "true")) { item.IsShop = true; } else { item.IsShop = false; } } if ((dt.Rows[i]["IsSNS"] != null) && (dt.Rows[i]["IsSNS"].ToString() != "")) { if ((dt.Rows[i]["IsSNS"].ToString() == "1") || (dt.Rows[i]["IsSNS"].ToString().ToLower() == "true")) { item.IsSNS = true; } else { item.IsSNS = false; } } if ((dt.Rows[i]["IsComment"] != null) && (dt.Rows[i]["IsComment"].ToString() != "")) { if ((dt.Rows[i]["IsComment"].ToString() == "1") || (dt.Rows[i]["IsComment"].ToString().ToLower() == "true")) { item.IsComment = true; } else { item.IsComment = false; } } if ((dt.Rows[i]["CreatedDate"] != null) && (dt.Rows[i]["CreatedDate"].ToString() != "")) { item.CreatedDate = new DateTime?(DateTime.Parse(dt.Rows[i]["CreatedDate"].ToString())); } if ((dt.Rows[i]["IsActive"] != null) && (dt.Rows[i]["IsActive"].ToString() != "")) { if ((dt.Rows[i]["IsActive"].ToString() == "1") || (dt.Rows[i]["IsActive"].ToString().ToLower() == "true")) { item.IsActive = true; } else { item.IsActive = false; } } list.Add(item); } } return list; }
public void gridView_RowUpdating(object sender, GridViewUpdateEventArgs e) { int num = (int) this.gridView.DataKeys[e.RowIndex].Value; string text = (this.gridView.Rows[e.RowIndex].Cells[0].Controls[0] as TextBox).Text; string str2 = (this.gridView.Rows[e.RowIndex].Cells[1].Controls[0] as TextBox).Text; if (string.IsNullOrWhiteSpace(text)) { MessageBox.ShowFailTip(this, "请输入链接文字!"); e.Cancel = true; this.gridView.OnBind(); } else if (string.IsNullOrWhiteSpace(str2)) { MessageBox.ShowFailTip(this, "请输入链接地址!"); e.Cancel = true; this.gridView.OnBind(); } else { CheckBox box = this.gridView.Rows[e.RowIndex].FindControl("IsCMS") as CheckBox; bool flag = false; if (box != null) { flag = box.Checked; } CheckBox box2 = this.gridView.Rows[e.RowIndex].FindControl("IsShop") as CheckBox; bool flag2 = false; if (box2 != null) { flag2 = box2.Checked; } CheckBox box3 = this.gridView.Rows[e.RowIndex].FindControl("IsSNS") as CheckBox; bool flag3 = false; if (box3 != null) { flag3 = box3.Checked; } CheckBox box4 = this.gridView.Rows[e.RowIndex].FindControl("IsComment") as CheckBox; bool flag4 = false; if (box4 != null) { flag4 = box4.Checked; } CheckBox box5 = this.gridView.Rows[e.RowIndex].FindControl("IsActive") as CheckBox; bool flag5 = false; if (box5 != null) { flag5 = box5.Checked; } Maticsoft.Model.Settings.SEORelation model = new Maticsoft.Model.Settings.SEORelation { RelationID = num, KeyName = text, LinkURL = str2, IsCMS = flag, IsShop = flag2, IsSNS = flag3, IsComment = flag4, IsActive = flag5 }; this.bll.Update(model); this.gridView.EditIndex = -1; this.gridView.OnBind(); } }