/// <summary> /// 插入ScheNotice /// </summary> /// <param name="ScheNotice">ScheNotice</param> public int InsertScheNotice(ScheNotice scheNotice) { Hashtable _map = new Hashtable(); _map.Add("UserName", scheNotice.UserName); _map.Add("TrueName", scheNotice.TrueName); _map.Add("Context", scheNotice.Context); _map.Add("ID", scheNotice.ID); scheNotice.ID = (int)ExecuteInsert("JNyulu.InsertScheNotice", _map); return(scheNotice.ID); }
/// <summary> /// 插入ScheNotice /// </summary> /// <param name="scheNotice">ScheNotice</param> public int InsertScheNotice(ScheNotice scheNotice) { int _id = -1; try { //_daoManager.BeginTransaction(); _id = _scheNoticeDao.InsertScheNotice(scheNotice); //_daoManager.CommitTransaction(); } catch (Exception ex) { //_daoManager.RollBackTransaction(); throw ex; } return(_id); }
public void PostSave(string ids, string userNames, string trueNames) { int _code = 0; string _message = "开课通知处理失败"; string[] _idList = ids.Split('|'); string[] _userNameList = userNames.Split('|'); string[] _trueNameList = trueNames.Split('|'); if ((_idList.Length == _userNameList.Length) && _idList.Length > 0) { int _id = 0; string _userName = string.Empty; string _trueName = string.Empty; StringBuilder _result = new StringBuilder("开课通知处理结果:"); for (int i = 0; i < _idList.Length; i++) { if (int.TryParse(_idList[i], out _id)) { _userName = _userNameList[i]; _trueName = _trueNameList[i]; ScheNotice _scheNotice = _scheNoticeService.GetScheNoticeByID(_id); _scheNotice.UserName = _userName; _scheNotice.TrueName = _trueName; _code = _scheNoticeService.UpdateScheNotice(_scheNotice); _result.AppendLine("编号" + _scheNotice.ID + "修改成功,编号:" + _code); } } _message = "修改成功"; } else { _message = "对不起,可能数据格式不对!"; } RenderText("{\"code\":\"" + _code + "\",\"message\":\"" + _message + "\"}"); CancelLayout(); }
/// <summary> /// 更新ScheNotice /// </summary> /// <param name="ScheNotice">ScheNotice</param> public int UpdateScheNotice(ScheNotice scheNotice) { int i = ExecuteUpdate("JNyulu.UpdateScheNotice", scheNotice); return(i); }
/// <summary> /// 更新ScheNotice /// </summary> /// <param name="scheNotice">ScheNotice</param> public int UpdateScheNotice(ScheNotice scheNotice) { return(_scheNoticeDao.UpdateScheNotice(scheNotice)); }
public void PostImportExcel() { string _fileExt = string.Empty; int _code = 0; string _message = string.Empty; try { HttpPostedFile _uploadFiles = Request.Files["uploadFile"] as HttpPostedFile; if (_uploadFiles == null || _uploadFiles.FileName.Length < 3) { _message = "您没有选择要上传的文件!"; _code = -4; } else { _fileExt = Path.GetExtension(_uploadFiles.FileName).ToLower(); //获取文件扩展名 String[] _allowedExt = { ".xls", ".xlsx" }; //允许上传的文件格式 if (!_allowedExt.Contains(_fileExt)) { _message = "您上传的格式为" + _fileExt + ", 本统只接受扩展名为" + string.Join("、", _allowedExt) + "格式文件"; _code = -3; } else if (_uploadFiles.ContentLength == 0) { _message = "上传的内容为空!"; _code = -2; } else if (_uploadFiles.ContentLength > 1024 * 1024 * 8) { _message = "您上传的文件超过了8M!"; _code = -1; } } if (_code == 0) { string _fileName = ShortFileNameUtil.ShortFileName(Guid.NewGuid().ToString()) + _fileExt; string _virtualPath = "/UploadFiles/scheNoticeXls/"; string _physicalPath = HttpContext.Server.MapPath(_virtualPath); if (!Directory.Exists(_physicalPath)) { Directory.CreateDirectory(_physicalPath); } string _fullPath = _physicalPath + _fileName; _uploadFiles.SaveAs(_fullPath); DataTable _employeeData = JNyuluUtils.ImportExcel(_fullPath); int _i = 0; StringBuilder _result = new StringBuilder(); _result.AppendLine("上传路径为:" + _virtualPath + _fileName); _result.AppendLine("Excel解析日志记录:"); foreach (DataRow dr in _employeeData.Rows) { try { //dr["电话"] dr["姓名"] dr["内容"] string _userName = dr["电话"].ToString() + ""; string _trueName = dr["姓名"].ToString() + ""; string _context = dr["内容"].ToString() + ""; if (!string.IsNullOrEmpty(_userName) && !string.IsNullOrEmpty(_trueName) && !string.IsNullOrEmpty(_context)) { ScheNotice _scheNotice = new ScheNotice(); _scheNotice.UserName = _userName; _scheNotice.TrueName = _trueName; _scheNotice.Context = _context; { _code = _scheNoticeService.InsertScheNotice(_scheNotice); } if (_code > 0) { LogHelper.Info("记录[" + _i + "]导入成功"); _result.AppendLine("记录[" + _i + "]导入成功"); } _code = _scheNotice.ID; } } catch (Exception ex) { _result.AppendLine(ex.ToString()); LogHelper.Error(ex.ToString()); continue; } _i++; } _message = _result.ToString(); } } catch (Exception ex) { _code = -1; _message = ex.Message; } finally { RenderText("{code: " + _code + ",message: \"" + _message.Replace(@"\", @"\\") + "\"}"); CancelLayout(); } }