/// <summary> /// 获取模板内的标签列表 /// </summary> /// <param name="templet">模板</param> /// <returns>已替换标签的模板</returns> private string ReplaceLable(string templet) { string Content = ""; int t1 = 0; int t2 = 0; List <string> lablist = new List <string>(); string tp = ""; tp = templet; while (t2 < tp.Length) { t1 = tp.IndexOf("{%"); if (t1 > -1) { tp = tp.Substring(t1, tp.Length - t1); t2 = tp.IndexOf("%}") + 2; if (t2 > 2) { lablist.Add(tp.Substring(0, t2)); tp = tp.Substring(t2, tp.Length - t2); } } else { t2 = tp.Length; } } ILabel ldal = new AccessDal.CodeMaker.Label(); IList <LabelInfo> lblist = new List <LabelInfo>(); //获取标签 foreach (string title in lablist) { LabelInfo info = ldal.LabelGetInfo(title); if (info != null) { if (info.Title != "") { lblist.Add(info); } } } Content = templet; foreach (LabelInfo info in lblist) { //替换标签 Content = Content.Replace(info.Title, info.Content); } return(Content); }
private void dgv_Data_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e) { int rowindex = e.RowIndex; int columnindex = e.ColumnIndex; string id = dgv_Data.Rows[rowindex].Cells["ID"].Value.ToString(); if (columnindex == 0) //编辑 { lb_ID.Text = id.ToString(); tb_Code.Text = dgv_Data.Rows[rowindex].Cells["Code"].Value.ToString(); tb_Title.Text = dgv_Data.Rows[rowindex].Cells["Title"].Value.ToString(); tb_Remark.Text = dgv_Data.Rows[rowindex].Cells["Remark"].Value.ToString(); } else if (columnindex == 1) //删除 { if (MessageBox.Show("确认删除?", "此删除不可恢复", MessageBoxButtons.YesNo) == DialogResult.Yes) { if (menuDal.LabelTypeByParentIDGetList(Convert.ToInt32(id)).Count > 0) { MessageBox.Show("请删除子目录。"); return; } DALFactory.CodeMaker.ILabel tlDal = new AccessDal.CodeMaker.Label(); if (tlDal.LabelByParentIDGetList(Convert.ToInt32(id)).Count > 0) { MessageBox.Show("请删除子目录模板标签。"); return; } if (menuDal.LabelType_Del(Convert.ToInt32(id)) == 1) { QueryData(); MessageBox.Show("删除成功。"); } else { MessageBox.Show("删除失败。"); } } } }