private void InitializeControl() { ctlCompanyField.UseEccOnly = true; ctlCompanyField.FlagActive = true; CADocumentDataSet mpaDocumentDS = (CADocumentDataSet)TransactionService.GetDS(this.TransactionID); CADocumentDataSet.CADocumentRow row = mpaDocumentDS.CADocument.FindByCADocumentID(this.CADocumentID); long tempDocumentID = row.DocumentID; ctlAttachment.Initialize(this.TransactionID, this.CADocumentID, this.InitialFlag); ctlInitiator.ControlGroupID = SCG.eAccounting.BLL.Implement.CAFieldGroup.All; ctlInitiator.Initialize(this.TransactionID, tempDocumentID, this.InitialFlag); ctlCAFormHeader.Initialize(this.TransactionID, tempDocumentID, this.InitialFlag); // send SCGDocument.DocumentID for check visible see history ctlHistory.Initialize(tempDocumentID); ctlApproverData.DocumentEditor = this; ctlCreatorData.ControlGroupID = SCG.eAccounting.BLL.Implement.CAFieldGroup.All; ctlRequesterData.ControlGroupID = SCG.eAccounting.BLL.Implement.CAFieldGroup.All; ctlApproverData.ControlGroupID = SCG.eAccounting.BLL.Implement.CAFieldGroup.All; ctlCreatorData.Initialize(this.TransactionID, this.CADocumentID, this.InitialFlag); ctlRequesterData.Initialize(this.TransactionID, this.CADocumentID, this.InitialFlag); ctlApproverData.Initialize(this.TransactionID, this.CADocumentID, this.InitialFlag); ctlCAFormHeader.DataBind(); ctlCreatorData.DataBind(); ctlRequesterData.DataBind(); ctlApproverData.DataBind(); }
public System.Data.DataSet PrepareDS(long documentID) { CADocumentDataSet documentDS = (CADocumentDataSet)this.PrepareDataToDataset(documentID, false); documentDS.AcceptChanges(); return(documentDS); }
public long AddCADocumentTransaction(Guid txID) { //Initial Data for another table. CADocumentDataSet caDocumentDS = (CADocumentDataSet)TransactionService.GetDS(txID); CADocumentDataSet.DocumentRow documentRow = caDocumentDS.Document.NewDocumentRow(); //create new row to dataset. caDocumentDS.Document.AddDocumentRow(documentRow); //add new row to dataset. CADocumentDataSet.CADocumentRow caDocumentRow = caDocumentDS.CADocument.NewCADocumentRow(); caDocumentRow.DocumentID = documentRow.DocumentID; caDocumentDS.CADocument.AddCADocumentRow(caDocumentRow); return(caDocumentRow.CADocumentID); }
public long SaveCADocument(Guid txID, long caDocumentID) { CADocumentDataSet caDocumentDS = (CADocumentDataSet)TransactionService.GetDS(txID); CADocumentDataSet.CADocumentRow caDocumentRow = caDocumentDS.CADocument.FindByCADocumentID(caDocumentID); long documentID = caDocumentRow.DocumentID; // Insert, Update SCGDocument. // Insert, Update, Delete DocumentInitiator. // Insert, Delete DocumentAttachment. documentID = SCGDocumentService.SaveSCGDocument(txID, documentID); // Insert, Update, Delete MPADocument. caDocumentID = ScgeAccountingDaoProvider.CADocumentDao.Persist(caDocumentDS.CADocument); // Insert, Update, Delete MPAItem. //MPAItemService.SaveMPADocumentItem(txID, mpaDocumentID); return(caDocumentID); }
public void BindControl(bool isCopy) { if (!isCopy && this.InitialFlag.Equals(FlagEnum.NewFlag)) { ctlCompanyField.ShowDefault(); ctlCreatorData.ShowDefault(); ctlRequesterData.ShowDefault(); ctlRegular.Checked = true; if (ctlSomeTime.Checked == true) { tableRegular.Visible = false; } if (ctlRegular.Checked == true) { sometimeRegular.Visible = false; } ctlWorkOutOfAreatxt.Enabled = false; ctlInitiator.RequesterID = UIHelper.ParseLong(ctlRequesterData.UserID); ctlApproverData.ShowDefaultApprover(UIHelper.ParseLong(ctlRequesterData.UserID)); } else { Guid txID = this.TransactionID; long caDocumentID = this.CADocumentID; CADocumentDataSet caDocumentDS = (CADocumentDataSet)TransactionService.GetDS(txID); CADocumentDataSet.CADocumentRow caDocumentRow = caDocumentDS.CADocument.FindByCADocumentID(this.CADocumentID); CADocumentDataSet.DocumentRow documentRow = caDocumentDS.Document.FindByDocumentID(caDocumentRow.DocumentID); SS.Standard.WorkFlow.DTO.WorkFlow workFlow = WorkFlowQueryProvider.WorkFlowQuery.GetWorkFlowByDocumentID(caDocumentRow.DocumentID); #region Header & Footer if (!isCopy) { ctlCAFormHeader.No = ScgeAccountingQueryProvider.SCGDocumentQuery.GetSCGDocumentByDocumentID(caDocumentRow.DocumentID).DocumentNo; ctlCAFormHeader.Status = ScgeAccountingQueryProvider.SCGDocumentQuery.GetDocumentCurrentStateName(UserAccount.CurrentLanguageID, caDocumentRow.DocumentID); if (documentRow.DocumentDate != DateTime.MinValue) { ctlCAFormHeader.CreateDate = UIHelper.ToDateString(documentRow.DocumentDate); } ctlCreatorData.SetValue(documentRow.CreatorID); } else { ctlCAFormHeader.Status = FlagEnum.NewFlag; ctlCreatorData.ShowDefault(); } ctlCompanyField.SetValue(documentRow.CompanyID); ctlSubject.Text = documentRow.Subject; ctlRequesterData.SetValue(documentRow.RequesterID); ctlApproverData.SetValue(documentRow.ApproverID); #endregion Header & Footer #region Tab Attachment ctlAttachment.BindControl(); #endregion #region Tab Memo ctlMemo.Text = documentRow.Memo; #endregion Tab Memo #region Tab General if (!caDocumentRow.IsCarLicenseNoNull()) { ctlCarLicenseNo.Text = caDocumentRow.CarLicenseNo; } if (!caDocumentRow.IsBrandNull()) { ctlBrand.Text = caDocumentRow.Brand; } if (!caDocumentRow.IsModelNull()) { ctlModel.Text = caDocumentRow.Model; } if (caDocumentRow.IsTemporary) { ctlSomeTime.Checked = true; ctlStartDateSumtime.Value = caDocumentRow.StartDate; ctlEndDateSumtime.Value = caDocumentRow.EndDate; if (ctlSomeTime.Checked == true) { tableRegular.Visible = false; } } else { ctlRegular.Checked = true; ctlStartDate.Value = caDocumentRow.StartDate; ctlEndDate.Value = caDocumentRow.EndDate; if (ctlRegular.Checked == true) { sometimeRegular.Visible = false; } } if (!caDocumentRow.IsIsWorkAreaNull()) { if (!caDocumentRow.IsIsWorkAreaNull() && caDocumentRow.IsWorkArea) { ctlWorkInArea.Checked = true; } else { ctlWorkOutOfArea.Checked = true; if (!caDocumentRow.IsRemarkNull()) { ctlWorkOutOfAreatxt.Text = caDocumentRow.Remark; } } } switch (caDocumentRow.CarType) { case "COM": ctlDropDownListCategory.SelectedIndex = UIHelper.ParseShort("1"); break; case "EMP": ctlDropDownListCategory.SelectedIndex = UIHelper.ParseShort("2"); break; default: break; } switch (caDocumentRow.OwnerType) { case "PRI": ctlDropDownListType.SelectedIndex = UIHelper.ParseShort("1"); break; case "PIC": ctlDropDownListType.SelectedIndex = UIHelper.ParseShort("2"); break; case "MOT": ctlDropDownListType.SelectedIndex = UIHelper.ParseShort("3"); break; default: break; } #endregion Tab General } #region Owner IList <SS.DB.DTO.ValueObject.TranslatedListItem> translateList1 = new List <SS.DB.DTO.ValueObject.TranslatedListItem>(); SS.DB.DTO.ValueObject.TranslatedListItem Owner1 = new SS.DB.DTO.ValueObject.TranslatedListItem(); Owner1.ID = UIHelper.ParseShort("1"); Owner1.Symbol = "Company"; translateList1.Add(Owner1); SS.DB.DTO.ValueObject.TranslatedListItem Owner2 = new SS.DB.DTO.ValueObject.TranslatedListItem(); Owner2.ID = UIHelper.ParseShort("2"); Owner2.Symbol = "Employee"; translateList1.Add(Owner2); ctlDropDownListCategory.DataSource = translateList1; ctlDropDownListCategory.DataTextField = "Symbol"; ctlDropDownListCategory.DataValueField = "Id"; ctlDropDownListCategory.DataBind(); ctlDropDownListCategory.SelectedIndex = 0; #endregion BindTypeOfCar(); this.UpdatePanel(); }
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()); } }
public void UpdateCADocumentTransaction(Guid txID, CADocument caDocument) { Spring.Validation.ValidationErrors errors = new Spring.Validation.ValidationErrors(); CADocumentDataSet caDocumentDS = (CADocumentDataSet)TransactionService.GetDS(txID); CADocumentDataSet.CADocumentRow caDocumentRow = caDocumentDS.CADocument.FindByCADocumentID(caDocument.CADocumentID); caDocumentRow.BeginEdit(); caDocumentRow.DocumentID = caDocument.DocumentID.DocumentID; //if (mpaDocument.StartDate < DateTime.Today) //{ // errors.AddError("Provider.Error", new Spring.Validation.ErrorMessage("StartDateMoreOrEqualToDay")); //} if (caDocument.StartDate > caDocument.EndDate) { errors.AddError("Provider.Error", new Spring.Validation.ErrorMessage("StartDateLessOrEqualEndDate")); } if (caDocument.StartDate.Equals(DateTime.MinValue)) { errors.AddError("Provider.Error", new Spring.Validation.ErrorMessage("StartDateIsRequired")); } else { caDocumentRow.StartDate = caDocument.StartDate; } if (caDocument.EndDate.Equals(DateTime.MinValue)) { errors.AddError("Provider.Error", new Spring.Validation.ErrorMessage("EndDateIsRequired")); } else { caDocumentRow.EndDate = caDocument.EndDate; } if (!errors.IsEmpty) { throw new ServiceValidationException(errors); } caDocumentRow.IsTemporary = caDocument.IsTemporary; caDocumentRow.CarLicenseNo = caDocument.CarLicenseNo; caDocumentRow.Brand = caDocument.Brand; caDocumentRow.Model = caDocument.Model; if (caDocument.IsWorkArea.HasValue) { caDocumentRow.IsWorkArea = caDocument.IsWorkArea.Value; } caDocumentRow.Remark = caDocument.Remark; caDocumentRow.CarType = caDocument.CarType; caDocumentRow.OwnerType = caDocument.OwnerType; caDocumentRow.Active = caDocument.Active; caDocumentRow.CreBy = UserAccount.UserID; caDocumentRow.CreDate = DateTime.Now; caDocumentRow.UpdBy = UserAccount.UserID; caDocumentRow.UpdDate = DateTime.Now; caDocumentRow.UpdPgm = UserAccount.CurrentProgramCode; caDocumentRow.EndEdit(); }
public System.Data.DataSet PrepareDS() { CADocumentDataSet documentDS = new CADocumentDataSet(); return(documentDS); }
public System.Data.DataSet PrepareDataToDataset(long documentID, bool isCopy) { CADocumentDataSet caDocumentDS = new CADocumentDataSet(); CADocument caDocument = ScgeAccountingQueryProvider.CADocumentQuery.GetCADocumentByDocumentID(documentID); Spring.Validation.ValidationErrors errors = new Spring.Validation.ValidationErrors(); if (caDocument == null) { errors.AddError("Provider.Error", new Spring.Validation.ErrorMessage("CADocumentNotFound")); } if (!errors.IsEmpty) { throw new ServiceValidationException(errors); } // Prepare Data to Document datatable. if (!isCopy) { SCGDocumentService.PrepareDataToDataset(caDocumentDS, documentID); } else { SCGDocumentService.PrepareDataInternalToDataset(caDocumentDS, documentID, isCopy); } // Set data to Document row CADocumentDataSet.CADocumentRow caDocumentRow = caDocumentDS.CADocument.NewCADocumentRow(); caDocumentRow.CADocumentID = caDocument.CADocumentID; if (!isCopy) { if (caDocument.DocumentID != null) { caDocumentRow.DocumentID = caDocument.DocumentID.DocumentID; } } else { if (caDocumentDS.Document.Rows.Count > 0) { CADocumentDataSet.DocumentRow docRow = (CADocumentDataSet.DocumentRow)caDocumentDS.Document.Rows[0]; caDocumentRow.DocumentID = docRow.DocumentID; } } caDocumentRow.StartDate = caDocument.StartDate; caDocumentRow.EndDate = caDocument.EndDate; caDocumentRow.IsTemporary = caDocument.IsTemporary; if (caDocument.CarLicenseNo != null) { caDocumentRow.CarLicenseNo = caDocument.CarLicenseNo; } if (caDocument.CarLicenseNo != null) { caDocumentRow.Brand = caDocument.Brand; } if (caDocument.Model != null) { caDocumentRow.Model = caDocument.Model; } if (caDocument.IsWorkArea != null) { caDocumentRow.IsWorkArea = caDocument.IsWorkArea.Value; } if (caDocument.Remark != null) { caDocumentRow.Remark = caDocument.Remark; } caDocumentRow.CarType = caDocument.CarType; caDocumentRow.OwnerType = caDocument.OwnerType; caDocumentRow.Active = caDocument.Active; caDocumentRow.CreBy = caDocument.CreBy; caDocumentRow.CreDate = caDocument.CreDate; caDocumentRow.UpdBy = caDocument.UpdBy; caDocumentRow.UpdDate = caDocument.UpdDate; caDocumentRow.UpdPgm = caDocument.UpdPgm; // Add ta document row to MPADocument. caDocumentDS.CADocument.AddCADocumentRow(caDocumentRow); // Prepare Data to MPAItemService Datatable. //MPAItemService.PrepareDataToDataset(mpaDocumentDS, mpaDocument.MPADocumentID); return(caDocumentDS); }