private void ValidateBeforeSubmit() { DTO.ResponseService <DTO.SummaryReceiveApplicant> res = new DTO.ResponseService <DTO.SummaryReceiveApplicant>(); res.DataResponse = (DTO.SummaryReceiveApplicant)Session["SummaryReceiveApplicant"]; List <DTO.ApplicantTemp> lst = new List <ApplicantTemp>(); res.DataResponse.ReceiveApplicantDetails.ToList().ForEach(x => { DTO.ApplicantTemp app = new ApplicantTemp(); app.APPLICANT_CODE = x.APPLICANT_CODE; app.TESTING_NO = x.TESTING_NO; app.TESTING_DATE = x.TESTING_DATE; app.EXAM_PLACE_CODE = x.EXAM_PLACE_CODE; app.APPLY_DATE = DateTime.Today; app.INSUR_COMP_CODE = x.INSUR_COMP_CODE; app.USER_ID = base.UserId; app.ID_CARD_NO = base.IdCard; app.APPLY_DATE = x.APPLY_DATE; //app.RUN_NO = Convert.ToString(x + 1); lst.Add(app); }); ApplicantBiz biz = new ApplicantBiz(); var checkBeforeSubmit = biz.ValidateApplicantSingleBeforeSubmit(lst); if (checkBeforeSubmit.ResultMessage == true) { ModalPopupExtenderListExam.Show(); } else { ImportInsertMode(); } }
// ทุกๆครั้งที่เลือกรายการสอบแบบปฏิทิน protected void lnkExamNumber_Click(object sender, EventArgs e) { var gr = (GridViewRow)((LinkButton)sender).NamingContainer; var strPlaceCode = (Label)gr.FindControl("lblPlaceCode"); var lblExamNumber = (Label)gr.FindControl("ExamNumberNo"); var lblExamDate = (Label)gr.FindControl("lblExamDate"); var lblExamTime = (Label)gr.FindControl("lblExamTime"); var lblExamPlaceGroup = (Label)gr.FindControl("lblGroupExamYard"); var lblExamPlace = (Label)gr.FindControl("lblPlaceName"); var lblProvince = (Label)gr.FindControl("lblProvice"); var lblSeat = (Label)gr.FindControl("lblExamAdmission"); var lblLicenseTypeName = (Label)gr.FindControl("lblLicenseTypeName"); var lblExamFee = (Label)gr.FindControl("lblExamFee"); var lblAgentType = (Label)gr.FindControl("lblAgentType"); var lblPlaceCode = (Label)gr.FindControl("lblPlaceCode"); var lblTestTimeCode = (Label)gr.FindControl("lblTestTimeCode"); var lblLicenseTypeCode = (Label)gr.FindControl("lblLicenseTypeCode"); var lblProvineCode = (Label)gr.FindControl("lblProvinceCode"); var lblExamPlaceGroupCode = (Label)gr.FindControl("lblExamPlaceGroupCode"); var lblExamOwnerName = (Label)gr.FindControl("lblExamOwnerName"); if (ListApplicant.Find(x => x.ExamDate == Convert.ToDateTime(lblExamDate.Text) && x.ExamTime == lblExamTime.Text) != null) { UCModalError1.ShowMessageError = "ได้มีการสมัครในวันและเวลาสอบนี้แล้วไม่สามารถสมัครสอบได้ กรุณาทำการสมัครสอบในวันพรุ่งนี้"; UCModalError1.ShowModalError(); } else if (ListApplicant.Find(x => x.ExamNumber == lblExamNumber.Text) == null) { txtDetailExamCode.Text = lblExamNumber.Text; txtDetailDateExam.Text = lblExamDate.Text; txtTestTime.Text = lblExamTime.Text; txtExamPlaceName.Text = lblExamPlaceGroup.Text; txtProvincePopup.Text = lblProvince.Text; txtLicenseTypeName.Text = lblLicenseTypeName.Text; txtDetailPlaceCode.Text = lblExamPlace.Text; txtExamOwner.Text = lblExamOwnerName.Text; Session["ExamNumber"] = lblExamNumber.Text; Session["ExamDate"] = lblExamDate.Text; Session["ExamTime"] = lblExamTime.Text; Session["ExamPlaceGroup"] = lblExamPlaceGroup.Text; Session["ExamPlace"] = lblExamPlace.Text; Session["Province"] = lblProvince.Text; Session["Seat"] = lblSeat.Text; Session["LicenseTypeName"] = lblLicenseTypeName.Text; Session["ExamFee"] = lblExamFee.Text; Session["AgentType"] = lblAgentType.Text; Session["PlaceCode"] = lblPlaceCode.Text; Session["ExamPlaceCode"] = strPlaceCode.Text; Session["TestingNo"] = lblExamNumber.Text; Session["TestingDate"] = lblExamDate.Text; Session["TestTimeCode"] = lblTestTimeCode.Text; Session["LicenseTypeCode"] = lblLicenseTypeCode.Text; Session["ProvinceCode"] = lblProvineCode.Text; Session["ExamPlaceGroupCode"] = lblExamPlaceGroupCode.Text; var list = new List <DTO.ApplicantTemp>(); list.Add(new ApplicantTemp() { APPLICANT_CODE = 0, TESTING_NO = lblExamNumber.Text, TESTING_DATE = Convert.ToDateTime(lblExamDate.Text), EXAM_PLACE_CODE = lblPlaceCode.Text, APPLY_DATE = DateTime.Today, USER_ID = UserProfile.Id, ID_CARD_NO = UserProfile.IdCard }); DateTime dtTestingDate = Convert.ToDateTime(lblExamDate.Text); ApplicantBiz biz = new ApplicantBiz(); DTO.ResultValidateApplicant res = biz.ValidateApplicantBeforeSaveList(lblExamNumber.Text, UserProfile.IdCard, dtTestingDate, lblTestTimeCode.Text, strPlaceCode.Text, lblExamTime.Text, ListApplicant); if (res.IsConfirm) { ModalPopupExtenderListExam.Show(); lblConfirmExam.Text = res.ValidateMessage; return; } if (!res.IsCanExam) { UCModalError1.ShowMessageError = res.ValidateMessage; UCModalError1.ShowModalError(); return; } var checkBeforeSubmit = biz.GeneralValidateApplicantSingleBeforeSubmit(list); if (checkBeforeSubmit.ResultMessage == true) { UCModalError1.ShowMessageError = "สมัครสอบซ้ำ"; UCModalError1.ShowModalError(); } else { if (ddlTypeLicense.SelectedValue == "03" || ddlTypeLicense.SelectedValue == "04" || ddlTypeLicense.SelectedValue == "11" || ddlTypeLicense.SelectedValue == "12") { lblDetailCompanyCode.Visible = false; ddlCompanyCode.Visible = false; } else { lblDetailCompanyCode.Visible = true; ddlCompanyCode.Visible = true; GetCompany(ddlTypeLicense.SelectedValue); } ModSingleApplicant.Show(); } } else { ModalListExam.Show(); UCModalError1.ShowMessageError = "รอบสอบนี้คุณได้เลือกเข้าไปในรายการแล้ว"; UCModalError1.ShowModalError(); } }