protected void btnSubmit_Click(object sender, EventArgs e) { if (Session["ZT_ADMIN"] == null) { Response.Redirect("Login.aspx"); } else { if (this.txtElementCode.Text.Trim() == "") { MessageBox.Show(this, "请输入菜单编号!"); return; } if (this.txtElementName.Text.Trim() == "") { MessageBox.Show(this, "请输入菜单名称!"); return; } if (this.txtElementShow.Text.Trim() == "") { MessageBox.Show(this, "请输入菜单是否显示!"); return; } if (this.txtParentCode.Text.Trim() == "") { MessageBox.Show(this, "请输入父级菜单编号!"); return; } WebProject.Model.SysManage.ZT_SYS_ElementInfo model_ElementInfo = new WebProject.Model.SysManage.ZT_SYS_ElementInfo(); model_ElementInfo.ElementName = this.txtElementName.Text.Trim(); model_ElementInfo.ElementCode = this.txtElementCode.Text.Trim(); model_ElementInfo.ParentCode = this.txtParentCode.Text.Trim(); model_ElementInfo.ElementLink = this.txtElementLink.Text.Trim(); model_ElementInfo.ElementShow = this.txtElementShow.Text.Trim(); model_ElementInfo.CreateBy = SessionUtil.GetAdminSession().AdminNo; model_ElementInfo.CreateDate = DateTime.Now; WebProject.BLL.SysManage.ZT_SYS_ElementInfo bll_ElementInfo = new WebProject.BLL.SysManage.ZT_SYS_ElementInfo(); bll_ElementInfo.Add(model_ElementInfo); LogManage.WriteLog(Request.UserHostAddress, "菜单管理", "添加菜单", "成功", "菜单名:" + model_ElementInfo.ElementName + ", 创建人:" + SessionUtil.GetAdminSession().AdminNo); MessageBox.ShowAndRedirect(this, "添加菜单成功!", "MenuList.aspx"); } }
/// <summary> /// ��������б� /// </summary> public List<WebProject.Model.SysManage.ZT_SYS_ElementInfo> DataTableToList(DataTable dt) { List<WebProject.Model.SysManage.ZT_SYS_ElementInfo> modelList = new List<WebProject.Model.SysManage.ZT_SYS_ElementInfo>(); int rowsCount = dt.Rows.Count; if (rowsCount > 0) { WebProject.Model.SysManage.ZT_SYS_ElementInfo model; for (int n = 0; n < rowsCount; n++) { model = new WebProject.Model.SysManage.ZT_SYS_ElementInfo(); if(dt.Rows[n]["ElementID"].ToString()!="") { model.ElementID=int.Parse(dt.Rows[n]["ElementID"].ToString()); } model.ElementCode=dt.Rows[n]["ElementCode"].ToString(); model.ElementName=dt.Rows[n]["ElementName"].ToString(); model.ElementDesc=dt.Rows[n]["ElementDesc"].ToString(); model.ParentCode=dt.Rows[n]["ParentCode"].ToString(); model.ElementLink=dt.Rows[n]["ElementLink"].ToString(); model.ElementPicLink=dt.Rows[n]["ElementPicLink"].ToString(); model.ElementShow=dt.Rows[n]["ElementShow"].ToString(); model.CreateBy=dt.Rows[n]["CreateBy"].ToString(); if(dt.Rows[n]["CreateDate"].ToString()!="") { model.CreateDate=DateTime.Parse(dt.Rows[n]["CreateDate"].ToString()); } model.LastUpdateBy=dt.Rows[n]["LastUpdateBy"].ToString(); if(dt.Rows[n]["LastUpdateDate"].ToString()!="") { model.LastUpdateDate=DateTime.Parse(dt.Rows[n]["LastUpdateDate"].ToString()); } model.Remark=dt.Rows[n]["Remark"].ToString(); modelList.Add(model); } } return modelList; }