public void Test() { var userInfo2 = new UserInfo2 { Name = "Joe", Age = 28, Education = new[] { "A", "B", "C", "D", "E" } }; var graph = SerializationHelper.SerializeObjectToString(userInfo2); var cloneUserInfo2 = SerializationHelper.DeserializeStringToObject <UserInfo2>(graph); Trace.WriteLine("cloneUserInfo2.Education:" + cloneUserInfo2.Education.Count()); Assert.AreEqual(3, cloneUserInfo2.Education.Count());//仅序列化前三项 foreach (var s in cloneUserInfo2.Education) { Trace.WriteLine(s); } CollectionAssert.AreEqual(new[] { "A", "B", "C" }, cloneUserInfo2.Education); Trace.WriteLine("userInfo2.Name:" + userInfo2.Name); Trace.WriteLine("cloneUserInfo2.Name:" + cloneUserInfo2.Name); Assert.AreEqual(userInfo2.Name, cloneUserInfo2.Name);//Name被序列化 Trace.WriteLine("userInfo2.Age:" + userInfo2.Age); Trace.WriteLine("cloneUserInfo2.Age:" + cloneUserInfo2.Age); Assert.AreNotEqual(userInfo2.Age, cloneUserInfo2.Age);//Age没有被序列化 }
//종료시 초기화 private void OnApplicationQuit() { this.userInfo.user.usernickname = ""; this.userInfo.user.usergold = 0; this.userInfo.user = new User1(); this.userInfo = new UserInfo2(); }
public static List <UserInfo2> GetListWhereUserInfoName(string strDutyName, string strSate) { List <UserInfo2> list = new List <UserInfo2>(); using (DCQUALITYDataContext db = new DCQUALITYDataContext()) { try { if (!string.IsNullOrEmpty(strDutyName)) { list = (from c in db.UserInfo2 where (c.DutyInfo.Duty_Name == strDutyName && c.Dictionary.Dictionary_Name == strSate) select c).ToList(); } else { list = (from c in db.UserInfo2 where (c.Dictionary.Dictionary_Name == strSate) select c).ToList(); // select c.UserName } UserInfo2 u = new UserInfo2(); u.UserName = "******"; list.Add(u); } catch (Exception ex) { throw new Exception(string.Format("根据项目名称和是否启动状态:{0}", ex.Message)); } finally { db.Connection.Close(); } } return(list); }
public ActionResult EditForm(long?id) { var obj = new UserInfo2(); if (id.HasValue) { obj = gamePlayerRepository.SelectOne(id.Value); } return(Json(new { data = obj }, JsonRequestBehavior.AllowGet)); }
private void btnAdd_Click() { try { int j = 0; int rint = 0; if (!btnCheck()) { return; } var useradd = new UserInfo2 { UserName = txtName.Text.Trim(), UserPhone = txtPhone.Text.Trim(), UserAddress = txtAddress.Text.Trim(), UserCarId = txtCardNo.Text.Trim(), UserCreateTime = DateTime.Now, UserCreateName = userCreateName, //创建人 User_Duty_ID = Convert.ToInt32(cobDuty_Name.SelectedValue.ToString()), //User_Dictionary_ID = 2, //用户状态 User_Dictionary_ID = Convert.ToInt32(cbxState.SelectedValue.ToString()),//DictionaryDAL.GetDictionaryID("启动"), UserRemark = txtRemark.Text.Trim() }; if (UserInfo2DAL.InsertOneQCRecord(useradd, out rint)) { MessageBox.Show("添加成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("添加失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } string Log_Content = String.Format("用户名称:{0} ", txtName.Text.Trim()); Common.WriteLogData("新增", Log_Content, Common.USERNAME);//添加日志 } catch (Exception ex) { Common.WriteTextLog("用户管理 btnAdd_Click()" + ex.Message.ToString()); MessageBox.Show("添加失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } finally { page = new PageControl(); page.PageMaxCount = tscbxPageSize2.SelectedItem.ToString(); LoadData(); } }
/// <summary> /// 新增一条质检记录 /// </summary> /// <param name="qcRecord">用户实体</param> /// /// <param name="rint">新增后自动增长编号</param> /// <returns></returns> public static bool InsertOneQCRecord(UserInfo2 qcRecord, out int rint) { rint = 0; bool rbool = true; using (DCQUALITYDataContext db = new DCQUALITYDataContext()) { try { db.UserInfo2.InsertOnSubmit(qcRecord); db.SubmitChanges(); rbool = true; } catch { rbool = false; } finally { db.Connection.Close(); } } return(rbool); }