private string uploadFile() { string res = "读取文件失败!"; DataTable dt = ExcelHelperV2_0.Import(Request); if (dt != null) { dt.Columns.Add("companyId"); dt.Columns.Add("departmentId"); dt.Columns.Add("department"); for (int i = 0; i < dt.Rows.Count; i++) { dt.Rows[i]["companyId"] = GetUserInfo().companyId; dt.Rows[i]["departmentId"] = "1"; dt.Rows[i]["department"] = "业力集团"; string[] values = dt.Rows[i]["毕业学校"].ToString().Split('-'); if (values.Length > 1)// { dt.Rows[i]["毕业学校"] = values[0]; dt.Rows[i]["专业"] = values[1]; } } res = UserInfoManage.InsertInfos(dt); } return(res); }
private string Add() { string res = "添加失败!"; DataSet ds = SqlHelper.GetFiledNameAndComment("users"); if (ds != null) { Dictionary <string, string> dict = new Dictionary <string, string>(); string[] exceptedField = new string[] { "passWord", "userId", "department", "departmentId", "companyId", "nativePlace" }; foreach (DataRow row in ds.Tables[0].Rows) { if (!exceptedField.Contains <string>(row["field"].ToString())) { dict.Add(row["field"].ToString(), Request.Form[row["field"].ToString()]); } } dict.Add("departmentId", Request.Form["department"]); UserInfo user = (UserInfo)Session["user"]; dict.Add("companyId", user.companyId.ToString()); string id = Request.Form["userId"]; res = UserInfoManage.InsertInfos(dict); } return(res); }