Пример #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);
            }
        }