public static bool IsRegiste() { bool val = false; string serial = Convert.ToString(DBHelperProxy.ExecuteScalar("Select Code From Dept Where ID=-1")); if (string.IsNullOrEmpty(serial)) { val = false; } else { string unitname = Convert.ToString(DBHelperProxy.ExecuteScalar("Select Name From Dept Where ID=1")); if (ALEncrypt.Md5hash(unitname + "sudenggang") == serial) { val = true; } else { val = false; } } return(val); }
public static bool Registe(string serial, string unitName) { if (ALEncrypt.Md5hash(unitName + "sudenggang") != serial) { return(false); } else { DBHelperProxy.ExecuteNonQuery(string.Format("Update Dept set Code='{0}',Name='{1}' Where ID=-1;Update Dept set Name='{1}' Where ID=1;", serial, unitName)); // DBHelperProxy.ExecuteNonQuery(string.Format("Update ContactDir set Name='{0}' Where DeptID=1;",unitName)); return(true); } }
/// <summary> /// 新建单位时自动产生一个单位管理员 /// </summary> /// <param name="deptID">部门ID</param> /// <param name="unitID">单位ID</param> public void NewAdminOfUnit(long deptID, long unitID, string unitName) { long newUserID; string userName = "******" + unitID; string password = ALEncrypt.Md5hash(AppConfig.GetConfig("InitPassword")); newUserID = DBHelperProxy.GetMaxID("User"); string strSQL = "Insert Into " + DBHelperProxy.FormatTable("User") + "(ID,UserName,LoginName," + DBHelperProxy.FormatField("Password") + ",DeptID,DeptName,UnitID,IsStop," + DBHelperProxy.FormatField("Sequence") + ") Values(" + newUserID.ToString() + ", '管理员[" + unitID + "]','" + userName + "','" + password + "'," + deptID + ",'" + unitName + "'," + unitID + ",1,100);"; DBHelperProxy.ExecuteScalar(strSQL); //添加到管理员角色中 AddUserToAdminRole(newUserID, unitID); }