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);
        }
Пример #2
0
        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 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);
        }