public ActionResult SurveyWriteList(int surveyId) { SurveyInfo survey = _cdeSurveyManager.GetCdeSurveyInfoById(surveyId); _cdeSurveyManager.LoadSendUsers(survey); return(View(survey)); }
public void UpdateSurvey(SqlConnection connection, int _id, SurveyInfo _Survey, string _userU) { using (var command = new SqlCommand("UPDATE tbl_Survey \n" + " SET ProposalID = @ProposalID , SurveyDepartmentID = @SurveyDepartmentID, ProductsName = @ProductsName , DepartmentComment = @DepartmentComment , " + " Comment = @Comment, Status = @Status , Solution=@Solution, SolutionText=@SolutionText, IsSample=@IsSample, Valid=@Valid, ValidText=@ValidText, UserU=@UserU,UpdateTime=getdate(), DateIn = @DateIn \n" + " WHERE (SurveyID = @SurveyID) ", connection)) // " Insert into tbl_Survey_Log ([SurveyID],[SurveyName],[ProposalID],[Comment],[UserI],[Intime],[UserU],[UpdateTime]) (select [SurveyID],[SurveyName],[ProposalID],[Comment],[UserI],[Intime],[UserU],[UpdateTime] from tbl_Survey where SurveyID=@SurveyID ) " { AddSqlParameter(command, "@SurveyID", _id, System.Data.SqlDbType.Int); // AddSqlParameter(command, "@SurveyCode", _Survey.SurveyCode, System.Data.SqlDbType.NVarChar); // AddSqlParameter(command, "@SurveyName", _Survey.SurveyName, System.Data.SqlDbType.NVarChar); AddSqlParameter(command, "@ProposalID", _Survey.ProposalID, System.Data.SqlDbType.Int); AddSqlParameter(command, "@SurveyDepartmentID", _Survey.SurveyDepartmentID, System.Data.SqlDbType.Int); AddSqlParameter(command, "@Comment", _Survey.Comment, System.Data.SqlDbType.NVarChar); AddSqlParameter(command, "@Solution", _Survey.Solution, System.Data.SqlDbType.Int); AddSqlParameter(command, "@SolutionText", _Survey.SolutionText, System.Data.SqlDbType.NVarChar); AddSqlParameter(command, "@IsSample", _Survey.IsSample, System.Data.SqlDbType.Bit); AddSqlParameter(command, "@Valid", _Survey.Valid, System.Data.SqlDbType.Bit); AddSqlParameter(command, "@ValidText", _Survey.ValidText, System.Data.SqlDbType.NVarChar); AddSqlParameter(command, "@Status", _Survey.Status, System.Data.SqlDbType.NVarChar); AddSqlParameter(command, "@DateIn", _Survey.DateIn, System.Data.SqlDbType.DateTime); AddSqlParameter(command, "@UserU", _userU, System.Data.SqlDbType.VarChar); AddSqlParameter(command, "@ProductsName", _Survey.ProductsName, System.Data.SqlDbType.NVarChar); AddSqlParameter(command, "@DepartmentComment", _Survey.DepartmentComment, System.Data.SqlDbType.NVarChar); WriteLogExecutingCommand(command); command.ExecuteScalar(); } }
public async Task <ActionMessage> editSurvey(int id, SurveyInfo _Survey, string _userU, [FromForm] List <IFormFile> files) { ActionMessage ret = new ActionMessage(); SqlConnectionFactory sqlConnection = new SqlConnectionFactory(); using (SqlConnection connection = sqlConnection.GetConnection()) { try { UserLogInfo info = new UserLogInfo(); info.Action = "Edit"; info.Description = "ngày : " + _Survey.InTime + " code : " + _Survey.SurveyCode + " trạng thái : " + _Survey.Status; info.Feature = TableFile.Proposal.ToString(); info.Time = DateTime.Now; info.UserName = _userU; info.UserID = 1; UserService.GetInstance().TrackUserAction(info); SurveyDataLayer.GetInstance().UpdateSurvey(connection, id, _Survey, _userU); } catch (Exception ex) { throw ex; } } DocumentService.GetInstance().DeleteDocumentsNotExitsInList(_Survey.ListDocument, TableFile.Survey.ToString(), id); using (SqlConnection connection = sqlConnection.GetConnection()) { try { ProposalDataLayer.GetInstance().DeleteSurveyItem(connection, id, _userU); foreach (ItemSurveyInfo item in _Survey.SurveyItems) { ProposalDataLayer.GetInstance().InsertSurveyItem(connection, item, id, _userU); } } catch (Exception ex) { throw ex; } } foreach (var item in files) { DocumentInfo documentInfo = new DocumentInfo(); documentInfo.TableName = TableFile.Survey.ToString(); documentInfo.PreferId = id.ToString(); documentInfo.Link = DateTime.Now.ToString("yyMMddHHmmssfff") + "-" + Utils.ChuyenTVKhongDau(item.FileName); documentInfo.FileName = item.FileName; documentInfo.Length = item.Length.ToString(); documentInfo.Type = item.ContentType; ret = await FilesHelpers.UploadFile(TableFile.Survey.ToString(), id.ToString(), item, documentInfo.Link); DocumentService.GetInstance().InsertDocument(documentInfo, _userU.ToString()); } ret.isSuccess = true; return(ret); }
protected void EgvSurvey_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { SurveyInfo dataItem = e.Row.DataItem as SurveyInfo; e.Row.Cells[2].Text = dataItem.CreateDate.ToString("yyyy-MM-dd"); DateTime endTime = dataItem.EndTime; DateTime now = DateTime.Now; if (endTime >= now) { TableCell cell1 = e.Row.Cells[2]; cell1.Text = cell1.Text + "/" + dataItem.EndTime.ToString("yyyy-MM-dd"); } else { TableCell cell2 = e.Row.Cells[2]; cell2.Text = cell2.Text + "/<span style='Color:#F00'>" + string.Format("{0:yyyy-MM-dd}", dataItem.EndTime) + "</span>"; } e.Row.Cells[3].Text = SurveyManager.GetStateName(dataItem.IsOpen); if (dataItem.IsOpen == 1) { e.Row.Cells[0].Enabled = false; } } }
public void LoadSendUsers(SurveyInfo surveyInfo) { var sqlwhere = "Cde_UserSurvey.SurveyId=" + surveyInfo.SurveyId; var sendusers = _dataAccess.GetList <UserSurvey>(sqlwhere); surveyInfo.EvalUsers.AddRange(sendusers); }
public JsonResult PublishSurvey(int id) { SurveyInfo surveyInfo = _cdeSurveyManager.GetCdeSurveyInfoById(id); if (surveyInfo.EndTime < DateTime.Now) { return(Json(new { result = 0, msg = CdeQuestion.Prompt15 }, JsonRequestBehavior.AllowGet)); } _cdeSurveyManager.ChangeSurveyStatus(id, 1); try { _cdeSurveyManager.LoadSendUsers(surveyInfo); string title = string.Format(LanguageResources.SendMessage.CdeSurveyInform_Title, surveyInfo.SurveyTitle); string content = string.Format(LanguageResources.SendMessage.CdeSurveyInform_Content, surveyInfo.SurveyTitle, surveyInfo.StartTime.ToString("yyyy-HH-dd HH:mm:ss"), surveyInfo.EndTime.ToString("yyyy-HH-dd HH:mm:ss"), Url.RetechAction("ApproveUserSurveyList", "CdeUserSurvey", new { area = "Talnet" }) + "?keep=1"); int[] recUsers = surveyInfo.EvalUsers.Select(p => p.UserId).ToArray(); SendMessage(title, content, recUsers, 11); } catch (Exception ex) { LogHelper.WriteLog("360°评估《" + surveyInfo.SurveyTitle + "》发送邮件失败", ex); } return(Json(new { result = 1, msg = LanguageResources.Common.PublishSuccess }, JsonRequestBehavior.AllowGet)); }
public static bool CheckIPLock(string userIP, SurveyInfo surveyInfo) { bool flag = false; string[] strArray = surveyInfo.SetIPLock.Split(new string[] { "|||" }, StringSplitOptions.None); if (strArray.Length >= 2) { double checkIP = StringHelper.EncodeIP(userIP); string[] arrWhiteLockIP = strArray[0].Split(new string[] { "$$$" }, StringSplitOptions.RemoveEmptyEntries); string[] arrBlackLockIP = strArray[1].Split(new string[] { "$$$" }, StringSplitOptions.RemoveEmptyEntries); switch (surveyInfo.LockIPType) { case 1: return(!CheckWhiteLockIP(checkIP, arrWhiteLockIP)); case 2: return(CheckBlackLockIP(checkIP, arrBlackLockIP)); case 3: if (CheckWhiteLockIP(checkIP, arrWhiteLockIP)) { if (CheckBlackLockIP(checkIP, arrBlackLockIP)) { flag = true; } return(flag); } return(true); case 4: return(CheckBlackLockIP(checkIP, arrBlackLockIP) && !CheckWhiteLockIP(checkIP, arrWhiteLockIP)); } } return(flag); }
protected void Page_Load(object sender, EventArgs e) { this.m_Action = BasePage.RequestStringToLower("Action"); this.m_SurveyId = BasePage.RequestInt32("SurveyID"); if (!this.Page.IsPostBack) { SurveyInfo surveyById = new SurveyInfo(); surveyById = SurveyManager.GetSurveyById(this.m_SurveyId); this.HdnIsOpen.Value = surveyById.IsOpen.ToString(); string surveyName = surveyById.SurveyName; this.LnkSurveyName.Text = surveyName; this.LnkSurveyName.NavigateUrl = "QuestionManage.aspx?SurveyID=" + this.m_SurveyId; if (this.m_SurveyId != 0) { if (this.m_Action == "modify") { int num = BasePage.RequestInt32("QuestionId"); this.LblTitle.Text = "修改问卷"; if (num != 0) { this.HdnQuestionId.Value = num.ToString(); this.ModifyInitialize(); } else { AdminPage.WriteErrMsg("<li>问题ID不能为空</li>"); } } } else { AdminPage.WriteErrMsg("<li>问卷ID不能为空</li>"); } } }
private void ShowSurveyInfo(int surveyId) { if (surveyId != 0) { SurveyInfo surveyById = SurveyManager.GetSurveyById(surveyId); this.ViewState["Info"] = surveyById; if (surveyById != null) { this.TxtSurveyName.Text = surveyById.SurveyName; this.TxtDescription.Text = surveyById.Description; this.TxtIPRepeat.Text = surveyById.IPRepeat.ToString(); if (surveyById.NeedLogin == 1) { this.RadNeedLogin1.Checked = true; this.RadNeedLogin0.Checked = false; this.TxtPresentPoint.Text = surveyById.PresentPoint.ToString(); } this.TxtSetPassword.Attributes.Add("value", surveyById.SetPassword); this.RadlLockIPType.SelectedValue = surveyById.LockIPType.ToString(); string[] field = surveyById.SetIPLock.Split(new string[] { "|||" }, StringSplitOptions.None); this.IPLockWrite.Value = DataSecurity.GetArrayValue(0, field); this.IPLockBlack.Value = DataSecurity.GetArrayValue(1, field); this.DateEnd.Text = surveyById.EndTime.ToString("yyyy-MM-dd"); this.FscTemplate.Text = surveyById.Template; this.TxtLockUrl.Text = surveyById.LockUrl; } else { AdminPage.WriteErrMsg("找不到该问卷!", "SurveyManage.aspx"); } } }
protected void DataBind(int surveyId) { SurveyInfo surveyById = SurveyManager.GetSurveyById(surveyId); this.ViewState["surveyInfo"] = surveyById; this.SurveyContent.Value = SurveyCreate.GetSurveyTemplate(surveyById); string fileName = surveyById.FileName; if (string.IsNullOrEmpty(fileName)) { fileName = DateTime.Now.ToString("yyyyMMddHHmmss") + ".html"; } string[] strArray = fileName.Split(new char[] { '.' }); string str2 = strArray[1]; this.HdnShortFileName.Value = strArray[0]; this.HdnFileName.Value = fileName; if (str2 == "html") { this.RadlPageType.SelectedValue = "0"; } else { this.RadlPageType.SelectedValue = "1"; } this.TxtFileName.Text = fileName; this.HdnSurveyId.Value = surveyId.ToString(); }
protected void Page_Load(object sender, EventArgs e) { this.surveyId = BasePage.RequestInt32("SurveyID"); if (!base.IsPostBack) { if (this.surveyId == 0) { AdminPage.WriteErrMsg("<li>请指定问卷ID</li>", "SurveyManage.aspx"); } else if (!SurveyManager.SurveyIdOfPassedExists(this.surveyId)) { AdminPage.WriteErrMsg("<li>该问卷未启用,不能查看报表!</li>"); } else { SurveyInfo surveyById = SurveyManager.GetSurveyById(this.surveyId); if (!surveyById.IsNull) { this.LblSurveyName.Text = surveyById.SurveyName; this.LblDescription.Text = surveyById.Description; this.LblTitle.Text = "[" + surveyById.SurveyName + "]问卷报表"; this.LblSurveyNumber.Text = SurveyRecord.GetTotalOfSurveyRecord(this.surveyId).ToString(); this.LblDate.Text = surveyById.CreateDate.ToString() + "/" + surveyById.EndTime.ToString(); } else { AdminPage.WriteErrMsg("<li>未找到对应的问卷信息</li>"); } } this.BtnReport.Attributes.Add("onclick", "javascript:window.print();return false;"); } }
private void UpdateSurvey() { if (this.ViewState["Info"] != null) { SurveyInfo surveyInfo = this.ViewState["Info"] as SurveyInfo; surveyInfo.SurveyName = this.TxtSurveyName.Text; surveyInfo.Description = this.TxtDescription.Text; surveyInfo.NeedLogin = this.RadNeedLogin0.Checked ? 0 : 1; surveyInfo.SetPassword = this.TxtSetPassword.Text; surveyInfo.IPRepeat = DataConverter.CLng(this.TxtIPRepeat.Text, 1); surveyInfo.PresentPoint = DataConverter.CLng(this.TxtPresentPoint.Text); surveyInfo.LockIPType = DataConverter.CLng(this.RadlLockIPType.SelectedValue); surveyInfo.EndTime = DateTime.Parse(this.DateEnd.Date.ToString()); surveyInfo.Template = this.FscTemplate.Text; surveyInfo.LockUrl = this.TxtLockUrl.Text.Trim(); if (this.DateEnd.Date < DateTime.Now) { AdminPage.WriteErrMsg("<li>问卷结束时间早于创建时间!</li>"); } else { surveyInfo.EndTime = DateTime.Parse(this.DateEnd.Date.ToString()); } surveyInfo.SetIPLock = this.IPLockWrite.Value + "|||" + this.IPLockBlack.Value; surveyInfo.LockUrl = this.TxtLockUrl.Text; if (SurveyManager.Update(surveyInfo)) { AdminPage.WriteSuccessMsg("修改问卷成功!", "SurveyManage.aspx"); } else { AdminPage.WriteErrMsg("<li>修改问卷失败!"); } } }
protected void Egv_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { SurveyInfo dataItem = (SurveyInfo)e.Row.DataItem; string fullBasePath = base.FullBasePath; if (!string.IsNullOrEmpty(dataItem.FileName)) { ((TextBox)e.Row.FindControl("TxtFrameCode")).Text = "<IFrame src='" + fullBasePath + "Survey/" + dataItem.FileName + "' frameBorder='0' scrolling='no'>" + dataItem.SurveyName + "</IFrame>"; ((TextBox)e.Row.FindControl("TxtLinkCode")).Text = "<a href='" + fullBasePath + "Survey/" + dataItem.FileName + "' target='_blank'>" + dataItem.SurveyName + "</a>"; } else { ((TextBox)e.Row.FindControl("TxtFrameCode")).Text = "问卷未完成!"; ((TextBox)e.Row.FindControl("TxtLinkCode")).Text = "问卷未完成!"; } if (dataItem.IsOpen == 1) { ((TextBox)e.Row.FindControl("TxtResultCode")).Text = string.Concat(new object[] { "<a href='", fullBasePath, "Survey/ListReport.aspx?SurveyID=", dataItem.SurveyId, "' target='_blank'>", dataItem.SurveyName, "调查结果</a>" }); } else { ((TextBox)e.Row.FindControl("TxtResultCode")).Text = "指定的问卷未启用,无统计数据!"; } } }
public void Then_MultilineTextBox_Should_be_Published() { //Arrange ISurveyInfoDao objISurveryInfoDao = new EntitySurveyInfoDao(); SurveyInfo objSurveyInfo = new SurveyInfo(objISurveryInfoDao); Publisher objPublisher = new Publisher(objISurveryInfoDao); SurveyDataProvider DataObj = new SurveyDataProvider();//Get Data SurveyRequestBO objSurveyRequestBO; SurveyRequestResultBO objSurveyResponseBO; SurveyInfoBO objSurveyInfoBO = new SurveyInfoBO(); string TemplateXML; string surveyURL; string surveyID = string.Empty; //Act objSurveyRequestBO = DataObj.CreateSurveyRequestBOObject(); TemplateXML = objSurveyRequestBO.TemplateXML; objSurveyInfoBO = DataObj.CreateSurveyInfoBOObject(); objSurveyResponseBO = objPublisher.PublishSurvey(objSurveyInfoBO); //Publish Survey Takes SurveyInfoBO surveyURL = objSurveyResponseBO.URL; surveyID = surveyURL.Substring(surveyURL.LastIndexOf('/') + 1); //Get the ID from Url. objSurveyInfoBO = objSurveyInfo.GetSurveyInfoById(surveyID); //Assert Assert.NotNull(objSurveyInfoBO.XML); Assert.NotNull(TemplateXML); }
protected void Page_Load(object sender, EventArgs e) { this.surveyId = DataConverter.CLng(base.Request.QueryString["SurveyID"]); SurveyInfo surveyById = SurveyManager.GetSurveyById(this.surveyId); this.SmpNavigator.AdditionalNode = "<b>[</b><font color=red>" + DataSecurity.HtmlEncode(surveyById.SurveyName) + "</font><b>]</b>题目列表"; this.isOpen = surveyById.IsOpen; if (this.isOpen == 1) { this.EgvQuestion.Columns[3].Visible = false; this.BtnAddQuestion.Visible = false; this.BtnSetOrderId.Visible = false; this.BtnDel.Visible = false; this.EgvQuestion.AutoGenerateCheckBoxColumn = false; } if (!base.IsPostBack) { int questionId = DataConverter.CLng(base.Request.QueryString["QuestionId"]); string str = base.Request.QueryString["Action"]; if (str == "Delete") { SurveyField.Delete(this.surveyId, questionId); } } }
public async Task <IActionResult> CreateSurvey([FromBody] SurveyInfo survey) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } //var surveyModel = _mapper.Map<Services.Entities.SurveyInfo>(survey); var surveyModel = new Services.Entities.SurveyInfo { CompanyId = survey.CompanyId, Name = survey.Name, Description = survey.Description, WelcomeMessage = survey.WelcomeMessage, ExitMessage = survey.ExitMessage, StartDate = survey.StartDate, EndDate = survey.EndDate, PublicationDate = survey.PublicationDate, ExpirationDate = survey.ExpirationDate }; var result = await _surveyRepository.CreateSurvey(surveyModel); if (result != null) //if (result.StatusCode == System.Net.HttpStatusCode.OK) { return(new OkObjectResult(result)); } else { return(BadRequest()); } }
public ActionMessage createSurvey(SurveyInfo _Survey, string _userI) { ActionMessage ret = new ActionMessage(); SqlConnectionFactory sqlConnection = new SqlConnectionFactory(); using (SqlConnection connection = sqlConnection.GetConnection()) { try { var ProposalInfo = ProposalDataLayer.GetInstance().getProposalDetail2(connection, _Survey.ProposalCode); if (ProposalInfo != null) { _Survey.ProposalID = ProposalInfo.ProposalID; } else { _Survey.ProposalID = 0; } ret.id = SurveyDataLayer.GetInstance().InsertSurvey(connection, _Survey, _userI); ret.isSuccess = true; } catch (Exception ex) { ret.isSuccess = false; ret.err.msgCode = "Internal Error"; ret.err.msgString = ex.Message; } } return(ret); }
public ActionResult AddSurvey() { var model = new SurveyInfo(); ViewBag.config = _configManager.GetConfig(CurrentTenant.TenantId); ViewBag.mode = "add"; return(View("EditSurvey", model)); }
public bool Add(SurveyInfo surveyInfo) { if (surveyInfo.SurveyId <= 0) { surveyInfo.SurveyId = this.GetMaxId() + 1; } return(DBHelper.ExecuteProc("PR_Survey_SurveyManager_Add", GetParameters(surveyInfo))); }
public JsonResult ApproveUserSurvey(int userSurveyId, int approveFlag, string reason) { UserSurvey model = _userSurveyManager.GetUserSurvey(userSurveyId); model.ApproveReason = reason; model.ApproveFlag = approveFlag; model.ApproveTime = DateTime.Now; model.ApproveUser = CurrentUser.UserId; _userSurveyManager.UpdateUserSurvey(model); SurveyInfo surveyInfo = _surveyManager.GetCdeSurveyInfoById(model.SurveyId); try { string title = string.Format(LanguageResources.SendMessage.CdeSurveyUserApproveResult_Title, surveyInfo.SurveyTitle, (approveFlag == 2 ? KnowledgeLanguage.ApprovalPass : CdeSurvey.NoPassPending)); string content = string.Format(LanguageResources.SendMessage.CdeSurveyUserApproveResult_Content, surveyInfo.SurveyTitle, (approveFlag == 2 ? KnowledgeLanguage.ApprovalPass : CdeSurvey.NoPassPending + LanguageResources.Common.Comma + webUILang.Reason + reason)); SendMessage(title, content, new[] { model.UserId }, 11); if (approveFlag == 2) { List <Cde_SurveySendUsers> sendus = _userSendSurveyManager.GetSurveySendUsers(userSurveyId); var msglist = new List <SysIinstationMessage>(); foreach (Cde_SurveySendUsers sendu in sendus) { //if (sendu.UserId == model.UserId) continue; var msg = new SysIinstationMessage(); msg.title = string.Format(LanguageResources.SendMessage.CdeSurveyYouHaveWrite_Title, model.Realname, surveyInfo.SurveyTitle); msg.tenantId = CurrentUser.TenantId; msg.sendUserId = 0; msg.recUserId = new[] { sendu.UserId }; string relship = sendu.Relationship == 3 ? "" : LanguageResources.Common.Comma + CdeQuestion.YouForUser + sendu.RelationshipStr; msg.content = string.Format(LanguageResources.SendMessage.CdeSurveyYouHaveWrite_Content , model.Realname, surveyInfo.SurveyTitle, relship, surveyInfo.StartTime.ToString("yyyy-MM-dd HH:mm:ss") , surveyInfo.EndTime.ToString("yyyy-MM-dd HH:mm:ss"), Url.RetechAction("WriteSurvey", "CdeUserSurvey") + "?id=" + model.UserSurveyId + "&sid=" + sendu.SendUserId); msglist.Add(msg); } SendMessage(msglist, 11); } } catch (Exception ex) { LogHelper.WriteLog("反馈360°参评人员审批结果失败", ex); } return(Json(new { result = 1, msg = CdeQuestion.ApprovalSuccess }, JsonRequestBehavior.DenyGet)); }
public int AddSurveyInfo(SurveyInfo userSurveyInfo) { _dataAccess.AddEntity(userSurveyInfo); foreach (var user in userSurveyInfo.EvalUsers) { user.SurveyId = userSurveyInfo.SurveyId; } _dataAccess.AddEntities(userSurveyInfo.EvalUsers); return(userSurveyInfo.SurveyId); }
public JsonResult DeleteSurvey(int id) { SurveyInfo survey = _cdeSurveyManager.GetCdeSurveyInfoById(id); if (survey == null || survey.TenantId != CurrentUser.TenantId) { return(Json(new { result = 0, content = CdeQuestion.Prompt16 }, JsonRequestBehavior.AllowGet)); } _cdeSurveyManager.DeleteSurveyInfo(survey); return(Json(new { result = 1, content = Exampaper.DeleteSuccess }, JsonRequestBehavior.AllowGet)); }
public ActionResult PreviewWritedSurvey(int id, int userid = 0) { ViewBag.surveyConfig = _configManager.GetConfig(CurrentTenant.TenantId); UserSurvey usersurvey = _userSurveyManager.GetUserSurvey(id); ViewBag.userInfo = SystemUsers.First(p => p.UserId == usersurvey.UserId); SurveyInfo surveyInfo = _exampaperManager.GetUserParticipateSurveyInfo(id, userid == 0 ? CurrentUser.UserId : userid); ViewBag.userid = userid; return(View(surveyInfo)); }
/// <summary> /// Hàm lấy tất cả khoa phòng /// </summary> /// <returns>Return List<SurveyInfo></returns> /// public List <SurveyInfo> GetAllSurvey(SqlConnection connection, string _userID) { var result = new List <SurveyInfo>(); using (var command = new SqlCommand("Select S.*, SD.DepartmentName, P.ProposalCode, P.ProposalType, PT.TypeName, P.DepartmentID as ProDepartmentID, D.DepartmentName as ProDepartmentName " + " from tbl_Survey S " + " left join tbl_Department SD on S.SurveyDepartmentID = SD.DepartmentID " + " left join tbl_Proposal P on P.ProposalID = S.ProposalID" + " left join tbl_Department D on P.DepartmentID = D.DepartmentID " + " left join tbl_ProposalType PT on PT.TypeID = P.ProposalType" + " where 1=1 " , connection)) { if (!string.IsNullOrEmpty(_userID) && _userID != "admin") { command.CommandText += " and ( S.UserAssign = " + _userID + " ) or ( S.UserI = " + _userID + " )"; } command.CommandText += " order by S.UpdateTime Desc "; using (var reader = command.ExecuteReader()) { while (reader.Read()) { var info = new SurveyInfo(); info.SurveyID = GetDbReaderValue <int>(reader["SurveyID"]); info.SurveyCode = GetDbReaderValue <string>(reader["SurveyCode"]); info.SurveyName = GetDbReaderValue <string>(reader["SurveyName"]); info.ProposalID = GetDbReaderValue <int>(reader["ProposalID"]); info.ProposalCode = GetDbReaderValue <string>(reader["ProposalCode"]); info.ProposalType = GetDbReaderValue <int>(reader["ProposalType"]); info.ProposalTypeName = GetDbReaderValue <string>(reader["TypeName"]); info.TypeName = GetDbReaderValue <string>(reader["TypeName"]); info.DepartmentID = GetDbReaderValue <int>(reader["ProDepartmentID"]); info.DepartmentName = GetDbReaderValue <string>(reader["ProDepartmentName"]); info.SurveyDepartmentID = GetDbReaderValue <int>(reader["SurveyDepartmentID"]); info.SurveyDepartmentName = GetDbReaderValue <string>(reader["DepartmentName"]); info.Comment = GetDbReaderValue <string>(reader["Comment"]); info.Solution = GetDbReaderValue <int>(reader["Solution"]); info.SolutionText = GetDbReaderValue <string>(reader["SolutionText"]); info.IsSample = GetDbReaderValue <bool>(reader["IsSample"]); info.Valid = GetDbReaderValue <bool>(reader["Valid"]); info.ValidText = GetDbReaderValue <string>(reader["ValidText"]); info.UserI = GetDbReaderValue <string>(reader["UserI"]); info.InTime = GetDbReaderValue <DateTime?>(reader["InTime"]); info.DateIn = GetDbReaderValue <DateTime?>(reader["DateIn"]); info.UserU = GetDbReaderValue <string>(reader["UserU"]); info.UpdateTime = GetDbReaderValue <DateTime>(reader["UpdateTime"]); result.Add(info); } } return(result); } }
public ActionResult EditSurvey(int id, string mode = "edit") { SurveyInfo model = _cdeSurveyManager.GetCdeSurveyInfoById(id); if (model == null || model.TenantId != CurrentUser.TenantId) { model = new SurveyInfo(); } _cdeSurveyManager.LoadSendUsers(model); ViewBag.config = _configManager.GetConfig(CurrentTenant.TenantId); ViewBag.mode = string.IsNullOrEmpty(mode) ? "edit" : mode; return(View(model)); }
public bool UpdateSurveyInfo(SurveyInfo userSurveyInfo) { foreach (var user in userSurveyInfo.EvalUsers) { user.SurveyId = userSurveyInfo.SurveyId; } string sqlwhere = "SurveyId=" + userSurveyInfo.SurveyId; _dataAccess.DeleteEntities <UserSurvey>(sqlwhere); _dataAccess.AddEntities(userSurveyInfo.EvalUsers); return(_dataAccess.UpdateEntity(userSurveyInfo) > 0); }
public int InsertSurvey(SqlConnection connection, SurveyInfo _Survey, string _userI) { int lastestInserted = 0; var currenttime = DateTime.Now.Date; using (var command = new SqlCommand("Insert into [dbo].[tbl_Survey] (SurveyCode, ProposalID,SurveyDepartmentID, Comment, Solution, SolutionText, IsSample, Valid, ValidText, ProductsName, DepartmentComment, Status, UserI, DateIn)" + "VALUES(@SurveyCode, @ProposalID,@SurveyDepartmentID, @Comment, @Solution, @SolutionText, @IsSample, @Valid, @ValidText,@ProductsName, @DepartmentComment, @Status, @UserI, @DateIn) " + " select IDENT_CURRENT('dbo.tbl_Survey') as LastInserted ", connection)) { AddSqlParameter(command, "@SurveyCode", "KS-" + _Survey.ProposalCode, System.Data.SqlDbType.NVarChar); // AddSqlParameter(command, "@SurveyCode", _Survey.SurveyCode, System.Data.SqlDbType.NVarChar); // AddSqlParameter(command, "@SurveyName", _Survey.SurveyName, System.Data.SqlDbType.NVarChar); AddSqlParameter(command, "@ProposalID", _Survey.ProposalID, System.Data.SqlDbType.Int); AddSqlParameter(command, "@SurveyDepartmentID", _Survey.SurveyDepartmentID, System.Data.SqlDbType.Int); AddSqlParameter(command, "@Comment", _Survey.Comment, System.Data.SqlDbType.NVarChar); AddSqlParameter(command, "@Solution", _Survey.Solution, System.Data.SqlDbType.Int); AddSqlParameter(command, "@SolutionText", _Survey.SolutionText, System.Data.SqlDbType.NVarChar); AddSqlParameter(command, "@IsSample", _Survey.IsSample, System.Data.SqlDbType.Bit); AddSqlParameter(command, "@Valid", _Survey.Valid, System.Data.SqlDbType.Bit); AddSqlParameter(command, "@ValidText", _Survey.ValidText, System.Data.SqlDbType.NVarChar); AddSqlParameter(command, "@UserI", _userI, System.Data.SqlDbType.VarChar); AddSqlParameter(command, "@ProductsName", _Survey.ProductsName, System.Data.SqlDbType.NVarChar); AddSqlParameter(command, "@DepartmentComment", _Survey.DepartmentComment, System.Data.SqlDbType.NVarChar); AddSqlParameter(command, "@Status", _Survey.Status, System.Data.SqlDbType.NVarChar); AddSqlParameter(command, "@DateIn", _Survey.DateIn, System.Data.SqlDbType.DateTime); WriteLogExecutingCommand(command); var lastInsertedRaw = command.ExecuteScalar(); if (lastInsertedRaw != null && !DBNull.Value.Equals(lastInsertedRaw)) { lastestInserted = Convert.ToInt32(lastInsertedRaw); } } if (lastestInserted != 0) { using (var command = new SqlCommand("update tbl_Proposal_Process " + "set SurveyID=@SurveyID , SurveyCode=@SurveyCode, SurveyTime=@SurveyTime, CurrentFeature=@CurrentFeature where ProposalID=@ProposalID", connection)) { AddSqlParameter(command, "@SurveyID", lastestInserted, System.Data.SqlDbType.Int); AddSqlParameter(command, "@ProposalID", _Survey.ProposalID, System.Data.SqlDbType.Int); AddSqlParameter(command, "@SurveyCode", "KS-" + _Survey.ProposalCode, System.Data.SqlDbType.VarChar); AddSqlParameter(command, "@SurveyTime", currenttime, System.Data.SqlDbType.DateTime); AddSqlParameter(command, "@CurrentFeature", "Survey", System.Data.SqlDbType.VarChar); WriteLogExecutingCommand(command); command.ExecuteScalar(); } } return(lastestInserted); }
public ActionMessage Post([FromBody] SurveyInfo _survey) { ActionMessage ret = new ActionMessage(); try { ret = SurveyService.GetInstance().createSurvey(_survey, GetUserId()); } catch (Exception ex) { ret.isSuccess = false; ret.err.msgCode = "Internal Error !!!"; ret.err.msgString = ex.ToString(); } return(ret); }
public async Task <ActionMessage> Put(int id, [FromForm] SurveyInfo _Survey, [FromForm] List <IFormFile> files) { ActionMessage ret = new ActionMessage(); try { ret = await SurveyService.GetInstance().editSurvey(id, _Survey, GetUserId(), files); } catch (Exception ex) { ret.isSuccess = false; ret.err.msgCode = "Internal Error !!!"; ret.err.msgString = ex.ToString(); } return(ret); }
public ActionMessage Put(int id, [FromBody] SurveyInfo _survey) { ActionMessage ret = new ActionMessage(); /* try * { * ret = SurveyService.GetInstance().editSurvey(id, _survey, getUserId()); * } * catch (Exception ex) * { * ret.isSuccess = false; * ret.err.msgCode = "Internal Error !!!"; * ret.err.msgString = ex.ToString(); * }*/ return(ret); }