protected override void OnInitData() { base.OnInitData(); try { if (String.IsNullOrEmpty(id)) { id = String.Empty; txtProjectCode.Text = String.Empty; txtProjectName.Text = String.Empty; txtProjectDesc.Text = String.Empty; txtWorkDate.Text = String.Empty; CtrlHelper.SelectDropDownList(ddlProjectType, DropAddFlag.Select.ToString()); CtrlHelper.SelectDropDownList(ddlProjectStatus, DropAddFlag.Select.ToString()); CtrlHelper.SelectDropDownList(ddlProjectManager, DropAddFlag.Select.ToString()); CtrlHelper.SelectDropDownList(ddlWorkUnit, DropAddFlag.Select.ToString()); } else { BusProject item = SqlBaseProvider.GetBusProject(id); if (String.IsNullOrEmpty(item.ProjectID)) { throw new Exception("未找到编号为[" + id + "]的员工信息!"); } id = item.ProjectID; txtProjectCode.Text = item.ProjectCode; txtProjectName.Text = item.ProjectName; txtWorkDate.Text = item.WorkDate.ToString(); txtProjectDesc.Text = item.ProjectDesc; CtrlHelper.SelectDropDownList(ddlProjectManager, item.ProjectManager.ToString()); CtrlHelper.SelectDropDownList(ddlProjectType, item.ProjectType.ToString()); CtrlHelper.SelectDropDownList(ddlProjectStatus, item.ProjectStatus.ToString()); CtrlHelper.SelectDropDownList(ddlWorkUnit, item.WorkUnit.ToString()); int mAuth = Program.ManInfo.Auths.FindAuthByCode(this.mCode); if (!CoreCtrls.CheckAuth(mAuth, AuthType.Edit)) { this.OnDisplayAllCtrls(false); tsbCancel.Visible = false; tsbSave.Visible = false; tsbEdit.Visible = false; this.fState = FormState.Detail; } else { this.OnDisplayEditCtrls(false); this.fState = FormState.Edit; } } } catch (Exception) { throw; } }
private void OnInitAuth() { mAuth = Program.ManInfo.Auths.FindAuthByCode(this.mCode); if (!CoreCtrls.CheckAuth(mAuth, AuthType.New)) { tsbAdd.Visible = false; } if (!CoreCtrls.CheckAuth(mAuth, AuthType.Edit)) { tsbEdit.Visible = false; } if (!(CoreCtrls.CheckAuth(mAuth, AuthType.New) || CoreCtrls.CheckAuth(mAuth, AuthType.Edit))) { tssModify.Visible = false; tsbSave.Visible = false; tsbCancel.Visible = false; tssSave.Visible = false; } if (!CoreCtrls.CheckAuth(mAuth, AuthType.Export)) { tsbExport.Visible = false; } }
protected override void OnInitAuth() { base.OnInitAuth(); int mAuth = Program.ManInfo.Auths.FindAuthByCode(this.mCode); if (CoreCtrls.CheckAuth(mAuth, AuthType.Set)) { tsbEdit.Visible = true; } }
private void OnInitAuth() { mAuth = Program.ManInfo.Auths.FindAuthByCode(this.mCode); //mAuth = (int)AuthType.All; if (!CoreCtrls.CheckAuth(mAuth, AuthType.Browse)) { tsbFirst.Visible = false; tsbPrev.Visible = false; tsbNext.Visible = false; tsbLast.Visible = false; tssNav.Visible = false; } tsbCopy.Visible = false; if (!CoreCtrls.CheckAuth(mAuth, AuthType.Search)) { tsbSearch.Visible = false; } if (!CoreCtrls.CheckAuth(mAuth, AuthType.New)) { tsbAdd.Visible = false; } if (!CoreCtrls.CheckAuth(mAuth, AuthType.Edit)) { tsbEdit.Visible = false; } if (!CoreCtrls.CheckAuth(mAuth, AuthType.Delete)) { tsbDelete.Visible = false; } if (!(CoreCtrls.CheckAuth(mAuth, AuthType.New) || CoreCtrls.CheckAuth(mAuth, AuthType.Edit) || CoreCtrls.CheckAuth(mAuth, AuthType.Delete))) { tssModify.Visible = false; } if (!CoreCtrls.CheckAuth(mAuth, AuthType.Print)) { tsbPrint.Visible = false; } if (!CoreCtrls.CheckAuth(mAuth, AuthType.Export)) { tsbExport.Visible = false; } }
private void clMenu_SelectedIndexChanged(object sender, EventArgs e) { if (authdt == null) { return; } if ((clMenu.SelectedIndex >= 0) && (clMenu.SelectedIndex < clMenu.Items.Count)) { if (clMenu.GetItemChecked(clMenu.SelectedIndex)) { DataRow dr = menudt.Rows[clMenu.SelectedIndex]; menudt.Rows[clMenu.SelectedIndex]["Is_Select"] = 1; int mauth = Convert.ToInt32(dr["M_Auth"]); int auth = 0; clAuth.Items.Clear(); foreach (DataRow authdr in authdt.Rows) { auth = Convert.ToInt32(authdr["Auth_ID"]); auth = Convert.ToInt32(Math.Pow(2, auth - 1)); if (CoreCtrls.CheckAuth(mauth, (AuthType)auth)) { clAuth.Items.Add(authdr["Auth_Name"]); if (CoreCtrls.CheckAuth(Convert.ToInt32(dr["Role_Auth"]), (AuthType)auth)) { clAuth.SetItemCheckState(clAuth.Items.Count - 1, CheckState.Checked); } else { clAuth.SetItemCheckState(clAuth.Items.Count - 1, CheckState.Unchecked); } } } } else { menudt.Rows[clMenu.SelectedIndex]["Is_Select"] = 0; clAuth.Items.Clear(); } } }
private void clAuth_SelectedIndexChanged(object sender, EventArgs e) { if (authdt == null) { return; } int i = 0; int auth = 0; if ((clMenu.SelectedIndex >= 0) && (clMenu.SelectedIndex < clMenu.Items.Count)) { DataRow dr = menudt.Rows[clMenu.SelectedIndex]; if ((clAuth.SelectedIndex >= 0) && (clAuth.SelectedIndex < clMenu.Items.Count)) { foreach (DataRow authdr in authdt.Rows) { if (authdr["Auth_Name"].ToString() == clAuth.Items[clAuth.SelectedIndex].ToString()) { auth = Convert.ToInt32(Math.Pow(2, Convert.ToInt32(authdr["Auth_ID"]) - 1)); break; } i++; } if (clAuth.GetItemChecked(clAuth.SelectedIndex)) { if (!CoreCtrls.CheckAuth(Convert.ToInt32(dr["Role_Auth"]), (AuthType)auth)) { dr["Role_Auth"] = Convert.ToInt32(dr["Role_Auth"]) + auth; } } else { if (CoreCtrls.CheckAuth(Convert.ToInt32(dr["Role_Auth"]), (AuthType)auth)) { dr["Role_Auth"] = Convert.ToInt32(dr["Role_Auth"]) - auth; } } } } }
private void OnInitAuth() { if (String.IsNullOrEmpty(this.mCode)) { return; } mAuth = Program.ManInfo.Auths.FindAuthByCode(this.mCode); if (!(CoreCtrls.CheckAuth(mAuth, AuthType.New) || CoreCtrls.CheckAuth(mAuth, AuthType.Edit) || CoreCtrls.CheckAuth(mAuth, AuthType.Delete))) { tsbSave.Visible = false; tsbCancel.Visible = false; tssPrint.Visible = false; } if (!CoreCtrls.CheckAuth(mAuth, AuthType.Print)) { tssPrint.Visible = false; tsbPreview.Visible = false; tsbPrint.Visible = false; } }
protected override void OnInitData() { base.OnInitData(); try { Global.EnableComboxTree(ectDept); if (String.IsNullOrEmpty(id)) { txtManID.Text = String.Empty; txtManName.Text = String.Empty; txtManTele.Text = String.Empty; CtrlHelper.SelectDropDownList(ddlManLevel, DropAddFlag.Select.ToString()); CtrlHelper.SelectDropDownList(ddlManStatus, DropAddFlag.Select.ToString()); CtrlHelper.SelectDropDownList(ddlManTitle, DropAddFlag.Select.ToString()); CtrlHelper.SelectDropDownList(ddlManType, DropAddFlag.Select.ToString()); if (Program.ManInfo.Man.ManLevel >= ml) { ectDept.SelectValue = Program.ManInfo.Man.DeptID; } else { ectDept.Text = String.Empty; } this.fState = FormState.Edit; } else { SysMan item = SqlBaseProvider.GetSysMan(id); if (String.IsNullOrEmpty(item.ManID)) { throw new Exception("未找到编号为[" + id + "]的员工信息!"); } txtManID.Text = item.ManID; txtManName.Text = item.ManName; txtManTele.Text = item.ManTele; CtrlHelper.SelectDropDownList(ddlManLevel, item.ManLevel.ToString()); CtrlHelper.SelectDropDownList(ddlManStatus, item.ManStatus.ToString()); CtrlHelper.SelectDropDownList(ddlManTitle, item.ManTitle.ToString()); CtrlHelper.SelectDropDownList(ddlManType, item.ManType.ToString()); ectDept.SelectValue = item.DeptID; int mAuth = Program.ManInfo.Auths.FindAuthByCode(this.mCode); if (!CoreCtrls.CheckAuth(mAuth, AuthType.Edit)) { this.OnDisplayAllCtrls(false); Global.DisableComboxTree(ectDept); tsbCancel.Visible = false; tsbSave.Visible = false; tsbEdit.Visible = false; this.fState = FormState.Detail; } else { this.OnDisplayEditCtrls(false); this.fState = FormState.Edit; } } if (Program.ManInfo.Man.ManLevel >= ml) { Global.DisableComboxTree(ectDept); } } catch (Exception ex) { Global.ShowSysError(ex); this.OnDisplayAllCtrls(false); Global.DisableComboxTree(ectDept); tsbCancel.Visible = false; tsbSave.Visible = false; tsbEdit.Visible = false; this.fState = FormState.Detail; } }
/// <summary> /// 窗体状态发生变化时处理,一般不重写 /// </summary> /// <param name="old"></param> /// <param name="now"></param> protected virtual void OnFormStateChanged(FormState old, FormState now) { if (old == now) { return; } // 如果是分页进入明细后为按条检索 if (PageOrRow) { if (etcMain.SelectedIndex == 0) { OnPageInit(true); } else { OnPageInit(false); } } switch (old) { case FormState.List: if (etcMain.SelectedIndex == 0) { etcMain.SelectedIndex = 1; tsbDetail.Text = "列表"; } switch (now) { case FormState.New: tsbEdit.Visible = false; tsbDelete.Visible = false; OnChoiceSave(true); break; case FormState.Edit: OnChoiceSave(true); break; } break; case FormState.Edit: switch (now) { case FormState.New: tsbEdit.Visible = false; tsbDelete.Visible = false; OnChoiceSave(true); break; case FormState.List: if (etcMain.SelectedIndex == 1) { etcMain.SelectedIndex = 0; tsbDetail.Text = "明细"; } OnChoiceSave(false); break; case FormState.Detail: OnChoiceSave(false); break; } break; case FormState.Detail: switch (now) { case FormState.New: tsbEdit.Visible = false; tsbDelete.Visible = false; OnChoiceSave(true); break; case FormState.List: if (etcMain.SelectedIndex == 1) { etcMain.SelectedIndex = 0; tsbDetail.Text = "明细"; } OnChoiceSave(false); break; case FormState.Edit: OnChoiceSave(true); break; } break; case FormState.New: OnChoiceSave(false); tsbEdit.Visible = CoreCtrls.CheckAuth(mAuth, AuthType.Edit); tsbDelete.Visible = CoreCtrls.CheckAuth(mAuth, AuthType.Delete); if (now == FormState.List) { if (etcMain.SelectedIndex == 1) { etcMain.SelectedIndex = 0; tsbDetail.Text = "明细"; } } break; } }