public void getUserMsg(string[] strMsg) { model.users userMd = new model.users(); //用户资料信息 userMd.userName = strMsg[0].ToString(); //用户名称 userMd.Id = Convert.ToInt32(strMsg[1].ToString()); //用户ID userMd.personaId = Convert.ToInt32(strMsg[4].ToString()); //角色ID us.User = userMd; }
/// <summary> /// 删除用户 /// </summary> /// <returns></returns> public string del(int id) { string s = string.Empty; try { model.pbxdatasourceDataContext context = new model.pbxdatasourceDataContext(); model.users p = (from c in context.users where c.Id == id select c).FirstOrDefault(); //context.users.DeleteOnSubmit(p); context.users.DeleteOnSubmit(p); context.SubmitChanges(); s = "删除成功!"; } catch (Exception ex) { s = "删除失败!"; } return(s); }
//public List<model.users> getUsers(IDataParameter[] ipara, string procName) //{ // List<model.users> list = new List<model.users>(); // DataTable dt = Select(ipara, procName); // list = DataRowToModel(dt.Rows); // return list; //} /// <summary> /// 得到一个对象实体 /// </summary> public List <model.users> DataRowToModel(DataRowCollection rowCollection) { List <model.users> list = new List <model.users>(); foreach (DataRow row in rowCollection) { model.users modelMd = new model.users(); //foreach (var item in modelMd.GetType().GetProperties()) //{ // string name = item.Name; //} if (row != null) { if (row["Id"] != null && row["Id"].ToString() != "") { modelMd.Id = int.Parse(row["Id"].ToString()); } if (row["personaId"] != null && row["personaId"].ToString() != "") { modelMd.personaId = int.Parse(row["personaId"].ToString()); } if (row["userName"] != null) { modelMd.userName = row["userName"].ToString(); } if (row["userPwd"] != null) { modelMd.userPwd = row["userPwd"].ToString(); } if (row["userRealName"] != null) { modelMd.userRealName = row["userRealName"].ToString(); } if (row["userSex"] != null && row["userSex"].ToString() != "") { modelMd.userSex = int.Parse(row["userSex"].ToString()); } if (row["UserPhone"] != null) { modelMd.UserPhone = row["UserPhone"].ToString(); } if (row["UserAddress"] != null) { modelMd.UserAddress = row["UserAddress"].ToString(); } if (row["UserEmail"] != null) { modelMd.UserEmail = row["UserEmail"].ToString(); } if (row["userIndex"] != null && row["userIndex"].ToString() != "") { modelMd.userIndex = int.Parse(row["userIndex"].ToString()); } if (row["UserManage"] != null && row["UserManage"].ToString() != "") { modelMd.UserManage = int.Parse(row["UserManage"].ToString()); } if (row["UserId"] != null && row["UserId"].ToString() != "") { modelMd.UserId = int.Parse(row["UserId"].ToString()); } if (row["Def1"] != null) { modelMd.Def1 = row["Def1"].ToString(); } if (row["Def2"] != null) { modelMd.Def2 = row["Def2"].ToString(); } if (row["Def3"] != null) { modelMd.Def3 = row["Def3"].ToString(); } if (row["Def4"] != null) { modelMd.Def4 = row["Def4"].ToString(); } if (row["Def5"] != null) { modelMd.Def5 = row["Def5"].ToString(); } } list.Add(modelMd); } return(list); }