public ApiResult ResetAdminPwd(string access_token, string accountID) { result = AccessToken.Check(access_token, "api/account/resetadmin"); if (result == null) { #region 参数验证 if (accountID == null || accountID == "") { return(Error("accuntID参数错误")); } #endregion #region 逻辑操作 T_Account accountModel = db.T_Account.Find(accountID); if (accountModel != null) { try { accountModel.Password = accountModel.AccountID.Substring(accountModel.AccountID.Length - 6, 6); db.SaveChanges(); return(Success("重置密码成功,初始密码为账号后六位")); } catch { return(Error("修改失败,请检查参数是否正确")); } } else { return(Error("数据错误,无法查找到此条记录")); } #endregion } return(result); }
public ActionResult SuperUser(string ClassID, string ClassNum) { if (Session["UserID"].ToString().Trim() != "999999") { return(Content("<script>alert('用户权限错误');window.location.href='../Login/Index';</script>")); } int num = int.Parse(ClassNum); for (int i = 0; i < num; i++) { T_Account user = new T_Account(); user.ID = ClassID + (i + 1).ToString("00"); user.password = ClassID + (i + 1).ToString("00"); db.T_Account.Add(user); try { db.SaveChanges(); } catch (DbEntityValidationException dbEx) { return(Content("<script>alert('错误:数据库保存错误,请联系管理员');history.go(-1);</script>")); } } return(Content("<script>alert('保存成功!');history.go(-1);</script>")); }
public ActionResult MdfPsw(string Psw0, string Psw1, string Psw2) { if (Session["UserID"] == null) { return(Content("<script>alert('用户登陆状态已失效,请重新登录');window.location.href='../Login/Index';</script>")); } string ID = Session["UserID"].ToString().Trim(); var user = from T_Account in db.T_Account where (T_Account.ID == ID) && (T_Account.password == Psw0.ToString().Trim()) select T_Account; if (user.Any() && user.Count() == 1) { if (0 == string.Compare(Psw1, Psw2)) { T_Account user1 = user.First(); user1.password = Psw1; db.SaveChanges(); return(Content("<script>alert('密码修改成功');window.location.href='../Evaluate/index';</script>")); } else { return(Content("<script>alert('错误:两次新密码输入不一致');history.go(-1);</script>")); } } else { return(Content("<script>alert('错误:原密码输入错误');history.go(-1);</script>")); } }
protected void save_Click(object sender, EventArgs e) { //表头 T_Account item = new T_Account(); item.AccountName = txt_account_name.Text.Trim(); if (string.IsNullOrEmpty(item.AccountName)) { Label1.Text = "账户名不能为空"; return; } item.AccountId = txt_account_id.Text.Trim(); if (string.IsNullOrEmpty(item.AccountId)) { Label1.Text = "账号不能为空"; return; } item.OpeningBank = txt_opening_bank.Text.Trim(); if (string.IsNullOrEmpty(item.OpeningBank)) { Label1.Text = "开户行不能为空"; return; } item.CurrencyID = Int32.Parse(ddl_currency.SelectedValue); string amount = txt_amount.Text.Trim(); if (string.IsNullOrEmpty(amount)) { item.Amount = 0; } else { item.Amount = Decimal.Parse(amount); } try { AccountAdapter aa = new AccountAdapter(); if (string.IsNullOrEmpty(HiddenField1.Value)) { aa.insertAccount(item); } else { aa.update(item); } clean(); GridView1.SelectedIndex = -1; show(); Label1.Text = "哟,小伙子,不错,被你录入成功了"; } catch (Exception ex) { Label1.Text = ex.Message; } }
public ActionResult btnLogin_Click(FormCollection formvalues) { if (formvalues["tbxOldPwd"] != null && formvalues["tbxNewPwd"] != null) { //修改账号密码 string UserID = Session["UserID"].ToString(); string oldPwd = formvalues["tbxOldPwd"].ToString(); string newPwd = formvalues["tbxNewPwd"].ToString(); var accountList = from T_Account in db.T_Account where ((T_Account.Psd == oldPwd) && (T_Account.ID == UserID)) select T_Account; if (accountList.Any()) { //修改密码 T_Account account = accountList.ToList().First(); account.Psd = newPwd; db.SaveChanges(); ShowNotify("密码更新成功!"); } else { //密码错误 ShowNotify("密码错误!"); //清空输入框 } } if (formvalues["tbxPwd"] != null && formvalues["tbxST_Num"] != null) { //初始化学生密码 string UserID = Session["UserID"].ToString(); string UserPwd = formvalues["tbxPwd"].ToString(); string ST_NUM = formvalues["tbxST_Num"].ToString(); var accountlist = from T_Account in db.T_Account where ((T_Account.Psd == UserPwd) && (T_Account.ID == UserID)) select T_Account; if (accountlist.Any()) { //密码正确 T_Account account = db.T_Account.Find(ST_NUM); if (account != null) { //此账号存在 account.Psd = ST_NUM.Substring(ST_NUM.Length - 6, 6); db.SaveChanges(); ShowNotify("密码初始化成功,为学号后六位!"); } else { //此账号不存在 ShowNotify("该学生账号不存在,请重新核对!"); } } else { //密码错误 } } return(UIHelper.Result()); }
public ApiBaseResult PrintLeave(string access_token, string LV_NUM) { ApiBaseResult result = Check(access_token); if (result == null) { result = new ApiBaseResult(); #region 检查此人是否有打印此请假条的权限 string[] sArray = access_token.Split('_'); string UserID = sArray[0]; string GuidString = sArray[1]; var accountList = from T_Account in db.T_Account where (T_Account.YB_AccessToken == GuidString) select T_Account; if (accountList.Any()) { T_Account accountModel = accountList.ToList().First(); if (accountModel.RoleID.ToString().Trim() == "1") { var leavelist = from vw_LeaveList in db.vw_LeaveList where (vw_LeaveList.StudentID == accountModel.ID && vw_LeaveList.ID == LV_NUM) select vw_LeaveList; if (leavelist.Any()) { string url = UpLoadQiNiu.UpLoadData(Print.Print_Form(LV_NUM), LV_NUM); if (url != null) { result.result = "success"; result.data = url; } else { result.result = "error"; result.messages = "出现错误,请联系系统维护人员"; } } else { result.result = "error"; result.messages = "您没有请假单号为" + LV_NUM + "此条请假记录"; } } else { result.result = "error"; result.messages = "此接口仅支持学生账号访问"; } } else { result.result = "error"; result.messages = "出现未知错误,请联系维护人员"; } #endregion } return(result); }
public ApiResult AddAdmin([FromBody] AdminAdd model) { result = AccessToken.Check(model.access_token, "api/account/addadmin"); if (result == null) { #region 参数验证 result = ParameterCheck.CheckParameters(model); if (result != null) { return(result); } #endregion #region 逻辑操作 var accountModel = from T_Account in db.T_Account where (T_Account.AccountID == model.AccountID) select T_Account; if (accountModel.Any()) { return(Error("该账号已存在")); } else { if (model.RoleID == "2" || model.RoleID == "3") { try { T_Account account = new T_Account(); account.AccountID = model.AccountID.Trim(); account.Name = model.AccountName.Trim(); account.OrgID = model.OrgID.Trim(); account.Tel = model.Tel.Trim(); account.RoleID = model.RoleID; account.Password = model.AccountID.Substring(model.AccountID.Length - 6, 6); account.State = "1";//1代表可使用 db.T_Account.Add(account); db.SaveChanges(); return(Success("添加账号成功,默认密码为账号后六位")); } catch { return(Error("添加失败,请检查参数是否正确")); } } else { return(Error("此接口只能设置校团委助理账号或学院账号")); } } #endregion } return(result); }
public ApiResult AddTeacher([FromBody] TeacherAdd model) { //此处的参数中,OrgID 和 RoleID 不能为空,且必须是数据库中包含的数据 //需要对OrgID 和 RoleID 对验证处理 验证处理部分代码尚未实现 //此处在数据库中添加了 触发器 做数据验证,输入的ID不存在时 rollback result = AccessToken.Check(model.access_token, "api/account/addteacher"); if (result == null) { #region 参数验证 result = ParameterCheck.CheckParameters(model); if (result != null) { return(result); } #endregion #region 逻辑操作 var accountModel = from T_Account in db.T_Account where (T_Account.AccountID == model.AccountID) select T_Account; if (accountModel.Any()) { return(Error("该账号已存在")); } else { try { T_Account account = new T_Account(); account.AccountID = model.AccountID.Trim(); account.Name = model.AccountName.Trim(); account.OrgID = model.OrgID.Trim(); account.Tel = model.Tel.Trim(); account.RoleID = "1"; account.Password = model.AccountID.Substring(model.AccountID.Length - 6, 6); account.State = "1";//1代表可使用 db.T_Account.Add(account); db.SaveChanges(); return(Success("添加账号成功,默认密码为账号后六位")); } catch { return(Error("添加失败,请检查参数是否正确")); } } #endregion } return(result); }
public ApiResult DeleteTeacher(string access_token, string accountID) { result = AccessToken.Check(access_token, "api/account/delteacher"); if (result == null) { #region 参数验证 if (accountID == null || accountID == "") { Dictionary <string, string> errorFields = new Dictionary <string, string>(); errorFields.Add("accountID", "accountID错误"); return(Error("参数格式错误", errorFields)); } #endregion #region 逻辑操作 var accountModel = from T_Account in db.T_Account where (T_Account.AccountID == accountID) select T_Account; if (accountModel.Any()) { if (accountModel.ToList().First().RoleID == "1") { //仅能删除角色为1的账号 try { T_Account model = db.T_Account.Find(accountID); db.T_Account.Remove(model); db.SaveChanges(); return(Success("删除成功")); } catch { return(Error("删除失败")); } } else { //不具备删除其他账号权限 return(Error("您不具备删除此账号权限")); } } else { return(Error("数据库中不包含此账号ID")); } #endregion } return(result); }
public ApiBaseResult PassWord([FromBody] ChangePsdModel PsdModel) { ApiBaseResult result; if (PsdModel != null) { if (PsdModel.old_psd == null || PsdModel.new_psd == null || PsdModel.access_token == null) { result = new ApiBaseResult(); result.result = "error"; result.messages = "参数格式错误或缺少参数!"; return(result); } } else { result = new ApiBaseResult(); result.result = "error"; result.messages = "参数格式错误或缺少参数!"; return(result); } result = Check(PsdModel.access_token); if (result == null) { result = new ApiBaseResult(); string StudentID = PsdModel.access_token.Substring(0, PsdModel.access_token.IndexOf("_")); T_Account account = db.T_Account.Find(StudentID); if (account.Psd == PsdModel.old_psd) { account.Psd = PsdModel.new_psd; db.SaveChanges(); result.result = "success"; } else { result.result = "error"; result.messages = "原密码错误,修改密码失败"; } return(result); } else { return(result); } }
public ApiResult Modify([FromBody] PasswordModify model) { //此处调用的是Check的重写方法,因为需验证是否操作的是本人的账户 result = AccessToken.Check(model.access_token, "api/password/modify", model.ID); if (result == null) { #region 参数验证 result = ParameterCheck.CheckParameters(model); if (result != null) { return(result); } if (model.NewPwd == model.OldPwd) { return(Error("新密码不能与原密码相同!")); } #endregion #region 逻辑操作 string old_pwd = model.OldPwd.ToString().Trim(); string new_pwd = model.NewPwd.ToString().Trim(); var accountlist = from T_Account in db.T_Account where (T_Account.AccountID == model.ID && T_Account.Password == old_pwd) select T_Account; if (accountlist.Any()) { try { T_Account accountmodel = db.T_Account.Find(model.ID); accountmodel.Password = new_pwd; db.SaveChanges(); return(Success("修改密码成功")); } catch { return(Error("修改密码失败")); } } else { return(Error("原密码输入错误")); } #endregion } return(result); }
public ApiResult ChangePersonalInfo([FromBody] PersonalInfoModify model) { result = AccessToken.Check(model.access_token, "api/account/changeinfo", model.ID); if (result == null) { #region 参数检查 result = ParameterCheck.CheckParameters(model); if (result != null) { return(result); } #endregion #region 逻辑操作 T_Account accountModel = db.T_Account.Find(model.ID); if (accountModel != null) { try { #region 修改服务器数据库数据 accountModel.Name = model.Name; accountModel.Tel = model.Tel; db.SaveChanges(); #endregion #region 清空服务器旧的缓存数据 AccessToken.Clear(model.access_token); #endregion return(Success("修改成功,请重新登陆!")); } catch { return(SystemError()); } } else { //若运行到此处 说明出现程序错误 返回SystemError return(SystemError()); } #endregion } return(result); }
public ApiResult ModifyAdmin([FromBody] AdminModify model) { result = AccessToken.Check(model.access_token, "api/account/modadmin"); if (result == null) { result = ParameterCheck.CheckParameters(model); if (result == null) { #region 参数验证 #endregion #region 逻辑操作 T_Account accountModel = db.T_Account.Find(model.AccountID); if (accountModel != null) { if (accountModel.RoleID == "2" || accountModel.RoleID == "3") { try { accountModel.Name = model.AccountName; accountModel.OrgID = model.OrgID; accountModel.Tel = model.Tel; db.SaveChanges(); return(Success("修改成功")); } catch { return(Error("修改失败,请检查参数是否正确")); } } else { return(Error("您不具备修改此账号权限")); } } else { return(Error("数据错误,无法查找到此条记录")); } #endregion } return(result); } return(result); }
public ApiResult BlockAccount(string access_token, string accountID) { result = AccessToken.Check(access_token, "api/account/blockstate"); if (result == null) { #region 参数验证 if (accountID == null || accountID == "") { return(Error("accuntID参数错误")); } #endregion #region 逻辑操作 T_Account accountModel = db.T_Account.Find(accountID); if (accountModel != null) { //只有助理账号可以被冻结、此处判断冻结账号是否为助理的账号 if (accountModel.RoleID != "2") { return(Error("此账号不能冻结")); } try { accountModel.State = (accountModel.State == "1") ? "0" : "1"; db.SaveChanges(); return(Success("修改状态成功")); } catch { return(Error("修改失败,请检查参数是否正确")); } } else { return(Error("数据错误,无法查找到此条记录")); } #endregion } return(result); }
/// <summary> /// 检查Access_Token /// </summary> /// <param name="access_token"></param> /// <returns></returns> public ApiBaseResult Check(string access_token) { ApiBaseResult result = new ApiBaseResult(); if (access_token != null) { string[] sArray = access_token.Split('_'); string UserID = sArray[0]; string GuidString = sArray[1]; T_Account account = db.T_Account.Find(UserID); if (account != null) { if (account.YB_AccessToken == GuidString) { return(null); } else { result.result = "error"; result.messages = "Access_Token错误"; return(result); } } else { result.result = "error"; result.messages = "Access_Token错误"; return(result); } } else { result.result = "error"; result.messages = "Access_Token为空,传值错误"; return(result); } }
public void update(T_Account item) { Manager.update(item); }
public void insertAccount(T_Account item) { Manager.insertAccount(item); }
public ApiBaseResult Access_Token_WeChat(string OpenID) { //存在问题:Access_Token会被访问两次,未找到原因 ApiBaseResult result = new ApiBaseResult(); var userList = from T_Account in db.T_Account where (T_Account.Wechat == OpenID) select T_Account; if (userList.Any()) { if (userList.ToList().First().LoginTime != null) { //判断1分钟内是否访问过该接口 TimeSpan ts = DateTime.Now - (DateTime)userList.ToList().First().LoginTime; //1分钟内已获得access_token if (ts.Minutes < 1) { AccessToken authorizeModel = new AccessToken(); string access_token = userList.ToList().First().ID + "_" + userList.ToList().First().YB_AccessToken; authorizeModel.access_token = access_token; result.result = "success"; result.data = authorizeModel; WriteLog("Old access_token", access_token); } else { //验证通过 string GuidString = Guid.NewGuid().ToString(); string access_token = ""; string UserID = userList.ToList().First().ID; T_Account account = db.T_Account.Find(UserID); account.LoginTime = DateTime.Now; access_token = account.ID + "_" + GuidString; account.Wechat = OpenID; account.YB_AccessToken = GuidString; db.SaveChanges(); AccessToken authorizeModel = new AccessToken(); authorizeModel.access_token = access_token; result.result = "success"; result.data = authorizeModel; WriteLog("New access_token", access_token); } } else { //验证通过 string GuidString = Guid.NewGuid().ToString(); string access_token = ""; string UserID = userList.ToList().First().ID; T_Account account = db.T_Account.Find(UserID); account.LoginTime = DateTime.Now; access_token = account.ID + "_" + GuidString; account.Wechat = OpenID; account.YB_AccessToken = GuidString; db.SaveChanges(); AccessToken authorizeModel = new AccessToken(); authorizeModel.access_token = access_token; result.result = "success"; result.data = authorizeModel; WriteLog("New access_token", access_token); } } else { //尚未绑定YiBanID result.result = "error"; result.messages = "尚未绑定账号的易班ID,通过Authorize接口实现易班账号绑定。"; } return(result); }
public ApiBaseResult Authorize([FromBody] User_Login user_login_info) { ApiBaseResult result = new ApiBaseResult(); string UserID = ""; string UserPSd = ""; string YiBanID = ""; #region 检查参数是否正确 if (user_login_info == null) { //参数错误 result.result = "error"; result.messages = "未接收到合法参数!"; return(result); } else { //存在合法参数正确 try { UserID = user_login_info.UserID; UserPSd = user_login_info.UserPsd; YiBanID = user_login_info.YiBanID; if (UserID == null || UserPSd == null || YiBanID == null) { result.result = "error"; result.messages = "参数格式错误或缺少参数!"; return(result); } } catch { result.result = "error"; result.messages = "参数格式错误或缺少参数!"; return(result); } } #endregion #region 账号绑定 var accountList = from T_Account in db.T_Account where (T_Account.YiBanID == YiBanID) select T_Account; if (accountList.Any()) { //此账号已绑定 result.result = "error"; result.messages = "此账号已绑定!"; } else { //此账号尚未绑定 T_Account account = db.T_Account.Find(UserID); if (account != null) { if (account.Psd == UserPSd) { //验证通过 string GuidString = Guid.NewGuid().ToString(); string access_token = UserID + "_" + GuidString; account.YiBanID = YiBanID; account.YB_AccessToken = GuidString; db.SaveChanges(); AccessToken authorizeModel = new AccessToken(); authorizeModel.access_token = access_token; result.result = "success"; result.data = authorizeModel; } else { //用户密码错误 result.result = "error"; result.messages = "账号密码错误!"; } } else { //此用户ID不存在 result.result = "error"; result.messages = "此用户ID不存在!"; } } #endregion return(result); }
protected void save_Click(object sender, EventArgs e) { T_SettlementLog log = new T_SettlementLog(); decimal out_amount = Decimal.Parse(TextBox5.Text.Trim()); decimal in_amount = Decimal.Parse(TextBox6.Text.Trim()); decimal exchange_rate = Decimal.Parse(txt_exchange_rate.Text.Trim()); log.InSettlementAmount = in_amount; log.OutSettlementAmount = out_amount; log.ExchangeRate = exchange_rate; List <T_Account> lists = new List <T_Account>(); T_Account list = new T_Account(); list.AccountId = txt_account_id.Text.Trim(); list.OpeningBank = ddl_opening_bank.SelectedValue; list.AccountName = txt_account_name.Text.Trim(); list.Amount = Decimal.Parse(txt_amount.Text.Trim()) - out_amount; list.CurrencyID = Int32.Parse(ddl_currency.SelectedValue); log.OutAccountId = list.AccountId; log.OutOpeningBank = list.OpeningBank; log.OutAccountName = list.AccountName; log.OutAmount = Decimal.Parse(txt_amount.Text.Trim()); log.OutCurrencyid = list.CurrencyID; lists.Add(list); list = new T_Account(); list.AccountId = TextBox2.Text.Trim(); list.OpeningBank = DropDownList2.SelectedValue; list.AccountName = TextBox3.Text.Trim(); list.Amount = Decimal.Parse(TextBox4.Text.Trim()) + in_amount; list.CurrencyID = Int32.Parse(DropDownList1.SelectedValue); log.InAccountId = list.AccountId; log.InOpeningBank = list.OpeningBank; log.InAccountName = list.AccountName; log.InAmount = Decimal.Parse(TextBox4.Text.Trim()); log.InCurrencyid = list.CurrencyID; lists.Add(list); log.OperateTime = DateTime.Now; log.Operater = UserInfoAdapter.CurrentUser.Name; try { AccountAdapter aa = new AccountAdapter(); aa.updateLists(lists); aa.log(log); show(); clean(); Label1.Text = "结汇成功"; } catch (Exception ex) { Label1.Text = ex.Message; return; } }