protected void Button1_Click(object sender, EventArgs e) { try{ var Qtype = DropDownList1.SelectedValue; var opptype = DropDownList2.SelectedValue; var mark = markTxt.Text; var pOpt = percentOption.Checked; // var preambleid = preambleLists.SelectedValue; //var preambleName = PreambleName.Text; //var preamble = preambleText.Text; //T_QuestionsPreamble p = null; // if (!string.IsNullOrEmpty(preamble)) // { // p = new T_QuestionsPreamble // { // Name = preambleName, // Body = preamble, // AddedBy = SessionHelper.FetchEmail(Session), // DateAdded = DateTime.Now // }; // _db.T_QuestionPreamble.Add(p); // _db.SaveChanges(); // } if (!string.IsNullOrEmpty(TextBox1.Text)) { var email = SessionHelper.FetchEmail(Session); var opttype = long.Parse(opptype);//(long)ErecruitHelper.OptionType.Single; decimal altmark = 1; var qMark = string.IsNullOrEmpty(mark) ? 1 : decimal.TryParse(mark, out altmark)?altmark:1; var tyId = long.Parse(Qtype); var tenantId = long.Parse(SessionHelper.GetTenantID(HttpContext.Current.Session)); T_Question q = new T_Question { //PreambleId = p != null ? p.Id : string.IsNullOrEmpty(preambleid)||(long.Parse(preambleid) == -1) ? 0 :long.Parse(preambleid), TypeId = tyId, OptionType = opttype, Section = Section.Text, TenantId = tenantId, IsActive = true, Details = TextBox1.Text, Mark = qMark, OptionPercentageMark = pOpt, AddedBy = email, DateAdded = DateTime.Now }; _db.T_Question.Add(q); _db.SaveChanges(); } Response.Redirect("QuestionsList.aspx", false); } catch (Exception ex) { ErecruitHelper.SetErrorData(ex, Session); Response.Redirect("ErrorPage.aspx", false); } }
// DELETE: api/Question/5 public Response Delete(int id) { try { T_Question queToBeFind = dalobj.T_Question.Find(id); if (queToBeFind != null) { dalobj.T_Question.Remove(queToBeFind); dalobj.SaveChanges(); response.Data = null; response.Status = "success"; response.Err = null; logger.Log("Specific Question deleted using id"); return(response); } else { response.Data = null; response.Status = "failed"; response.Err = null; logger.Log("Specific Question Not found using id"); return(response); } } catch (Exception cause) { response.Data = cause.Message; response.Status = "Failed"; response.Err = cause; logger.Log("Exception occured returned Error msg"); return(response); } }
public JsonResult DeleteQuestion(int id) { JsonModel jm = new JsonModel(); IQuestionBLL questionBll = BLLFactory <IQuestionBLL> .GetBLL("QuestionBLL"); T_Question question = questionBll.GetEntity(m => m.Id == id); if (question != null) { if (questionBll.Delete(question)) { if (!string.IsNullOrEmpty(question.Imgs)) { //删除图片 string[] Imgs = question.Imgs.Split(';'); for (int i = 0; i < Imgs.Count(); i++) { DelFile(Imgs[i]); } } if (!string.IsNullOrEmpty(question.AudioPath)) { //删除语音 DelFile(question.AudioPath); } jm.Content = "删除问题" + question.Title + "成功"; } } else { jm.Msg = "该上报问题不存在"; } return(Json(jm, JsonRequestBehavior.AllowGet)); }
public Response Post([FromBody] T_Question que) { try { if (que != null) { dalobj.T_Question.Add(que); dalobj.SaveChanges(); response.Data = null; response.Status = "success"; response.Err = null; logger.Log("Question inserted in db"); return(response); } else { response.Data = null; response.Status = "failed"; response.Err = null; logger.Log("Invalid Credentials"); return(response); } } catch (Exception cause) { response.Data = cause.Message; response.Status = "Failed"; response.Err = cause; logger.Log("Exception occured returned Error msg"); return(response); } }
private void bunifuImageButton9_Click(object sender, EventArgs e) { var tQuestion = new T_Question(); var question = new Frm_Question(); question.titletxt.Text = @"Confirmation"; question.msgtxt.Text = @"Do you want to load this customer?"; tQuestion.Show(this); question.ShowDialog(); if (question.DialogResult == DialogResult.Yes) { Hascustomer = true; CustomerRetrieve = true; CustomerId = lblid.Text; question.Hide(); tQuestion.Close(); popup.TitleText = @"Information"; popup.Image = Properties.Resources.information; popup.ContentText = @"" + lblfullname.Text + " has been loaded in this this transaction"; popup.Popup(); Focus(); } question.Dispose(); tQuestion.Close(); Focus(); }
/// <summary> /// 如何是修改,则读取数据绑定 /// </summary> /// <param name="questionID"></param> protected void databind(int questionID) { E_Question data = new E_Question(); data.QuestionID = questionID; data.EnterpriseID = EnterpriceID; data = new T_Question().GetModel(data); if (data != null) { txtQuestionName.Text = data.QuestionName; rblQuestionType.SelectedValue = data.QuestionType.ToString(); rpList.DataSource = data.QuestionItem; rpList.DataBind(); } //加载与该问题相关的名录 data = new E_Question(); data.EnterpriseID = EnterpriceID; data.QuestionID = questionID; DataTable dt = new T_Question().ListSelect(data); lblClientNum.Text = dt.Rows.Count.ToString(); rpClientInfo.DataSource = dt; rpClientInfo.DataBind(); }
/// <summary> /// 绑定页面数据 /// </summary> protected void databind() { int ciid = Requests.GetQueryInt("ciid", 0); //-----------------绑定基本信息------------------------------ E_ClientInfo data = new T_ClientInfo().GetModel(new E_ClientInfo() { EnterpriseID = EnterpriceID, ClientInfoID = ciid, EPUserTMRID = 0 }); if (data == null) { Jscript.AlertAndRedirect(this, "信息不存在", "ClientInfoSearch.aspx"); return; } ltClientName.Text = data.ClientName; ltAddress.Text = data.Address; ltZipCode.Text = data.ZipCode; ltLinkman.Text = data.Linkman; ltPosition.Text = data.Position; ltEmail.Text = data.Email; ltTel.Text = data.Tel; ltMobile.Text = data.Mobile; hlWebsite.NavigateUrl = data.Website.IndexOf("http://") == -1?"http://" + data.Website:data.Website; hlWebsite.Text = data.Website; ltFax.Text = data.Fax; ltRemark.Text = data.Remark; //-----------------绑定名录属性------------------------------ Property1.SourceID = data.SourceID; Property1.TradeID = data.TradeID; Property1.AreaID = data.AreaID; //-----------------绑定状态------------------------------ ltStatus.Text = data.Status.ToString(); //hdStatus.Value = ((int)data.Status).ToString(); ////----------------绑定沟通记录--------------------- //rpExchangeList.DataSource = new T_Exchange().GetList(new E_Exchange() { EnterpriseID = EnterpriceID, ClientItemID = ciid }); //rpExchangeList.DataBind(); //----------------调查问卷---------------- DataSet ds = new T_Question().List(new MLMGC.DataEntity.Enterprise.Material.E_Question() { EnterpriseID = EnterpriceID, ClientInfoID = ciid }); if (ds != null && ds.Tables.Count == 2) { dtItem = ds.Tables[1]; rpList.DataSource = ds.Tables[0]; rpList.DataBind(); } //----------------获取当前用户角色信息---------------- int roleid = new T_User().GetEPRoleID(new E_EnterpriseUser() { EnterpriseID = EnterpriceID, EPUserTMRID = EPUserTMRID }); btnMyGet.Visible = (roleid == (int)EnumRole.销售人员); IsShowExchange = !(roleid == (int)EnumRole.销售人员);//销售人员不能查看沟通记录 }
public JsonResult DisposeQuestion(DisposeQuestionModel model) { JsonModel jm = new JsonModel(); if (ModelState.IsValid) { //获取要处理的上报问题 IQuestionBLL questionBll = BLLFactory <IQuestionBLL> .GetBLL("QuestionBLL"); T_Question question = questionBll.GetEntity(m => m.Id == model.Id); if (question != null) { //修改处理状态并添加处理记录 question.Status = ConstantParam.DISPOSED; question.IsPublish = model.IsPublish ? 1 : 0; T_QuestionDispose questionDispose = new T_QuestionDispose() { DisposeDesc = model.DisposeDesc, DisposeUserId = GetSessionModel().UserID, QuestionId = model.Id, DisposeTime = DateTime.Now }; //保存到数据库 questionBll.DisposeQuestion(question, questionDispose); IUserPushBLL userPushBLL = BLLFactory <IUserPushBLL> .GetBLL("UserPushBLL"); var userPush = userPushBLL.GetEntity(p => p.UserId == question.UploadUserId); if (userPush != null) { string registrationId = userPush.RegistrationId; string alert = "您" + question.UploadTime.ToString("yyyy-MM-dd HH:mm") + "上报的问题已处理"; //通知信息 bool flag = PropertyUtils.SendPush("上报问题处理", alert, ConstantParam.MOBILE_TYPE_OWNER, registrationId); if (!flag) { jm.Msg = "推送发生异常"; } } //日志记录 jm.Content = PropertyUtils.ModelToJsonString(model); } else { jm.Msg = "该问题不存在"; } } else { jm.Msg = ConstantParam.JSON_RESULT_MODEL_CHECK_ERROR; } return(Json(jm, JsonRequestBehavior.AllowGet)); }
public ApiResultModel SetQuestionDisposer(SetDisposerModel model) { ApiResultModel resultModel = new ApiResultModel(); try { IPropertyUserBLL userBll = BLLFactory <IPropertyUserBLL> .GetBLL("PropertyUserBLL"); T_PropertyUser user = userBll.GetEntity(u => u.Id == model.UserId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT); if (user != null) { //如果验证Token不通过或已过期 if (DateTime.Now > user.TokenInvalidTime || model.Token != user.Token) { resultModel.Msg = APIMessage.TOKEN_INVALID; return(resultModel); } //更新最近登录时间和Token失效时间 user.LatelyLoginTime = DateTime.Now; user.TokenInvalidTime = DateTime.Now.AddDays(Convert.ToInt32(PropertyUtils.GetConfigParamValue("TokenInvalid"))); userBll.Update(user); //获取要指派处理人的问题 IQuestionBLL questionBll = BLLFactory <IQuestionBLL> .GetBLL("QuestionBLL"); T_Question question = questionBll.GetEntity(m => m.Id == model.Id); if (question != null) { //指派处理人 question.DisposerId = model.DisposerId; //保存到数据库 if (!questionBll.Update(question)) { resultModel.Msg = APIMessage.SET_DISPOSER_FAIL; } } else { resultModel.Msg = APIMessage.QUESTION_NOEXIST; } } else { resultModel.Msg = APIMessage.NO_USER; } } catch { resultModel.Msg = APIMessage.REQUEST_EXCEPTION; } return(resultModel); }
protected void Button1_Click(object sender, EventArgs e) { T_Question q = new T_Question { TypeId = long.Parse(DropDownList1.SelectedValue), OptionType = long.Parse(DropDownList2.SelectedValue), IsActive = true, Details = TextBox1.Text }; _db.T_Question.Add(q); _db.SaveChanges(); Response.Redirect("QuestionsList.aspx", false); }
public ActionResult QuestionCompanyPlatformDetail(int id) { IQuestionBLL questionBll = BLLFactory <IQuestionBLL> .GetBLL("QuestionBLL"); //获取要查看的问题 T_Question question = questionBll.GetEntity(m => m.Id == id); if (question != null) { return(View(question)); } else { return(RedirectToAction("QuestionCompanyPlatformList")); } }
public JsonResult SetQuestionDisposer(SetQuestionDisposerModel model) { JsonModel jm = new JsonModel(); if (ModelState.IsValid) { //获取要指派处理人的上报问题结果 IQuestionBLL resultBll = BLLFactory <IQuestionBLL> .GetBLL("QuestionBLL"); T_Question result = resultBll.GetEntity(m => m.Id == model.Id); if (result != null) { //指派处理人 result.DisposerId = model.DisposerId; //保存到数据库 if (resultBll.Update(result)) { //日志记录 jm.Content = PropertyUtils.ModelToJsonString(model); //推送给处理人 IPropertyUserPushBLL userPushBLL = BLLFactory <IPropertyUserPushBLL> .GetBLL("PropertyUserPushBLL"); var userPush = userPushBLL.GetEntity(p => p.UserId == model.DisposerId); if (userPush != null) { string registrationId = userPush.RegistrationId; //通知信息 bool flag = PropertyUtils.SendPush("业主上报问题", "有新的问题需要您处理,请查看", ConstantParam.MOBILE_TYPE_PROPERTY, registrationId); if (!flag) { jm.Msg = "推送发生异常"; } } } else { jm.Msg = "指派处理人失败"; } } } else { jm.Msg = ConstantParam.JSON_RESULT_MODEL_CHECK_ERROR; } return(Json(jm, JsonRequestBehavior.AllowGet)); }
public JsonResult QuestionReport(T_Question model) { //点击图片input触发的提交事件,不进行提交 if (model.Id == 1) { return(null); } else { int userId = GetCurrentUser().Id; JsonModel jm = new JsonModel(); try { IQuestionBLL questionBll = BLLFactory <IQuestionBLL> .GetBLL("QuestionBLL"); T_Question question = new T_Question(); question.UploadUserId = userId; question.UploadTime = DateTime.Now; question.ClientSaveTime = DateTime.Now; question.Title = model.Title; question.Status = 0; question.PropertyPlaceId = model.PropertyPlaceId; if (string.IsNullOrEmpty(model.Imgs)) { question.Imgs = ""; } else { question.Imgs = GetMultimedia(ConstantParam.QUESTION_DIR, model.Imgs); } question.Desc = model.Desc; question.IsPublish = 0; questionBll.Save(question); } catch { jm.Msg = "提交失败"; } return(Json(jm, JsonRequestBehavior.AllowGet)); } }
public ActionResult DisposeQuestion(int id) { IQuestionBLL questionBll = BLLFactory <IQuestionBLL> .GetBLL("QuestionBLL"); T_Question question = questionBll.GetEntity(m => m.Id == id); if (question != null) { DisposeQuestionModel model = new DisposeQuestionModel() { Id = question.Id, Title = question.Title }; return(View(model)); } else { return(RedirectToAction("QuestionList")); } }
// PUT: api/Question/5 public Response Put(int id, [FromBody] T_Question que) { try { T_Question queToBeFind = dalobj.T_Question.Find(id); if (queToBeFind != null) { queToBeFind.SubId = que.SubId; queToBeFind.Question = que.Question; queToBeFind.Opt1 = que.Opt1; queToBeFind.Opt2 = que.Opt2; queToBeFind.Opt3 = que.Opt3; queToBeFind.Opt4 = que.Opt4; queToBeFind.CorrectAns = que.CorrectAns; dalobj.SaveChanges(); response.Data = null; response.Status = "success"; response.Err = null; logger.Log("Specific Question updated using id"); return(response); } else { response.Data = null; response.Status = "failed"; response.Err = null; logger.Log("Specific Question Not found using id"); return(response); } } catch (Exception cause) { response.Data = cause.Message; response.Status = "Failed"; response.Err = cause; logger.Log("Exception occured returned Error msg"); return(response); } }
/// <summary> /// 数据绑定 /// </summary> protected void databind() { clientinfoid = Requests.GetQueryInt("ciid", 0); E_Question data = new E_Question(); data.EnterpriseID = EnterpriceID; data.ClientInfoID = clientinfoid; DataSet ds = new T_Question().List(data); if (ds != null && ds.Tables.Count == 2) { if (ds.Tables[0].Rows.Count == 0) { hide = true; } dtItem = ds.Tables[1]; rpList.DataSource = ds.Tables[0]; rpList.DataBind(); } }
/// <summary> /// 删除问题 /// </summary> /// <param name="questionID"></param> protected void Delete(int questionID) { E_Question data = new E_Question(); data.QuestionID = questionID; data.EnterpriseID = EnterpriceID; bool flag = new T_Question().Delete(data); if (flag) { new MLMGC.BLL.Enterprise.T_Log().Add(new MLMGC.DataEntity.Enterprise.E_Log() { EnterpriseID = EnterpriceID, UserID = UserID, LogTitle = "删除问题", IP = MLMGC.COMP.Requests.GetRealIP() }); //MLMGC.COMP.Jscript.AlertAndRedirect(this, "删除成功", "MaterialList.aspx"); MLMGC.COMP.Jscript.ShowMsg("删除成功", this); } else { MLMGC.COMP.Jscript.ShowMsg("删除失败", this); } }
public ApiResultModel AddQuestion(QuestionModel model) { ApiResultModel resultModel = new ApiResultModel(); try { //根据用户ID查找业主 IUserBLL ownerBll = BLLFactory <IUserBLL> .GetBLL("UserBLL"); T_User owner = ownerBll.GetEntity(u => u.Id == model.UserId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT); //如果业主存在 if (owner != null) { //如果验证Token不通过或已过期 if (DateTime.Now > owner.TokenInvalidTime || model.Token != owner.Token) { resultModel.Msg = APIMessage.TOKEN_INVALID; return(resultModel); } //更新最近登录时间和Token失效时间 owner.LatelyLoginTime = DateTime.Now; owner.TokenInvalidTime = DateTime.Now.AddDays(Convert.ToInt32(PropertyUtils.GetConfigParamValue("TokenInvalid"))); ownerBll.Update(owner); //问题基本信息上传 T_Question question = new T_Question() { Title = model.Title, Desc = model.Desc, PropertyPlaceId = model.PropertyPlaceId, UploadTime = DateTime.Now, UploadUserId = model.UserId, Status = ConstantParam.NO_DISPOSE, ClientSaveTime = DateTime.Now }; //问题上报文件资源保存目录 string dir = HttpContext.Current.Server.MapPath(ConstantParam.QUESTION_FILE + model.PropertyPlaceId); if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } //问题图片上传 if (!string.IsNullOrEmpty(model.PicList)) { var fileName = DateTime.Now.ToFileTime().ToString() + ".zip"; string filepath = Path.Combine(dir, fileName); using (FileStream fs = new FileStream(filepath, FileMode.Create)) { using (BinaryWriter bw = new BinaryWriter(fs)) { byte[] datas = Convert.FromBase64String(model.PicList); bw.Write(datas); bw.Close(); } } //图片集路径保存 question.Imgs = PropertyUtils.UnZip(filepath, dir, ConstantParam.QUESTION_FILE + model.PropertyPlaceId); } //语音文件上传 if (!string.IsNullOrEmpty(model.VoiceFile)) { var fileName = DateTime.Now.ToFileTime().ToString() + ".amr"; string filepath = Path.Combine(dir, fileName); using (FileStream fs = new FileStream(filepath, FileMode.Create)) { using (BinaryWriter bw = new BinaryWriter(fs)) { byte[] datas = Convert.FromBase64String(model.VoiceFile); bw.Write(datas); bw.Close(); } } //语音路径保存 question.AudioPath = ConstantParam.QUESTION_FILE + model.PropertyPlaceId + "/" + fileName; question.VoiceDuration = model.VoiceDuration; } //保存提报的问题 IQuestionBLL questionBll = BLLFactory <IQuestionBLL> .GetBLL("QuestionBLL"); questionBll.Save(question); } else { resultModel.Msg = APIMessage.NO_USER; } } catch { resultModel.Msg = APIMessage.REQUEST_EXCEPTION; } return(resultModel); }
protected void proceedtoUpload_Click(object sender, EventArgs e) { var tenantId = long.Parse(SessionHelper.GetTenantID(HttpContext.Current.Session)); string fId = FileID.Value; //long preaId = 0; if (!string.IsNullOrEmpty(fId)) { string ext = EXT.Value; var data = File.ReadAllBytes(fId); ImportFromExcel import = new ImportFromExcel(); if (ext == ".xls") { import.LoadXls(data); } else if (ext == ".xlsx") { import.LoadXlsx(data); } //first parameter it's the sheet number in the excel workbook //second paramter it's the number of rows to skip at the start(we have an header in the file) List <QuestionUploadModel> all = import.ExcelToList <QuestionUploadModel>(0, 1); if (all.Count() < 1) { resultLbl.Text = "Either you uploaded an empty file or you provided wrong file type. Only allowed file type is .csv, .xls or.xlsx!"; } else { resultLbl.Text = ""; var Qtype = DropDownList1.SelectedValue; var ex = 0; var obj = new List <object>(); foreach (var s in all) { ex += _db.SearchQuestion(s.Question.ToLower()).Where(x => x.TypeId == long.Parse(Qtype)).Count(); T_Question q = new T_Question { PreambleId = 0, TypeId = long.Parse(Qtype), OptionType = (long)ErecruitHelper.OptionType.Single, IsActive = true, Details = s.Question, Section = s.Section, TenantId = tenantId, AddedBy = SessionHelper.FetchEmail(Session), DateAdded = DateTime.Now }; _db.T_Question.Add(q); _db.SaveChanges(); var opts = new List <T_Option>(); if (!string.IsNullOrEmpty(s.A)) { opts.Add(new T_Option { Q_Id = q.Id, Details = s.A, Answer = s.Answer == ErecruitHelper.OptionIndex.A.ToString(), AddedBy = SessionHelper.FetchEmail(Session), DateAdded = DateTime.Now }); } if (!string.IsNullOrEmpty(s.B)) { opts.Add(new T_Option { Q_Id = q.Id, Details = s.B, Answer = s.Answer == ErecruitHelper.OptionIndex.B.ToString(), AddedBy = SessionHelper.FetchEmail(Session), DateAdded = DateTime.Now }); } if (!string.IsNullOrEmpty(s.C)) { opts.Add(new T_Option { Q_Id = q.Id, Details = s.C, Answer = s.Answer == ErecruitHelper.OptionIndex.C.ToString(), AddedBy = SessionHelper.FetchEmail(Session), DateAdded = DateTime.Now }); } if (!string.IsNullOrEmpty(s.D)) { opts.Add(new T_Option { Q_Id = q.Id, Details = s.D, Answer = s.Answer == ErecruitHelper.OptionIndex.D.ToString(), AddedBy = SessionHelper.FetchEmail(Session), DateAdded = DateTime.Now }); } if (!string.IsNullOrEmpty(s.E)) { opts.Add(new T_Option { Q_Id = q.Id, Details = s.E, Answer = s.Answer == ErecruitHelper.OptionIndex.E.ToString(), AddedBy = SessionHelper.FetchEmail(Session), DateAdded = DateTime.Now }); } ExtensionMethods.InsertAllOnSubmit(_db.T_Option, opts); //_db.T_Option.InsertAllOnSubmit(opts); _db.SaveChanges(); } if (ex > 0) { resultLbl.Text = "Some Question(s) already exist in the system therefore were skipped."; } else { resultLbl.Text = "Questions Uploaded"; } } } else { resultLbl.Text = "No file to upload. Kindly chose a file."; } }
protected void Save_Click(object sender, EventArgs e) { try { // var all = new List<string[]>(); var tenantId = long.Parse(SessionHelper.GetTenantID(HttpContext.Current.Session)); string fId = FileID.Value; //long preaId = 0; if (!string.IsNullOrEmpty(fId)) { string ext = EXT.Value; //all = ErecruitHelper.GetLinesFromFile(fId, ext); var data = File.ReadAllBytes(fId); ImportFromExcel import = new ImportFromExcel(); if (ext == ".xls") { import.LoadXls(data); } else if (ext == ".xlsx") { import.LoadXlsx(data); } //first parameter it's the sheet number in the excel workbook //second paramter it's the number of rows to skip at the start(we have an header in the file) List <QuestionUploadModel> all = import.ExcelToList <QuestionUploadModel>(0, 1); if (all.Count() < 1) { resultLbl.Text = "Either you uploaded an empty file or you provided wrong file type. Only allowed file type is .csv, .xls or.xlsx!"; } else { resultLbl.Text = ""; var Qtype = DropDownList1.SelectedValue; var ex = 0; var obj = new List <object>(); foreach (var s in all) { ex += _db.SearchQuestion(s.Question.ToLower()).Where(x => x.TypeId == long.Parse(Qtype)).Count(); T_Question q = new T_Question { PreambleId = 0, TypeId = long.Parse(Qtype), OptionType = (long)ErecruitHelper.OptionType.Single, IsActive = true, Details = s.Question, TenantId = tenantId, Section = s.Section, AddedBy = SessionHelper.FetchEmail(Session), DateAdded = DateTime.Now }; _db.T_Question.Add(q); _db.SaveChanges(); var opts = new List <T_Option>(); if (!string.IsNullOrEmpty(s.A)) { opts.Add(new T_Option { Q_Id = q.Id, Details = s.A, Answer = s.Answer == ErecruitHelper.OptionIndex.A.ToString(), AddedBy = SessionHelper.FetchEmail(Session), DateAdded = DateTime.Now }); } if (!string.IsNullOrEmpty(s.B)) { opts.Add(new T_Option { Q_Id = q.Id, Details = s.B, Answer = s.Answer == ErecruitHelper.OptionIndex.B.ToString(), AddedBy = SessionHelper.FetchEmail(Session), DateAdded = DateTime.Now }); } if (!string.IsNullOrEmpty(s.C)) { opts.Add(new T_Option { Q_Id = q.Id, Details = s.C, Answer = s.Answer == ErecruitHelper.OptionIndex.C.ToString(), AddedBy = SessionHelper.FetchEmail(Session), DateAdded = DateTime.Now }); } if (!string.IsNullOrEmpty(s.D)) { opts.Add(new T_Option { Q_Id = q.Id, Details = s.D, Answer = s.Answer == ErecruitHelper.OptionIndex.D.ToString(), AddedBy = SessionHelper.FetchEmail(Session), DateAdded = DateTime.Now }); } if (!string.IsNullOrEmpty(s.E)) { opts.Add(new T_Option { Q_Id = q.Id, Details = s.E, Answer = s.Answer == ErecruitHelper.OptionIndex.E.ToString(), AddedBy = SessionHelper.FetchEmail(Session), DateAdded = DateTime.Now }); } // _db.T_Option.InsertAllOnSubmit(opts); ExtensionMethods.InsertAllOnSubmit(_db.T_Option, opts); _db.SaveChanges(); } if (ex > 0) { resultLbl.Text = "Some Question(s) already exist in the system therefore were skipped."; } else { resultLbl.Text = "Questions Uploaded"; } } } else { HttpPostedFile file = QuestionFile.PostedFile; if (file != null && file.ContentLength > 0) { string fname = Path.GetFileName(file.FileName); string ext = System.IO.Path.GetExtension(file.FileName); string fileID = Guid.NewGuid().ToString(); string path = ""; // var all = new List<string[]>(); if (Directory.Exists(Server.MapPath("~/UploadedQuestions/"))) { path = Server.MapPath(Path.Combine("~/UploadedQuestions/", fileID + ext)); // PPath = Path.Combine("~/Passports/", cand.Code + ext); file.SaveAs(path); } else { Directory.CreateDirectory(Server.MapPath("~/UploadedQuestions/")); path = Server.MapPath(Path.Combine("~/UploadedQuestions/", fileID + ext)); // PPath = Path.Combine("~/Passports/", cand.Code + ext); file.SaveAs(path); } var data = File.ReadAllBytes(path); ImportFromExcel import = new ImportFromExcel(); if (ext == ".xls") { import.LoadXls(data); } else if (ext == ".xlsx") { import.LoadXlsx(data); } //first parameter it's the sheet number in the excel workbook //second paramter it's the number of rows to skip at the start(we have an header in the file) List <QuestionUploadModel> all = import.ExcelToList <QuestionUploadModel>(0, 1); if (all.Count() < 1) { resultLbl.Text = "Either you uploaded an empty file or you provided wrong file type. Only allowed file type is .csv, .xls or.xlsx!"; } else { resultLbl.Text = ""; var Qtype = DropDownList1.SelectedValue; var ex = 0; var obj = new List <object>(); foreach (var s in all) { ex += _db.SearchQuestion(s.Question.ToLower()).Where(x => x.TypeId == long.Parse(Qtype)).Count(); T_Question q = new T_Question { PreambleId = 0, TypeId = long.Parse(Qtype), OptionType = (long)ErecruitHelper.OptionType.Single, IsActive = true, Details = s.Question, Section = s.Section, TenantId = tenantId, AddedBy = SessionHelper.FetchEmail(Session), DateAdded = DateTime.Now }; _db.T_Question.Add(q); _db.SaveChanges(); var opts = new List <T_Option>(); if (!string.IsNullOrEmpty(s.A)) { opts.Add(new T_Option { Q_Id = q.Id, Details = s.A, Answer = s.Answer == ErecruitHelper.OptionIndex.A.ToString(), AddedBy = SessionHelper.FetchEmail(Session), DateAdded = DateTime.Now }); } if (!string.IsNullOrEmpty(s.B)) { opts.Add(new T_Option { Q_Id = q.Id, Details = s.B, Answer = s.Answer == ErecruitHelper.OptionIndex.B.ToString(), AddedBy = SessionHelper.FetchEmail(Session), DateAdded = DateTime.Now }); } if (!string.IsNullOrEmpty(s.C)) { opts.Add(new T_Option { Q_Id = q.Id, Details = s.C, Answer = s.Answer == ErecruitHelper.OptionIndex.C.ToString(), AddedBy = SessionHelper.FetchEmail(Session), DateAdded = DateTime.Now }); } if (!string.IsNullOrEmpty(s.D)) { opts.Add(new T_Option { Q_Id = q.Id, Details = s.D, Answer = s.Answer == ErecruitHelper.OptionIndex.D.ToString(), AddedBy = SessionHelper.FetchEmail(Session), DateAdded = DateTime.Now }); } if (!string.IsNullOrEmpty(s.E)) { opts.Add(new T_Option { Q_Id = q.Id, Details = s.E, Answer = s.Answer == ErecruitHelper.OptionIndex.E.ToString(), AddedBy = SessionHelper.FetchEmail(Session), DateAdded = DateTime.Now }); } ExtensionMethods.InsertAllOnSubmit(_db.T_Option, opts); //_db.T_Option.InsertAllOnSubmit(opts); _db.SaveChanges(); } if (ex > 0) { resultLbl.Text = "Some Question(s) already exist in the system therefore were skipped."; } else { resultLbl.Text = "Questions Uploaded"; } } } } } catch (Exception ex) { ErecruitHelper.SetErrorData(ex, Session); Response.Redirect("ErrorPage.aspx", false); } }
public ApiResultModel DisposeQuestion(DisposerModel model) { ApiResultModel resultModel = new ApiResultModel(); try { IPropertyUserBLL userBll = BLLFactory <IPropertyUserBLL> .GetBLL("PropertyUserBLL"); T_PropertyUser user = userBll.GetEntity(u => u.Id == model.UserId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT); if (user != null) { //如果验证Token不通过或已过期 if (DateTime.Now > user.TokenInvalidTime || model.Token != user.Token) { resultModel.Msg = APIMessage.TOKEN_INVALID; return(resultModel); } //更新最近登录时间和Token失效时间 user.LatelyLoginTime = DateTime.Now; user.TokenInvalidTime = DateTime.Now.AddDays(Convert.ToInt32(PropertyUtils.GetConfigParamValue("TokenInvalid"))); userBll.Update(user); //获取要处理的问题 IQuestionBLL questionBll = BLLFactory <IQuestionBLL> .GetBLL("QuestionBLL"); T_Question question = questionBll.GetEntity(m => m.Id == model.Id); if (question != null) { //修改处理状态并添加处理记录 question.Status = ConstantParam.DISPOSED; question.IsPublish = model.IsPublish; T_QuestionDispose questionDispose = new T_QuestionDispose() { DisposeDesc = model.DisposeDesc, DisposeUserId = user.Id, QuestionId = model.Id, DisposeTime = DateTime.Now }; //保存到数据库 questionBll.DisposeQuestion(question, questionDispose); //推送通知 IUserPushBLL userPushBLL = BLLFactory <IUserPushBLL> .GetBLL("UserPushBLL"); var userPush = userPushBLL.GetEntity(p => p.UserId == question.UploadUserId); if (userPush != null) { string registrationId = userPush.RegistrationId; string alert = "您" + question.UploadTime.ToString("yyyy-MM-dd HH:mm") + "上报的问题已处理"; //通知信息 bool flag = PropertyUtils.SendPush("上报问题处理", alert, ConstantParam.MOBILE_TYPE_OWNER, registrationId); if (!flag) { resultModel.Msg = "问题处理完成,推送失败"; } } } else { resultModel.Msg = APIMessage.QUESTION_NOEXIST; } } else { resultModel.Msg = APIMessage.NO_USER; } } catch { resultModel.Msg = APIMessage.REQUEST_EXCEPTION; } return(resultModel); }
private async void printReceiptToolStripMenuItem_Click(object sender, EventArgs e) { if (_payments < AmountDue) { // var msg = new T_Message(); // var ok = new Frm_OK(); // ok.OkDescription = "Error"; // ok.msgtxt.Text = @"Insufficient amount! Please check and try again!"; // ok.titletxt.Text = @"Error"; // msg.Show(this); // ok.ShowDialog(); // msg.Close(); // Focus(); //PopupNotifier popup=new PopupNotifier(); popup.TitleText = "Error"; popup.ContentText = "Insufficient amount! Please check and try again!"; popup.Popup(); } else { var tQuestion = new T_Question(); var question = new Frm_Question(); question.titletxt.Text = @"Confirmation"; question.msgtxt.Text = @"This action will save this transaction. Do you want to continue this transaction?"; tQuestion.Show(this); question.ShowDialog(); tQuestion.Close(); Focus(); if (question.DialogResult != DialogResult.Yes) { return; } //*******Print receipt******************** UseWaitCursor = true; if (!Hascustomer) { Sqlcmd.Parameters.Clear(); await Conopen(); Strsql = "Update tbl_Transaction set inv_amnt_due=@inv_amnt_due, inv_tax=@inv_tax,inv_tax_tot=@inv_tax_tot,Inv_Money_Render=@Inv_Money_Render, Inv_Change=@Inv_Change, Inv_total=@Inv_total, Inv_Num_of_items=@Inv_Num_of_items, tran_stat=@tran_stat Where Inv_Num=@Inv_Num"; Sqlcmd.Parameters.AddWithValue("@inv_amnt_due", Convert.ToSingle(lblsubtotal.Text)); Sqlcmd.Parameters.AddWithValue("@inv_tax", Convert.ToSingle(lbltax.Text)); Sqlcmd.Parameters.AddWithValue("@inv_tax_tot", Convert.ToSingle(lbltotaltax.Text)); Sqlcmd.Parameters.AddWithValue("@Inv_Money_Render", Convert.ToSingle(numericUpDown1.Text)); Sqlcmd.Parameters.AddWithValue("@Inv_Change", Convert.ToSingle(lblchange.Text)); Sqlcmd.Parameters.AddWithValue("@Inv_total", Convert.ToSingle(AmountDue)); Sqlcmd.Parameters.AddWithValue("@Inv_Num_of_items", Convert.ToInt32(Totitems)); Sqlcmd.Parameters.AddWithValue("@Inv_Num", lblinvoice.Text); Sqlcmd.Parameters.AddWithValue("@tran_stat", "Cash"); Sqlcmd.Connection = Cnn; Sqlcmd.CommandText = Strsql; Sqlcmd.ExecuteNonQuery(); Sqlcmd.Dispose(); Strsql = ""; Cnn.Close(); //*********retrieve product sold to deduct to products table await XretriveProduct(); popup.TitleText = @"Success"; popup.ContentText = @"Transaction successful!"; popup.Popup(); var frmReports = new FrmReports { StrReport = "Receipt", PrintWhere = ("{V_Receipt.Inv_Num} ='" + lblinvoice.Text + "'") }; frmReports.ShowDialog(); frmReports.Close(); timer1.Stop(); NewTrans = true; FillCart = true; CustomerRetrieve = false; CustomerId = null; Hascustomer = false; UseWaitCursor = false; Dispose(); } else { Sqlcmd.Parameters.Clear(); await Conopen(); Strsql = "Update tbl_Transaction set inv_amnt_due=@inv_amnt_due, inv_tax=@inv_tax,inv_tax_tot=@inv_tax_tot,Inv_Money_Render=@Inv_Money_Render, Inv_Change=@Inv_Change, Inv_total=@Inv_total, Inv_Num_of_items=@Inv_Num_of_items, tran_stat=@tran_stat, cus_ID=@cus_ID Where Inv_Num=@Inv_Num"; Sqlcmd.Parameters.AddWithValue("@inv_amnt_due", Convert.ToSingle(lblsubtotal.Text)); Sqlcmd.Parameters.AddWithValue("@inv_tax", Convert.ToSingle(lbltax.Text)); Sqlcmd.Parameters.AddWithValue("@inv_tax_tot", Convert.ToSingle(lbltotaltax.Text)); Sqlcmd.Parameters.AddWithValue("@Inv_Money_Render", Convert.ToSingle(numericUpDown1.Text)); Sqlcmd.Parameters.AddWithValue("@Inv_Change", Convert.ToSingle(lblchange.Text)); Sqlcmd.Parameters.AddWithValue("@Inv_total", Convert.ToSingle(AmountDue)); Sqlcmd.Parameters.AddWithValue("@Inv_Num_of_items", Convert.ToInt32(Totitems)); Sqlcmd.Parameters.AddWithValue("@Inv_Num", lblinvoice.Text); Sqlcmd.Parameters.AddWithValue("@tran_stat", "Cash"); Sqlcmd.Parameters.AddWithValue("@cus_ID", CustomerId); Sqlcmd.Connection = Cnn; Sqlcmd.CommandText = Strsql; Sqlcmd.ExecuteNonQuery(); Sqlcmd.Dispose(); Strsql = ""; Cnn.Close(); //*********retrieve product sold to deduct to products table await XretriveProduct(); popup.TitleText = @"Success"; popup.ContentText = @"Transaction successful!"; popup.Popup(); var frmReports = new FrmReports { StrReport = "Receipt_Customer", PrintWhere = ("{V_Receipt_Customer.Inv_Num} ='" + lblinvoice.Text + "'") }; frmReports.ShowDialog(); frmReports.Close(); timer1.Stop(); NewTrans = true; FillCart = true; CustomerRetrieve = false; CustomerId = null; Hascustomer = false; UseWaitCursor = false; Dispose(); } } }
/// <summary> /// 点击保存按钮处理事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSubmit_Click(object sender, EventArgs e) { //判断标题是否输入 string questionName = txtQuestionName.Text; if (questionName == "") { MLMGC.COMP.Jscript.ShowMsg("请输入标题", this); return; } //获取界面里所有隐藏域集合 System.Collections.Specialized.NameValueCollection nv = Request.Form; string[] child_ItemIDs = nv.GetValues("hdQuestionItemIDs"); string[] child_ItemNameS = nv.GetValues("hdQuestionItemNameS"); if (child_ItemIDs == null || child_ItemNameS == null) { return; } if (child_ItemIDs.Length != child_ItemNameS.Length) { MLMGC.COMP.Jscript.ShowMsg("参数错误", this); return; } if (child_ItemIDs.Length == 0) { MLMGC.COMP.Jscript.ShowMsg("请输入选项", this); return; } //封装数据 E_Question data = new E_Question(); data.EnterpriseID = EnterpriceID; data.QuestionName = questionName; data.Flag = cbDeleteRelation.Checked ? 1 : 0; data.QuestionType = Convert.ToInt32(rblQuestionType.SelectedValue); data.QuestionItem = new List <E_QuestionItem>(); E_QuestionItem item = null; for (int i = 0; i < child_ItemIDs.Length; i++) { item = new E_QuestionItem(); item.QuestionItemID = Convert.ToInt64(child_ItemIDs[i]); item.QuestionItemName = child_ItemNameS[i]; data.QuestionItem.Add(item); } //判断是添加还是修改 if (type == "add") { bool flag = new T_Question().Add(data); new MLMGC.BLL.Enterprise.T_Log().Add(new MLMGC.DataEntity.Enterprise.E_Log() { EnterpriseID = EnterpriceID, UserID = UserID, LogTitle = "添加问题", IP = MLMGC.COMP.Requests.GetRealIP() }); if (flag) { MLMGC.COMP.Jscript.AlertAndRedirect(this, "添加成功", "QuestionList.aspx"); } else { MLMGC.COMP.Jscript.ShowMsg("添加失败", this); } } else { //获取项目资料编号 int questionID = MLMGC.COMP.Requests.GetQueryInt("questionid", 0); data.QuestionID = questionID; bool flag = new T_Question().Update(data); new MLMGC.BLL.Enterprise.T_Log().Add(new MLMGC.DataEntity.Enterprise.E_Log() { EnterpriseID = EnterpriceID, UserID = UserID, LogTitle = "修改问题", IP = MLMGC.COMP.Requests.GetRealIP() }); if (flag) { MLMGC.COMP.Jscript.AlertAndRedirect(this, "修改成功", "QuestionList.aspx"); } else { MLMGC.COMP.Jscript.ShowMsg("修改失败", this); } } }