/// <summary> /// 绑定分点列表 /// </summary> private void BindGridLabTo() //分点列表 { try { //分页查询条件 PageUtil pageUtil = new PageUtil(gdLabItem.PageIndex, gdLabItem.PageSize); Hashtable ht1 = new Hashtable(); //ht1.Add("Userid", DictUserId); ht1.Add("pageStart", pageUtil.GetPageStartNum()); //pageUtil.GetPageStartNum() ht1.Add("pageEnd", pageUtil.GetPageEndNum()); // pageUtil.GetPageEndNum() //设置总项数 gdLabItem.RecordCount = new DictlabService().GetDictlabPageLstCount(ht1); gdLabItem.DataSource = new DictlabService().GetDictlabPageLst(ht1); List <Dictlabdept> dictlabdep = new DictlabdeptService().GetDictlabdeptPageLstUser(ht1).ToList(); //double userId = 0; //if (gvList.SelectedRowIndexArray.Length > 0) //{ // object[] objValue = gvList.DataKeys[gvList.SelectedRowIndexArray[0]]; // userId = TypeParse.StrToDouble(objValue[0], 0); //} //全部列表 List <Dictlab> labLst = new DictlabService().GetDictlabPageLst(ht1).ToList <Dictlab>(); Hashtable ht2 = new Hashtable(); ht2.Add("Userid", DictUserId); ht2.Add("pageStart", pageUtil.GetPageStartNum()); ht2.Add("pageEnd", pageUtil.GetPageEndNum()); IList <Dictuserandlab> dictlabList = new DictuserlabService().GetDictuserandlabPageLst(ht2); gdLabItem.DataBind(); int[] labArray = new int[dictlabList.Count]; if (dictlabList.Count != 0) { int index = 0; foreach (Dictuserandlab item in dictlabList) { labArray[index] = labLst.IndexOf(labLst.Find(lab => lab.Dictlabid == item.Dictlabid)); index++; } gdLabItem.SelectedRowIndexArray = labArray; } else { gdLabItem.SelectedRowIndexArray = new int[] { }; } } catch (Exception ex) { MessageBoxShow(ex.Message, MessageBoxIcon.Error); } }
/// <summary> /// 分点添加 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSave_Click(object sender, EventArgs e) { try { StringBuilder sb = new StringBuilder(); SortedList SQLlist = new SortedList(new MySort()); //double userId = 0; //if (gvList.SelectedRowIndexArray.Length > 0) //{ // object[] objValue = gvList.DataKeys[gvList.SelectedRowIndexArray[0]]; // userId = TypeParse.StrToDouble(objValue[0], 0); //} if (DictUserId != 0) { if (gdLabItem.SelectedRowIndexArray.Length > 0) { var library = new DictuserlabService(); Dictuserandlab userlab = new Dictuserandlab(); userlab.Dictuserid = DictUserId; Hashtable hts = new Hashtable(); hts.Add("value", userlab.Dictuserid); SQLlist.Add(new Hashtable() { { "DELETE", "Dict.DeleteDictuserandlabByUserId" } }, userlab.Dictuserid); foreach (int row in gdLabItem.SelectedRowIndexArray) { Dictuserandlab dictuserandlabList = new Dictuserandlab(); dictuserandlabList.Dictuserandlabid = library.getSeqID("SEQ_DICTUSERANDLAB"); dictuserandlabList.Dictlabid = Convert.ToDouble(gdLabItem.DataKeys[row][0].ToString()); dictuserandlabList.Dictuserid = Convert.ToInt32(DictUserId); dictuserandlabList.Createdate = DateTime.Now; SQLlist.Add(new Hashtable() { { "INSERT", "Dict.InsertDictuserandlab" } }, dictuserandlabList); } if (library.ExecuteSqlTran(SQLlist)) { BindGridLabTo(); MessageBoxShow("所选分点已成功保存,需重新登陆数据才能生效!", MessageBoxIcon.Information); } else { MessageBoxShow("所选分点添加有误!", MessageBoxIcon.Warning); } } else { MessageBoxShow("您未选择分点!", MessageBoxIcon.Warning); } } else { MessageBoxShow("您还未选择用户!", MessageBoxIcon.Warning); } } catch (Exception ex) { MessageBoxShow(ex.Message, MessageBoxIcon.Error); } }