protected void btnAdd_OnClick(object sender, EventArgs e) { Project p = new Project(); p.ProjectID = bp.GetMaxID() + 1; p.ProjectName = PubCom.CheckString(txtName.Text.Trim()); p.ProjectContent = PubCom.CheckString(txtContent.Text.Trim()); p.ProjectPeriod = DpProjectPeriod.SelectedValue; p.OrgName = PubCom.CheckString(txtOrgName.Text.Trim()); p.StartTime = DateTime.Parse(StarTime.Text.Trim()); p.EndTime = DateTime.Parse(EndTime.Text.Trim()); string str = txtProjectStage.Text.Trim(); str = str.Replace("<", "<"); str = str.Replace(">", ">"); str = str.Replace(" ", " "); str = str.Replace("\r\n", "<br>"); p.ProjectStage = str; if (dpExpert.SelectedValue != "") { p.ExpertID = Utils.StrToInt(dpExpert.SelectedValue, 0); } if (dpLm.SelectedValue != "") { p.LmMemberID = Utils.StrToInt(dpLm.SelectedValue, 0); } if (dpTd.SelectedValue != "") { p.TdMemberID = Utils.StrToInt(dpTd.SelectedValue, 0); } if (dpstu.SelectedValue != "") { p.StuMemberID = Utils.StrToInt(dpstu.SelectedValue, 0); } if (bp.Insert(p) == 1) { //// 插入日志 add SysOperateLog log = new SysOperateLog(); log.LogID = StringHelper.getKey(); log.LogType = LogType.项目信息.ToString(); log.OperateUser = GetLogUserName(); log.OperateDate = DateTime.Now; log.LogOperateType = "项目新增"; log.LogAfterObject = JsonHelper.Obj2Json(p); bsol.Insert(log); Message.ShowOKAndRedirect(this, "添加项目成功", "ProjectManage.aspx"); } else { Message.ShowWrong(this, "添加项目失败!"); return; } }
public ProjectResponse InsertProject([FromBody] ProjectsRequest request) { ProjectResponse response = new ProjectResponse(); using (TransactionScope scope = new TransactionScope()) { try { if (!BAplication.ValidateAplicationToken(request.ApplicationToken)) { response.Code = "2"; response.Message = Messages.ApplicationTokenNoAutorize; return(response); } string webRoot = _env.ContentRootPath; string rootPath = _appSettings.Value.rootPath; string ProjectPath = _appSettings.Value.ProjectPath; BaseRequest baseRequest = new BaseRequest(); foreach (MProject model in request.Projects) { MProject project = new MProject(); project.ProjectCode = model.ProjectCode; project.Description = model.Description; project.Type = model.Type; project.Status = model.Status; project.StartDate = model.StartDate; project.EndDate = model.EndDate; project.Title = model.Title; project.AwardId = model.AwardId; project.AwardStatus = model.AwardStatus; BProject.Insert(project); } response.Code = "0"; response.Message = "Success"; scope.Complete(); } catch (Exception ex) { response.Code = "2"; response.Message = ex.Message; scope.Dispose(); } } return(response); }