private bool WfChkSecurity() { // 輸入的帳號及密碼 string userId, passWord; StringBuilder sbSql; List <SqlParameter> sqlParmList; try { userId = txt_InputUserid.Text; passWord = txt_InputPassword.Text; if (GlobalFn.varIsNull(userId)) { WfShowErrorMsg("請輸入使用者 ID !"); return(false); } if (GlobalFn.varIsNull(passWord)) { WfShowErrorMsg("請輸入使用者 密碼 !"); return(false); } sbSql = new StringBuilder(); sbSql.AppendLine("SELECT * FROM ada_tb "); sbSql.AppendLine("WHERE ada01=@ada01"); //sbSql.AppendLine("AND ada05=@ada05"); sqlParmList = new List <SqlParameter>(); sqlParmList.Add(new SqlParameter("ada01", userId)); //sqlParmList.Add(new SqlParameter("ada05", passWord)); //drAda = BoSecurity.OfGetDataRow(sbSql.ToString(), sqlParmList.ToArray()); var adaModel = BoSecurity.OfGetAdaModel(userId); //取得使用者資料 if (adaModel == null) { WfShowErrorMsg("無此帳號,請重新輸入!"); IntTryTimes++; if (IntTryTimes >= 3) { WfShowErrorMsg("輸入錯誤三次以上,程式即將關閉...!"); this.DialogResult = DialogResult.Cancel; this.Close(); } return(false); } else { var md5Hash = GlobalFn.genMd5Hash(passWord); if (md5Hash != adaModel.ada05) { WfShowErrorMsg("帳號或密碼錯誤,請重新輸入!"); IntTryTimes++; if (IntTryTimes >= 3) { WfShowErrorMsg("輸入錯誤三次以上,程式即將關 閉...!"); this.DialogResult = DialogResult.Cancel; this.Close(); } return(false); } } LoginInfo.UserNo = GlobalFn.isNullRet(adaModel.ada01, ""); LoginInfo.UserName = GlobalFn.isNullRet(adaModel.ada02, ""); LoginInfo.GroupNo = GlobalFn.isNullRet(adaModel.ada03, ""); if (!GlobalFn.varIsNull(LoginInfo.GroupNo)) { var adeTbModel = BoSecurity.OfGetAdeModel(LoginInfo.GroupNo); if (adeTbModel != null) { LoginInfo.GroupLevel = adeTbModel.ade03; } } //LoginInfo.DeptNo = Global_Fn.isNullRet(ldr_ada["ada03"], ""); //移至開啟視窗中執行 //LoginInfo.DeptName = ""; //移至開啟視窗中執行 LoginInfo.UserRole = GlobalFn.isNullRet(adaModel.ada04, ""); this.DialogResult = DialogResult.OK; return(true); //this.Close(); } catch (Exception ex) { throw ex; } }
protected override bool WfItemCheck(object sender, ItemCheckInfo e) { List <vw_admi100s> detailList = null; int chkCnts = 0; try { #region 單頭 vw_admi100 if (e.Row.Table.Prefix.ToLower() == "vw_admi100") { switch (e.Column.ToLower()) { case "ada01": //使用者ID if (GlobalFn.varIsNull(e.Value)) { return(true); } if (FormEditMode == YREditType.新增) { if (BoAdm.OfChkAdaPKExists(e.Value.ToString())) { WfShowErrorMsg("使用者ID已存在!"); return(false); } } break; case "ada03": //使用者部門 if (GlobalFn.varIsNull(e.Value)) { e.Row["ada03_c"] = ""; break; } if (BoAdm.OfChkAdePKExists(e.Value.ToString()) == false) { WfShowErrorMsg("無此使用者部門代號,請確認!"); return(false); } e.Row["ada03_c"] = BoAdm.OfGetAde02(e.Value.ToString()); break; case "ada04": if (GlobalFn.varIsNull(e.Value)) { e.Row["ada04_c"] = ""; break; } if (BoAdm.OfChkAdcPKExists(e.Value.ToString()) == false) { WfShowErrorMsg("無此角色代號,請確認!"); return(false); } e.Row["ada04_c"] = BoAdm.OfGetAdc02(e.Value.ToString()); break; case "ada05": //登入密碼 要處理編碼方式 if (GlobalFn.varIsNull(e.Value)) { if (!GlobalFn.varIsNull(OldValue)) { e.Row["ada05"] = OldValue; return(true); } } e.Row["ada05"] = GlobalFn.genMd5Hash(e.Value.ToString()); e.Row["ada06"] = "Y"; break; case "ada08": //預設營運公司 if (GlobalFn.varIsNull(e.Value)) { return(true); } if (BoAdm.OfChkAtaPKExists(e.Value.ToString()) == false) { WfShowErrorMsg("無此公司別,請確認!"); return(false); } //檢查單身是否有此登入公司 detailList = TabDetailList[0].DtSource.ToList <vw_admi100s>(); if (detailList != null) { chkCnts = detailList.Where(p => p.adb02 == e.Value.ToString()) .Count(); } if (detailList == null || chkCnts == 0) { var result = WfShowConfirmMsg("無此登入公司別權限,是否要新增?"); if (result == DialogResult.Yes) { var newRow = TabDetailList[0].DtSource.NewRow(); WfSetDetailRowDefault(0, newRow); newRow["adb02"] = e.Value; var ataModel = BoAdm.OfGetAtaModel(e.Value.ToString()); newRow["adb02_c"] = ataModel.ata02; TabDetailList[0].DtSource.Rows.Add(newRow); } } break; } } #endregion #region 單身 vw_admi100s if (e.Row.Table.Prefix.ToLower() == "vw_admi100s") { switch (e.Column.ToLower()) { case "adb02": //可登入公司 if (GlobalFn.varIsNull(e.Value)) { e.Row["adb02_c"] = ""; return(true); } if (BoAdm.OfChkAtaPKExists(e.Value.ToString()) == false) { WfShowErrorMsg("無此公司代號,請確認!"); return(false); } detailList = TabDetailList[0].DtSource.ToList <vw_admi100s>(); chkCnts = detailList.Where(p => p.adb02.ToUpper() == e.Value.ToString().ToUpper()).Count(); if (chkCnts > 1) { WfShowErrorMsg("公司代碼重覆,請確認!"); return(false); } e.Row["adb02_c"] = BoAdm.OfGetAta02(e.Value.ToString()); break; } } #endregion return(true); } catch (Exception ex) { throw ex; } }