public void SubmitResponse() { IList <DocumentInitiator> OverroleInitiators = new List <DocumentInitiator>(); foreach (GridViewRow row in ctlOverRoleGridview.Rows) { Label ctlInitiatorLabel = (Label)ctlOverRoleGridview.Rows[row.RowIndex].FindControl("ctlInitiatorLabel"); Label ctlEmailLabel = (Label)ctlOverRoleGridview.Rows[row.RowIndex].FindControl("ctlEmailLabel"); CheckBox ctlSMSChk = (CheckBox)ctlOverRoleGridview.Rows[row.RowIndex].FindControl("ctlSMSChk"); CheckBox ctlSkipChk = (CheckBox)ctlOverRoleGridview.Rows[row.RowIndex].FindControl("ctlSkipChk"); TextBox ctlSkipReasonText = (TextBox)ctlOverRoleGridview.Rows[row.RowIndex].FindControl("ctlSkipReasonText"); long DocumentInitiatorID = UIHelper.ParseLong(ctlOverRoleGridview.DataKeys[row.RowIndex]["InitiatorID"].ToString()); long UserID = UIHelper.ParseLong(ctlOverRoleGridview.DataKeys[row.RowIndex]["UserID"].ToString()); DocumentInitiator documentInitiator = ScgeAccountingQueryProvider.DocumentInitiatorQuery.FindProxyByIdentity(DocumentInitiatorID); documentInitiator.IsSkip = ctlSkipChk.Checked; documentInitiator.SkipReason = ctlSkipReasonText.Text; OverroleInitiators.Add(documentInitiator); //DocumentInitiatorService.SaveOrUpdate(documentInitiator); UpdatePanelOverRole.Update(); } DocumentInitiatorService.UpdateDocumentInitiatorWhenOverRole(OverroleInitiators); }
public long Save() { Spring.Validation.ValidationErrors errors = new Spring.Validation.ValidationErrors(); CADocumentDataSet caDocumentDS = (CADocumentDataSet)TransactionService.GetDS(this.TransactionID); if (caDocumentDS == null) { OnDsNull(); } CADocumentDataSet.CADocumentRow caDocumentRow = caDocumentDS.CADocument.FindByCADocumentID(this.CADocumentID); long tempDocumentID = caDocumentRow.DocumentID; #region SCGDocument SCGDocument scgDocument = new SCGDocument(tempDocumentID); if (!string.IsNullOrEmpty(ctlCompanyField.CompanyID)) { scgDocument.CompanyID = new DbCompany(UIHelper.ParseLong(ctlCompanyField.CompanyID)); } scgDocument.CreatorID = new SuUser(UIHelper.ParseLong(ctlCreatorData.UserID)); if (!string.IsNullOrEmpty(ctlRequesterData.UserID)) { scgDocument.RequesterID = new SuUser(UIHelper.ParseLong(ctlRequesterData.UserID)); } scgDocument.Subject = ctlSubject.Text; if (!string.IsNullOrEmpty(ctlApproverData.UserID)) { scgDocument.ApproverID = new SuUser(UIHelper.ParseLong(ctlApproverData.UserID)); } scgDocument.DocumentType = new SS.Standard.WorkFlow.DTO.DocumentType(DocumentTypeID.CADocument); scgDocument.Memo = ctlMemo.Text; scgDocument.Active = true; try { // Save SCG Document to Transaction. SCGDocumentService.UpdateTransactionDocument(this.TransactionID, scgDocument, false, true); } catch (ServiceValidationException ex) { errors.MergeErrors(ex.ValidationErrors); } #endregion SCGDocument #region CADocument CADocument caDocument = new CADocument(this.CADocumentID); caDocument.DocumentID = scgDocument; if (ctlSomeTime.Checked) { caDocument.IsTemporary = true; try { if (ctlStartDateSumtime.Value != null) { caDocument.StartDate = ctlStartDateSumtime.Value.Value; } if (ctlEndDateSumtime.Value != null) { caDocument.EndDate = ctlEndDateSumtime.Value.Value; } } catch (FormatException fex) { errors.AddError("Provider.Error", new Spring.Validation.ErrorMessage("Invalid_Date_Format")); throw new ServiceValidationException(errors); } } else if (ctlRegular.Checked) { caDocument.IsTemporary = false; try { if (ctlStartDate.Value != null) { caDocument.StartDate = ctlStartDate.Value.Value; } if (ctlEndDate.Value != null) { caDocument.EndDate = ctlEndDate.Value.Value; } } catch (FormatException fex) { errors.AddError("Provider.Error", new Spring.Validation.ErrorMessage("Invalid_Date_Format")); throw new ServiceValidationException(errors); } } caDocument.CarLicenseNo = ctlCarLicenseNo.Text; caDocument.Brand = ctlBrand.Text; caDocument.Model = ctlModel.Text; switch (ctlDropDownListCategory.SelectedValue) { case "1": caDocument.OwnerType = OwnerMileage.Employee; break; case "2": caDocument.OwnerType = OwnerMileage.Company; break; default: break; } switch (ctlDropDownListType.SelectedValue) { case "1": caDocument.CarType = TypeOfCar.PrivateCar; break; case "2": caDocument.CarType = TypeOfCar.MotorCycle; break; case "3": caDocument.CarType = TypeOfCar.Pickup; break; default: break; } if (caDocument.IsTemporary) { if (ctlWorkInArea.Checked || ctlWorkOutOfArea.Checked) { if (ctlWorkInArea.Checked) { caDocument.IsWorkArea = true; } else if (ctlWorkOutOfArea.Checked) { caDocument.IsWorkArea = false; caDocument.Remark = ctlWorkOutOfAreatxt.Text; } } else { errors.AddError("Provider.Error", new Spring.Validation.ErrorMessage("Please Select Work Area.")); } } else { if (ctlWorkInArea.Checked) { caDocument.IsWorkArea = true; } else if (ctlWorkOutOfArea.Checked) { caDocument.IsWorkArea = false; caDocument.Remark = ctlWorkOutOfAreatxt.Text; } } caDocument.Active = true; try { // Get ta document information and save to transaction. CADocumentService.UpdateCADocumentTransaction(this.TransactionID, caDocument); } catch (ServiceValidationException ex) { errors.MergeErrors(ex.ValidationErrors); } if (!errors.IsEmpty) { throw new ServiceValidationException(errors); } #endregion CADocument try { ctlInitiator.Save(); DocumentInitiatorService.ValidateDocumentInitiator(this.TransactionID, this.CADocumentID); } catch (ServiceValidationException ex) { errors.MergeErrors(ex.ValidationErrors); } if (!errors.IsEmpty) { // If have some validation error then return error. throw new ServiceValidationException(errors); } else { return(this.SaveToDatabase()); } }