public ActionResult doDirInfo(int id, int pid) { List <SelectListItem> list = new List <SelectListItem>(); foreach (var item in _dirbll.GetModelList("")) { list.Add(new SelectListItem() { Text = item.dir_Name, Value = item.id.ToString() }); } ViewData["ddldir"] = new SelectList(list, "Value", "Text"); tb_Directory model = new tb_Directory(); if (pid > 0) { model.dir_ParentId = pid; } else { if (id > 0) { model = _dirbll.GetModel(id); } } return(View(model)); }
public string NewTreeNode() { string flag = "0"; try { string txtDirName = Request.Form["txtDirName"]; string ddldir = Request.Form["ddldir"]; tb_Directory directory = new tb_Directory(); directory.dir_Name = txtDirName; directory.dir_ParentId = Convert.ToInt32(ddldir); directory.createDate = DateTime.Now; directory.createUser = CurrentUserInfo.PersonnelID; directory.isDelete = false; directory.updateDate = DateTime.Now; directory.updateUser = CurrentUserInfo.PersonnelID; var tempmodel = _dirbll.GetModel(directory.dir_ParentId.Value); directory.dir_Value1 = tempmodel.dir_Value1 + string.Format("{0:D3}", _dirbll.GetModelListForNodesCount(directory.dir_ParentId.Value) + 1) + ","; if (_dirbll.Add(directory) > 0) { flag = "1"; } } catch { flag = "0"; } return(flag); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(tb_Directory model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update tb_Directory set "); strSql.Append("dir_Name=@dir_Name,"); strSql.Append("dir_ParentId=@dir_ParentId,"); strSql.Append("dir_Level=@dir_Level,"); strSql.Append("dir_Order=@dir_Order,"); strSql.Append("createUser=@createUser,"); strSql.Append("updateUser=@updateUser,"); strSql.Append("createDate=@createDate,"); strSql.Append("updateDate=@updateDate,"); strSql.Append("isDelete=@isDelete,"); strSql.Append("dir_IsLeaf=@dir_IsLeaf,"); strSql.Append("dir_Value1=@dir_Value1"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@dir_Name", SqlDbType.NVarChar, 100), new SqlParameter("@dir_ParentId", SqlDbType.Int, 4), new SqlParameter("@dir_Level", SqlDbType.Int, 4), new SqlParameter("@dir_Order", SqlDbType.Int, 4), new SqlParameter("@createUser", SqlDbType.Int, 4), new SqlParameter("@updateUser", SqlDbType.Int, 4), new SqlParameter("@createDate", SqlDbType.DateTime), new SqlParameter("@updateDate", SqlDbType.DateTime), new SqlParameter("@isDelete", SqlDbType.Bit, 1), new SqlParameter("@dir_IsLeaf", SqlDbType.Bit, 1), new SqlParameter("@dir_Value1", SqlDbType.VarChar, -1), new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = model.dir_Name; parameters[1].Value = model.dir_ParentId; parameters[2].Value = model.dir_Level; parameters[3].Value = model.dir_Order; parameters[4].Value = model.createUser; parameters[5].Value = model.updateUser; parameters[6].Value = model.createDate; parameters[7].Value = model.updateDate; parameters[8].Value = model.isDelete; parameters[9].Value = model.dir_IsLeaf; parameters[10].Value = model.dir_Value1; parameters[11].Value = model.id; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
public string doDirCU(tb_Directory model) { string flag = "0"; try { if (model.id > 0) { model.updateDate = DateTime.Now; model.updateUser = CurrentUserInfo.PersonnelID; if (model.id == 1) { model.dir_ParentId = 0; if (_dirbll.Update(model)) { flag = "1"; } } else { var tempmodel = _dirbll.GetModel(model.dir_ParentId.Value); model.dir_Value1 = tempmodel.dir_Value1 + string.Format("{0:D3}", _dirbll.GetModelListForNodesCount(model.dir_ParentId.Value) + 1) + ","; if (_dirbll.Update(model)) { flag = "1"; } } } else { model.createDate = DateTime.Now; model.createUser = CurrentUserInfo.PersonnelID; model.isDelete = false; model.updateDate = DateTime.Now; model.updateUser = CurrentUserInfo.PersonnelID; var tempmodel = _dirbll.GetModel(model.dir_ParentId.Value); model.dir_Value1 = tempmodel.dir_Value1 + string.Format("{0:D3}", _dirbll.GetModelListForNodesCount(model.dir_ParentId.Value) + 1) + ","; if (_dirbll.Add(model) > 0) { flag = "1"; } } } catch { flag = "0"; } return(flag); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(tb_Directory model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into tb_Directory("); strSql.Append("dir_Name,dir_ParentId,dir_Level,dir_Order,createUser,updateUser,createDate,updateDate,isDelete,dir_IsLeaf,dir_Value1)"); strSql.Append(" values ("); strSql.Append("@dir_Name,@dir_ParentId,@dir_Level,@dir_Order,@createUser,@updateUser,@createDate,@updateDate,@isDelete,@dir_IsLeaf,@dir_Value1)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@dir_Name", SqlDbType.NVarChar, 100), new SqlParameter("@dir_ParentId", SqlDbType.Int, 4), new SqlParameter("@dir_Level", SqlDbType.Int, 4), new SqlParameter("@dir_Order", SqlDbType.Int, 4), new SqlParameter("@createUser", SqlDbType.Int, 4), new SqlParameter("@updateUser", SqlDbType.Int, 4), new SqlParameter("@createDate", SqlDbType.DateTime), new SqlParameter("@updateDate", SqlDbType.DateTime), new SqlParameter("@isDelete", SqlDbType.Bit, 1), new SqlParameter("@dir_IsLeaf", SqlDbType.Bit, 1), new SqlParameter("@dir_Value1", SqlDbType.VarChar, -1) }; parameters[0].Value = model.dir_Name; parameters[1].Value = model.dir_ParentId; parameters[2].Value = model.dir_Level; parameters[3].Value = model.dir_Order; parameters[4].Value = model.createUser; parameters[5].Value = model.updateUser; parameters[6].Value = model.createDate; parameters[7].Value = model.updateDate; parameters[8].Value = model.isDelete; parameters[9].Value = model.dir_IsLeaf; parameters[10].Value = model.dir_Value1; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public tb_Directory GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 id,dir_Name,dir_ParentId,dir_Level,dir_Order,createUser,updateUser,createDate,updateDate,isDelete,dir_IsLeaf,dir_Value1 from tb_Directory "); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = id; tb_Directory model = new tb_Directory(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
/// <summary> /// 得到一个对象实体 /// </summary> public tb_Directory DataRowToModel(DataRow row) { tb_Directory model = new tb_Directory(); if (row != null) { if (row["id"] != null && row["id"].ToString() != "") { model.id = int.Parse(row["id"].ToString()); } if (row["dir_Name"] != null) { model.dir_Name = row["dir_Name"].ToString(); } if (row["dir_ParentId"] != null && row["dir_ParentId"].ToString() != "") { model.dir_ParentId = int.Parse(row["dir_ParentId"].ToString()); } if (row["dir_Level"] != null && row["dir_Level"].ToString() != "") { model.dir_Level = int.Parse(row["dir_Level"].ToString()); } if (row["dir_Order"] != null && row["dir_Order"].ToString() != "") { model.dir_Order = int.Parse(row["dir_Order"].ToString()); } if (row["createUser"] != null && row["createUser"].ToString() != "") { model.createUser = int.Parse(row["createUser"].ToString()); } if (row["updateUser"] != null && row["updateUser"].ToString() != "") { model.updateUser = int.Parse(row["updateUser"].ToString()); } if (row["createDate"] != null && row["createDate"].ToString() != "") { model.createDate = DateTime.Parse(row["createDate"].ToString()); } if (row["updateDate"] != null && row["updateDate"].ToString() != "") { model.updateDate = DateTime.Parse(row["updateDate"].ToString()); } if (row["isDelete"] != null && row["isDelete"].ToString() != "") { if ((row["isDelete"].ToString() == "1") || (row["isDelete"].ToString().ToLower() == "true")) { model.isDelete = true; } else { model.isDelete = false; } } if (row["dir_IsLeaf"] != null && row["dir_IsLeaf"].ToString() != "") { if ((row["dir_IsLeaf"].ToString() == "1") || (row["dir_IsLeaf"].ToString().ToLower() == "true")) { model.dir_IsLeaf = true; } else { model.dir_IsLeaf = false; } } if (row["dir_Value1"] != null) { model.dir_Value1 = row["dir_Value1"].ToString(); } } return(model); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(tb_Directory model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(tb_Directory model) { return(dal.Add(model)); }