private void BindDDL(depts current) { List <DeptTree> listdepts = new List <DeptTree>(); foreach (depts dep in DeptHelper.Depts) { listdepts.Add(new DeptTree { ID = dep.ID, Name = dep.Name, SortIndex = dep.SortIndex, ParentID = dep.ParentID, Remark = dep.Remark, Enabled = dep.Enabled } ); } List <DeptTree> depts = ResolveDDL <DeptTree>(listdepts, current.ID); // 绑定到下拉列表(启用模拟树功能和不可选择项功能) ddlParent.EnableSimulateTree = true; ddlParent.DataTextField = "Name"; ddlParent.DataValueField = "ID"; ddlParent.DataSimulateTreeLevelField = "TreeLevel"; ddlParent.DataEnableSelectField = "Enabled"; ddlParent.DataSource = depts; ddlParent.DataBind(); if (current.ParentID > 0) { // 选中当前节点的父节点 ddlParent.SelectedValue = current.ParentID.ToString(); } }
protected void btnSaveClose_Click(object sender, EventArgs e) { int id = GetQueryIntValue("id"); depts item = Core.Container.Instance.Resolve <IServiceDepts>().GetEntity(id); //Dept item = DB.Depts.Include(d => d.Parent).Where(d => d.ID == id).FirstOrDefault(); if (item != null) { item.Name = tbxName.Text.Trim(); item.SortIndex = Convert.ToInt32(tbxSortIndex.Text.Trim()); item.Remark = tbxRemark.Text.Trim(); int parentID = Convert.ToInt32(ddlParent.SelectedValue); if (parentID == -1) { item.ParentID = 0; } else { item.ParentID = parentID; } Core.Container.Instance.Resolve <IServiceDepts>().Update(item); //DB.SaveChanges(); } //FineUIPro.Alert.Show("保存成功!", String.Empty, FineUIPro.Alert.DefaultIcon, FineUIPro.ActiveWindow.GetHidePostBackReference()); PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); }
//protected void btnSaveClose_Click(object sender, EventArgs e) //{ // int selectedRowIndex = Grid1.SelectedRowIndex; // string deptID = Grid1.DataKeys[selectedRowIndex][0].ToString(); // string deptName = Grid1.DataKeys[selectedRowIndex][1].ToString(); // //PageContext.RegisterStartupScript(ActiveWindow.GetWriteBackValueReference(deptID, deptName) // // + ActiveWindow.GetHideReference()); // PageContext.RegisterStartupScript(String.Format("selectDept({0},{1});", JsHelper.Enquote(deptName), JsHelper.Enquote(deptID))); //} protected void Grid1_RowDataBound(object sender, FineUIPro.GridRowEventArgs e) { // 行绑定后,确定应该选择哪一行 depts dept = e.DataItem as depts; if (dept != null && _deptID == dept.ID) { _selectedRowIndex = e.RowIndex; } }
private void LoadData() { btnClose.OnClientClick = ActiveWindow.GetHideReference(); int id = GetQueryIntValue("id"); users current = Core.Container.Instance.Resolve <IServiceUsers>().GetEntity(id); //User item = DB.Users // .Include(u => u.Dept) // .Include(u => u.Roles) // .Include(u => u.Titles) // .Where(u => u.ID == id).FirstOrDefault(); //item.Name = tbxName.Text.Trim(); if (current == null) { // 参数错误,首先弹出Alert对话框然后关闭弹出窗口 Alert.Show("参数错误!", String.Empty, ActiveWindow.GetHideReference()); return; } labName.Text = current.Name; labRealName.Text = current.ChineseName; labCompanyEmail.Text = current.CompanyEmail; labEmail.Text = current.Email; labCellPhone.Text = current.CellPhone; labOfficePhone.Text = current.OfficePhone; labOfficePhoneExt.Text = current.OfficePhoneExt; labHomePhone.Text = current.HomePhone; labRemark.Text = current.Remark; labEnabled.Text = current.Enabled ? "启用" : "禁用"; labGender.Text = current.Gender; // 用户所属角色 IList <ICriterion> qryList = new List <ICriterion>(); qryList.Add(Expression.Eq("UserID", current.ID)); IList <roleusers> entityList = Core.Container.Instance.Resolve <IServiceRoleUsers>().GetAllByKeys(qryList); List <roles> roleList = new List <roles>(); foreach (roleusers obj in entityList) { roles entity = Core.Container.Instance.Resolve <IServiceRoles>().GetEntity(obj.RoleID); roleList.Add(entity); } labRole.Text = String.Join(",", roleList.Select(r => r.Name).ToArray()); // 用户所属的部门 if (current.DeptID != 0) { depts Dept = Core.Container.Instance.Resolve <IServiceDepts>().GetEntity(current.DeptID); labDept.Text = Dept.Name; } }
private void InitUserDept(users current) { if (current.DeptID != 0) { depts Dept = Core.Container.Instance.Resolve <IServiceDepts>().GetEntity(current.DeptID); if (Dept != null) { tbSelectedDept.Text = Dept.Name; hfSelectedDept.Text = Dept.ID.ToString(); } } //// 打开编辑窗口 //string selectDeptURL = String.Format("./user_select_dept.aspx?ids=<script>{0}</script>", hfSelectedDept.GetValueReference()); //tbSelectedDept.OnClientTriggerClick = Window1.GetSaveStateReference(hfSelectedDept.ClientID, tbSelectedDept.ClientID) // + Window1.GetShowReference(selectDeptURL, "选择用户所属的部门"); }
private void LoadData() { btnClose.OnClientClick = ActiveWindow.GetHideReference(); int id = GetQueryIntValue("id"); depts current = Core.Container.Instance.Resolve <IServiceDepts>().GetEntity(id); //Dept current = DB.Depts.Find(id); if (current == null) { // 参数错误,首先弹出Alert对话框然后关闭弹出窗口 Alert.Show("参数错误!", String.Empty, ActiveWindow.GetHideReference()); return; } // 每页记录数 Grid1.PageSize = ConfigHelper.PageSize; ddlGridPageSize.SelectedValue = ConfigHelper.PageSize.ToString(); BindGrid(); }
private void SaveItem() { depts item = new depts(); item.Name = tbxName.Text.Trim(); item.SortIndex = Convert.ToInt32(tbxSortIndex.Text.Trim()); item.Remark = tbxRemark.Text.Trim(); int parentID = Convert.ToInt32(ddlParent.SelectedValue); if (parentID == -1) { item.ParentID = 0; } else { item.ParentID = parentID; } Core.Container.Instance.Resolve <IServiceDepts>().Create(item); //DB.Depts.Add(item); //DB.SaveChanges(); }
private void LoadData() { btnClose.OnClientClick = ActiveWindow.GetHideReference(); int id = GetQueryIntValue("id"); depts current = Core.Container.Instance.Resolve <IServiceDepts>().GetEntity(id); //Dept current = DB.Depts.Include(d => d.Parent) // .Where(d => d.ID == id).FirstOrDefault(); if (current == null) { // 参数错误,首先弹出Alert对话框然后关闭弹出窗口 Alert.Show("参数错误!", String.Empty, ActiveWindow.GetHideReference()); return; } tbxName.Text = current.Name; tbxSortIndex.Text = current.SortIndex.ToString(); tbxRemark.Text = current.Remark; // 绑定下拉列表 BindDDL(current); }