public bool EditMemberInfo(string userIDO, string userID, string userName, string pwd, byte[] img, string treeNodeId) { string rlDBType = dl.init(); string sql = ""; string errMsg = ""; bool result = false; if (rlDBType == "SQL") { try { if (img != null) { SqlConnection sqlconn = SAC.DBOperations.DBsql.GetConnection(); if (userIDO == userID) { sql += "update T_SYS_MEMBERINFO set T_USERNAME=@T_USERNAME,T_PASSWD=@T_PASSWD,B_ATTACHMENT=@B_ATTACHMENT where T_USERID='" + userIDO + "'"; SqlCommand sqlcmd = new SqlCommand(sql, sqlconn); sqlcmd.Parameters.Add("@T_USERNAME", userName); sqlcmd.Parameters.Add("@T_PASSWD", pwd); sqlcmd.Parameters.Add("@B_ATTACHMENT", img); if (sqlcmd.ExecuteNonQuery() > 0) { result = true; } } else { sql += "update T_SYS_MEMBERINFO set T_USERID=@T_USERID,T_USERNAME=@T_USERNAME,T_PASSWD=@T_PASSWD,B_ATTACHMENT=@B_ATTACHMENT where T_USERID='" + userIDO + "'"; SqlCommand sqlcmd = new SqlCommand(sql, sqlconn); sqlcmd.Parameters.Add("@T_USERID", userID); sqlcmd.Parameters.Add("@T_USERNAME", userName); sqlcmd.Parameters.Add("@T_PASSWD", pwd); sqlcmd.Parameters.Add("@B_ATTACHMENT", img); result = DBsql.RunNonQuery("update T_SYS_MEMBERGRP set T_USERID='" + userID + "' where T_USERID='" + userIDO + "';", out errMsg); if (sqlcmd.ExecuteNonQuery() > 0 && result == true) { result = true; } } sqlconn.Close(); } else { if (userIDO == userID) { sql += "update T_SYS_MEMBERINFO set T_USERNAME='******',T_PASSWD='" + pwd + "' where T_USERID='" + userIDO + "';"; } else { sql += "update T_SYS_MEMBERINFO set T_USERID='" + userID + "',T_USERNAME='******',T_PASSWD='" + pwd + "' where T_USERID='" + userIDO + "';update T_SYS_MEMBERGRP set T_USERID='" + userID + "' where T_USERID='" + userIDO + "';"; } result = dl.RunNonQuery(sql, out errMsg); } } catch (Exception ex) { LogHelper.WriteLog(LogHelper.EnLogType.Run, "发生时间:" + DateTime.Now.ToString("yyyy-MM-dd H:mm:ss") + "/n错误信息:" + ex.Message); } } else if (rlDBType == "DB2") { try { if (img != null) { OleDbConnection con = new OleDbConnection(DBdb2.SetConString()); con.Open(); if (userIDO == userID) { sql += "update T_SYS_MEMBERINFO set T_USERNAME=?,T_PASSWD=?,B_ATTACHMENT=? where T_USERID='" + userIDO + "'"; OleDbCommand oledbcom = new OleDbCommand(sql, con); oledbcom.Parameters.Add("?", userName); oledbcom.Parameters.Add("?", pwd); oledbcom.Parameters.Add("?", img); if (oledbcom.ExecuteNonQuery() > 0) { result = true; } } else { sql += "update T_SYS_MEMBERINFO set T_USERID=?,T_USERNAME=?,T_PASSWD=?,B_ATTACHMENT=? where T_USERID='" + userIDO + "'"; OleDbCommand oledbcom = new OleDbCommand(sql, con); oledbcom.Parameters.Add("?", userID); oledbcom.Parameters.Add("?", userName); oledbcom.Parameters.Add("?", pwd); oledbcom.Parameters.Add("?", img); result = DBdb2.RunNonQuery("update T_SYS_MEMBERGRP set T_USERID='" + userID + "' where T_USERID='" + userIDO + "';", out errMsg); if (oledbcom.ExecuteNonQuery() > 0 && result == true) { result = true; } } con.Close(); } else { if (userIDO == userID) { sql += "update T_SYS_MEMBERINFO set T_USERNAME='******',T_PASSWD='" + pwd + "' where T_USERID='" + userIDO + "';"; } else { sql += "update T_SYS_MEMBERINFO set T_USERID='" + userID + "',T_USERNAME='******',T_PASSWD='" + pwd + "' where T_USERID='" + userIDO + "';update T_SYS_MEMBERGRP set T_USERID='" + userID + "' where T_USERID='" + userIDO + "';"; } result = dl.RunNonQuery(sql, out errMsg); } } catch (Exception ex) { LogHelper.WriteLog(LogHelper.EnLogType.Run, "发生时间:" + DateTime.Now.ToString("yyyy-MM-dd H:mm:ss") + "/n错误信息:" + ex.Message); } } else if (rlDBType == "ORACLE") { try { if (img != null) { OracleConnection con = new OracleConnection(SAC.DBOperations.OracleHelper.retStr()); con.Open(); if (userIDO == userID) { sql += "update T_SYS_MEMBERINFO set T_USERNAME=:blobtodb,T_PASSWD=:blobtodb,B_ATTACHMENT=:blobtodb where T_USERID='" + userIDO + "'"; OracleCommand orlcmd = new OracleCommand(sql, con); orlcmd.Parameters.Add("blobtodb", userName); orlcmd.Parameters.Add("blobtodb", pwd); orlcmd.Parameters.Add("blobtodb", img); if (orlcmd.ExecuteNonQuery() > 0) { result = true; } } else { sql += "update T_SYS_MEMBERINFO set T_USERID=:blobtodb,T_USERNAME=:blobtodb,T_PASSWD=:blobtodb,B_ATTACHMENT=:blobtodb where T_USERID='" + userIDO + "'"; OracleCommand orlcmd = new OracleCommand(sql, con); orlcmd.Parameters.Add("blobtodb", userID); orlcmd.Parameters.Add("blobtodb", userName); orlcmd.Parameters.Add("blobtodb", pwd); orlcmd.Parameters.Add("blobtodb", img); result = SAC.DBOperations.DBoracle.RunNonQuery("update T_SYS_MEMBERGRP set T_USERID='" + userID + "' where T_USERID='" + userIDO + "';", out errMsg); if (orlcmd.ExecuteNonQuery() > 0 && result == true) { result = true; } } con.Close(); } else { if (userIDO == userID) { sql += "update T_SYS_MEMBERINFO set T_USERNAME='******',T_PASSWD='" + pwd + "' where T_USERID='" + userIDO + "';"; } else { sql += "update T_SYS_MEMBERINFO set T_USERID='" + userID + "',T_USERNAME='******',T_PASSWD='" + pwd + "' where T_USERID='" + userIDO + "';update T_SYS_MEMBERGRP set T_USERID='" + userID + "' where T_USERID='" + userIDO + "';"; } result = dl.RunNonQuery(sql, out errMsg); } } catch (Exception ex) { LogHelper.WriteLog(LogHelper.EnLogType.Run, "发生时间:" + DateTime.Now.ToString("yyyy-MM-dd H:mm:ss") + "/n错误信息:" + ex.Message); } } return(result); }
/// <summary> /// 添加人员信息 /// </summary> /// <param name="id">用户编码</param> /// <param name="name">真实姓名</param> /// <param name="pwd">登陆密码</param> /// <param name="img">图片</param> /// <returns></returns> public bool AddMember(string id, string name, string pwd, byte[] img, string orgID) { string rlDBType = dl.init(); string errMsg; string sql1 = ""; string sql2 = ""; bool result = false; if (rlDBType == "SQL") { if (img != null && img.Length > 0) { sql1 = "insert into T_SYS_MEMBERINFO(T_USERID,T_USERNAME,T_PASSWD,B_ATTACHMENT) values(@T_USERID,@T_USERNAME,@T_PASSWD,@B_ATTACHMENT);"; } else { sql1 = "insert into T_SYS_MEMBERINFO(T_USERID,T_USERNAME,T_PASSWD) values(@T_USERID,@T_USERNAME,@T_PASSWD);"; } sql2 = "insert into T_SYS_MEMBERGRP(T_USERID,T_GRPID) values('" + id + "','" + orgID + "')"; try { SqlConnection sqlconn = SAC.DBOperations.DBsql.GetConnection(); SqlCommand sqlcmd = new SqlCommand(sql1, sqlconn); if (img != null && img.Length > 0) { sqlcmd.Parameters.Add("@T_USERID", id); sqlcmd.Parameters.Add("@T_USERNAME", name); sqlcmd.Parameters.Add("@T_PASSWD", pwd); sqlcmd.Parameters.Add("@B_ATTACHMENT", img); } else { sqlcmd.Parameters.Add("@T_USERID", id); sqlcmd.Parameters.Add("@T_USERNAME", name); sqlcmd.Parameters.Add("@T_PASSWD", pwd); } if (sqlcmd.ExecuteNonQuery() > 0) { result = true; } sqlconn.Close(); dl.RunNonQuery(sql2, out errMsg); } catch (Exception ex) { LogHelper.WriteLog(LogHelper.EnLogType.Run, "发生时间:" + DateTime.Now.ToString("yyyy-MM-dd H:mm:ss") + "/n错误信息:" + ex.Message); } } else if (rlDBType == "DB2") { if (img != null && img.Length > 0) { sql1 = "insert into T_SYS_MEMBERINFO(T_USERID,T_USERNAME,T_PASSWD,B_ATTACHMENT) values(?,?,?,?);"; } else { sql1 = "insert into T_SYS_MEMBERINFO(T_USERID,T_USERNAME,T_PASSWD) values(?,?,?);"; } sql2 = "insert into T_SYS_MEMBERGRP(T_USERID,T_GRPID) values('" + id + "','" + orgID + "')"; try { OleDbConnection con = new OleDbConnection(SAC.DBOperations.DBdb2.SetConString()); con.Open(); OleDbCommand oledbcom = new OleDbCommand(sql1, con); if (img != null && img.Length > 0) { oledbcom.Parameters.Add("?", id); oledbcom.Parameters.Add("?", name); oledbcom.Parameters.Add("?", pwd); oledbcom.Parameters.Add("?", img); } else { oledbcom.Parameters.Add("?", id); oledbcom.Parameters.Add("?", name); oledbcom.Parameters.Add("?", pwd); } if (oledbcom.ExecuteNonQuery() > 0) { result = true; } con.Close(); dl.RunNonQuery(sql2, out errMsg); } catch (Exception ex) { LogHelper.WriteLog(LogHelper.EnLogType.Run, "发生时间:" + DateTime.Now.ToString("yyyy-MM-dd H:mm:ss") + "/n错误信息:" + ex.Message); } } else if (rlDBType == "ORACLE") { if (img != null && img.Length > 0) { sql1 = "insert into T_SYS_MEMBERINFO(T_USERID,T_USERNAME,T_PASSWD,B_ATTACHMENT) values(:blobtodb,:blobtodb,:blobtodb,:blobtodb);"; } else { sql1 = "insert into T_SYS_MEMBERINFO(T_USERID,T_USERNAME,T_PASSWD) values(:blobtodb,:blobtodb,:blobtodb);"; } sql2 = "insert into T_SYS_MEMBERGRP(T_USERID,T_GRPID) values('" + id + "','" + orgID + "')"; try { OracleConnection con = new OracleConnection(SAC.DBOperations.OracleHelper.retStr()); con.Open(); OracleCommand oledbcom = new OracleCommand(sql1, con); if (img != null && img.Length > 0) { oledbcom.Parameters.Add("blobtodb", id); oledbcom.Parameters.Add("blobtodb", name); oledbcom.Parameters.Add("blobtodb", pwd); oledbcom.Parameters.Add("blobtodb", img); } else { oledbcom.Parameters.Add("blobtodb", id); oledbcom.Parameters.Add("blobtodb", name); oledbcom.Parameters.Add("blobtodb", pwd); } if (oledbcom.ExecuteNonQuery() > 0) { result = true; } con.Close(); dl.RunNonQuery(sql2, out errMsg); } catch (Exception ex) { LogHelper.WriteLog(LogHelper.EnLogType.Run, "发生时间:" + DateTime.Now.ToString("yyyy-MM-dd H:mm:ss") + "/n错误信息:" + ex.Message); } } return(result); }