protected void btnSignup_Click(object sender, EventArgs e) { if (string.IsNullOrWhiteSpace(txtFullName.Text) || string.IsNullOrWhiteSpace(txtUsername.Text) || string.IsNullOrWhiteSpace(txtPassword.Text)) { litMessage.Text = "Name, Username and Password fields are mandatory."; divAlert.Attributes["class"] += " alert-danger"; divAlert.Visible = true; } else { bool inserted = UserDBHelper.InsertUser(txtFullName.Text, txtUsername.Text, txtPassword.Text, txtEmail.Text, txtMobile.Text); if (!inserted) { litMessage.Text = "Please choose another Username."; divAlert.Attributes["class"] += " alert-danger"; divAlert.Visible = true; } else { litMessage.Text = "Signup success for Username <strong>" + txtUsername.Text + "</strong>"; divAlert.Attributes["class"] += " alert-success"; divAlert.Visible = true; } } }
protected void Page_Load(object sender, EventArgs e) { if (Session["USER"] != null && UserDBHelper.IsUserAdmin(Session["USER"].ToString())) { litTalk.Text = "Welcome " + Session["USER"]; } }
protected void Page_Load(object sender, EventArgs e) { this.Form.DefaultButton = this.btnExamID.UniqueID; if (Session["USER"] != null && !UserDBHelper.IsUserAdmin(Session["USER"].ToString())) { litTalk.Text = "Welcome " + Session["USER"]; } }
private void LoadDataForEdit(string Id) { UserDBHelper db = new UserDBHelper(this); ICursor cData = db.getUserById(int.Parse(Id)); if (cData.MoveToFirst()) { txtFirstname.Text = cData.GetString(cData.GetColumnIndex("Firstname")); txtLastname.Text = cData.GetString(cData.GetColumnIndex("Lastname")); txtAddress.Text = cData.GetString(cData.GetColumnIndex("Address")); txtEmail.Text = cData.GetString(cData.GetColumnIndex("Email")); } }
private void LoadUserInList() { UserDBHelper dbVals = new UserDBHelper(this); if (txtSearch.Text.Trim().Length < 1) { listItems = dbVals.GetAllUsers(); } else { listItems = dbVals.GetUsersByName(txtSearch.Text.Trim()); } lv.Adapter = new UserListBaseAdapter(this, listItems); lv.ItemLongClick += lv_ItemLongClick; }
public void InputData(string path) { UserDBHelper excelInfo = new UserDBHelper(); if (excelInfo.importUser(path)) { UnityToWeb("ImportStuInfoCallback", "success"); Debug.Log("导入,成功"); } else { UnityToWeb("ImportStuInfoCallback", "failed"); Debug.Log("导入,失败"); } }
protected void btnSignIn_Click(object sender, EventArgs e) { int?userId = UserDBHelper.IsCredentialsValid(txtUserName.Text, txtPassword.Text); if (userId != null) { Session["USER"] = txtUserName.Text; Session["USERID"] = userId; if (UserDBHelper.IsUserAdmin(Session["USER"].ToString())) { Session["ISADMIN"] = "1"; Response.Redirect("AdminHome.aspx"); } Response.Redirect("Home.aspx"); } }
private void button1_Click(object sender, EventArgs e) { //Creating Object UserDBHelper userdb UserDBHelper userdb = new UserDBHelper(); if (txtUsername.Text != string.Empty && txtPassword.Text != string.Empty) { //Create Object Users and pass the value of userdb method searchUser to user Users user = userdb.searchUser(txtUsername.Text, txtPassword.Text); //Condition if the user is exist or not if (user != null) { if (user.IsAdmin == true) { Home hm = new Home(user); hm.ShowDialog(); this.Close(); } else { POS ps = new POS(user); ps.ShowDialog(); this.Close(); } } else { string title = "Login Failed"; string message = "Invalid Username or Password. Please Try Again"; MessageBox.Show(message, title); } } else { string title = "Login Failed"; string message = "Username or Password are empty"; MessageBox.Show(message, title); } }
private static void TestUserDB() { Console.WriteLine("It works!"); var db = new UserDBHelper(); { bool run = true; while (run) { Console.WriteLine( "1. Add user\n" + "2. Remove user by id\n" + "3. Add to friends\n" + "4. Remove from friends\n" + "5. Print users\n" + "6. Print relations\n" + "7. Print user info"); var key = Console.ReadKey().Key; Console.WriteLine(); switch (key) { case ConsoleKey.D1: { Console.WriteLine(); RandomUserRegistration(db.RegisterUserToTable, db.RemoveUserByIdFromTable, db.FindUserByNickname); break; } case ConsoleKey.D2: { Console.WriteLine(); System.Int32 id; Console.Write("Write id to delete: "); var idStr = Console.ReadLine(); if (Int32.TryParse(idStr, out id)) { db.RemoveUserByIdFromTable(id); } break; } case ConsoleKey.D3: { Int32 thisIdInt; Int32 idToAddInt; Console.Write("Write userid [who want to add]: "); string thisIdString = Console.ReadLine(); if (thisIdString.Length > 0) { if (Int32.TryParse(thisIdString, out thisIdInt)) { Console.Write("Write userid [whom want to add]: "); string idToAddString = Console.ReadLine(); if (idToAddString.Length > 0) { if (Int32.TryParse(idToAddString, out idToAddInt)) { if (thisIdInt != 0 && idToAddInt != 0) { db.AddUserToFriends(thisIdInt, idToAddInt); } } else { Console.WriteLine($"Can't pasrse idToAddString: {idToAddString}"); } } } else { Console.WriteLine($"Can't pasrse thisIdString: {thisIdString}"); } } break; } case ConsoleKey.D4: { Int32 thisIdInt; Int32 idToRemoveInt; Console.Write("Write userid [who want to remove]: "); string thisIdString = Console.ReadLine(); if (thisIdString.Length > 0) { if (Int32.TryParse(thisIdString, out thisIdInt)) { Console.Write("Write userid [whom want to remove]: "); string idToRemoveString = Console.ReadLine(); if (idToRemoveString.Length > 0) { if (Int32.TryParse(idToRemoveString, out idToRemoveInt)) { if (thisIdInt != 0 && idToRemoveInt != 0) { db.RemoveUserFromFriends(thisIdInt, idToRemoveInt); } } else { Console.WriteLine($"Can't pasrse idToAddString: {idToRemoveString}"); } } } else { Console.WriteLine($"Can't pasrse thisIdString: {thisIdString}"); } } break; } case ConsoleKey.D5: { Console.Clear(); Console.WriteLine("Users:"); var usersList = db.GetAllUsers(); foreach (var el in usersList) { Console.WriteLine($"{el.UserId} {el.FullName} {el.Nickname} {el.Email}"); } break; } case ConsoleKey.D6: { Console.Clear(); Console.WriteLine("\nRelations:"); var friends = db.GetUsersFriendsTable(1); Console.WriteLine("Frineds: "); foreach (var friend in friends) { Console.WriteLine($"{friend.UserId} - {friend.FriendId}"); } var followers = db.GetUsersFollowersTable(1); Console.WriteLine("Followers: "); foreach (var follower in followers) { Console.WriteLine($"{follower.UserId} - {follower.FollowerId}"); } var followings = db.GetUsersFollowingsTable(1); Console.WriteLine("Followings: "); foreach (var following in followings) { Console.WriteLine($"{following.UserId} - {following.FollowingId}"); } Console.WriteLine(); break; } case ConsoleKey.D7: { var usersInfo = db.GetAllUsersInfo(); //foreach (var user in usersInfo) //{ // Console.WriteLine($"{user.Nickname} {user.UserId} {user.CoreId}"); //} break; } case ConsoleKey.C: { Console.Clear(); break; } case ConsoleKey.Escape: { run = false; break; } default: { break; } } } } }
private static void TestGameDB() { var db = new UserDBHelper(); using (var gamedb = new GameDBHelper()) { List <GameUnitsTable> GetCoreArmy(int coreId) { var result = new List <GameUnitsTable>(); var warriorUnit = gamedb.GetUnitProperty("Warrior"); var attackAircraftUnit = gamedb.GetUnitProperty("AttackAircraft"); var numberWarriors = gamedb.CasernGetNumberOfWarriors(coreId); var numberAttackAircraft = gamedb.CasernGetNumberOfAttackAircraft(coreId); for (int i = 0; i < numberWarriors; i++) { result.Add( new GameUnitsTable() { GameUnitId = warriorUnit.GameUnitId, GameUnitType = warriorUnit.GameUnitType, GameUnitName = warriorUnit.GameUnitName, GameUnitHP = warriorUnit.GameUnitHP, GameUnitAttack = warriorUnit.GameUnitAttack, GameUnitDefence = warriorUnit.GameUnitDefence, GameUnitGoldIncome = warriorUnit.GameUnitGoldIncome, GameUnitGoldOutcome = warriorUnit.GameUnitGoldOutcome }); } for (int i = 0; i < numberAttackAircraft; i++) { result.Add(new GameUnitsTable() { GameUnitId = attackAircraftUnit.GameUnitId, GameUnitType = attackAircraftUnit.GameUnitType, GameUnitName = attackAircraftUnit.GameUnitName, GameUnitHP = attackAircraftUnit.GameUnitHP, GameUnitAttack = attackAircraftUnit.GameUnitAttack, GameUnitDefence = attackAircraftUnit.GameUnitDefence, GameUnitGoldIncome = attackAircraftUnit.GameUnitGoldIncome, GameUnitGoldOutcome = attackAircraftUnit.GameUnitGoldOutcome }); } return(result); } bool run = true; while (run) { Console.WriteLine( "1. Show all\n" + "2. Show battle\n" + "3. Random registration\n" + "4. Show all cores\n" + "5. Build casern test\n" + "6. Core info\n" ); var key = Console.ReadKey().Key; Console.WriteLine(); switch (key) { case ConsoleKey.D1: { break; } case ConsoleKey.D2: { Console.WriteLine(); Console.WriteLine("Battle begins"); List <GameUnitsTable> attackers = GetCoreArmy(1); List <GameUnitsTable> defenders = GetCoreArmy(2); var result = 0; // GameEngine.Battle(attackers, defenders); Console.WriteLine(result == 0 ? "Attackers won the battle!" : "Defenders won the battle!"); break; } case ConsoleKey.D3: { Console.WriteLine(); RandomUserRegistration( db.RegisterUserToTable, db.RemoveUserByIdFromTable, db.FindUserByNickname); break; } case ConsoleKey.D4: { Console.WriteLine(); Console.WriteLine("Cores: "); var coreList = gamedb.GetAllCores() .FromJson <List <SessionCoresTable> >(); foreach (var el in coreList) { var elmap = gamedb .FindCoreMapByMapIdAsNoTracking(el.CoreMapId) .FromJson <SessionMapTable>(); Console.WriteLine( $"userid: {el.UserId} " + $"mapid: {el.CoreMapId} " + $"map [{elmap.XCoord}, {elmap.YCoord}]" ); } break; } case ConsoleKey.D5: { Console.Clear(); Console.WriteLine("Build casern"); gamedb.CoreBuildCasern(1); Console.Read(); break; } case ConsoleKey.D6: { Console.Clear(); Console.WriteLine("Core info"); var list = db.GetAllUsers(); foreach (var el in list) { var coreId = UserDBHelper.GetCoreIdByUserId(el.UserId); if (coreId != -1) { var coreInfo = gamedb .GetCoreInfoById(coreId) .FromJson <CoreInfo>(); //var coreMap = gamedb // .FindCoreMapByMapIdAsNoTracking(coreInfo.CoreMapId) // .FromJson<SessionMapTable>(); // //Console.WriteLine($"Core info [UserId={el.UserId}]"); //Console.WriteLine($"coreid: {coreInfo.CoreId} " + // $"money: {coreInfo.Money} " + // $"base capacity: {coreInfo.BaseCapacity}"+ // $"map[{coreMap.XCoord}, {coreMap.YCoord}]"); } else { Console .WriteLine($"Can not find core id for userid: {el.UserId}"); } } Console.WriteLine(); break; } case ConsoleKey.C: { Console.Clear(); break; } case ConsoleKey.Escape: { run = false; break; } default: { break; } } } } }
// public SoftKey ytsoftkey;//引用由域天工具随机生成的加密类模块 void Awake() { userDB = new UserDBHelper(); UIEventListener.Get(username.gameObject).onClick = hideMsg; UIEventListener.Get(pwd.gameObject).onClick = hideMsg; }
public void ReceiveWeb(string json) { Debug.LogError("ReceiveWebAction:" + json); Dictionary <string, System.Object> dic = JsonConvert.DeserializeObject <Dictionary <string, System.Object> >(json); string action = dic["Action"].ToString(); switch (action) { case "UserLogin": string callback; UserDBHelper userDBLogin = new UserDBHelper(); try { User user = userDBLogin.getUser(dic["param1"].ToString(), dic["param2"].ToString(), dic["param3"].ToString()); string userStr = JsonConvert.SerializeObject(user); if (userName == null) { userName = user.Name; } if (user != null) { callback = "{\"Action\":\"LoginCallback\",\"param1\":\"success\",\"param2\":" + userStr + "}"; MySession.user = user; } else { callback = "{\"Action\":\"LoginCallback\",\"param1\":\"failed\",\"param2\":\"用户名密码错误!\"}"; MySession.user = null; } } catch (Exception) { callback = "{\"Action\":\"LoginCallback\",\"param1\":\"failed\",\"param2\":\"服务器配置错误!\"}"; } UnityToWeb(callback); break; case "MusicOnOff": //音乐开关 if (dic["param1"].ToString() == "0") { AudioManager.getInstance().AudioPause(global::AudioManager.MusicNumType.groundMusic); } else { AudioManager.getInstance().AudioPlay(global::AudioManager.MusicNumType.groundMusic); } break; case "VoiceControl": //音量控制 AudioManager.getInstance().SetAudioVolume(global::AudioManager.MusicNumType.groundMusic, int.Parse(dic["param1"].ToString()) / 20.0f); break; case "GetExternalLinks": //获取链接数据-知识界面 string callbackExternalLinks; InfoLinksDBHelper externalLinksDB = new InfoLinksDBHelper(); string externalLinksStr = externalLinksDB.getGetLinks(dic["param1"].ToString(), int.Parse(dic["param2"].ToString()), int.Parse(dic["param3"].ToString())); int totalNum = externalLinksDB.getGetTotalLinksNum(dic["param1"].ToString()); callbackExternalLinks = "{\"Action\":\"GetExternalLinksCallback\",\"param1\":" + externalLinksStr + ",\"param2\":\"" + totalNum + "\"}"; Debug.LogError("callback:" + callbackExternalLinks); UnityToWeb(callbackExternalLinks); break; case "GetExternalLinksByPage": //通过page获取链接数据 -知识界面 string callbackLinksByPage; InfoLinksDBHelper linkByPageDB = new InfoLinksDBHelper(); string linkByPageStr = linkByPageDB.getGetLinks(dic["param1"].ToString(), int.Parse(dic["param2"].ToString()), int.Parse(dic["param3"].ToString())); callbackLinksByPage = "{\"Action\":\"GetExternalLinksByPageCallback\",\"param1\":\"" + linkByPageStr + "\"}"; UnityToWeb(callbackLinksByPage); break; case "DeleteExternalLinks": //通过page获取链接数据 -知识界面 string DeleteExternalLinksResult = ""; InfoLinksDBHelper DeleteExternalLinksDB = new InfoLinksDBHelper(); bool DeleteExternalLinksisSuccessed = DeleteExternalLinksDB.deleteLink(int.Parse(dic["param1"].ToString())); if (DeleteExternalLinksisSuccessed) { DeleteExternalLinksResult = "success"; } else { DeleteExternalLinksResult = "faild"; } string DeleteExternalLinksCallback = "{\"Action\":\"DeleteExternalLinksCallback\",\"param1\":\"" + DeleteExternalLinksResult + "\"}"; UnityToWeb(DeleteExternalLinksCallback); break; case "AddExternalLinks": string AddExternalLinksResult = ""; InfoLinksDBHelper AddExternalLinksDB = new InfoLinksDBHelper(); LinkInfo info = new LinkInfo(); info.Type = dic["param1"].ToString(); info.Address = dic["param2"].ToString(); bool AddExternalLinksisSuccessed = AddExternalLinksDB.addLink(info); if (AddExternalLinksisSuccessed) { AddExternalLinksResult = "success"; } else { AddExternalLinksResult = "faild"; } string AddExternalLinksCallback = "{\"Action\":\"AddExternalLinksCallback\",\"param1\":\"" + AddExternalLinksResult + "\",\"param2\":\"" + info.Type + "\"}"; UnityToWeb(AddExternalLinksCallback); break; case "EditExternalLinks": Dictionary <string, string> EditExternalLinksdicTemp = JsonConvert.DeserializeObject <Dictionary <string, string> >(dic["param1"].ToString()); string EditExternalLinksResult = ""; InfoLinksDBHelper EditExternalLinksDB = new InfoLinksDBHelper(); LinkInfo EditExternalLinksinfo = new LinkInfo(); EditExternalLinksinfo.Id = int.Parse(EditExternalLinksdicTemp["Id"]); //EditExternalLinksinfo.Type = EditExternalLinksdicTemp["type"]; EditExternalLinksinfo.Address = EditExternalLinksdicTemp["Address"]; bool EditExternalLinksisSuccessed = EditExternalLinksDB.updateLink(EditExternalLinksinfo); if (EditExternalLinksisSuccessed) { EditExternalLinksResult = "success"; } else { EditExternalLinksResult = "faild"; } string EditExternalLinksCallback = "{\"Action\":\"AddExternalLinksCallback\",\"param1\":\"" + EditExternalLinksResult + "\"}"; UnityToWeb(EditExternalLinksCallback); break; case "OpenExternalLinks": //根据type,link打开外部链接 OpenLink(dic["param1"].ToString(), dic["param2"].ToString()); break; case "updateLinks": if ((dic["param1"].ToString()).Equals("ppt")) { UIManager.getInstance().GetComponent <OpenFile>().OpenFileByType(OpenFile.FileType.Ppt, updateLinks, dic["param2"].ToString()); } else if ((dic["param1"].ToString()).Equals("word")) { UIManager.getInstance().GetComponent <OpenFile>().OpenFileByType(OpenFile.FileType.Word, updateLinks, dic["param2"].ToString()); } else if ((dic["param1"].ToString()).Equals("excel")) { UIManager.getInstance().GetComponent <OpenFile>().OpenFileByType(OpenFile.FileType.Excel, updateLinks, dic["param2"].ToString()); } else if ((dic["param1"].ToString()).Equals("video")) { UIManager.getInstance().GetComponent <OpenFile>().OpenFileByType(OpenFile.FileType.Vedio, updateLinks, dic["param2"].ToString()); } break; case "UpExternalLinks": if ((dic["param1"].ToString()).Equals("ppt")) { UIManager.getInstance().GetComponent <OpenFile>().OpenFileByType(OpenFile.FileType.Ppt, UpLinks); } else if ((dic["param1"].ToString()).Equals("word")) { UIManager.getInstance().GetComponent <OpenFile>().OpenFileByType(OpenFile.FileType.Word, UpLinks); } else if ((dic["param1"].ToString()).Equals("excel")) { UIManager.getInstance().GetComponent <OpenFile>().OpenFileByType(OpenFile.FileType.Excel, UpLinks); } else if ((dic["param1"].ToString()).Equals("video")) { UIManager.getInstance().GetComponent <OpenFile>().OpenFileByType(OpenFile.FileType.Vedio, UpLinks); } else if ((dic["param1"].ToString()).Equals("all")) { UIManager.getInstance().GetComponent <OpenFile>().OpenFileByType(OpenFile.FileType.AllType, UpLinks); } break; case "EnterScene": //根据进入培训场景 switch (dic["param2"].ToString()) { case "sbrz": UIManager.getInstance().enterEquipKnow("DeviceKnow1", (TrainUI.TrainMode) int.Parse(dic["param3"].ToString())); break; case "dlyl": UIManager.getInstance().enterTrain(dic["param1"].ToString(), "电路原理", (TrainUI.TrainMode) int.Parse(dic["param3"].ToString())); break; case "sbcj": UIManager.getInstance().enterTrain(dic["param1"].ToString(), "设备拆解", (TrainUI.TrainMode) int.Parse(dic["param3"].ToString())); break; case "sbzz": UIManager.getInstance().enterTrain(dic["param1"].ToString(), "设备组装", (TrainUI.TrainMode) int.Parse(dic["param3"].ToString())); break; case "sbxs": UIManager.getInstance().enterTrain(dic["param1"].ToString(), "设备巡视", (TrainUI.TrainMode) int.Parse(dic["param3"].ToString())); break; case "sbjx": UIManager.getInstance().enterTrain(dic["param1"].ToString(), "设备检修", (TrainUI.TrainMode) int.Parse(dic["param3"].ToString())); break; case "DBQgz": UIManager.getInstance().enterTrain(dic["param1"].ToString(), "设备故障", (TrainUI.TrainMode) int.Parse(dic["param3"].ToString())); break; } break; case "StudentRegister": Dictionary <string, string> dicTemp = JsonConvert.DeserializeObject <Dictionary <string, string> >(dic["param1"].ToString()); UserDBHelper userDBStu = new UserDBHelper(); User userStu = new User(); userStu.Name = dicTemp["name"]; userStu.Sex = dicTemp["sex"]; userStu.Phone = dicTemp["phone"]; userStu.IdCard = dicTemp["ide"]; userStu.Term = dicTemp["term"]; userStu.Workshop = dicTemp["workshop"]; userStu.Group = dicTemp["team"]; userStu.AccountID = dicTemp["id"]; userStu.Pwd = dicTemp["pwd"]; bool isSuccessed = userDBStu.addUser(userStu); //“success”:成功 “faild”:失败 string result = ""; if (isSuccessed) { result = "success"; } else { result = "faild"; } string callBackStudentRegister = "{\"Action\":\"StudentRegisterCallback\",\"param1\":\"" + result + "\"}"; UnityToWeb(callBackStudentRegister); break; case "StudentEdit": Dictionary <string, string> dicTempStuEdit = JsonConvert.DeserializeObject <Dictionary <string, string> >(dic["param1"].ToString()); UserDBHelper userDBStuEdit = new UserDBHelper(); User userStuEdit = new User(); userStuEdit.Name = dicTempStuEdit["name"]; userStuEdit.Sex = dicTempStuEdit["sex"]; userStuEdit.Phone = dicTempStuEdit["phone"]; userStuEdit.IdCard = dicTempStuEdit["ide"]; userStuEdit.Term = dicTempStuEdit["term"]; userStuEdit.Workshop = dicTempStuEdit["workshop"]; userStuEdit.Group = dicTempStuEdit["team"]; userStuEdit.AccountID = dicTempStuEdit["id"]; userStuEdit.Pwd = dicTempStuEdit["pwd"]; bool isSuccessedStuEdit = userDBStuEdit.updateUser(userStuEdit); //“success”:成功 “faild”:失败 string resultStuEdit = ""; if (isSuccessedStuEdit) { resultStuEdit = "success"; } else { resultStuEdit = "faild"; } string callBackStuEdit = "{\"Action\":\"StudentEditCallback\",\"param1\":\"" + resultStuEdit + "\"}"; UnityToWeb(callBackStuEdit); break; case "StudentDelete": UserDBHelper userInfoDBStudentDelete = new UserDBHelper(); bool isSuccessedStudentDelete = userInfoDBStudentDelete.deleteUser(int.Parse(dic["param1"].ToString())); string resultisSuccessedStudentDelete = ""; if (isSuccessedStudentDelete) { resultisSuccessedStudentDelete = "success"; } else { resultisSuccessedStudentDelete = "faild"; } string callBackStudentDelete = "{\"Action\":\"StudentDeleteCallback\",\"param1\":\"" + resultisSuccessedStudentDelete + "\"}"; UnityToWeb(callBackStudentDelete); break; case "GetStuInfo": UserDBHelper userInfoDB = new UserDBHelper(); int userNum = userInfoDB.getTotalXueyuanUserNum(); List <User> users = userInfoDB.getXueyuanUserByPage(int.Parse(dic["param1"].ToString()), int.Parse(dic["param2"].ToString())); string callBackStuInfo = "{\"Action\":\"GetStuInfoCallback\",\"param1\":" + JsonConvert.SerializeObject(users) + ",\"param2\":\"" + userNum + "\"}"; Debug.Log(callBackStuInfo); UnityToWeb(callBackStuInfo); break; case "GetStuScoreInfo": string stuScoreBackJson = gradeManager.gradeManager(dic["param1"].ToString(), int.Parse(dic["param2"].ToString()), int.Parse(dic["param3"].ToString())); UnityToWeb(stuScoreBackJson); break; case "TestBack": //当前成绩返回 if (UIManager.getInstance().getCurrentUIType() == UIType.TrainUI) { UIManager.getInstance().trainUI.backMenu(); } else if (UIManager.getInstance().getCurrentUIType() == UIType.CircuitUI) { UIManager.getInstance().circuitUI.backMenu(); } break; case "TestAgin": //当前成绩页面再考一次 if (UIManager.getInstance().getCurrentUIType() == UIType.TrainUI) { UIManager.getInstance().trainUI.afreshExam(); } else if (UIManager.getInstance().getCurrentUIType() == UIType.CircuitUI) { UIManager.getInstance().circuitUI.afreshExam(); } break; case "CheckCircuitErrorInfo": break; case "CheckErrorInfo": if (int.Parse(dic["param1"].ToString()) == 2) { UIManager.getInstance().circuitUI.cause(int.Parse(dic["param2"].ToString())); } else { UIManager.getInstance().trainUI.cause(int.Parse(dic["param1"].ToString()), int.Parse(dic["param2"].ToString())); } break; case "getTwoQuestionTest": string topicsJson = JsonConvert.SerializeObject(gradeManager.getTopic2Ds(int.Parse(dic["param1"].ToString()))); float examTime = gradeManager.getExamTimeById(int.Parse(dic["param1"].ToString())); UnityToWeb("getTwoQuestionTest", topicsJson, examTime.ToString()); break; case "getTwoTestScore": string twoScore = gradeManager.examGrade2D(dic["param1"].ToString()); UnityToWeb("getTwoTestScoreBack", twoScore); break; case "AddTwoQuestion": string twoQuestionBack = ""; if (gradeManager.topic2DResolve(dic["param1"].ToString())) { twoQuestionBack = "success"; } else { twoQuestionBack = "failed"; } UnityToWeb("AddTwoQuestionCallback", twoQuestionBack); break; case "AddTwoQuestionImg": UIManager.getInstance().GetComponent <OpenFile>().OpenFileByType(OpenFile.FileType.Image, uploadImg, dic["param1"].ToString()); break; case "GetTwoQuestion": int currentPage = int.Parse(dic["param1"].ToString()); int pageNum = int.Parse(dic["param2"].ToString()); int SubjectId = int.Parse(dic["SubjectId"].ToString()); List <Topic2D> topics = gradeManager.getTopic2Ds(SubjectId, currentPage, pageNum); int topicCount = gradeManager.getTopic2DCount(SubjectId); float scoreCount = gradeManager.getTopic2DScoreCount(SubjectId); string questionCallbackJson = "{\"Action\":\"GetTwoQuestionCallback\",\"param1\":" + JsonConvert.SerializeObject(topics) + ",\"param2\":\"" + topicCount.ToString() + "\",\"param3\":\"" + scoreCount.ToString() + "\"}"; UnityToWeb(questionCallbackJson); break; case "DeleteTwoQuestion": if (gradeManager.deleteTopic2D(int.Parse(dic["param1"].ToString()))) { UnityToWeb("DeleteTwoQuestionCallback", "success"); } else { UnityToWeb("DeleteTwoQuestionCallback", "failed"); } break; case "UpdateTwoQuestion": if (gradeManager.updateTopic2DResolve(dic["param1"].ToString())) { UnityToWeb("UpdateTwoQuestionCallback", "success"); } else { UnityToWeb("UpdateTwoQuestionCallback", "failed"); } break; case "getTestScorePage": string scorePageJson = gradeManager.getHistoryGrade(int.Parse(dic["param1"].ToString()), int.Parse(dic["param2"].ToString())); UnityToWeb("getTestScoreBack", scorePageJson); break; case "getTestCharts": string chartsJson = gradeManager.getGradeCharts(int.Parse(dic["param1"].ToString())); UnityToWeb("getTestChartsBack", chartsJson); break; ///update score; case "updateTwoScore": UnityToWeb("updateTwoScoreCallback", gradeManager.updateTopic2DScore(int.Parse(dic["param1"].ToString()), float.Parse(dic["param2"].ToString()), int.Parse(dic["param3"].ToString())).ToString()); break; case "updateThreeScore": UnityToWeb("updateThreeScoreCallback", gradeManager.updateTopic3DScore(int.Parse(dic["param1"].ToString()), float.Parse(dic["param2"].ToString()), int.Parse(dic["param3"].ToString())).ToString()); break; case "updateFourScore": UnityToWeb("updateFourScoreCallback", gradeManager.updateTopic3DScore(int.Parse(dic["param1"].ToString()), float.Parse(dic["param2"].ToString()), int.Parse(dic["param3"].ToString())).ToString()); break; ////param1 : score//15 5 2 14 1 2 case "updateCircuitScore": //DataBackup(); //UnityToWeb("updateCircuitScoreCallback", gradeManager.updateTopicCircuitScore(int.Parse(dic["param2"].ToString()), float.Parse(dic["param4"].ToString()), int.Parse(dic["param1"].ToString()), dic["param3"].ToString(), char.Parse(dic["param5"].ToString())).ToString()); UnityToWeb("updateCircuitScoreCallback", gradeManager.updateTopicCircuitScore(int.Parse(dic["param2"].ToString()), float.Parse(dic["param1"].ToString()), int.Parse(dic["param3"].ToString())).ToString()); break; case "getCircuits": UnityToWeb("getCircuitsCallback", JsonConvert.SerializeObject(gradeManager.getCircuitTopics())); break; case "updateIsExam": UnityToWeb("updateIsExamCallback", gradeManager.updateIsExam(int.Parse(dic["param1"].ToString()), char.Parse(dic["param2"].ToString())).ToString()); break; case "GetThreeQuestion": List <Topic3D> topic3Ds = gradeManager.getTopic3Ds(int.Parse(dic["param3"].ToString()), int.Parse(dic["param1"].ToString()), int.Parse(dic["param2"].ToString())); int topic3DCount = gradeManager.getTopic3DCount(int.Parse(dic["param3"].ToString())); float topic3DScore = gradeManager.getTopic3DScoreCount(int.Parse(dic["param3"].ToString())); string ThreeQuestionCallbackJson = "{\"Action\":\"GetThreeQuestionCallback\",\"param1\":" + JsonConvert.SerializeObject(topic3Ds) + ",\"param2\":\"" + topic3DCount.ToString() + "\",\"param3\":\"" + topic3DScore.ToString() + "\",\"param4\":\"" + dic["param3"].ToString() + "\",\"param5\":\"" + (gradeManager.getExamSubject(int.Parse(dic["param3"].ToString())).IsExam ? "1" : "0") + "\"}"; UnityToWeb(ThreeQuestionCallbackJson); break; ////four case "GetFourQuestion": List <CircuitTopicNew> topic4Ds = gradeManager.getTopicCircuitTopicNew(int.Parse(dic["param3"].ToString())); int topic4DCount = gradeManager.getTopicCircuitCount(int.Parse(dic["param3"].ToString())); float topic4DScore = gradeManager.getTopicCircuitScoreCount(int.Parse(dic["param3"].ToString())); string FourQuestionCallbackJson = "{\"Action\":\"GetFourQuestionCallback\",\"param1\":" + JsonConvert.SerializeObject(topic4Ds) + ",\"param2\":\"" + topic4DCount.ToString() + "\",\"param3\":\"" + topic4DScore.ToString() + "\",\"param4\":\"" + dic["param3"].ToString() + "\",\"param5\":\"" + (gradeManager.getExamSubject(int.Parse(dic["param3"].ToString())).IsExam ? "1" : "0") + "\"}"; UnityToWeb(FourQuestionCallbackJson); break; //new four //// case "updateSubjectExam": if (gradeManager.updateSubjectExam(int.Parse(dic["param1"].ToString()), dic["param2"].ToString())) { UnityToWeb("updateSubjectExamCallback", "success"); } else { UnityToWeb("updateSubjectExamCallback", "faild"); } break; case "BackToSbrzStudy": UIManager.getInstance().equipKnowUI.changeMode(TrainUI.TrainMode.Study); break; case "BackToMenu": UIManager.getInstance().equipKnowUI.backMenu(); break; case "ImportStuInfo": UIManager.getInstance().GetComponent <OpenFile>().OpenFileByType(OpenFile.FileType.Excel, InputData); break; case "PlayMusicByID": PlayMusicByID(int.Parse(dic["param1"].ToString())); break; case "updateAllTopic3DScore": gradeManager.updateAllTopic3DScore(int.Parse(dic["param3"].ToString())); List <Topic3D> topic3ds = gradeManager.getTopic3Ds(int.Parse(dic["param3"].ToString()), int.Parse(dic["param1"].ToString()), int.Parse(dic["param2"].ToString())); int topic3dCount = gradeManager.getTopic3DCount(int.Parse(dic["param3"].ToString())); float topic3dScore = gradeManager.getTopic3DScoreCount(int.Parse(dic["param3"].ToString())); string updateAllTopic3DScoreJson = "{\"Action\":\"updateAllTopic3DScoreCallBack\",\"param1\":" + JsonConvert.SerializeObject(topic3ds) + ",\"param2\":\"" + topic3dCount.ToString() + "\",\"param3\":\"" + topic3dScore.ToString() + "\",\"param4\":\"" + dic["param3"].ToString() + "\",\"param5\":\"" + (gradeManager.getExamSubject(int.Parse(dic["param3"].ToString())).IsExam ? "1" : "0") + "\"}"; UnityToWeb(updateAllTopic3DScoreJson); break; case "updateAllTopic2DScore": gradeManager.updateAllTopic2DScore(int.Parse(dic["param3"].ToString())); List <Topic2D> topic2ds = gradeManager.getTopic2Ds(int.Parse(dic["param3"].ToString()), int.Parse(dic["param1"].ToString()), int.Parse(dic["param2"].ToString())); int topic2dCount = gradeManager.getTopic2DCount(int.Parse(dic["param3"].ToString())); float topic2dScore = gradeManager.getTopic2DScoreCount(int.Parse(dic["param3"].ToString())); string updateAllTopic2DScoreJson = "{\"Action\":\"updateAllTopic2DScoreCallBack\",\"param1\":" + JsonConvert.SerializeObject(topic2ds) + ",\"param2\":\"" + topic2dCount.ToString() + "\",\"param3\":\"" + topic2dScore.ToString() + "\",\"param4\":\"" + dic["param3"].ToString() + "\",\"param5\":\"" + (gradeManager.getExamSubject(int.Parse(dic["param3"].ToString())).IsExam ? "1" : "0") + "\"}"; UnityToWeb(updateAllTopic2DScoreJson); break; case "closeSystem": UIManager.getInstance().exitSystem(); break; case "StopMusicByID": AudioManager.getInstance().AudioStop(AudioManager.MusicNumType.realtimeMusic); break; case "GetDurationCharts": Dictionary <string, int> grades = gradeManager.GetDurationCharts(int.Parse(dic["param1"].ToString())); string[] ExamTime = new string[grades.Count]; float[] Grade = new float[grades.Count]; int count = 0; foreach (KeyValuePair <string, int> kvp in grades) { ExamTime[count] = kvp.Key; Grade[count] = kvp.Value; count++; } string GetDurationChartsJson = "{\"Action\":\"GetDurationChartsCallback\",\"param1\":" + JsonConvert.SerializeObject(ExamTime) + ",\"param2\":" + JsonConvert.SerializeObject(Grade) + "}"; Debug.Log(GetDurationChartsJson); UnityToWeb(GetDurationChartsJson); break; case "GetScoreCharts": Dictionary <string, float> gradeScore = gradeManager.GetScoreCharts(int.Parse(dic["param1"].ToString())); string[] ExamTimeScore = new string[gradeScore.Count]; float[] GradeScore = new float[gradeScore.Count]; int countScore = 0; foreach (KeyValuePair <string, float> kvp in gradeScore) { ExamTimeScore[countScore] = kvp.Key; GradeScore[countScore] = kvp.Value; countScore++; } string GetScoreChartsJson = "{\"Action\":\"GetScoreChartsCallback\",\"param1\":" + JsonConvert.SerializeObject(ExamTimeScore) + ",\"param2\":" + JsonConvert.SerializeObject(GradeScore) + "}"; Debug.Log(GetScoreChartsJson); UnityToWeb(GetScoreChartsJson); break; case "getSumStuDate": string getSumStuCallbackJson = "{\"Action\":\"getSumStuCallback\",\"param1\":" + JsonConvert.SerializeObject(gradeManager.getSumStuDate(dic["param1"].ToString())) + "}"; UnityToWeb(getSumStuCallbackJson); break; case "getSumCurveDate": string getSumCurveCallbackJson = "{\"Action\":\"getSumCurveCallback\",\"param1\":" + JsonConvert.SerializeObject(gradeManager.getSumCurveDate()) + "}"; UnityToWeb(getSumCurveCallbackJson); break; case "SubmitReportDate": string wordPath = createWord(dic["param1"].ToString()); string submitBack; string SubmitReportDateCallbackJson; if (wordPath == null || wordPath == "") { submitBack = "failed"; } else { submitBack = "success"; } SubmitReportDateCallbackJson = "{\"Action\":\"SubmitReportDateCallback\",\"param1\":\"" + submitBack + "\",\"param2\":\"" + wordPath + "\"}"; UnityToWeb(SubmitReportDateCallbackJson); break; case "SystemBackup": DoBackup(); string BackupJson = "{\"Action\":\"SystemBackupCallback\",\"param1\":\"1\"}"; UnityToWeb(BackupJson); break; case "RestoreBackup": restore(int.Parse(dic["param1"].ToString())); string RestoreJson = "{\"Action\":\"RestoreBackupCallback\",\"param1\":\"1\"}"; UnityToWeb(RestoreJson); break; case "GetSystemBackup": //string GetSystemBackupJson = "{\"Action\":\"GetSystemBackupCallback\",\"param1\":" + JsonConvert.SerializeObject(GetSystemBackup(int.Parse(dic["param1"].ToString()), int.Parse(dic["param2"].ToString()))) + "}"; UnityToWeb(GetSystemBackup(int.Parse(dic["param1"].ToString()), int.Parse(dic["param2"].ToString()))); break; case "DeleteBackup": string back = ""; if (DeleteBackup(int.Parse(dic["param1"].ToString()))) { back = "success"; } else { back = "failed"; } string deleteBackupJson = "{\"Action\":\"DeleteBackupCallback\",\"param1\":\"" + back + "\"}"; UnityToWeb(deleteBackupJson); break; } }
private void Btncreate_Click(object sender, EventArgs e) { UserDBHelper db = new UserDBHelper(this); string pattern = @"(?=(([a-z0-9])\2?(?!\2))+$)^(?=.*[a-zA-Z])(?=.*[0-9])"; if (txtLastname.Text.Trim().Length > 4 || txtLastname.Text.Trim().Length < 13) { bool test = Regex.IsMatch(txtFirstname.Text, pattern, RegexOptions.IgnoreCase); if (!test) { Toast.MakeText(this, "Validation error two or more repeating strings, letter or numbers detected.", ToastLength.Short).Show(); return; } } else { Toast.MakeText(this, "You must enter combination of strings and numbers in range of min 5 and max 12 characters.", ToastLength.Short).Show(); } if (txtLastname.Text.Trim().Length > 4 || txtLastname.Text.Trim().Length < 13) { bool test = Regex.IsMatch(txtLastname.Text, pattern, RegexOptions.IgnoreCase); if (!test) { Toast.MakeText(this, "Validation error two or more repeating strings, letter or numbers detected.", ToastLength.Short).Show(); return; } } else { Toast.MakeText(this, "You must enter combination of strings and numbers in range of min 5 and max 12 characters.", ToastLength.Short).Show(); } if (txtAddress.Text.Trim().Length > 4 || txtAddress.Text.Trim().Length < 13) { bool test = Regex.IsMatch(txtAddress.Text, pattern, RegexOptions.IgnoreCase); if (!test) { Toast.MakeText(this, "Validation error two or more repeating strings, letter or numbers detected.", ToastLength.Short).Show(); return; } } else { Toast.MakeText(this, "You must enter combination of strings and numbers in range of min 5 and max 12 characters.", ToastLength.Short).Show(); } if (txtEmail.Text.Trim().Length < 5) { string EmailPattern = @"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"; if (!Regex.IsMatch(txtEmail.Text, EmailPattern, RegexOptions.IgnoreCase)) { Toast.MakeText(this, "Email address must be in format [email protected].", ToastLength.Short).Show(); return; } } User us = new User(); us.Firstname = txtFirstname.Text; us.Lastname = txtLastname.Text; us.Address = txtAddress.Text; us.Email = txtEmail.Text; try { db.AddNewUser(us); Toast.MakeText(this, "New User Created Successfully.", ToastLength.Short).Show(); Finish(); var mainActivity = new Intent(this, typeof(UserActivity)); StartActivity(mainActivity); } catch (Exception ex) { throw new Exception(ex.Message); } }
private void DeleteSelectedUser(string Id) { UserDBHelper _db = new UserDBHelper(activity); _db.DeleteUser(Id); }