Пример #1
0
        /// <summary>
        /// 添加实验室
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnDepSave_Click(object sender, EventArgs e)
        {
            try
            {
                StringBuilder sb      = new StringBuilder();
                SortedList    SQLlist = new SortedList(new MySort());
                if (DictUserId != 0)
                {
                    if (gdDep.SelectedRowIndexArray.Length != 0)
                    {
                        var library = new DictuserandlabdeptService();
                        Dictuserandlabdept userdep = new Dictuserandlabdept();
                        userdep.Dictuserid = DictUserId;
                        Hashtable hts = new Hashtable();
                        hts.Add("value", userdep.Dictuserid);
                        SQLlist.Add(new Hashtable()
                        {
                            { "DELETE", "Dict.DeleteDictuserandlabdeptByUserId" }
                        }, userdep.Dictuserid);
                        foreach (int row in gdDep.SelectedRowIndexArray)
                        {
                            Dictuserandlabdept dictuserandlabdep = new Dictuserandlabdept();
                            dictuserandlabdep.Dictuserandlabdeptid = library.getSeqID("SEQ_DICTUSERANDLABDEPT");
                            dictuserandlabdep.Dictlabdeptid        = Convert.ToDouble(gdDep.DataKeys[row][0].ToString());
                            dictuserandlabdep.Dictuserid           = Convert.ToInt32(DictUserId);
                            dictuserandlabdep.Createdate           = DateTime.Now;
                            SQLlist.Add(new Hashtable()
                            {
                                { "INSERT", "Dict.InsertDictuserandlabdept" }
                            }, dictuserandlabdep);
                        }

                        if (library.ExecuteSqlTran(SQLlist))
                        {
                            BindGridDep();
                            MessageBoxShow("所选实验室已成功保存,需重新登陆数据才能生效!", MessageBoxIcon.Information);
                        }
                        else
                        {
                            MessageBoxShow("所选实验室添加有误!", MessageBoxIcon.Warning);
                        }
                    }
                    else
                    {
                        MessageBoxShow("您未选择实验室!", MessageBoxIcon.Warning);
                    }
                }
                else
                {
                    MessageBoxShow("您还未选择用户!", MessageBoxIcon.Warning);
                }
            }
            catch (Exception ex)
            {
                MessageBoxShow(ex.Message, MessageBoxIcon.Error);
            }
        }
Пример #2
0
        /// <summary>
        /// 绑定实验室
        /// </summary>
        private void BindGridDep()
        {
            try
            {
                //分页查询条件
                PageUtil  pageUtil = new PageUtil(gdDep.PageIndex, gdDep.PageSize);
                Hashtable ht1      = new Hashtable();
                //ht1.Add("Userid", DictUserId);
                ht1.Add("pageStart", pageUtil.GetPageStartNum());
                ht1.Add("pageEnd", pageUtil.GetPageEndNum());
                //设置总项数
                gdDep.RecordCount = new DictlabdeptService().GetDictlabdeptPageLstCount(ht1);
                gdDep.DataSource  = new DictlabdeptService().GetDictlabdeptPageLst(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);
                //}
                Hashtable ht2 = new Hashtable();
                ht2.Add("Userid", DictUserId);
                ht2.Add("pageStart", pageUtil.GetPageStartNum());
                ht2.Add("pageEnd", pageUtil.GetPageEndNum());
                IList <Dictuserandlabdept> dictlabIlst = new DictuserandlabdeptService().GetDictuserandlabdeptPageLst(ht2);
                gdDep.DataBind();
                int[] labArray = new int[dictlabIlst.Count];
                if (dictlabIlst.Count != 0)
                {
                    int index = 0;
                    foreach (Dictuserandlabdept item in dictlabIlst)
                    {
                        labArray[index] = dictlabdep.IndexOf(dictlabdep.Find(lab => lab.Dictlabdeptid == item.Dictlabdeptid));
                        index++;
                    }
                    gdDep.SelectedRowIndexArray = labArray;
                }
                else
                {
                    gdDep.SelectedRowIndexArray = new int[] { };
                }
            }
            catch (Exception ex)
            {
                MessageBoxShow(ex.Message, MessageBoxIcon.Error);
            }
        }