/// <summary> /// 是否为空密码 false表示无需校验或已设置密码可登陆 true表示密码为空需重置 /// </summary> /// <param name="userID"></param> /// <returns></returns> private bool IsUserPwdNull(string userID) { try { //appcfg表配置用来判断是否校验密码 string value = DrectSoft.Service.DS_SqlService.GetConfigValueByKey("IsNeedPWDVailde"); if (value == "0" || value == null || value.Trim() == "") { return(false); } else { string sql = @"select u.id,u.passwd,u.regdate from users u where u.valid='1'and u.id=@userID"; SqlParameter[] sps = { new SqlParameter("@userID", SqlDbType.VarChar, 50) }; sps[0].Value = userID; DataTable dt = DrectSoft.DSSqlHelper.DS_SqlHelper.ExecuteDataTable(sql, sps, CommandType.Text); string password = dt.Rows[0]["PASSWD"].ToString().Trim(); string nullPwd = HisEncryption.EncodeString(dt.Rows[0]["REGDATE"].ToString().Trim(), HisEncryption.PasswordLength, ""); if (password == nullPwd) { return(true);//密码为空字符加密 } } return(false); } catch (Exception ex) { throw ex; } }
private void CreateUserPassword(string password, out string encryptDateTime, out string encryptNewPassword) { DateTime now = DateTime.Now; encryptDateTime = now.ToString("yyyyMMdd") + now.ToString("T"); encryptNewPassword = HisEncryption.EncodeString(encryptDateTime, 8, password); }
private void AddNewRow() { try { //从3000以后的作为临时用户 //todo 权限控制 DataRow newRow = UsersData.NewRow(); txt_ID.Text = "00123"; if (txt_ID.Text.Trim() != "00") { string extraCodeLong = txt_ID.Text.Trim().Insert(0, "000000"); string strLoginCode = extraCodeLong.Substring(extraCodeLong.Length - 6, 6); newRow["ID"] = strLoginCode; } newRow["Name"] = txt_Name.Text; newRow["DEPTID"] = m_App.User.CurrentDeptId; newRow["WARDID"] = m_App.User.CurrentWardId; //newRow["NarcosisMark"] = DBNull.Value; DateTime now = DateTime.Now; string encryptDateTime = now.ToString("yyyyMMdd") + now.ToString("T"); newRow["Passwd"] = HisEncryption.EncodeString( encryptDateTime, HisEncryption.PasswordLength, txt_Pswd.Text.Trim().ToString()); newRow["RegDate"] = encryptDateTime; newRow["JOBID"] = m_App.User.GWCodes; newRow["Operator"] = m_App.User.Id; //string regdate = string.Empty; //CreateUserPassword(txt_Pswd.Text, out regdate, out pswd); //newRow["Passwd"] = pswd; //newRow["RegDate"] = regdate; //newRow["Operator"] = m_App.User.ID; newRow["Valid"] = 1; newRow["Status"] = 0; UsersData.Rows.Add(newRow); DataRow newTpRow = TempUsers.NewRow(); if (txt_ID.Text.Trim() != "00") { string extraCodeLong = txt_ID.Text.Trim().Insert(0, "000000"); string strLoginCode = extraCodeLong.Substring(extraCodeLong.Length - 6, 6); newTpRow["UserID"] = strLoginCode; } // newTpRow["Name"] = txt_Name.Text; newTpRow["MasterID"] = m_App.User.Id; newTpRow["StartDate"] = dateEditstart.Text; newTpRow["EndDate"] = dateEditend.Text; TempUsers.Rows.Add(newTpRow); } catch (Exception ex) { throw ex; } }
private void CreateUserPassword(string password, out string encryptDateTime, out string encryptNewPassword) { try { DateTime now = DateTime.Now; encryptDateTime = now.ToString("yyyyMMdd") + now.ToString("T"); encryptNewPassword = HisEncryption.EncodeString( encryptDateTime, HisEncryption.PasswordLength, password); } catch (Exception ex) { throw ex; } }
/// <summary> /// 临时工号的插入方法 /// <auth>张业兴</auth> /// <date>2012-12-18</date> /// </summary> private void Insert() { try { string strLoginCode = string.Empty; SqlParameter[] parms; if (txt_ID.Text.Trim() != "00") { string extraCodeLong = txt_ID.Text.Trim().Insert(0, "000000"); strLoginCode = extraCodeLong.Substring(extraCodeLong.Length - 6, 6); } if (ValidateExist(strLoginCode, "users") < 0 && ValidateExist(strLoginCode, "tempUsers") < 0) { //向USERS表中插入新数据 string insertUsers = "insert into USERS(ID,NAME,DEPTID,WARDID,CATEGORY,GRADE,PASSWD,REGDATE,JOBID,OPERATOR,VALID,STATUS)values(@ID,@NAME,@DEPTID,@WARDID,(select a.category from Users a where a.valid =1 and a.ID =@OPERATOR),(select a.grade from Users a where a.valid =1 and a.ID =@OPERATOR),@PASSWD,@REGDATE,@JOBID,@OPERATOR,@VALID,@STATUS)"; parms = new SqlParameter[] { new SqlParameter("@ID", SqlDbType.NVarChar, 6), new SqlParameter("@NAME", SqlDbType.NVarChar, 16), new SqlParameter("@DEPTID", SqlDbType.NVarChar, 12), new SqlParameter("@WARDID", SqlDbType.NVarChar, 12), new SqlParameter("@PASSWD", SqlDbType.NVarChar, 32), new SqlParameter("@REGDATE", SqlDbType.NVarChar, 19), new SqlParameter("@JOBID", SqlDbType.NVarChar, 255), new SqlParameter("@OPERATOR", SqlDbType.NVarChar, 6), new SqlParameter("@VALID", SqlDbType.Int), new SqlParameter("@STATUS", SqlDbType.Int) }; parms[0].Value = strLoginCode; parms[1].Value = txt_Name.Text.Trim().ToString(); parms[2].Value = m_App.User.CurrentDeptId; parms[3].Value = m_App.User.CurrentWardId; DateTime now = DateTime.Now; string encryptDateTime = now.ToString("yyyyMMdd") + now.ToString("T"); parms[4].Value = HisEncryption.EncodeString(encryptDateTime, HisEncryption.PasswordLength, txt_Pswd.Text.Trim().ToString()); parms[5].Value = encryptDateTime; parms[6].Value = m_App.User.GWCodes; parms[7].Value = m_App.User.Id; parms[8].Value = 1; parms[9].Value = 0; int count = DS_SqlHelper.ExecuteNonQuery(insertUsers, parms, CommandType.Text); //向TempUsers表中插入新数据 string insertTempUsers = "insert into TEMPUSERS(USERID,MASTERID,STARTDATE,ENDDATE) values(@USERID,@MASTERID,@STARTDATE,@ENDDATE)"; parms = new SqlParameter[] { new SqlParameter("@USERID", SqlDbType.NVarChar, 6), new SqlParameter("@MASTERID", SqlDbType.NVarChar, 6), new SqlParameter("@STARTDATE", SqlDbType.Char, 19), new SqlParameter("@ENDDATE", SqlDbType.Char, 19) }; parms[0].Value = strLoginCode; parms[1].Value = m_App.User.Id; parms[2].Value = dateEditstart.Text; parms[3].Value = dateEditend.Text; DS_SqlHelper.ExecuteNonQuery(insertTempUsers, parms, CommandType.Text); } else { DrectSoft.Common.Ctrs.DLG.MyMessageBox.Show("该临时工号已经存在,新增失败!"); } } catch (Exception ex) { throw ex; } }