/// <summary> /// 创建区域节点 /// </summary> /// <param name="parentCode"></param> /// <param name="itype"></param> /// <returns></returns> public ActionResult CreateNode(string parentCode, string itype) { int order = 0; if (parentCode.Contains("temp")) { parentCode = parentCode.Split('_')[1]; } var dictNode = aInstance.GetModelByCode(parentCode); string newCode = string.Empty; newCode = aInstance.GenerateCode(); if (!string.IsNullOrEmpty(newCode)) { var model = new Bse_Area() { Area_Code = newCode, Area_PCode = parentCode, Area_PName = dictNode.Area_Name }; return(Json(model)); } else { return(Json(new { result = "fail" })); } }
/// <summary> /// 区域维护(submit) /// </summary> /// <param name="dict">区域实体数据源</param> /// <returns></returns> public ActionResult AreaOperation(Bse_Area dict) { var flag = false; //如果Dict_ID 为0,则表示为添加 if (dict.Area_ID == 0) { //Bse_Dict PNode = dictInstance.GetModel(" AND Dict_Code='" + dict.Dict_PCode + "' AND Dict_Key='" + dict.Dict_Key + "'"); //dict.Dict_Code = dictInstance.CreateDictNode(PNode, false, ref order); flag = aInstance.Add(dict); //权限点插入 aInstance.SynFunction(dict); } else { flag = aInstance.Update(dict); //权限点插入 aInstance.SynFunction(dict); } if (flag) { return(Json(new { result = "success", target = dict })); } else { return(Json(new { result = "fail" })); } //return View(); }
public bool Update(Bse_Area model) { if (aInstance.Update(model) > 0) { return(true); } return(false); }
public bool Add(Bse_Area model) { if (aInstance.Add(model) > 0) { return(true); } return(false); }
public bool Delete(Bse_Area model) { model.Stat = 1; if (aInstance.Update(model) > 0) { return(true); } return(false); }
public void SynFunction(Bse_Area area) { var model = fInstance.GetListByWhere(string.Format("AND Fun_Code='{0}' AND Fun_PCode='{1}'", area.Area_Code, area.Area_PCode)).FirstOrDefault(); if (model == null) { Sys_Function fun = new Sys_Function(); fun.Fun_Code = area.Area_Code; fun.Fun_Name = area.Area_Name; fun.Fun_PCode = area.Area_PCode; fun.Fun_PName = area.Area_PName; fun.Fun_iType = "Area"; fInstance.Add(fun); } else { model.Fun_Name = area.Area_Name; fInstance.Update(model); } }
/// <summary> /// 获取区域节点数据 /// </summary> /// <param name="nodeCode">区域编码</param> /// <returns></returns> public ActionResult GetNode(string nodeCode) { Bse_Area dict = new Bse_Area(); if (nodeCode.Contains("temp_")) { var newNodeCode = nodeCode.Split('_')[1]; dict = aInstance.GetModel(string.Format("AND Area_Code='{0}'", newNodeCode)); } else { dict = aInstance.GetModel(string.Format("AND Area_Code='{0}'", nodeCode)); } var result = new JsonResult() { Data = new { result = "success", data = dict } }; return(result); }
/// <summary> /// 获取所有的 Bse_Area对象(即:一条记录 /// </summary> public List <Bse_Area> GetAll() { List <Bse_Area> ret = new List <Bse_Area>(); string sql = "SELECT Area_ID,Area_Code,Area_Mark,Area_Name,Area_Addr,Area_PCode,Area_PName,SN_Bak,Stat,CreateTime,UpdateTime,DeleteTime FROM Bse_Area where 1=1 AND ((Stat is null) or (Stat=0) ) order by Area_ID desc "; SqlDataReader dr = null; try { dr = (SqlDataReader)idb.ReturnReader(sql); while (dr.Read()) { Bse_Area bse_Area = new Bse_Area(); if (dr["Area_ID"] != DBNull.Value) { bse_Area.Area_ID = Convert.ToDecimal(dr["Area_ID"]); } if (dr["Area_Code"] != DBNull.Value) { bse_Area.Area_Code = Convert.ToString(dr["Area_Code"]); } if (dr["Area_Mark"] != DBNull.Value) { bse_Area.Area_Mark = Convert.ToString(dr["Area_Mark"]); } if (dr["Area_Name"] != DBNull.Value) { bse_Area.Area_Name = Convert.ToString(dr["Area_Name"]); } if (dr["Area_Addr"] != DBNull.Value) { bse_Area.Area_Addr = Convert.ToString(dr["Area_Addr"]); } if (dr["Area_PCode"] != DBNull.Value) { bse_Area.Area_PCode = Convert.ToString(dr["Area_PCode"]); } if (dr["Area_PName"] != DBNull.Value) { bse_Area.Area_PName = Convert.ToString(dr["Area_PName"]); } if (dr["SN_Bak"] != DBNull.Value) { bse_Area.SN_Bak = Convert.ToString(dr["SN_Bak"]); } if (dr["Stat"] != DBNull.Value) { bse_Area.Stat = Convert.ToInt32(dr["Stat"]); } if (dr["CreateTime"] != DBNull.Value) { bse_Area.CreateTime = Convert.ToDateTime(dr["CreateTime"]); } if (dr["UpdateTime"] != DBNull.Value) { bse_Area.UpdateTime = Convert.ToDateTime(dr["UpdateTime"]); } if (dr["DeleteTime"] != DBNull.Value) { bse_Area.DeleteTime = Convert.ToDateTime(dr["DeleteTime"]); } ret.Add(bse_Area); } }catch (System.Exception ex) { throw ex; } finally { if (dr != null) { dr.Close(); } if (idb.GetConnection() != null && idb.GetConnection().State == ConnectionState.Open) { idb.GetConnection().Close(); } } return(ret); }
/// <summary> /// 获取指定的 Bse_Area对象集合 /// </summary> public List <Bse_Area> GetListByWhere(string strCondition) { List <Bse_Area> ret = new List <Bse_Area>(); string sql = "SELECT Area_ID,Area_Code,Area_Mark,Area_Name,Area_Addr,Area_PCode,Area_PName,SN_Bak,Stat,CreateTime,UpdateTime,DeleteTime FROM Bse_Area WHERE 1=1 AND ((Stat is null) or (Stat=0) ) "; if (!string.IsNullOrEmpty(strCondition)) { strCondition.Replace('\'', '"'); //防sql注入 sql += strCondition; } sql += " ORDER BY Area_ID DESC "; SqlDataReader dr = null; try { dr = (SqlDataReader)idb.ReturnReader(sql); while (dr.Read()) { Bse_Area bse_Area = new Bse_Area(); if (dr["Area_ID"] != DBNull.Value) { bse_Area.Area_ID = Convert.ToDecimal(dr["Area_ID"]); } if (dr["Area_Code"] != DBNull.Value) { bse_Area.Area_Code = Convert.ToString(dr["Area_Code"]); } if (dr["Area_Mark"] != DBNull.Value) { bse_Area.Area_Mark = Convert.ToString(dr["Area_Mark"]); } if (dr["Area_Name"] != DBNull.Value) { bse_Area.Area_Name = Convert.ToString(dr["Area_Name"]); } if (dr["Area_Addr"] != DBNull.Value) { bse_Area.Area_Addr = Convert.ToString(dr["Area_Addr"]); } if (dr["Area_PCode"] != DBNull.Value) { bse_Area.Area_PCode = Convert.ToString(dr["Area_PCode"]); } if (dr["Area_PName"] != DBNull.Value) { bse_Area.Area_PName = Convert.ToString(dr["Area_PName"]); } if (dr["SN_Bak"] != DBNull.Value) { bse_Area.SN_Bak = Convert.ToString(dr["SN_Bak"]); } if (dr["Stat"] != DBNull.Value) { bse_Area.Stat = Convert.ToInt32(dr["Stat"]); } if (dr["CreateTime"] != DBNull.Value) { bse_Area.CreateTime = Convert.ToDateTime(dr["CreateTime"]); } if (dr["UpdateTime"] != DBNull.Value) { bse_Area.UpdateTime = Convert.ToDateTime(dr["UpdateTime"]); } if (dr["DeleteTime"] != DBNull.Value) { bse_Area.DeleteTime = Convert.ToDateTime(dr["DeleteTime"]); } ret.Add(bse_Area); } }catch (System.Exception ex) { throw ex; } finally { if (dr != null) { dr.Close(); } if (idb.GetConnection() != null && idb.GetConnection().State == ConnectionState.Open) { idb.GetConnection().Close(); } } return(ret); }
/// <summary> /// 获取指定的 Bse_Area对象(即:一条记录 /// </summary> public Bse_Area GetByKey(decimal area_ID) { Bse_Area bse_Area = new Bse_Area(); string sql = "SELECT Area_ID,Area_Code,Area_Mark,Area_Name,Area_Addr,Area_PCode,Area_PName,SN_Bak,Stat,CreateTime,UpdateTime,DeleteTime FROM Bse_Area WHERE 1=1 AND ((Stat is null) or (Stat=0) ) AND Area_ID=@Area_ID "; idb.AddParameter("@Area_ID", area_ID); SqlDataReader dr = null; try { dr = (SqlDataReader)idb.ReturnReader(sql); while (dr.Read()) { if (dr["Area_ID"] != DBNull.Value) { bse_Area.Area_ID = Convert.ToDecimal(dr["Area_ID"]); } if (dr["Area_Code"] != DBNull.Value) { bse_Area.Area_Code = Convert.ToString(dr["Area_Code"]); } if (dr["Area_Mark"] != DBNull.Value) { bse_Area.Area_Mark = Convert.ToString(dr["Area_Mark"]); } if (dr["Area_Name"] != DBNull.Value) { bse_Area.Area_Name = Convert.ToString(dr["Area_Name"]); } if (dr["Area_Addr"] != DBNull.Value) { bse_Area.Area_Addr = Convert.ToString(dr["Area_Addr"]); } if (dr["Area_PCode"] != DBNull.Value) { bse_Area.Area_PCode = Convert.ToString(dr["Area_PCode"]); } if (dr["Area_PName"] != DBNull.Value) { bse_Area.Area_PName = Convert.ToString(dr["Area_PName"]); } if (dr["SN_Bak"] != DBNull.Value) { bse_Area.SN_Bak = Convert.ToString(dr["SN_Bak"]); } if (dr["Stat"] != DBNull.Value) { bse_Area.Stat = Convert.ToInt32(dr["Stat"]); } if (dr["CreateTime"] != DBNull.Value) { bse_Area.CreateTime = Convert.ToDateTime(dr["CreateTime"]); } if (dr["UpdateTime"] != DBNull.Value) { bse_Area.UpdateTime = Convert.ToDateTime(dr["UpdateTime"]); } if (dr["DeleteTime"] != DBNull.Value) { bse_Area.DeleteTime = Convert.ToDateTime(dr["DeleteTime"]); } } }catch (System.Exception ex) { throw ex; } finally { if (dr != null) { dr.Close(); } if (idb.GetConnection() != null && idb.GetConnection().State == ConnectionState.Open) { idb.GetConnection().Close(); } } return(bse_Area); }
/// <summary> /// 更新 Bse_Area对象(即:一条记录 /// </summary> public int Update(Bse_Area bse_Area) { StringBuilder sbParameter = new StringBuilder(); StringBuilder sb = new StringBuilder(); sb.Append(@"UPDATE Bse_Area SET "); if (bse_Area.Area_Code_IsChanged) { sbParameter.Append("Area_Code=@Area_Code, "); } if (bse_Area.Area_Mark_IsChanged) { sbParameter.Append("Area_Mark=@Area_Mark, "); } if (bse_Area.Area_Name_IsChanged) { sbParameter.Append("Area_Name=@Area_Name, "); } if (bse_Area.Area_Addr_IsChanged) { sbParameter.Append("Area_Addr=@Area_Addr, "); } if (bse_Area.Area_PCode_IsChanged) { sbParameter.Append("Area_PCode=@Area_PCode, "); } if (bse_Area.Area_PName_IsChanged) { sbParameter.Append("Area_PName=@Area_PName, "); } if (bse_Area.SN_Bak_IsChanged) { sbParameter.Append("SN_Bak=@SN_Bak, "); } if (bse_Area.Stat_IsChanged) { sbParameter.Append("Stat=@Stat, "); } if (bse_Area.CreateTime_IsChanged) { sbParameter.Append("CreateTime=@CreateTime, "); } if (bse_Area.UpdateTime_IsChanged) { sbParameter.Append("UpdateTime=@UpdateTime, "); } if (bse_Area.DeleteTime_IsChanged) { sbParameter.Append("DeleteTime=@DeleteTime "); } sb.Append(sbParameter.ToString().Trim().TrimEnd(',')); sb.Append(" WHERE 1=1 AND ((Stat is null) or (Stat=0)) and Area_ID=@Area_ID; "); string sql = sb.ToString(); if (bse_Area.Area_Code_IsChanged) { if (string.IsNullOrEmpty(bse_Area.Area_Code)) { idb.AddParameter("@Area_Code", DBNull.Value); } else { idb.AddParameter("@Area_Code", bse_Area.Area_Code); } } if (bse_Area.Area_Mark_IsChanged) { if (string.IsNullOrEmpty(bse_Area.Area_Mark)) { idb.AddParameter("@Area_Mark", DBNull.Value); } else { idb.AddParameter("@Area_Mark", bse_Area.Area_Mark); } } if (bse_Area.Area_Name_IsChanged) { if (string.IsNullOrEmpty(bse_Area.Area_Name)) { idb.AddParameter("@Area_Name", DBNull.Value); } else { idb.AddParameter("@Area_Name", bse_Area.Area_Name); } } if (bse_Area.Area_Addr_IsChanged) { if (string.IsNullOrEmpty(bse_Area.Area_Addr)) { idb.AddParameter("@Area_Addr", DBNull.Value); } else { idb.AddParameter("@Area_Addr", bse_Area.Area_Addr); } } if (bse_Area.Area_PCode_IsChanged) { if (string.IsNullOrEmpty(bse_Area.Area_PCode)) { idb.AddParameter("@Area_PCode", DBNull.Value); } else { idb.AddParameter("@Area_PCode", bse_Area.Area_PCode); } } if (bse_Area.Area_PName_IsChanged) { if (string.IsNullOrEmpty(bse_Area.Area_PName)) { idb.AddParameter("@Area_PName", DBNull.Value); } else { idb.AddParameter("@Area_PName", bse_Area.Area_PName); } } if (bse_Area.SN_Bak_IsChanged) { if (string.IsNullOrEmpty(bse_Area.SN_Bak)) { idb.AddParameter("@SN_Bak", DBNull.Value); } else { idb.AddParameter("@SN_Bak", bse_Area.SN_Bak); } } if (bse_Area.Stat_IsChanged) { if (bse_Area.Stat == 0) { idb.AddParameter("@Stat", 0); } else { idb.AddParameter("@Stat", bse_Area.Stat); } } if (bse_Area.CreateTime_IsChanged) { if (bse_Area.CreateTime == DateTime.MinValue) { idb.AddParameter("@CreateTime", DBNull.Value); } else { idb.AddParameter("@CreateTime", bse_Area.CreateTime); } } if (bse_Area.UpdateTime_IsChanged) { if (bse_Area.UpdateTime == DateTime.MinValue) { idb.AddParameter("@UpdateTime", DBNull.Value); } else { idb.AddParameter("@UpdateTime", bse_Area.UpdateTime); } } if (bse_Area.DeleteTime_IsChanged) { if (bse_Area.DeleteTime == DateTime.MinValue) { idb.AddParameter("@DeleteTime", DBNull.Value); } else { idb.AddParameter("@DeleteTime", bse_Area.DeleteTime); } } idb.AddParameter("@Area_ID", bse_Area.Area_ID); return(idb.ExeCmd(sql)); }
/// <summary> /// 添加 Bse_Area对象(即:一条记录) /// </summary> public int Add(Bse_Area bse_Area) { string sql = "INSERT INTO Bse_Area (Area_Code,Area_Mark,Area_Name,Area_Addr,Area_PCode,Area_PName,SN_Bak,Stat,CreateTime,UpdateTime,DeleteTime) VALUES (@Area_Code,@Area_Mark,@Area_Name,@Area_Addr,@Area_PCode,@Area_PName,@SN_Bak,@Stat,@CreateTime,@UpdateTime,@DeleteTime)"; if (string.IsNullOrEmpty(bse_Area.Area_Code)) { idb.AddParameter("@Area_Code", DBNull.Value); } else { idb.AddParameter("@Area_Code", bse_Area.Area_Code); } if (string.IsNullOrEmpty(bse_Area.Area_Mark)) { idb.AddParameter("@Area_Mark", DBNull.Value); } else { idb.AddParameter("@Area_Mark", bse_Area.Area_Mark); } if (string.IsNullOrEmpty(bse_Area.Area_Name)) { idb.AddParameter("@Area_Name", DBNull.Value); } else { idb.AddParameter("@Area_Name", bse_Area.Area_Name); } if (string.IsNullOrEmpty(bse_Area.Area_Addr)) { idb.AddParameter("@Area_Addr", DBNull.Value); } else { idb.AddParameter("@Area_Addr", bse_Area.Area_Addr); } if (string.IsNullOrEmpty(bse_Area.Area_PCode)) { idb.AddParameter("@Area_PCode", DBNull.Value); } else { idb.AddParameter("@Area_PCode", bse_Area.Area_PCode); } if (string.IsNullOrEmpty(bse_Area.Area_PName)) { idb.AddParameter("@Area_PName", DBNull.Value); } else { idb.AddParameter("@Area_PName", bse_Area.Area_PName); } if (string.IsNullOrEmpty(bse_Area.SN_Bak)) { idb.AddParameter("@SN_Bak", DBNull.Value); } else { idb.AddParameter("@SN_Bak", bse_Area.SN_Bak); } if (bse_Area.Stat == 0) { idb.AddParameter("@Stat", 0); } else { idb.AddParameter("@Stat", bse_Area.Stat); } if (bse_Area.CreateTime == DateTime.MinValue) { idb.AddParameter("@CreateTime", DBNull.Value); } else { idb.AddParameter("@CreateTime", bse_Area.CreateTime); } if (bse_Area.UpdateTime == DateTime.MinValue) { idb.AddParameter("@UpdateTime", DBNull.Value); } else { idb.AddParameter("@UpdateTime", bse_Area.UpdateTime); } if (bse_Area.DeleteTime == DateTime.MinValue) { idb.AddParameter("@DeleteTime", DBNull.Value); } else { idb.AddParameter("@DeleteTime", bse_Area.DeleteTime); } return(idb.ExeCmd(sql)); }