protected void ctlReqNoOpenBtn_Click(object sender, EventArgs e) { SearchCriteria criteria = this.BuildCriteria(); //set criteria to session string pageName = this.GetCurrentPageName(); Session[pageName + "_" + UserAccount.UserID.ToString()] = criteria; if (!string.IsNullOrEmpty(ctlRequestNo.Text)) { IList <long> docId = ScgeAccountingQueryProvider.SCGDocumentQuery.GetDocumentIDByDocumentNo(ctlRequestNo.Text); if (docId.Count == 0) { ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "js", "alert('Request No. is not found.');", true); } else if (docId.Count > 1) { ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "js", "alert('Can not open document because many documents are using this reference No.');", true); } else { SS.Standard.WorkFlow.DTO.WorkFlow wf = WorkFlowQueryProvider.WorkFlowQuery.GetWorkFlowByDocumentID(docId[0]); Response.Redirect("DocumentView.aspx?wfid=" + wf.WorkFlowID.ToString()); } } else { ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "js", "alert('Please input request No.');", true); } }
public void PrepareAdvance(IList <SCG.eAccounting.DTO.ValueObject.Advance> advanceList) { foreach (SCG.eAccounting.DTO.ValueObject.Advance advance in advanceList) { AvAdvanceDocument advanceDocument = ScgeAccountingQueryProvider.AvAdvanceDocumentQuery.FindProxyByIdentity(advance.AdvanceID); if (advanceDocument.TADocumentID != null && advanceDocument.TADocumentID != 0) { // For query only advance that // 1. Status = OutStanding // 2. Do not used in Expense that has flag <> 'Cancel' SCG.eAccounting.DTO.ValueObject.Advance avCriteria = new SCG.eAccounting.DTO.ValueObject.Advance(); avCriteria.CompanyID = CompanyID; avCriteria.RequesterID = RequesterID; avCriteria.AdvanceType = FnExpenseDocumentService.GetExpenseType(this.ExpDocumentID, this.TransactionId); advance.ExpenseType = avCriteria.AdvanceType; avCriteria.TADocumentID = advanceDocument.TADocumentID; //Delete all advance and remittance in ExpenseAdvance Datatable. //กรณีที่มีรายการ advance ที่อ้างอิง TA อยู่ใน advanceList ที่เลือกมา this.ClearAdvanceGridview(); //this.ClearRemittanceGridview(); FnExpenseDocumentService.SetTA(this.TransactionId, this.ExpDocumentID, avCriteria); TADocument ta = ScgeAccountingQueryProvider.TADocumentQuery.FindByIdentity(advanceDocument.TADocumentID.Value); SS.Standard.WorkFlow.DTO.WorkFlow wf = SS.Standard.WorkFlow.Query.WorkFlowQueryProvider.WorkFlowQuery.GetWorkFlowByDocumentID(ta.DocumentID.DocumentID); ctlTANoLabel.Visible = false; ctlTALinkButton.Text = ta.DocumentID.DocumentNo; ctlTALinkButton.OnClientClick = "window.open('../Programs/DocumentView.aspx?wfid=" + wf.WorkFlowID.ToString() + "')"; ctlBusinessChk.Checked = ta.IsBusinessPurpose; ctlTrainingChk.Checked = ta.IsTrainningPurpose; ctlOtherChk.Checked = ta.IsOtherPurpose; ctlOther.Text = ta.OtherPurposeDescription; ctlCountry.Text = ta.Country; ctlFromDateCal.Value = ta.FromDate; ctlToDateCal.Value = ta.ToDate; ctlAddAdvance.Enabled = false; ctlAdvanceGridView.Columns[7].Visible = false; ctlTANoLookup.Enabled = true; ctlDeleteTA.Enabled = true; break; } else { double totalAdvance = FnExpenseDocumentService.AddExpenseAdvanceToTransaction(this.TransactionId, this.ExpDocumentID, advanceList, 0); FnExpenseDocumentService.SetTotalAdvance(this.TransactionId, 0, totalAdvance); FnExpenseDocumentService.RefreshRemittance(this.TransactionId, this.ExpDocumentID); //break; } } }
/// <summary> /// Initializes a new instance of the WorkFlowResponse class /// </summary> /// <param name="active">Initial <see cref="WorkFlowResponse.Active" /> value</param> /// <param name="creBy">Initial <see cref="WorkFlowResponse.CreBy" /> value</param> /// <param name="creDate">Initial <see cref="WorkFlowResponse.CreDate" /> value</param> /// <param name="updBy">Initial <see cref="WorkFlowResponse.UpdBy" /> value</param> /// <param name="updDate">Initial <see cref="WorkFlowResponse.UpdDate" /> value</param> /// <param name="updPgm">Initial <see cref="WorkFlowResponse.UpdPgm" /> value</param> /// <param name="rowVersion">Initial <see cref="WorkFlowResponse.RowVersion" /> value</param> /// <param name="workFlow">Initial <see cref="WorkFlowResponse.WorkFlow" /> value</param> /// <param name="workFlowState">Initial <see cref="WorkFlowResponse.WorkFlowState" /> value</param> public WorkFlowResponse(bool active, long creBy, DateTime creDate, long updBy, DateTime updDate, string updPgm, byte[] rowVersion, SS.Standard.WorkFlow.DTO.WorkFlow workFlow, SS.Standard.WorkFlow.DTO.WorkFlowStateEvent workFlowStateEvent) { this.active = active; this.creBy = creBy; this.creDate = creDate; this.updBy = updBy; this.updDate = updDate; this.updPgm = updPgm; this.rowVersion = rowVersion; this.workFlow = workFlow; this.workFlowStateEvent = workFlowStateEvent; }
protected void ctlRemittanceGridview_DataBound(object sender, EventArgs e) { ExpenseDataSet expenseDS = (ExpenseDataSet)TransactionService.GetDS(this.TransactionId); ExpenseDataSet.FnExpenseDocumentRow row = expenseDS.FnExpenseDocument.FindByExpenseID(this.ExpDocumentID); SS.Standard.WorkFlow.DTO.WorkFlow wf = null; int Ordinal = 0; if (Request["wfid"] != null) { WorkFlowID = UIHelper.ParseLong(Request["wfid"].ToString()); wf = WorkFlowQueryProvider.WorkFlowQuery.FindByIdentity(WorkFlowID); CurrentState = wf.CurrentState.Name; Ordinal = wf.CurrentState.Ordinal; } DbCurrency mainCurrency = null; if (!row.IsMainCurrencyIDNull()) { mainCurrency = SsDbQueryProvider.DbCurrencyQuery.FindByIdentity(row.MainCurrencyID); } if (mainCurrency != null) { ctlRemittanceGridview.Columns[7].HeaderText = string.Format(GetProgramMessage("ctlLblRemittanceMainAmount"), "(" + mainCurrency.Symbol + ")"); } string expenseType = FnExpenseDocumentService.GetExpenseType(this.ExpDocumentID, this.TransactionId); bool isRepOffice = row.IsIsRepOfficeNull() ? false : row.IsRepOffice; if (!expenseType.Equals(ZoneType.Domestic)) { if (isRepOffice) { if (CurrentState.Equals(WorkFlowStateFlag.WaitVerify) || Ordinal > 5) { ctlRemittanceGridview.Columns[7].Visible = true; ctlRemittanceGridview.Columns[8].Visible = true; } else { ctlRemittanceGridview.Columns[7].Visible = true; ctlRemittanceGridview.Columns[8].Visible = false; } } else { ctlRemittanceGridview.Columns[7].Visible = false; ctlRemittanceGridview.Columns[8].Visible = true; } } }
/// <summary> /// Initializes a new instance of the WorkFlowResponseToken class /// </summary> /// <param name="tokenCode">Initial <see cref="WorkFlowResponseToken.TokenCode" /> value</param> /// <param name="userID">Initial <see cref="WorkFlowResponseToken.userID" /> value</param> /// <param name="tokenType">Initial <see cref="WorkFlowResponseToken.tokenType" /> value</param> /// <param name="workFlowStateEventID">Initial <see cref="WorkFlowResponseToken.WorkFlowStateEventID" /> value</param> /// <param name="active">Initial <see cref="WorkFlowResponseToken.Active" /> value</param> /// <param name="creBy">Initial <see cref="WorkFlowResponseToken.CreBy" /> value</param> /// <param name="creDate">Initial <see cref="WorkFlowResponseToken.CreDate" /> value</param> /// <param name="updBy">Initial <see cref="WorkFlowResponseToken.UpdBy" /> value</param> /// <param name="updDate">Initial <see cref="WorkFlowResponseToken.UpdDate" /> value</param> /// <param name="updPgm">Initial <see cref="WorkFlowResponseToken.UpdPgm" /> value</param> /// <param name="rowVersion">Initial <see cref="WorkFlowResponseToken.RowVersion" /> value</param> /// <param name="workFlow">Initial <see cref="WorkFlowResponseToken.workFlow" /> value</param> public WorkFlowResponseToken(string tokenCode, long userID, string tokenType, bool active, long creBy, DateTime creDate, long updBy, DateTime updDate, string updPgm, byte[] rowVersion, SS.Standard.WorkFlow.DTO.WorkFlow workFlow) { this.tokenCode = tokenCode; this.userID = userID; this.tokenType = tokenType; this.active = active; this.creBy = creBy; this.creDate = creDate; this.updBy = updBy; this.updDate = updDate; this.updPgm = updPgm; this.rowVersion = rowVersion; this.workFlow = workFlow; }
/// <summary> /// Initializes a new instance of the WorkFlowStateEventPermission class /// </summary> /// <param name="roleID">Initial <see cref="WorkFlowStateEventPermission.RoleID" /> value</param> /// <param name="userID">Initial <see cref="WorkFlowStateEventPermission.UserID" /> value</param> /// <param name="active">Initial <see cref="WorkFlowStateEventPermission.Active" /> value</param> /// <param name="creBy">Initial <see cref="WorkFlowStateEventPermission.CreBy" /> value</param> /// <param name="creDate">Initial <see cref="WorkFlowStateEventPermission.CreDate" /> value</param> /// <param name="updBy">Initial <see cref="WorkFlowStateEventPermission.UpdBy" /> value</param> /// <param name="updDate">Initial <see cref="WorkFlowStateEventPermission.UpdDate" /> value</param> /// <param name="updPgm">Initial <see cref="WorkFlowStateEventPermission.UpdPgm" /> value</param> /// <param name="rowVersion">Initial <see cref="WorkFlowStateEventPermission.RowVersion" /> value</param> /// <param name="workFlowID">Initial <see cref="WorkFlowStateEventPermission.WorkFlowID" /> value</param> /// <param name="workFlowStateEventID">Initial <see cref="WorkFlowStateEventPermission.WorkFlowStateEventID" /> value</param> public WorkFlowStateEventPermission(short?roleID, long?userID, bool active, long creBy, DateTime creDate, long updBy, DateTime updDate, string updPgm, byte[] rowVersion, SS.Standard.WorkFlow.DTO.WorkFlow workFlowID, SS.Standard.WorkFlow.DTO.WorkFlowStateEvent workFlowStateEventID) { this.roleID = roleID; this.userID = userID; this.active = active; this.creBy = creBy; this.creDate = creDate; this.updBy = updBy; this.updDate = updDate; this.updPgm = updPgm; this.rowVersion = rowVersion; this.workFlow = workFlow; this.workFlowStateEvent = workFlowStateEvent; }
public IList <object> GetEditableFields(long?documentID) { IList <object> editableFields = new List <object>(); if (documentID.HasValue) // Check whether new flag then return the default editableFields. { SS.Standard.WorkFlow.DTO.WorkFlow workFlow = WorkFlowQueryProvider.WorkFlowQuery.GetWorkFlowByDocumentID(documentID.Value); if (workFlow != null) { return(WorkFlowService.GetEditableFields(workFlow.WorkFlowID)); } } editableFields.Add(RemittanceFieldGroup.All); editableFields.Add(RemittanceFieldGroup.Company); editableFields.Add(RemittanceFieldGroup.FullClearing); return(editableFields); }
public IList <object> GetEditableFields(long?documentID) { IList <object> editableFields = new List <object>(); if (!documentID.HasValue) // Check whether new flag then return the default editableFields. { editableFields.Add(MPAFieldGroup.All); editableFields.Add(MPAFieldGroup.Company); editableFields.Add(MPAFieldGroup.Initiator); } else // Check whether view or edit flag then return editableFields from workflow state. { SS.Standard.WorkFlow.DTO.WorkFlow workFlow = WorkFlowQueryProvider.WorkFlowQuery.GetWorkFlowByDocumentID(documentID.Value); editableFields = WorkFlowService.GetEditableFields(workFlow.WorkFlowID); } return(editableFields); }
protected void Advance_OnObjectLookUpCalling(object sender, ObjectLookUpCallingEventArgs e) { UserControls.LOV.AV.AdvanceLookup advanceLookUp = sender as UserControls.LOV.AV.AdvanceLookup; ExpenseDataSet expenseDS = (ExpenseDataSet)TransactionService.GetDS(this.TransactionId); ExpenseDataSet.FnExpenseDocumentRow row = expenseDS.FnExpenseDocument.FindByExpenseID(this.ExpDocumentID); if (!row.IsMainCurrencyIDNull()) { this.MainCurrencyID = row.MainCurrencyID; } if (!row.IsPBIDNull()) { this.PBID = row.PBID; } this.IsRepOffice = row.IsIsRepOfficeNull() ? false : row.IsRepOffice; advanceLookUp.CompanyID = CompanyID; // UIHelper.ParseLong(((LOV.SCG.DB.CompanyField)this.Parent.Parent.Parent.Parent.FindControl("ctlCompanyField")).CompanyID); advanceLookUp.RequesterID = RequesterID; // UIHelper.ParseLong(((ActorData)this.Parent.Parent.Parent.Parent.FindControl("ctlRequesterData")).UserID); advanceLookUp.AdvanceType = FnExpenseDocumentService.GetExpenseType(this.ExpDocumentID, this.TransactionId); advanceLookUp.IsRelateWithRemittanceButNotInExpense = true; advanceLookUp.PBID = this.PBID; advanceLookUp.MainCurrencyID = this.MainCurrencyID; advanceLookUp.IsRepOffice = this.IsRepOffice; if (!string.IsNullOrEmpty(Request.Params["wfid"]) && UIHelper.ParseInt(Request.Params["wfid"]) > 0) { long workFlowID = UIHelper.ParseLong(Request.Params["wfid"]); SS.Standard.WorkFlow.DTO.WorkFlow wf = WorkFlowQueryProvider.WorkFlowQuery.FindByIdentity(workFlowID); if (wf != null && wf.CurrentState != null && wf.CurrentState.Name != null && wf.CurrentState.Name.Equals(WorkFlowStateFlag.Draft)) { advanceLookUp.CurrentUserID = UserAccount.UserID; } } else { advanceLookUp.CurrentUserID = UserAccount.UserID; } }
public IList <object> GetVisibleFields(long?documentID) { IList <object> visibleFields = new List <object>(); if (documentID.HasValue) // Check whether new flag then return the default editableFields. { SS.Standard.WorkFlow.DTO.WorkFlow workFlow = WorkFlowQueryProvider.WorkFlowQuery.GetWorkFlowByDocumentID(documentID.Value); if (workFlow != null) { return(WorkFlowService.GetVisibleFields(workFlow.WorkFlowID)); } } //Because of Remiitance Document does not has Hold State , //And It don't have spacial group , then return group All visibleFields.Add(RemittanceFieldGroup.All); visibleFields.Add(RemittanceFieldGroup.Company); visibleFields.Add(RemittanceFieldGroup.FullClearing); return(visibleFields); }
protected void ctlSend_Click(object sender, ImageClickEventArgs e) { //เรียก service สำหรับส่ง email SS.Standard.WorkFlow.DTO.WorkFlow workFlow = new SS.Standard.WorkFlow.DTO.WorkFlow(); long workFlowID = 0; if (this.RequesterID != 0) { workFlow = WorkFlowQueryProvider.WorkFlowQuery.GetWorkFlowByDocumentID(this.DocumentID); if (workFlow != null) { try { workFlowID = workFlow.WorkFlowID; if (this.EmailType.Equals("EM09")) { SCGEmailService.SendEmailEM09(workFlow.Document.DocumentID, ctlCC.Text, ctlRemark.Text, string.Empty); } else if (this.EmailType.Equals("EM10")) { SCGEmailService.SendEmailEM10(this.AdvanceDocumentID, UIHelper.ParseLong(ctlUserID.Text), ctlCC.Text, ctlRemark.Text, false); } else if (this.EmailType.Equals("EM15")) { SCGEmailService.SendEmailEM15(workFlowID, UIHelper.ParseLong(ctlUserID.Text)); } ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "SendEmailSuccess", "alert('" + GetMessage("Send Complete") + "');", true); Hide(); } catch (Exception ex) { throw ex; } } } }
public void Initialize(long documentID) { this.DocumentID = documentID; SS.Standard.WorkFlow.DTO.WorkFlow workFlow = WorkFlowQueryProvider.WorkFlowQuery.GetWorkFlowByDocumentID(documentID); if (workFlow != null) { this.WorkFlowID = workFlow.WorkFlowID; ctlHistoryGridView.DataCountAndBind(); } else { ctlHistoryGridView.DataBind(); } if (RequestCount() > 0) { IsEmptyData = false; } else { IsEmptyData = true; } }
public long SaveToDatabase() { // Save all table in dataset to database and clear transaction. long caDocumentID = CADocumentService.SaveCADocument(this.TransactionID, this.CADocumentID); // Get ta document CADocument caDocument = ScgeAccountingQueryProvider.CADocumentQuery.FindProxyByIdentity(caDocumentID); TransactionService.Commit(this.TransactionID); #region Work Flow long workFlowID = 0; // Save New WorkFlow. if ((caDocument != null) && (caDocument.DocumentID != null)) { SCGDocument document = ScgeAccountingQueryProvider.SCGDocumentQuery.FindProxyByIdentity(caDocument.DocumentID.DocumentID); SS.Standard.WorkFlow.DTO.WorkFlow workFlow = new SS.Standard.WorkFlow.DTO.WorkFlow(); // WorkFlow Type ID = 9 is CA Workflow Image. wait confirm where to store this data. workFlow.WorkFlowType = new SS.Standard.WorkFlow.DTO.WorkFlowType(WorkFlowTypeID.CAWorkFlow); // WorkFlow Type ID = 9 is CA Workflow Image. wait confirm where to store this data. workFlow.CurrentState = WorkFlowQueryProvider.WorkFlowStateQuery.FindWorkFlowStateIDByTypeIDAndStateName(WorkFlowTypeID.CAWorkFlow, WorkFlowStateFlag.Draft); workFlow.Description = null; workFlow.Document = document; workFlow.Active = true; workFlow.CreBy = document.CreBy; workFlow.CreDate = document.CreDate; workFlow.UpdBy = document.UpdBy; workFlow.UpdDate = document.UpdDate; workFlow.UpdPgm = document.UpdPgm; workFlowID = WorkFlowService.CheckExistAndAddNew(workFlow); } #endregion Work Flow return(workFlowID); }
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 void Initialize(string initFlag, long?documentID) { CADocumentDataSet caDocumentDS; long caDocumentID = 0; Guid txID = Guid.Empty; bool isCopy = false; //#region Visible Mode //ctlAddRequester.Visible = true; //this.isShowFooter = true; //#endregion Visible Mode if (initFlag.Equals(FlagEnum.NewFlag) && Request.QueryString["cp"] == null) { caDocumentDS = (CADocumentDataSet)CADocumentService.PrepareDS(); txID = TransactionService.Begin(caDocumentDS); caDocumentID = CADocumentService.AddCADocumentTransaction(txID); ctlCAFormHeader.Status = FlagEnum.NewFlag; } else if (((initFlag.Equals(FlagEnum.EditFlag) || (initFlag.Equals(FlagEnum.ViewFlag)))) && ((documentID.HasValue) && (documentID.Value != 0))) { caDocumentDS = (CADocumentDataSet)CADocumentService.PrepareDS(documentID.Value); txID = TransactionService.Begin(caDocumentDS); if (caDocumentDS.Document.Rows.Count > 0) { caDocumentID = UIHelper.ParseLong(caDocumentDS.CADocument.Rows[0]["CADocumentID"].ToString()); } } else if (Request.QueryString["cp"] != null && UIHelper.ParseLong(Request.QueryString["cp"]) == 1) { caDocumentDS = (CADocumentDataSet)CADocumentService.PrepareDataToDataset(UIHelper.ParseLong(Request.QueryString["docId"]), true); txID = TransactionService.Begin(caDocumentDS); isCopy = true; if (caDocumentDS.CADocument.Rows.Count > 0) { caDocumentID = UIHelper.ParseLong(caDocumentDS.CADocument.Rows[0]["CADocumentID"].ToString()); } } this.TransactionID = txID; this.CADocumentID = caDocumentID; this.InitialFlag = initFlag; // Define value to each DocumentEditor Property. // And store it in viewstate. this.VisibleFields = CADocumentService.GetVisibleFields(documentID); this.EditableFields = CADocumentService.GetEditableFields(documentID); this.InitializeControl(); this.BindControl(isCopy); #region Show Tab // ให้ Tab ที่มีข้อมูลโชว์ขึ้นมา ส่วน Tab ที่ไม่มีข้อมูล ไม่ต้องโชว์ string strCurrentState = ""; if (!string.IsNullOrEmpty(Request.Params["wfid"]) && UIHelper.ParseInt(Request.Params["wfid"]) > 0) { long workFlowID = UIHelper.ParseLong(Request.Params["wfid"]); SS.Standard.WorkFlow.DTO.WorkFlow wf = WorkFlowQueryProvider.WorkFlowQuery.FindByIdentity(workFlowID); if (wf != null && wf.CurrentState != null && wf.CurrentState.Name != null) { strCurrentState = wf.CurrentState.Name; } } if (strCurrentState == "Draft") { ctlTabMemo.Visible = true; ctlTabInitial.Visible = true; ctlTabAttachment.Visible = true; ctlTabHistory.Visible = true; ctlUpdatePanelTab.Update(); } else if (this.InitialFlag.Equals(FlagEnum.ViewFlag)) { if (string.IsNullOrEmpty(ctlMemo.Text)) { ctlTabMemo.Visible = false; } else { ctlTabMemo.Visible = true; } if (ctlInitiator.IsEmptyData) { ctlTabInitial.Visible = false; } else { ctlTabInitial.Visible = true; } if (ctlAttachment.IsEmptyData) { ctlTabAttachment.Visible = false; } else { ctlTabAttachment.Visible = true; } if (ctlHistory.IsEmptyData) { ctlTabHistory.Visible = false; } else { ctlTabHistory.Visible = true; } ctlUpdatePanelTab.Update(); } else { ctlTabMemo.Visible = true; ctlTabInitial.Visible = true; ctlTabAttachment.Visible = true; ctlTabHistory.Visible = true; ctlUpdatePanelTab.Update(); } #endregion Show Tab }
public void UpdateInvoiceItemOnTransaction(FnExpenseInvoiceItem item, Guid txId, string expenseType) { ExpenseDataSet ds = (ExpenseDataSet)TransactionService.GetDS(txId); bool isRepOffice = false; long documentId = 0; if (item.Invoice != null && item.Invoice.Expense != null) { ExpenseDataSet.FnExpenseDocumentRow expRow = ds.FnExpenseDocument.FindByExpenseID(item.Invoice.Expense.ExpenseID); documentId = expRow == null ? 0 : expRow.DocumentID; if (!expRow.IsIsRepOfficeNull()) { isRepOffice = expRow.IsRepOffice; } } SS.Standard.WorkFlow.DTO.WorkFlow workflow = SS.Standard.WorkFlow.Query.WorkFlowQueryProvider.WorkFlowQuery.GetWorkFlowByDocumentID(documentId); Spring.Validation.ValidationErrors errors = new Spring.Validation.ValidationErrors(); if (workflow == null || (workflow != null && workflow.CurrentState.Name.Equals(WorkFlowStateFlag.Draft))) { // Validate CostCenter. if (item.CostCenter == null) { errors.AddError("InvoiceItem.Error", new Spring.Validation.ErrorMessage("RequiredCostCenter")); } else { if (ScgDbQueryProvider.DbCostCenterQuery.FindByIdentity(item.CostCenter.CostCenterID) == null) { errors.AddError("InvoiceItem.Error", new Spring.Validation.ErrorMessage("RequiredCostCenter")); } } } // Validate Account. if (item.Account == null) { errors.AddError("InvoiceItem.Error", new Spring.Validation.ErrorMessage("RequiredAccountID")); } else { if (ScgDbQueryProvider.DbAccountQuery.FindByIdentity(item.Account.AccountID) == null) { errors.AddError("InvoiceItem.Error", new Spring.Validation.ErrorMessage("RequiredAccountID")); } } if (!string.IsNullOrEmpty(item.SaleOrder) && item.SaleOrder.Length < 10) { errors.AddError("InvoiceItem.Error", new Spring.Validation.ErrorMessage("SaleOrder_Has_10_Digit")); } if (expenseType.Equals(ZoneType.Domestic)) { // Validate Amount. if (!isRepOffice) { if (!item.Amount.HasValue || (item.Amount.HasValue && item.Amount.Value == 0)) { errors.AddError("InvoiceItem.Error", new Spring.Validation.ErrorMessage("RequiredAmount")); } } else { if (!item.LocalCurrencyAmount.HasValue || (item.LocalCurrencyAmount.HasValue && item.LocalCurrencyAmount.Value == 0)) { errors.AddError("InvoiceItem.Error", new Spring.Validation.ErrorMessage("RequiredAmount")); } } } else if (expenseType.Equals(ZoneType.Foreign)) { // Validate Currency. if (!item.CurrencyID.HasValue || (item.CurrencyID.HasValue && item.CurrencyID.Value == 0)) { errors.AddError("InvoiceItem.Error", new Spring.Validation.ErrorMessage("RequiredCurrency")); } // Validate Amount. if (!item.CurrencyAmount.HasValue || (item.CurrencyAmount.HasValue && item.CurrencyAmount.Value == 0)) { errors.AddError("InvoiceItem.Error", new Spring.Validation.ErrorMessage("RequiredAmount")); } // Validate ExchangeRate. if (!item.ExchangeRate.HasValue) { errors.AddError("InvoiceItem.Error", new Spring.Validation.ErrorMessage("RequiredExchangeRate")); } else if ((item.ExchangeRate.HasValue) && (item.ExchangeRate.Value == 0)) { errors.AddError("InvoiceItem.Error", new Spring.Validation.ErrorMessage("RequiredExchangeRate")); } } if (!errors.IsEmpty) { throw new ServiceValidationException(errors); } //ExpenseDataSet ds = (ExpenseDataSet)TransactionService.GetDS(txId); ExpenseDataSet.FnExpenseInvoiceItemRow row = ds.FnExpenseInvoiceItem.FindByInvoiceItemID(item.InvoiceItemID); row.InvoiceID = item.Invoice.InvoiceID; if (item.CostCenter != null) { row.CostCenterID = item.CostCenter.CostCenterID; } else { row.SetCostCenterIDNull(); } row.AccountID = item.Account.AccountID; if (item.IO != null) { row.IOID = item.IO.IOID; } else { row.SetIOIDNull(); } if (item.CurrencyID.HasValue) { row.CurrencyID = item.CurrencyID.Value; } if (item.ExchangeRate.HasValue) { row.ExchangeRate = item.ExchangeRate.Value; } if (item.CurrencyAmount.HasValue) { row.CurrencyAmount = item.CurrencyAmount.Value; } if (item.MainCurrencyID.HasValue) { row.MainCurrencyID = item.MainCurrencyID.Value; } if (item.LocalCurrencyAmount.HasValue) { row.LocalCurrencyAmount = (decimal)item.LocalCurrencyAmount.Value; } if (item.MainCurrencyAmount.HasValue) { row.MainCurrencyAmount = item.MainCurrencyAmount.Value; } if (expenseType.Equals(ZoneType.Foreign) && !isRepOffice) { row.Amount = (double)Math.Round((decimal)(item.CurrencyAmount.Value * item.ExchangeRate.Value), 2, MidpointRounding.AwayFromZero); } else { if (item.Amount.HasValue) { row.Amount = item.Amount.Value; } } row.SaleOrder = item.SaleOrder; row.SaleItem = item.SaleItem; row.Description = item.Description; row.ReferenceNo = item.ReferenceNo; row.VendorCodeAP = item.VendorCodeAP; row.Active = true; //row.CreBy = UserAccount.UserID; //row.CreDate = DateTime.Now; row.UpdBy = UserAccount.UserID; row.UpdDate = DateTime.Now; row.UpdPgm = UserAccount.CurrentProgramCode; //ds.FnExpenseInvoiceItem.AddFnExpenseInvoiceItemRow(row); }
protected void ctlInvoiceItem_DataBound(object sender, EventArgs e) { BaseGridView gridview = (BaseGridView)sender; if (DocumentType.Equals(ZoneType.Domestic)) { gridview.Columns[5].Visible = false; gridview.Columns[4].Visible = false; gridview.Columns[6].Visible = false; } else { gridview.Columns[5].Visible = true; gridview.Columns[4].Visible = true; gridview.Columns[6].Visible = true; } if (IsRepOffice) { SS.Standard.WorkFlow.DTO.WorkFlow workflow = null; if (!string.IsNullOrEmpty(Request.Params["wfid"]) && UIHelper.ParseInt(Request.Params["wfid"]) > 0) { long workFlowID = UIHelper.ParseLong(Request.Params["wfid"]); try { workflow = WorkFlowQueryProvider.WorkFlowQuery.FindByIdentity(workFlowID); } catch (Exception ex) { throw ex; } } gridview.Columns[7].Visible = true; //local currency gridview.Columns[7].HeaderText = string.Format(GetMessage("AmountCurrencyHeaderColumn"), "(" + SelectedCurrency + ")"); ExpenseDataSet expDs = (ExpenseDataSet)TransactionService.GetDS(TransactionId); ExpenseDataSet.FnExpenseDocumentRow expRow = expDs.FnExpenseDocument.FindByExpenseID(this.ExpDocumentID); if (!expRow.IsMainCurrencyIDNull()) { DbCurrency mainCurrency = SsDbQueryProvider.DbCurrencyQuery.FindByIdentity(expRow.MainCurrencyID); if (mainCurrency != null) { gridview.Columns[8].HeaderText = string.Format(GetMessage("AmountCurrencyHeaderColumn"), "(" + mainCurrency.Symbol + ")"); } } if ((workflow != null && workflow.CurrentState.Ordinal >= 5) && (UserAccount.IsAccountant || UserAccount.IsPayment)) { if (!expRow.IsMainCurrencyIDNull() && !expRow.IsLocalCurrencyIDNull() && (expRow.MainCurrencyID == expRow.LocalCurrencyID)) { gridview.Columns[8].Visible = false; //hide main currency } else { gridview.Columns[8].Visible = true; //show main currency } gridview.Columns[9].Visible = true; //THB } else { gridview.Columns[8].Visible = false; gridview.Columns[9].Visible = false; } } else { gridview.Columns[7].Visible = false; gridview.Columns[8].Visible = false; gridview.Columns[9].Visible = true; } }
protected void ctlRepeater_ItemDataBound(object sender, RepeaterItemEventArgs e) { string url = string.Empty; if (e.Item.DataItem != null) { ExpenseDataSet expDs = (ExpenseDataSet)TransactionService.GetDS(TransactionId); ExpenseDataSet.FnExpenseInvoiceRow invoice = (ExpenseDataSet.FnExpenseInvoiceRow)e.Item.DataItem; ExpenseDataSet.FnExpenseDocumentRow expenseDocumentRow = expDs.FnExpenseDocument.FindByExpenseID(this.ExpDocumentID); PopupCaller popupEdit = (PopupCaller)e.Item.FindControl("ctlEditPopupCaller"); PopupCaller popupView = (PopupCaller)e.Item.FindControl("ctlViewPopupCaller"); LinkButton edit = (LinkButton)e.Item.FindControl("ctlEdit"); LinkButton delete = (LinkButton)e.Item.FindControl("ctlDelete"); LinkButton view = (LinkButton)e.Item.FindControl("ctlView"); Literal totalBaseAmount = (Literal)e.Item.FindControl("ctlTotalAmount"); Literal totalNetAmount = (Literal)e.Item.FindControl("ctlNetAmount"); if (IsRepOffice) { totalBaseAmount.Text = UIHelper.BindDecimal(invoice.TotalBaseAmountLocalCurrency.ToString()); totalNetAmount.Text = UIHelper.BindDecimal(invoice.NetAmountLocalCurrency.ToString()); } else { totalBaseAmount.Text = UIHelper.BindDecimal(invoice.TotalBaseAmount.ToString()); totalNetAmount.Text = UIHelper.BindDecimal(invoice.NetAmount.ToString()); } if (!invoice.IsInvoiceDocumentTypeNull() && invoice.InvoiceDocumentType.Equals(InvoiceType.Perdiem)) { popupEdit.URL = ShowPerdiemPopup(FlagEnum.EditFlag, invoice.InvoiceID); popupView.URL = ShowPerdiemPopup(FlagEnum.ViewFlag, invoice.InvoiceID); } if (!invoice.IsInvoiceDocumentTypeNull() && invoice.InvoiceDocumentType.Equals(InvoiceType.General)) { url = ShowExpenseGeneral(invoice.InvoiceID); popupEdit.URL = url.Replace("[mode]", FlagEnum.EditFlag); popupView.URL = url.Replace("[mode]", FlagEnum.ViewFlag); } // Show Mileage. if (!invoice.IsInvoiceDocumentTypeNull() && invoice.InvoiceDocumentType.Equals(InvoiceType.Mileage)) { popupEdit.URL = ShowMileagePopup(FlagEnum.EditFlag); popupView.URL = ShowMileagePopup(FlagEnum.ViewFlag); } SS.Standard.WorkFlow.DTO.WorkFlow workflow = SS.Standard.WorkFlow.Query.WorkFlowQueryProvider.WorkFlowQuery.GetWorkFlowByDocumentID(this.DocumentID); if (InitialFlag.Equals(FlagEnum.ViewFlag)) { edit.Visible = false; delete.Visible = false; view.Visible = true; } else { edit.Visible = true; view.Visible = false; if (!invoice.IsInvoiceDocumentTypeNull() && invoice.InvoiceDocumentType.Equals(InvoiceType.Mileage)) { delete.Visible = false; } else if (workflow != null && workflow.CurrentState.Name.Equals(WorkFlowStateFlag.Hold)) { delete.Visible = false; } else { delete.Visible = true; } } Literal seq = (Literal)e.Item.FindControl("ctlSeq"); seq.Text += e.Item.ItemIndex + 1; BaseGridView gridview = (BaseGridView)e.Item.FindControl("ctlInvoiceItem"); string filter = String.Format("InvoiceID = {0}", invoice.InvoiceID); gridview.DataSource = expDs.FnExpenseInvoiceItem.Select(filter); gridview.DataBind(); } }
public void BindControl() { SS.Standard.WorkFlow.DTO.WorkFlow workflow = null; long workFlowID = 0; if (!string.IsNullOrEmpty(Request.Params["wfid"]) && UIHelper.ParseInt(Request.Params["wfid"]) > 0) { workFlowID = UIHelper.ParseLong(Request.Params["wfid"]); workflow = WorkFlowQueryProvider.WorkFlowQuery.FindByIdentity(workFlowID); } if (DocumentType.Equals(ZoneType.Foreign) || this.IsRepOffice) { ctlAddMilage.Style["display"] = "none"; } else { ctlAddMilage.Style["display"] = string.Empty; } if (!InitialFlag.Equals(FlagEnum.ViewFlag) && (workflow == null || (workflow != null && !workflow.CurrentState.Name.Equals(WorkFlowStateFlag.Hold)))) { ctlAddGeneralExpense.Enabled = true; ctlAddPerdiem.Enabled = true; ctlAddMilage.Enabled = true; } else { ctlAddGeneralExpense.Enabled = false; ctlAddPerdiem.Enabled = false; ctlAddMilage.Enabled = false; } ctlSimpleExpense.DocumentType = this.DocumentType; ctlPerdiemPopupCaller.URL = ShowPerdiemPopup(InitialFlag, null); ctlInvoicePopupCaller.URL = String.Format(invoiceURL.Replace("[mode]", FlagEnum.NewFlag), this.TransactionId, this.ExpDocumentID, this.DocumentType, this.DocumentID, string.Empty); ctlMileagePopupCaller.URL = ShowMileagePopup(InitialFlag); ExpenseDataSet expDs = (ExpenseDataSet)TransactionService.GetDS(this.TransactionId); ExpenseDataSet.FnExpenseDocumentRow expenseDocumentRow = expDs.FnExpenseDocument.FindByExpenseID(this.ExpDocumentID); this.DocumentID = expenseDocumentRow.DocumentID; ctlDivExchangeRateLocalInfo.Style["display"] = "none"; ctlDivExchangeRateMainInfo.Style["display"] = "none"; if (!InitialFlag.Equals(FlagEnum.NewFlag) && IsRepOffice) { try { if ((workflow != null && workflow.CurrentState.Ordinal >= 5) && (UserAccount.IsAccountant || UserAccount.IsPayment)) { string mainCurrencySymbol = string.Empty; string localCurrencySymbol = string.Empty; if (!expenseDocumentRow.IsLocalCurrencyIDNull()) { DbCurrency localCurrency = SsDbQueryProvider.DbCurrencyQuery.FindByIdentity(expenseDocumentRow.LocalCurrencyID); localCurrencySymbol = localCurrency.Symbol; } if (!expenseDocumentRow.IsMainCurrencyIDNull()) { DbCurrency mainCurrency = SsDbQueryProvider.DbCurrencyQuery.FindByIdentity(expenseDocumentRow.MainCurrencyID); mainCurrencySymbol = mainCurrency.Symbol; } ctlExRateMainCurrencyLabel.Text = GetProgramMessage("DisplayExchangeRateInfo"); ctlExchangeRateMain.Text = UIHelper.BindExchangeRate(expenseDocumentRow.IsExchangeRateMainToTHBCurrencyNull() ? string.Empty : expenseDocumentRow.ExchangeRateMainToTHBCurrency.ToString()); ctlExchangeRateMainUnit.Text = CurrencySymbol.THB + "/" + mainCurrencySymbol; ctlExRateLocalCurrencyLabel.Text = GetProgramMessage("DisplayExchangeRateInfo"); ctlExchangeRateLocal.Text = UIHelper.BindExchangeRate(expenseDocumentRow.IsExchangeRateForLocalCurrencyNull() ? string.Empty : expenseDocumentRow.ExchangeRateForLocalCurrency.ToString()); ctlExchangeRateLocalUnit.Text = localCurrencySymbol + "/" + mainCurrencySymbol; ctlDivExchangeRateMainInfo.Style["display"] = "block"; if (!expenseDocumentRow.IsMainCurrencyIDNull() && !expenseDocumentRow.IsLocalCurrencyIDNull() && (expenseDocumentRow.MainCurrencyID != expenseDocumentRow.LocalCurrencyID)) { ctlDivExchangeRateLocalInfo.Style["display"] = "block"; } } } catch (Exception ex) { throw ex; } } }
public void Initialize(Guid txID, long documentID, string initFlag) { this.TransactionId = txID; this.DocumentID = documentID; this.InitialFlag = initFlag; int messageCode = 0; string message = string.Empty; bool boolVerify = false; bool boolVerifyAndApproveVerify = false; bool boolApprove = false; bool boolApproveDocument = false; bool showWarningChangeAmount = false; long workFlowID = long.Parse(Request.QueryString["wfid"] == null ? "0" : Request.QueryString["wfid"].Trim()); if (workFlowID > 0) { SS.Standard.WorkFlow.DTO.WorkFlow workflow = SS.Standard.WorkFlow.Query.WorkFlowQueryProvider.WorkFlowQuery.FindByIdentity(workFlowID); SS.Standard.WorkFlow.DTO.Document document = SS.Standard.WorkFlow.Query.WorkFlowQueryProvider.WorkFlowQuery.GetDocumentByWorkFlowID(workFlowID); if (document.DocumentType.DocumentTypeID == 1) //AdvanceDomesticDocument { boolVerify = AdvanceWorkFlowService.CanVerifyWaitVerify(workFlowID); boolVerifyAndApproveVerify = AdvanceWorkFlowService.CanVerifyAndApproveVerifyWaitVerify(workFlowID); boolApprove = AdvanceWorkFlowService.CanApproveWaitApproveVerify(workFlowID); boolApproveDocument = AdvanceWorkFlowService.CanApproveWaitApprove(workFlowID); } else if (document.DocumentType.DocumentTypeID == 5) //AdvanceForeignDocument { boolVerify = AdvanceForeignWorkFlowService.CanVerifyWaitVerify(workFlowID); boolVerifyAndApproveVerify = AdvanceForeignWorkFlowService.CanVerifyAndApproveVerifyWaitVerify(workFlowID); boolApprove = AdvanceForeignWorkFlowService.CanApproveWaitApproveVerify(workFlowID); boolApproveDocument = AdvanceForeignWorkFlowService.CanApproveWaitApprove(workFlowID); } else if (document.DocumentType.DocumentTypeID == 3 || document.DocumentType.DocumentTypeID == 7) //ExpenseDomesticDocument, ExpenseForeignDocument { boolVerify = ExpenseWorkFlowService.CanVerifyWaitVerify(workFlowID); boolVerifyAndApproveVerify = ExpenseWorkFlowService.CanVerifyAndApproveVerifyWaitVerify(workFlowID); boolApprove = ExpenseWorkFlowService.CanApproveWaitApproveVerify(workFlowID); boolApproveDocument = ExpenseWorkFlowService.CanApproveWaitApprove(workFlowID); if (workflow != null) { showWarningChangeAmount = workflow.CurrentState.Ordinal >= 6 && boolApprove; } } } isSeeHistory = ScgeAccountingQueryProvider.AvAdvanceDocumentQuery.isSeeHistoryReject(this.DocumentID); ctlSeeHistory.Visible = isSeeHistory; #region Warning message Requester and Approver is the same person if ((boolVerify || boolVerifyAndApproveVerify || boolApprove) && ((UserAccount.IsApproveVerifyDocument || UserAccount.IsVerifyDocument) || (UserAccount.IsApproveVerifyPayment || UserAccount.IsVerifyPayment))) { isSeeMessage = ScgeAccountingQueryProvider.AvAdvanceDocumentQuery.isSeeMessage(this.DocumentID); if (isSeeMessage) { ctlSeeMessage.Visible = isSeeMessage; messageCode = ScgeAccountingQueryProvider.AvAdvanceDocumentQuery.isMessage(this.DocumentID); if (UserAccount.CurrentLanguageID == 1) { if (messageCode == 1) { message = "และผู้เบิกค่าใช้จ่าย"; } else if (messageCode == 2) { message = "และผู้รับเงิน"; } else if (messageCode == 3) { message = ", ผู้เบิกค่าใช้จ่าย และผู้รับเงิน"; } } else if (UserAccount.CurrentLanguageID == 2) { if (messageCode == 1) { message = "and Requester"; } else if (messageCode == 2) { message = "and Receiver"; } else if (messageCode == 3) { message = ", Requester and Receiver"; } } this.ctlSeeMessage.Text = string.Format(this.GetProgramMessage("$SeeMessage$"), message); } } else { ctlSeeMessage.Visible = false; } #endregion ctlWarning.Visible = false; SCG.eAccounting.DTO.SCGDocument doc = ScgeAccountingQueryProvider.SCGDocumentQuery.FindByIdentity(DocumentID); if ((boolVerify || boolVerifyAndApproveVerify || boolApprove || boolApproveDocument) && ((UserAccount.UserID == doc.ApproverID.Userid || UserAccount.IsApproveVerifyDocument || UserAccount.IsVerifyDocument) || (UserAccount.IsApproveVerifyPayment || UserAccount.IsVerifyPayment))) { if (doc.RequesterID.Userid != doc.ReceiverID.Userid) { ctlWarning.Visible = true; ctlWarning.Text = this.GetMessage("RequesterAndReceiverShouldBeTheSamePerson"); } } ctlWarningChangeAmount.Visible = false; if (ParameterServices.EnableShowWarningMsgAmountHasBeenCorrected) { if (showWarningChangeAmount && UserAccount.IsApproveVerifyDocument) { FnExpenseDocument expenseDocument = ScgeAccountingQueryProvider.FnExpenseDocumentQuery.GetExpenseDocumentByDocumentID(doc.DocumentID); if (expenseDocument.AmountApproved != null && expenseDocument.TotalExpense != expenseDocument.AmountApproved) { ctlWarningChangeAmount.Visible = true; ctlWarningChangeAmount.Text = this.GetMessage("AmountHasBeenCorrected"); } } } }
public void BindControl(bool refreshHeader) { this.refreshHeaderGrid = refreshHeader; if (InitialFlag.Equals(FlagEnum.ViewFlag)) { ctlAddAdvance.Enabled = false; ctlTANoLookup.Visible = false; ctlDeleteTA.Visible = false; } else { ctlAddAdvance.Enabled = true; ctlTANoLookup.Visible = true; ctlDeleteTA.Visible = true; } if (this.DocumentType.Equals(ZoneType.Domestic)) { this.IsDomestic = true; ctlRemittanceGridview.Visible = false; ctlTALookup.TravelBy = TravellBy.Domestic; ctlControlPanel.Visible = false; } else { this.IsDomestic = false; ctlRemittanceGridview.Visible = true; ctlTALookup.TravelBy = TravellBy.Foreign; ctlControlPanel.Visible = true; } ExpenseDataSet expenseDS = (ExpenseDataSet)TransactionService.GetDS(this.TransactionId); ExpenseDataSet.FnExpenseDocumentRow row = expenseDS.FnExpenseDocument.FindByExpenseID(this.ExpDocumentID); if (!row.IsTADocumentIDNull()) { ctlTANoLookup.Enabled = false; TADocument ta = ScgeAccountingQueryProvider.TADocumentQuery.FindByIdentity(row.TADocumentID); SS.Standard.WorkFlow.DTO.WorkFlow wf = SS.Standard.WorkFlow.Query.WorkFlowQueryProvider.WorkFlowQuery.GetWorkFlowByDocumentID(ta.DocumentID.DocumentID); ctlAddAdvance.Enabled = false; ctlTANoLabel.Visible = false; ctlTALinkButton.Text = ta.DocumentID.DocumentNo; ctlTALinkButton.OnClientClick = "window.open('../Programs/DocumentView.aspx?wfid=" + wf.WorkFlowID.ToString() + "')"; ctlBusinessChk.Checked = !(row.IsIsBusinessPurposeNull() || row.IsBusinessPurpose == false); ctlTrainingChk.Checked = !(row.IsIsTrainningPurposeNull() || row.IsTrainningPurpose == false); ctlOtherChk.Checked = !(row.IsIsOtherPurposeNull() || row.IsOtherPurpose == false); ctlOther.Text = row.IsOtherPurposeDescriptionNull() ? String.Empty : row.OtherPurposeDescription; ctlCountry.Text = row.IsCountryNull() ? String.Empty : row.Country; if (!row.IsFromDateNull()) { ctlFromDateCal.Value = row.FromDate; } if (!row.IsToDateNull()) { ctlToDateCal.Value = row.ToDate; } ctlPersonLevel.Text = row.IsPersonalLevelNull() ? String.Empty : row.PersonalLevel; ctlExchangeRateForPerdiem.Text = row.IsExchangeRateForUSDAdvanceNull() ? String.Empty : row.ExchangeRateForUSDAdvance.ToString(); } else { ResetTADataZone(); if (expenseDS.FnExpenseAdvance.Rows.Count > 0) { ctlTANoLookup.Enabled = false; ctlDeleteTA.Enabled = false; } } BindAdvanceGridView(); BindRemittanceGridview(); ctlUpdatePanelExpenseGeneral.Update(); }
public void BindDifferenceAmountSummary() { FnExpenseDocumentService.CalculateTotalExpense(this.TransactionId, this.ExpDocumentID, IsRepOffice); FnExpenseDocumentService.CalculateDifferenceAmount(this.TransactionId, this.ExpDocumentID, IsRepOffice); ExpenseDataSet expDS = (ExpenseDataSet)TransactionService.GetDS(this.TransactionId); if (expDS != null) { ExpenseDataSet.FnExpenseDocumentRow expRow = expDS.FnExpenseDocument.FindByExpenseID(this.ExpDocumentID); if (expRow != null) { if (!IsRepOffice) { DivTotalSummaryForThailand.Style["display"] = "block"; DivTotalSummaryForRepOffice.Style["display"] = "none"; ctlTotalExpense.Text = UIHelper.BindDecimalNumberAccountFormat(expRow.TotalExpense.ToString()); ctlTotalExpense.ForeColor = expRow.TotalExpense < 0 ? System.Drawing.Color.Red : System.Drawing.Color.Black; ctlTotalAdvance.Text = UIHelper.BindDecimalNumberAccountFormat((-1 * expRow.TotalAdvance).ToString()); ctlTotalAdvance.ForeColor = (-1 * expRow.TotalAdvance) < 0 ? System.Drawing.Color.Red : System.Drawing.Color.Black; ctlTotalRemitted.Text = UIHelper.BindDecimalNumberAccountFormat(expRow.TotalRemittance.ToString()); ctlTotalRemitted.ForeColor = expRow.TotalRemittance < 0 ? System.Drawing.Color.Red : System.Drawing.Color.Black; ctlDifferenceAmount.Text = UIHelper.BindDecimalNumberAccountFormat(expRow.DifferenceAmount.ToString()); ctlDifferenceAmount.ForeColor = expRow.DifferenceAmount < 0 ? System.Drawing.Color.Red : System.Drawing.Color.Black; } else { DivTotalSummaryForThailand.Style["display"] = "none"; DivTotalSummaryForRepOffice.Style["display"] = "block"; ctlTHBCurrencyTab.Visible = false; ctlMainCurrencyTab.Visible = false; if (CounterCashierID.HasValue) { Dbpb pb = ScgDbQueryProvider.DbPBQuery.FindByIdentity(CounterCashierID.Value); DbCurrency localCurrency = SsDbQueryProvider.DbCurrencyQuery.FindByIdentity(LocalCurrencyID.HasValue ? LocalCurrencyID.Value : (short)0); DbCurrency mainCurrency = SsDbQueryProvider.DbCurrencyQuery.FindByIdentity(pb.MainCurrencyID.HasValue ? pb.MainCurrencyID.Value : (short)0); if (localCurrency != null) { ctlLocalCurrencyTab.HeaderText = localCurrency.Symbol; } if (mainCurrency != null) { ctlMainCurrencyTab.HeaderText = mainCurrency.Symbol; } } #region Amount LocalCurrency Tab ctlLocalCurrencyTab.Visible = true; ctlTotalExpenseLocal.Text = UIHelper.BindDecimalNumberAccountFormat(expRow.TotalExpenseLocalCurrency.ToString()); ctlTotalExpenseLocal.ForeColor = expRow.TotalExpenseLocalCurrency < 0 ? System.Drawing.Color.Red : System.Drawing.Color.Black; if (!expRow.IsTotalAdvanceLocalCurrencyNull()) { ctlTotalAdvanceLocal.Text = UIHelper.BindDecimalNumberAccountFormat((-1 * expRow.TotalAdvanceLocalCurrency).ToString()); ctlTotalAdvanceLocal.ForeColor = (-1 * expRow.TotalAdvanceLocalCurrency) < 0 ? System.Drawing.Color.Red : System.Drawing.Color.Black; } if (!expRow.IsTotalRemittanceLocalCurrencyNull()) { ctlTotalRemittanceLocal.Text = UIHelper.BindDecimalNumberAccountFormat(expRow.TotalRemittanceLocalCurrency.ToString()); ctlTotalRemittanceLocal.ForeColor = expRow.TotalRemittanceLocalCurrency < 0 ? System.Drawing.Color.Red : System.Drawing.Color.Black; } if (!expRow.IsDifferenceAmountLocalCurrencyNull()) { ctlDifferenceAmtLocal.Text = UIHelper.BindDecimalNumberAccountFormat(expRow.DifferenceAmountLocalCurrency.ToString()); ctlDifferenceAmtLocal.ForeColor = expRow.DifferenceAmountLocalCurrency < 0 ? System.Drawing.Color.Red : System.Drawing.Color.Black; } #endregion SS.Standard.WorkFlow.DTO.WorkFlow workflow = SS.Standard.WorkFlow.Query.WorkFlowQueryProvider.WorkFlowQuery.GetWorkFlowByDocumentID(expRow.DocumentID); if (workflow != null && workflow.CurrentState.Ordinal >= 5) { if (UserAccount.IsAccountant || UserAccount.IsPayment) { #region Amount MainCurrency Tab if (expRow.LocalCurrencyID != expRow.MainCurrencyID) { ctlMainCurrencyTab.Visible = true; } ctlTotalExpenseMainCurrency.Text = UIHelper.BindDecimalNumberAccountFormat(expRow.TotalExpenseMainCurrency.ToString()); ctlTotalExpenseMainCurrency.ForeColor = expRow.TotalExpenseMainCurrency < 0 ? System.Drawing.Color.Red : System.Drawing.Color.Black; ctlTotalAdvanceMainCurrency.Text = UIHelper.BindDecimalNumberAccountFormat((-1 * expRow.TotalAdvanceMainCurrency).ToString()); ctlTotalAdvanceMainCurrency.ForeColor = (-1 * expRow.TotalAdvanceMainCurrency) < 0 ? System.Drawing.Color.Red : System.Drawing.Color.Black; ctlTotalRemittanceMainCurrency.Text = UIHelper.BindDecimalNumberAccountFormat(expRow.TotalRemittanceMainCurrency.ToString()); ctlTotalRemittanceMainCurrency.ForeColor = expRow.TotalRemittanceMainCurrency < 0 ? System.Drawing.Color.Red : System.Drawing.Color.Black; ctlDifferenceAmtMainCurrency.Text = UIHelper.BindDecimalNumberAccountFormat(expRow.DifferenceAmountMainCurrency.ToString()); ctlDifferenceAmtMainCurrency.ForeColor = expRow.DifferenceAmountMainCurrency < 0 ? System.Drawing.Color.Red : System.Drawing.Color.Black; #endregion #region Amount THB Currency Tab ctlTHBCurrencyTab.Visible = true; ctlTotalExpenseTHB.Text = UIHelper.BindDecimalNumberAccountFormat(expRow.TotalExpense.ToString()); ctlTotalExpenseTHB.ForeColor = expRow.TotalExpense < 0 ? System.Drawing.Color.Red : System.Drawing.Color.Black; ctlTotalAdvanceTHB.Text = UIHelper.BindDecimalNumberAccountFormat((-1 * expRow.TotalAdvance).ToString()); ctlTotalAdvanceTHB.ForeColor = (-1 * expRow.TotalAdvance) < 0 ? System.Drawing.Color.Red : System.Drawing.Color.Black; ctlTotalRemittanceTHB.Text = UIHelper.BindDecimalNumberAccountFormat(expRow.TotalRemittance.ToString()); ctlTotalRemittanceTHB.ForeColor = expRow.TotalRemittance < 0 ? System.Drawing.Color.Red : System.Drawing.Color.Black; ctlDifferenceAmtTHB.Text = UIHelper.BindDecimalNumberAccountFormat(expRow.DifferenceAmount.ToString()); ctlDifferenceAmtTHB.ForeColor = expRow.DifferenceAmount < 0 ? System.Drawing.Color.Red : System.Drawing.Color.Black; #endregion } } } } } }
protected void ctlAdvanceGridview_DataBound(object sender, EventArgs e) { ExpenseDataSet expenseDS = (ExpenseDataSet)TransactionService.GetDS(this.TransactionId); if (expenseDS != null) { ExpenseDataSet.FnExpenseDocumentRow row = expenseDS.FnExpenseDocument.FindByExpenseID(this.ExpDocumentID); SS.Standard.WorkFlow.DTO.WorkFlow wf = null; int Ordinal = 0; if (Request["wfid"] != null) { WorkFlowID = UIHelper.ParseLong(Request["wfid"].ToString()); wf = WorkFlowQueryProvider.WorkFlowQuery.FindByIdentity(WorkFlowID); CurrentState = wf.CurrentState.Name; Ordinal = wf.CurrentState.Ordinal; } //DbCurrency localCurrency = null; DbCurrency mainCurrency = null; //if (!row.IsLocalCurrencyIDNull()) //{ // localCurrency = SsDbQueryProvider.DbCurrencyQuery.FindByIdentity(row.LocalCurrencyID); //} if (!row.IsMainCurrencyIDNull()) { mainCurrency = SsDbQueryProvider.DbCurrencyQuery.FindByIdentity(row.MainCurrencyID); } //if (localCurrency != null) //{ // ctlAdvanceGridView.Columns[4].HeaderText = string.Format(GetMessage("AmountCurrencyHeaderColumn"), "(" + localCurrency.Symbol + ")"); //} //else //{ ctlAdvanceGridView.Columns[4].HeaderText = string.Format(GetMessage("AmountCurrencyHeaderColumn"), ""); //} if (mainCurrency != null) { ctlAdvanceGridView.Columns[5].HeaderText = string.Format(GetMessage("AmountCurrencyHeaderColumn"), "(" + mainCurrency.Symbol + ")"); ctlAdvanceGridView.HeaderRow.Cells[5].Text = string.Format(GetMessage("AmountCurrencyHeaderColumn"), "(" + mainCurrency.Symbol + ")"); } else { ctlAdvanceGridView.Columns[5].HeaderText = string.Format(GetMessage("AmountCurrencyHeaderColumn"), ""); } string expenseType = FnExpenseDocumentService.GetExpenseType(this.ExpDocumentID, this.TransactionId); bool isRepOffice = row.IsIsRepOfficeNull() ? false : row.IsRepOffice; if (expenseType.Equals(ZoneType.Domestic)) { if (isRepOffice) { if (CurrentState.Equals(WorkFlowStateFlag.WaitVerify) || Ordinal > 5) { ctlAdvanceGridView.Columns[4].Visible = false; ctlAdvanceGridView.Columns[5].Visible = true; ctlAdvanceGridView.Columns[6].Visible = true; } else { ctlAdvanceGridView.Columns[4].Visible = false; ctlAdvanceGridView.Columns[5].Visible = true; ctlAdvanceGridView.Columns[6].Visible = false; } } else { ctlAdvanceGridView.Columns[4].Visible = false; ctlAdvanceGridView.Columns[5].Visible = false; ctlAdvanceGridView.Columns[6].Visible = true; } } else { if (isRepOffice) { if (CurrentState.Equals(WorkFlowStateFlag.WaitVerify) || Ordinal > 5) { ctlAdvanceGridView.Columns[4].Visible = false; ctlAdvanceGridView.Columns[5].Visible = true; ctlAdvanceGridView.Columns[6].Visible = true; } else { ctlAdvanceGridView.Columns[4].Visible = false; ctlAdvanceGridView.Columns[5].Visible = true; ctlAdvanceGridView.Columns[6].Visible = false; } } else { ctlAdvanceGridView.Columns[4].Visible = false; ctlAdvanceGridView.Columns[5].Visible = false; ctlAdvanceGridView.Columns[6].Visible = true; } } } if (ctlAdvanceGridView.Rows.Count == 0) { ctlTANoLookup.Enabled = true; ctlDeleteTA.Enabled = true; //this.ClearRemittanceGridview(); } }