public static void SaveList(List<Proxy.DrugCategory> list) { BLL.Category bv = new BLL.Category(); foreach (Proxy.DrugCategory v in list) { // try to load by primary key bv.LoadByPrimaryKey(v.ID.Value); // if the entry doesn't exist, create it if (bv.RowCount == 0) { bv.AddNew(); } // populate the contents of v on the to the database list if( v.ID.HasValue ) bv.ID = v.ID.Value; if( v.CategoryName != "" && v.CategoryName != null ) bv.CategoryName = v.CategoryName; if( v.CategoryCode != "" && v.CategoryCode != null ) bv.CategoryCode = v.CategoryCode; if( v.Description != "" && v.Description != null ) bv.Description = v.Description; bv.Save(); } }
public static void SaveList(List <Proxy.DrugCategory> list) { BLL.Category bv = new BLL.Category(); foreach (Proxy.DrugCategory v in list) { // try to load by primary key bv.LoadByPrimaryKey(v.ID.Value); // if the entry doesn't exist, create it if (bv.RowCount == 0) { bv.AddNew(); } // populate the contents of v on the to the database list if (v.ID.HasValue) { bv.ID = v.ID.Value; } if (v.CategoryName != "" && v.CategoryName != null) { bv.CategoryName = v.CategoryName; } if (v.CategoryCode != "" && v.CategoryCode != null) { bv.CategoryCode = v.CategoryCode; } if (v.Description != "" && v.Description != null) { bv.Description = v.Description; } bv.Save(); } }
public string DelCategory(string nId) { if (string.IsNullOrEmpty(nId)) { return("没有找到要删除的数据,请检查"); } Guid gId = Guid.Empty; if (!Guid.TryParse(nId, out gId)) { return("当前行的主键ID不合法,请检查"); } BLL.Category cBll = new BLL.Category(); int effect = cBll.Delete(nId); if (effect > 0) { return("操作成功"); } else { return("操作失败"); } }
/// <summary> /// 绑定下拉列表类别 /// </summary> public void BindddlType(int PID, DropDownList ddl, bool state = false) { BLL.Category bll = new BLL.Category(); Model.Category model = new Model.Category(); int typelevel = 0; if (PID != 0) { model = bll.GetModel(PID); typelevel = model.LevelNum + 1; } DataTable dt = bll.GetListChild(PID, state); foreach (DataRow item in dt.Rows) { string value = item["Id"].ToString(); int levelNum = int.Parse(item["LevelNum"].ToString()) - typelevel; string title = item["Title"].ToString(); if (levelNum > 0) { title = "|--" + title; title = Utils.StringOfChar(levelNum, " ") + title; } ddl.Items.Add(new ListItem(title, value)); } }
//#region Web Service Getters // public static List<Proxy.Category> GetAll() // { // BLL.Category v = new BLL.Category(); // v.LoadAll(); // return ToList(v); // } // public static List<Proxy.Category> GetUpdatesAfter(int LastVersion) // { // BLL.Category v = new BLL.Category(); // v.LoadUpdatesAfter( LastVersion ); // return ToList(v); // } //#endregion #region Utilities public static List <Proxy.DrugCategory> ToList(BLL.Category v) { List <Proxy.DrugCategory> list = new List <Proxy.DrugCategory>(); while (!v.EOF) { Proxy.DrugCategory t = new Proxy.DrugCategory(); if (!v.IsColumnNull("ID")) { t.ID = v.ID; } if (!v.IsColumnNull("CategoryName")) { t.CategoryName = v.CategoryName; } if (!v.IsColumnNull("CategoryCode")) { t.CategoryCode = v.CategoryCode; } if (!v.IsColumnNull("Description")) { t.Description = v.Description; } list.Add(t); v.MoveNext(); } return(list); }
/// <summary> /// 绑定父级分类 /// </summary> /// <param name="listControl"></param> private void InitCategoryList(ListControl listControl) { if (listControl.Items.Count > 0) { listControl.Items.Clear(); } listControl.Items.Add(new ListItem("请选择", "0")); Dictionary <string, string> dic = null; if (cBll == null) { cBll = new BLL.Category(); } dic = cBll.GetKeyValueByParentName("所有分类"); if (dic != null && dic.Count > 0) { foreach (KeyValuePair <string, string> kvp in dic) { ListItem li = null; li = ddlCategory.Items.FindByValue(kvp.Key); if (li == null) { string name = kvp.Value; string value = kvp.Key; listControl.Items.Add(new ListItem(name, value)); CreateSubNode(listControl, value, name); } } } }
public async Task <IActionResult> Deactivate([FromBody] int[] ids) { var bcategory = new BLL.Category(unitOfWork); await bcategory.Deactivate(ids); return(Json("Success!")); }
public string UpdateCategory(string nId, string name, string parentId) { if (string.IsNullOrEmpty(nId)) { return("没有找到要编辑的数据,请检查"); } Guid gId = Guid.Empty; if (!Guid.TryParse(nId, out gId)) { return("当前编辑行的主键ID不合法,请检查"); } if (string.IsNullOrEmpty(name)) { return("类型名称不能为空"); } if (string.IsNullOrEmpty(parentId)) { return("所属名称对应值不正确,请检查"); } Guid pId = Guid.Empty; if (!Guid.TryParse(parentId, out pId)) { return("所属名称对应值格式不正确"); } Model.Category model = new Model.Category(); model.NumberID = nId; model.CategoryName = name; model.ParentID = pId; model.Title = "All"; model.Sort = 0; model.Remark = string.Empty; model.LastUpdatedDate = DateTime.Now; BLL.Category cBll = new BLL.Category(); int effect = cBll.Update(model); if (effect == 110) { return("已存在相同记录"); } if (effect > 0) { return("操作成功"); } else { return("操作失败"); } }
private void Bind() { GetSearchItem(); int totalCount = 0; if (bll == null) { bll = new BLL.Category(); } rpData.DataSource = bll.GetList(AspNetPager1.CurrentPageIndex, AspNetPager1.PageSize, out totalCount, sqlWhere, parms == null ? null : parms.ToArray());; rpData.DataBind(); AspNetPager1.RecordCount = totalCount; }
/// <summary> /// 获取类别名称 /// </summary> /// <param name="cid"></param> /// <returns></returns> public string GetCategoryName(int cid) { string cName = ""; if (cid == 0) { cName = "顶级类别"; } else { BLL.Category bll = new BLL.Category(); cName = bll.GetModel(cid).Title; } return(cName); }
/// <summary> /// 绑定子级分类 /// </summary> /// <param name="listControl"></param> /// <param name="parentValue"></param> /// <param name="parentName"></param> private void CreateSubNode(ListControl listControl, string parentValue, string parentName) { if (bll == null) { bll = new BLL.Category(); } Dictionary <string, string> dic = bll.GetKeyValueByParentId(parentValue); foreach (KeyValuePair <string, string> kvp in dic) { string name = parentName + "-/-" + kvp.Value; string value = kvp.Key; listControl.Items.Add(new ListItem(name, value)); CreateSubNode(listControl, value, name); } }
public static void DeleteList(List <int> list) { BLL.Category bv = new BLL.Category(); foreach (int v in list) { // try to load by primary key bv.LoadByPrimaryKey(v); // if the entry doesn't exist, create it if (bv.RowCount > 0) { bv.MarkAsDeleted(); bv.Save(); } // populate the contents of v on the to the database list } }
/// <summary> /// 批量删除数据 /// </summary> private void OnDelete() { string itemsAppend = hV.Value.Trim(); if (string.IsNullOrEmpty(itemsAppend)) { WebHelper.MessageBox.Messager(this.Page, lbtnPostBack, "请至少勾选一行进行操作", "操作错误", "error"); return; } if (bll == null) { bll = new BLL.Category(); } string[] itemsAppendArr = itemsAppend.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); List <string> list = new List <string>(); foreach (string item in itemsAppendArr) { string[] itemArr = item.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries); Dictionary <string, string> dic = bll.GetKeyValueByParentId(itemArr[0]); if (dic != null && dic.Count > 0) { WebHelper.MessageBox.Messager(this.Page, lbtnPostBack, "不能删除,原因:分类名称为“" + itemArr[1] + "”存在子级,请先删除所有子级"); return; } list.Add(itemArr[0]); } if (list.Count > 0) { if (bll.DeleteBatch(list)) { WebHelper.MessageBox.MessagerShow(this.Page, lbtnPostBack, "操作成功"); GetSearchItem(); Bind(); } else { WebHelper.MessageBox.Messager(this.Page, lbtnPostBack, "操作失败,请检查", "系统提示"); } } }
/// <summary> /// 绑定父级分类 /// </summary> /// <param name="listControl"></param> private void InitCategoryList(ListControl listControl) { if (listControl.Items.Count > 0) { listControl.Items.Clear(); } listControl.Items.Add(new ListItem("请选择", "0")); Dictionary <string, string> dic = null; if (cBll == null) { cBll = new BLL.Category(); } if (!string.IsNullOrEmpty(parentName)) { dic = cBll.GetKeyValueOnParentName(parentName); //只显示当前父级名称及其子节点的选择 if (dic != null && dic.Count > 0) { listControl.Items.Clear(); dic.Distinct(); } } else { dic = cBll.GetKeyValue("and ParentID='0' "); } foreach (KeyValuePair <string, string> kvp in dic) { ListItem li = null; li = ddlCategory.Items.FindByValue(kvp.Key); if (li == null) { string name = kvp.Value; string value = kvp.Key; listControl.Items.Add(new ListItem(name, value)); CreateSubNode(listControl, value, name); } } }
public void ProcessRequest(HttpContext context) { Leadin.BLL.Category bll = new BLL.Category(); context.Response.ContentType = "text/plain"; List <Model.Category> modelList = bll.GetModelList(""); var result = modelList.Select(m => new { id = m.Id, pId = m.ParentId, name = m.Title, open = false, target = "DeployBase", url = "/oasystem/oacategory/detail.aspx?dptid=" + m.Id.ToString(CultureInfo.InvariantCulture) }).ToList(); context.Response.Write(JsonMapper.ToJson(result)); }
//#region Web Service Getters // public static List<DrugCategory> GetAll() // { // BLL.DrugCategory v = new BLL.DrugCategory(); // v.LoadAll(); // return ToList(v); // } // public static List<DrugCategory> GetUpdatesAfter(long? lastVersion,DateTime? lastUpdateTime) // { // BLL.DrugCategory v = new BLL.DrugCategory(); // if(lastVersion.HasValue && lastVersion.Value != 0) // { // v.LoadUpdatesAfter( lastVersion.Value ); // }else if(lastUpdateTime.HasValue) // { // v.LoadUpdatesAfterByTime(lastUpdateTime.Value); // }else // { // v.LoadAll(); // } // return ToList(v); // } // public static List<int> GetDeletedIDsAfter(long LastVersion) // { // BLL.DrugCategory v = new BLL.DrugCategory(); // v.LoadDeletedIDs(LastVersion); // List<int> list = new List<int>(); // while (!v.EOF) // { // list.Add((int)v.GetColumn("ID")); // v.MoveNext(); // } // return list; // } //#endregion #region Utilities #endregion #region Web service Saving public static void SaveList(List <HCMIS.Desktop.DirectoryServices.DrugCategory> list) { BLL.Category bv = new BLL.Category(); foreach (HCMIS.Desktop.DirectoryServices.DrugCategory v in list) { // try to load by primary key bv.LoadByPrimaryKey(v.ID.Value); // if the entry doesn't exist, create it if (bv.RowCount == 0) { bv.AddNew(); } // populate the contents of v on the to the database list if (v.ID.HasValue) { bv.ID = v.ID.Value; } if (v.CategoryName != "" && v.CategoryName != null) { bv.CategoryName = v.CategoryName; } if (v.CategoryCode != "" && v.CategoryCode != null) { bv.CategoryCode = v.CategoryCode; } if (v.Description != "" && v.Description != null) { bv.Description = v.Description; } //if( v.IsDeleted.HasValue ) // bv.IsDeleted = v.IsDeleted.Value; //if( v.UpdateTime.HasValue ) // bv.UpdateTime = v.UpdateTime.Value; bv.Save(); } }
/// <summary> /// 绑定数据 /// </summary> private void Bind() { //如果当前是编辑进入页面,择执行修改操作 if (!string.IsNullOrEmpty(cId)) { if (cBll == null) { cBll = new BLL.Category(); } Model.Category model = cBll.GetModel(cId); ListItem li = null; if (model != null) { txtCategoryname.Value = model.CategoryName; li = ddlCategory.Items.FindByValue(model.ParentID); if (li != null) { li.Selected = true; } txtRemark.Value = model.Remark; } } }
public static List <Model.CategoryInfo> GetList() { BLL.Category bll = new BLL.Category(); if (!enableCaching) { return(bll.GetList()); } string key = "category_all"; List <Model.CategoryInfo> data = (List <Model.CategoryInfo>)HttpRuntime.Cache[key]; if (data == null) { data = bll.GetList(); AggregateCacheDependency cd = DependencyFactory.GetProvinceCityDependency(); HttpRuntime.Cache.Add(key, data, cd, DateTime.Now.AddHours(categoryTimeout), Cache.NoSlidingExpiration, CacheItemPriority.High, null); } return(data); }
/// <summary> /// 绑定父级分类 /// </summary> /// <param name="listControl"></param> private void InitCategoryList(ListControl listControl) { if (listControl.Items.Count > 0) { listControl.Items.Clear(); } listControl.Items.Add(new ListItem("请选择", "0")); if (bll == null) { bll = new BLL.Category(); } Dictionary <string, string> dic = bll.GetKeyValue(" and ParentID='0' "); foreach (KeyValuePair <string, string> kvp in dic) { string name = kvp.Value; string value = kvp.Key; listControl.Items.Add(new ListItem(name, value)); CreateSubNode(listControl, value, name); } }
public string GetTreeJsonForCategory() { BLL.Category cBll = new BLL.Category(); return(cBll.GetTreeJson()); }
/// <summary> /// 保存数据 /// </summary> private void OnSave() { hBackToN.Value = (int.Parse(hBackToN.Value) + 1).ToString();; #region 获取输入并验证 string sName = txtCategoryname.Value.Trim(); string sParentID = "0"; string sRemark = txtCategoryname.Value.Trim(); if (ddlCategory.SelectedIndex > -1) { sParentID = ddlCategory.SelectedValue; } if (string.IsNullOrEmpty(sName)) { WebHelper.MessageBox.Messager(this.Page, lbtnSave, "分类名称不能为空", "操作错误", "error"); return; } #endregion if (cBll == null) { cBll = new BLL.Category(); } Model.Category model = new Model.Category(); model.CategoryName = sName; model.ParentID = sParentID; model.Remark = sRemark; model.Sort = 0; model.CreateDate = DateTime.Now; model.Title = title; int result = -1; if (!string.IsNullOrEmpty(cId)) { model.NumberID = cId; result = cBll.Update(model); } else { result = cBll.Insert(model); } if (result == 110) { WebHelper.MessageBox.Messager(this.Page, lbtnSave, "分类名称已存在,请换一个再重试!"); return; } if (result > 0) { WebHelper.MessageBox.MessagerShow(this.Page, lbtnSave, "提交成功!"); //重新加载所属分类 InitCategoryList(ddlCategory); } else { WebHelper.MessageBox.Messager(this.Page, lbtnSave, "提交失败,系统异常!", "系统提示"); } }
public static void DeleteList(List<int> list) { BLL.Category bv = new BLL.Category(); foreach (int v in list) { // try to load by primary key bv.LoadByPrimaryKey(v); // if the entry doesn't exist, create it if (bv.RowCount > 0) { bv.MarkAsDeleted(); bv.Save(); } // populate the contents of v on the to the database list } }
public static void SaveList(List<HCMIS.Desktop.DirectoryServices.DrugCategory> list) { BLL.Category bv = new BLL.Category(); foreach (HCMIS.Desktop.DirectoryServices.DrugCategory v in list) { // try to load by primary key bv.LoadByPrimaryKey(v.ID.Value); // if the entry doesn't exist, create it if (bv.RowCount == 0) { bv.AddNew(); } // populate the contents of v on the to the database list if( v.ID.HasValue ) bv.ID = v.ID.Value; if( v.CategoryName != "" && v.CategoryName != null ) bv.CategoryName = v.CategoryName; if( v.CategoryCode != "" && v.CategoryCode != null ) bv.CategoryCode = v.CategoryCode; if( v.Description != "" && v.Description != null ) bv.Description = v.Description; //if( v.IsDeleted.HasValue ) // bv.IsDeleted = v.IsDeleted.Value; //if( v.UpdateTime.HasValue ) // bv.UpdateTime = v.UpdateTime.Value; bv.Save(); } }