/// <summary> /// 保存操作 fenghp /// </summary> /// <param name="user"></param> /// <returns></returns> public bool Save(DADictuser user) { int nflag = 0; //新增 if (user.Dictuserid == 0 || user.Dictuserid == null) { try { //user.Dictuserid = new BaseService().getSeqID("SEQ_DA_DICTUSER"); new BaseService().insert("InsertDADictuser", user); nflag = 1; } catch (Exception ex) { nflag = 0; throw new Exception(ex.Message); } } else//修改 { try { new BaseService().update("UpdateDADictuser", user); nflag = 1; } catch (Exception ex) { nflag = 0; throw new Exception(ex.Message); } } return(nflag > 0); }
//开始服务 private void btnStart_Click(object sender, EventArgs e) { decimal cid = DefaultConfig.DACONFIGID; decimal.TryParse(ConfigurationManager.AppSettings["DaConfigID"], out cid); //读取默认配置 config = new DAConfigBLL().SelectyDAConfigInfo(cid); if (config == null) { SetTB("没有维护配置文件!"); return; } //设置间隔时间 timer.Interval = config.IntervalToDouble; double dInterval = 0; //获取配置时间间隔,设置logtimer间隔时间 fenghp string sss = ConfigurationManager.AppSettings["ErrorLogInterval"].ToString(); double.TryParse(ConfigurationManager.AppSettings["ErrorLogInterval"].ToString(), out dInterval); logtimer.Interval = dInterval * 1000 * 60; sendtimer.Interval = dInterval * 1000 * 60; //查询admin信息 user.Usercode = "admin"; user = new DADictuserBLL().GetDADictuserInfoByUserCode(user); //开启 timer.Start(); logtimer.Start(); SetTB("服务开启!"); btnStart.Enabled = false; btnStop.Enabled = true; btnStop.Focus(); //更新webservice WebServiceUtils.SetIsUpdate(config.Address); DownResult(); // UploadLog(); //自动上传订单 string issend = ConfigurationManager.AppSettings["IsSend"]; if (issend == "1") { sendtimer.Start(); sendOrders(); } }
//绑定数据 private void DataBind() { if (Id != 0) { //限制用户修改权限 if (curUserCode.ToLower() != "admin" && UserCode.ToLower() != curUserCode.ToLower()) { //当前用户不是管理员时不能保存 btnSava.Enabled = false; } //当前用户为管理员,要修改的用户也为管理员,不能修改管理员用户名 if (curUserCode.ToLower() == "admin" && UserCode.ToLower() == "admin") { tbxUserCode.Enabled = false; } //当前用户不为管理员,修改的是自己的用户 if (curUserCode.ToLower() != "admin" && UserCode.ToLower() == curUserCode.ToLower()) { btnSava.Enabled = true; tbxUserCode.Enabled = false; } Hashtable ht = new Hashtable(); ht.Add("Dictuserid", Id); List <DADictuser> userLst = userBll.GetDADictuserInfo(ht); if (userLst.Count > 0) { DADictuser user = userLst[0]; tbxUserCode.Text = user.Usercode; tbxUserName.Text = user.Username; tbxUserPwd.Text = user.Password; tbxPwdOK.Text = user.Password; password = user.Password; tbxUserDescript.Text = user.Remark; if (user.Isactive == "1") { cbUserIdOK.Checked = true; } else { cbUserIdOK.Checked = false; } } } else { this.Text = "添加用户信息"; } }
private void btnOK_Click(object sender, EventArgs e) { //验证 if (desencrypt.getMd5Hash(tbxOldUserPwd.Text.ToString()) != password) { ShowMessageHelper.ShowBoxMsg("旧密码错误,请重新输入!"); tbxOldUserPwd.Focus(); return; } if (tbxUserPwd.Text.Contains(" ")) { ShowMessageHelper.ShowBoxMsg("密码不能存在空格!"); tbxUserPwd.Focus(); return; } if (tbxUserPwd.Text == string.Empty) { ShowMessageHelper.ShowBoxMsg("密码不能为空!"); tbxUserPwd.Focus(); return; } if (tbxUserPwd.Text.Trim().Length < 6) { ShowMessageHelper.ShowBoxMsg("密码过于简单,请输入大于6位的密码!"); return; } if (tbxPwdOK.Text.ToString() != tbxUserPwd.Text.ToString()) { ShowMessageHelper.ShowBoxMsg("两次输入的密码不一致,请重新输入!"); tbxPwdOK.Focus(); return; } DADictuser user = new DADictuser(); user.Usercode = UserCode; user = userBll.GetDADictuserInfoByUserCode(user); user.Password = desencrypt.getMd5Hash(tbxPwdOK.Text.ToString()); if (userBll.Save(user)) { ShowMessageHelper.ShowBoxMsg("修改成功!"); this.DialogResult = DialogResult.OK; this.Close(); } else { ShowMessageHelper.ShowBoxMsg("修改失败!"); } }
private void FrmModifyPwd_Load(object sender, EventArgs e) { //医院用户才能修改密码 if (SystemConfig.UserInfo.UserType == 1) { UserCode = SystemConfig.UserInfo.UserCode; DADictuser user = new DADictuser(); user.Usercode = UserCode; user = userBll.GetDADictuserInfoByUserCode(user); password = user.Password; } else { btnOK.Enabled = false; } }
//判断是否已经存在用户编码 private bool isExist(DADictuser dictUser) { bool istrue = false; DADictuser user = new DADictuser(); user = userBll.GetDADictuserInfoByUserCode(dictUser); if (user != null) { if (Id == 0)//如果是添加 { istrue = true; } else { if (user.Dictuserid != dictUser.Dictuserid) { istrue = true; } } } return(istrue); }
/// <summary> /// 用戶登錄 /// </summary> private void DoLogin() { try { string strCode = tbxUserName.Text.ToString(); string strPwd = desEncrypt.getMd5Hash(tbxPwd.Text.ToString()); //获取用户信息 DADictuser user = new DADictuser(); user.Usercode = strCode; string strUsercode = user.Usercode; user = new DADictuserBLL().GetDADictuserInfoByUserCode(user); //获取系统参数 decimal cid = DefaultConfig.DACONFIGID; //转换不成功 if (!decimal.TryParse(ConfigurationManager.AppSettings["DaConfigID"], out cid)) { ShowMessageHelper.ShowBoxMsg("请先维护好配置ID!"); return; } config = configBll.SelectyDAConfigInfo(cid); if (config == null) { ShowMessageHelper.ShowBoxMsg("没有ID为[" + cid + "]的配置记录"); return; } //再次校验用户名 if (user == null || user.Usercode != strUsercode) { ShowMessageHelper.ShowBoxMsg("帐号或密码错误,请重新输入!"); return; } //存在对应用户校验密码跟用户状态 if (user != null && user.Password == strPwd) { //账户已被停用 if (user.Isactive.ToString() == "0") { ShowMessageHelper.ShowBoxMsg("该账户已被停用!"); return; } else//账户未已被停用 { //保存用户信息 LoginUserInfo userInfo = new LoginUserInfo(); userInfo.UserCode = tbxUserName.Text.ToString(); userInfo.UserId = user.Dictuserid.ToString(); userInfo.UserName = user.Username; userInfo.UserType = 1; //登录webservice获取SID保存 if (config != null) { string strSideCode = config.Sitecode; //分点代码 string strUrl = config.Address; //调用webservice地址 string username = config.Username; //登录用户名 string password = config.Password; //登录用户密码 //设置调用webservice登录方法的参数 string[] par = new string[] { strSideCode, username, password, user.Username }; //获取webservice更新 WebServiceUtils.SetIsUpdate(config.Address); //登录验证 object loginResult = WebServiceUtils.ExecuteMethod("Login", par); //返回登录验证信息:1|SID,0|errorMsg string[] loginMsg = loginResult.ToString().Split('|'); //登录成功 设置SID if (loginMsg[0] == "1") { userInfo.SID = loginMsg[1].ToString(); ////设置调用webservice获取中心库数据(客户表、项目表、基础字典表)方法的参数 //DateTime itemdt = new DATablelastdateBLL().SelectyDATablelastdateInfoByTableName("da_dicttestitem"); //DateTime librarydt = new DATablelastdateBLL().SelectyDATablelastdateInfoByTableName("da_dictlibrary"); //DateTime customerdt = new DATablelastdateBLL().SelectyDATablelastdateInfoByTableName("da_dictcustomer"); //object[] parameters = new object[] { userInfo.SID, itemdt, librarydt, customerdt }; //string strXML = WebServiceUtils.Execute(strUrl, "GetCenterTableDate", parameters); //string reg = common.GetCenterTableDate(strXML); //ShowMessageHelper.ShowBoxMsg(reg); } else { ShowMessageHelper.ShowBoxMsg("WebService登录失败,错误信息:" + loginMsg[1].ToString() + "\n请检查系统参数配置!"); } } //保存用户信息到SystemConfig类 SystemConfig.UserInfo = userInfo; //登录成功 bLogin = true; this.DialogResult = DialogResult.OK; } } else { ShowMessageHelper.ShowBoxMsg("帐号或密码错误,请重新输入!"); return; } } catch (Exception ex) { ShowMessageHelper.ShowBoxMsg("登录的过程中发生了错误,错误信息:" + ex.Message, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
///<summary> ///根据Usercode获取用户 fenghp ///</summary> ///<param name="DADictuser"></param> /// <returns></returns> public DADictuser GetDADictuserInfoByUserCode(DADictuser dictuser) { return(baseService.selectObj <DADictuser>("GetDADictuserInfoByCode", dictuser)); }
//保存 private void btnSava_Click(object sender, EventArgs e) { DADictuser user = new DADictuser(); user.Dictuserid = Id; if (tbxUserCode.Text.Contains(" ")) { ShowMessageHelper.ShowBoxMsg("用户编码不能存在空格!"); tbxUserCode.Focus(); return; } if (tbxUserCode.Text.Trim() == string.Empty) { ShowMessageHelper.ShowBoxMsg("用户编码不能为空!"); tbxUserCode.Focus(); return; } user.Usercode = tbxUserCode.Text.Trim().ToString(); if (isExist(user)) { ShowMessageHelper.ShowBoxMsg("用户编码已经存在,请重新输入!"); tbxUserCode.Focus(); return; } if (tbxUserName.Text.Trim() == string.Empty) { ShowMessageHelper.ShowBoxMsg("用户名称不能为空!"); tbxUserName.Focus(); return; } if (tbxUserPwd.Text.Contains(" ")) { ShowMessageHelper.ShowBoxMsg("密码不能存在空格!"); tbxUserPwd.Focus(); return; } if (tbxUserPwd.Text == string.Empty) { ShowMessageHelper.ShowBoxMsg("密码不能为空!"); tbxUserPwd.Focus(); return; } if (tbxUserPwd.Text.Length < 6) { ShowMessageHelper.ShowBoxMsg("密码过于简单,请输入大于6位的密码!"); return; } if (tbxPwdOK.Text.ToString() != tbxUserPwd.Text.ToString()) { ShowMessageHelper.ShowBoxMsg("两次输入的密码不一致,请重新输入!"); tbxPwdOK.Focus(); return; } if (tbxPwdOK.Text.ToString() == password) { user.Password = password; } else { user.Password = desencrypt.getMd5Hash(tbxPwdOK.Text.ToString()); } user.Usercode = tbxUserCode.Text.Trim().ToString(); user.Username = tbxUserName.Text.ToString(); user.Isactive = cbUserIdOK.Checked == true ? "1" : "0"; user.Remark = tbxUserDescript.Text.ToString(); user.Createdate = DateTime.Now; if (userBll.Save(user)) { ShowMessageHelper.ShowBoxMsg("保存成功!"); this.DialogResult = DialogResult.OK; this.Close(); } else { ShowMessageHelper.ShowBoxMsg("保存失败!"); } }