public int UpdateATest(string uid, string id, int order, int time, string result) { OxcoderIFactory.IFactory factory = new OxcoderFactory.SqlSeverFactory(); OxcoderIDAL.TestInfoIDAL test = factory.getTestInstance(); OxcoderIDAL.UserIDAL user = factory.getUserInstance(); string tid = test.GetTestID(id); Model.Quiz p1 = searchQuizInfo(id, order); if (result.Equals(p1.output) || p1.output == "") { test.UpdateATest(tid, order, time); SqlDataReader rd = user.UserInfo(uid); if (rd.Read()) { int price1 = Convert.ToInt32(rd["User_Level"].ToString()); int price = Convert.ToInt32(rd["User_Price"].ToString()) + time / 10; if ((price - 4000) / 1000 > 0) { user.UpdateUserLevel((price1 + 1).ToString(), price.ToString(), uid); } user.UpdateUserLevel(rd["User_Level"].ToString(), price.ToString(), uid); } } if (order == 2) { DataRow dr = test.GetTestDetail(tid).Tables[0].Rows[0]; if (dr["Test_Quiz0_State"].ToString().Equals("-1") && dr["Test_Quiz1_State"].ToString().Equals("-1") && dr["Test_Quiz2_State"].ToString().Equals("-1")) { test.SetTestState(tid); } } return(1); }
public User UserInfo(string userID) { OxcoderIFactory.IFactory factory = new OxcoderFactory.SqlSeverFactory(); OxcoderIDAL.UserIDAL dalad = factory.getUserInstance(); User userInfo = new User(); SqlDataReader rd = dalad.UserInfo(userID); if (rd.Read()) { userInfo.User_ID = rd["User_ID"].ToString(); userInfo.User_Email = rd["User_Email"].ToString(); userInfo.User_Name = rd["User_Name"].ToString(); userInfo.User_Password = rd["User_Password"].ToString(); userInfo.User_Age = rd["User_Age"].ToString(); userInfo.User_Level = rd["User_Level"].ToString(); userInfo.User_Price = rd["User_Price"].ToString(); userInfo.User_Phone = rd["User_Phone"].ToString(); userInfo.User_Sex = rd["User_Sex"].ToString(); } return(userInfo); }