public void Save() { FnExpenseDocument expenseDocument = new FnExpenseDocument(this.ExpDocumentID); if (ctlBusinessChk.Checked) { expenseDocument.IsBusinessPurpose = true; } if (ctlTrainingChk.Checked) { expenseDocument.IsTrainningPurpose = true; } if (ctlOtherChk.Checked) { expenseDocument.IsOtherPurpose = true; expenseDocument.OtherPurposeDescription = ctlOther.Text; } if (!string.IsNullOrEmpty(ctlFromDateCal.DateValue)) { expenseDocument.FromDate = UIHelper.ParseDate(ctlFromDateCal.DateValue); } if (!string.IsNullOrEmpty(ctlToDateCal.DateValue)) { expenseDocument.ToDate = UIHelper.ParseDate(ctlToDateCal.DateValue); } expenseDocument.Country = ctlCountry.Text; //expenseDocument.PersonalLevel = ctlPersonLevel.Text; //expenseDocument.ExchangeRateForUSDAdvance = UIHelper.ParseDouble(ctlExchangeRateForPerdiem.Text); //expenseDocument.ExchangeRateForUSD = UIHelper.ParseDouble(ctlExchangeRateDeparture.Text); FnExpenseDocumentService.UpdateExpenseDocumentAdvanceToTransaction(expenseDocument, this.TransactionId); BindControl(true); }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { this.TxId = new Guid(Request.QueryString["txId"]); this.ExpDocumentID = Convert.ToInt64(string.IsNullOrEmpty(Request.QueryString["expId"]) ? "-1" : Request.QueryString["expId"]); this.InitialFlag = Request.QueryString["mode"]; long? documentID = string.IsNullOrEmpty(Request.QueryString["docId"]) ? (long?)null : ((Convert.ToInt64(Request.QueryString["docId"]) < 0) ? (long?)null : Convert.ToInt64(Request.QueryString["docId"])); string invoiceType = string.IsNullOrEmpty(Request.QueryString["invType"]) ? InvoiceType.General : Request.QueryString["invType"].ToString(); this.VisibleFields = FnExpenseDocumentService.GetVisibleFields(documentID); this.EditableFields = FnExpenseDocumentService.GetEditableFields(documentID); long?invoiceId = null; if (!string.IsNullOrEmpty(Request.QueryString["invId"])) { invoiceId = UIHelper.ParseLong(Request.QueryString["invId"]); } ctlInvoiceForm.DocumentType = Request.QueryString["docType"]; ctlInvoiceForm.ExpDocumentID = this.ExpDocumentID; if (invoiceType.Equals(InvoiceType.Mileage)) { ctlInvoiceForm.InitailizeInvoice(this.InitialFlag, invoiceId, this.TxId, InvoiceType.Mileage); } else { ctlInvoiceForm.Initialize(this.InitialFlag, invoiceId, this.TxId); } } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { this.TxId = new Guid(Request.QueryString["txID"]); this.ExpDocumentID = Convert.ToInt64(string.IsNullOrEmpty(Request.QueryString["expId"]) ? "-1" : Request.QueryString["expId"]); this.InitialFlag = Request.QueryString["mode"]; long? documentID = string.IsNullOrEmpty(Request.QueryString["docId"]) ? (long?)null : ((Convert.ToInt64(Request.QueryString["docId"]) < 0) ? (long?)null : Convert.ToInt64(Request.QueryString["docId"])); string documentType = string.IsNullOrEmpty(Request.QueryString["docType"]) ? ZoneType.Domestic : Request.QueryString["docType"]; this.VisibleFields = FnExpenseDocumentService.GetVisibleFields(documentID); this.EditableFields = FnExpenseDocumentService.GetEditableFields(documentID); long?mileageId = null; if (!string.IsNullOrEmpty(Request.QueryString["mileageId"])) { mileageId = UIHelper.ParseLong(Request.QueryString["mileageId"]); } ctlMileage.DocumentType = documentType; ctlMileage.DocumentID = documentID; ctlMileage.ExpDocumentID = this.ExpDocumentID; ctlMileage.Initialize(this.InitialFlag, mileageId, this.TxId); } }
public void BindSummary() { if (ctlExpenseItemGrid.Rows.Count > 0) { double totalAmount = 0; foreach (GridViewRow row in ctlExpenseItemGrid.Rows) { if (!IsRepOffice) { Literal ctlLblAmount = ctlExpenseItemGrid.Rows[row.RowIndex].FindControl("ctlLblAmount") as Literal; totalAmount += UIHelper.ParseDouble(ctlLblAmount.Text); } else { Literal ctlLblLocalCurrencyAmount = ctlExpenseItemGrid.Rows[row.RowIndex].FindControl("ctlLblAmountLocalCurrency") as Literal; totalAmount += UIHelper.ParseDouble(ctlLblLocalCurrencyAmount.Text); } } ctlTotalAmountTHB.Text = UIHelper.BindDecimal(totalAmount.ToString()); } ctlAmount.Text = UIHelper.BindDecimal(FnExpenseDocumentService.GetExpenseTotalBaseAmount(this.TransactionId, ExpDocumentID).ToString()); ctlNetAmount.Text = UIHelper.BindDecimal(FnExpenseDocumentService.GetExpenseTotalNetAmount(this.TransactionId, ExpDocumentID).ToString()); ctlVatAmount.Text = UIHelper.BindDecimal(FnExpenseDocumentService.GetExpenseTotalVatAmount(this.TransactionId, ExpDocumentID).ToString()); ctlWHTAmount.Text = UIHelper.BindDecimal(FnExpenseDocumentService.GetExpenseTotalWHTAmount(this.TransactionId, ExpDocumentID).ToString()); ctlUpdatePanelViewByAccount.Update(); }
private string GetPerdiemType(FnExpensePerdiemItem item, Guid txId) { ExpenseDataSet ds = (ExpenseDataSet)TransactionService.GetDS(txId); ExpenseDataSet.FnExpensePerdiemRow perRow = ds.FnExpensePerdiem.FindByExpensePerdiemID(item.ExpensePerdiem.ExpensePerdiemID); return(FnExpenseDocumentService.GetExpenseType(perRow.ExpenseID, txId)); }
public void SaveExpenseRecommend() { if (ctlSimpleExpense.Visible) { ctlSimpleExpense.SaveExpenseRecommend(); FnExpenseDocumentService.CalculateTotalExpense(this.TransactionId, this.ExpDocumentID, IsRepOffice); FnExpenseDocumentService.CalculateDifferenceAmount(this.TransactionId, this.ExpDocumentID, IsRepOffice); this.BindExpenseGrid(); ExpenseDocumentEditor.NotifyPaymentDetailChange(); } }
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; } } }
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; } } }
protected void TA_OnObjectLookUpCalling(object sender, ObjectLookUpCallingEventArgs e) { UserControls.LOV.SCG.DB.TALookup taLookUp = sender as UserControls.LOV.SCG.DB.TALookup; string expenseType = FnExpenseDocumentService.GetExpenseType(this.ExpDocumentID, this.TransactionId); if (expenseType.Equals(ZoneType.Domestic)) { taLookUp.TravelBy = TravellBy.Domestic; } else { taLookUp.TravelBy = TravellBy.Foreign; } taLookUp.RequesterID = this.RequesterID.ToString(); taLookUp.CompanyID = this.CompanyID.ToString(); }
public void BindAdvanceGridView() { ExpenseDataSet expenseDS = (ExpenseDataSet)TransactionService.GetDS(this.TransactionId); ExpenseDataSet.FnExpenseAdvanceRow[] rows = (ExpenseDataSet.FnExpenseAdvanceRow[])expenseDS.FnExpenseAdvance.Select(); List <long> advanceIdList = new List <long>(); foreach (ExpenseDataSet.FnExpenseAdvanceRow row in rows) { // Prepare list of advance id for query advanceIdList.Add(row.AdvanceID); } if (advanceIdList.Count > 0) { if (ScgeAccountingQueryProvider.AvAdvanceDocumentQuery.FindAdvancDocumentByAdvanceIds(advanceIdList).Count > 0) { IsEmptyAdvance = false; } else { IsEmptyAdvance = true; } ctlAdvanceGridView.DataSource = ScgeAccountingQueryProvider.AvAdvanceDocumentQuery.FindAdvancDocumentByAdvanceIds(advanceIdList); ctlAdvanceGridView.DataBind(); if (!this.IsRepOffice) { ctlExchangeRateForPerdiem.Text = FnExpenseDocumentService.GetAdvanceExchangeRate(this.TransactionId, ParameterServices.USDCurrencyID).AdvanceExchangeRateAmount.ToString("#,##0.00000"); } else { ctlExchangeRateForPerdiem.Text = FnExpenseDocumentService.GetAdvanceExchangeRateRepOffice(this.TransactionId, ParameterServices.USDCurrencyID, this.ExpDocumentID).AdvanceExchangeRateAmount.ToString("#,##0.00000"); } } else { IsEmptyAdvance = true; ctlAdvanceGridView.DataSource = null; ctlAdvanceGridView.DataBind(); ctlExchangeRateForPerdiem.Text = "0.00000"; } ctlUpdatePanelExpenseGeneral.Update(); }
public void ClearAdvanceGridview() { ExpenseDataSet expenseDS = (ExpenseDataSet)TransactionService.GetDS(this.TransactionId); ExpenseDataSet.FnExpenseDocumentRow expRow = expenseDS.FnExpenseDocument.FindByExpenseID(this.ExpDocumentID); ExpenseDataSet.FnExpenseAdvanceRow[] rows = (ExpenseDataSet.FnExpenseAdvanceRow[])expenseDS.FnExpenseAdvance.Select(); foreach (ExpenseDataSet.FnExpenseAdvanceRow row in rows) { double totalAmount = FnExpenseDocumentService.DeleteExpenseAdvanceFromTransaction(this.TransactionId, row.AdvanceID, (double)expRow.TotalAdvance); FnExpenseDocumentService.SetTotalAdvance(this.TransactionId, 0, totalAmount); FnExpenseDocumentService.RefreshRemittance(this.TransactionId, this.ExpDocumentID); row.Delete(); } this.BindAdvanceGridView(); }
protected void ExpensesMPA_OnObjectLookUpReturn(object sender, ObjectLookUpReturnArgs e) { if (e.ObjectReturn != null) { IList <SCG.eAccounting.DTO.ValueObject.ExpensesMPA> list = (IList <SCG.eAccounting.DTO.ValueObject.ExpensesMPA>)e.ObjectReturn; FnExpenseDocumentService.AddExpenseMPAToTransaction(this.TransactionId, this.ExpDocumentID, list); this.BindExpenseMPAGridView(); if (!ExpenseDocumentEditor.NotifyUpdateExpense()) { return; } ExpenseDocumentEditor.NotifyPaymentDetailChange(); } ctlUpdatePanelExpenseGeneral.Update(); }
protected void ctlctlAddExpenseMPA_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName.Equals("DeleteExpensesMPA")) { int rowIndex = ((GridViewRow)((ImageButton)e.CommandSource).NamingContainer).RowIndex; long mpaDocumentID = UIHelper.ParseLong(ctlExpeseMPAGridView.DataKeys[rowIndex]["MPADocumentID"].ToString()); FnExpenseDocumentService.DeleteExpenseMPAFromTransaction(this.TransactionId, mpaDocumentID); this.BindExpenseMPAGridView(); this.ExpenseDocumentEditor.NotifyPaymentDetailChange(); } else if (e.CommandName.Equals("PopupDocument")) { int rowIndex = ((GridViewRow)((LinkButton)e.CommandSource).NamingContainer).RowIndex; long workflowID = UIHelper.ParseLong(ctlExpeseMPAGridView.DataKeys[rowIndex]["WorkflowID"].ToString()); ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), string.Empty, "window.open('../Programs/DocumentView.aspx?wfid=" + workflowID.ToString() + "')", true); } }
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; } }
protected void TA_OnObjectLookUpReturn(object sender, ObjectLookUpReturnArgs e) { ctlAddAdvance.Enabled = false; TADocumentObj TA = (TADocumentObj)e.ObjectReturn; ctlAdvanceGridView.Columns[5].Visible = false; // 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); avCriteria.TADocumentID = TA.TADocumentID; FnExpenseDocumentService.SetTA(this.TransactionId, this.ExpDocumentID, avCriteria); if (TA.TADocumentID.HasValue) { ctlTANoLabel.Visible = false; ctlTALinkButton.Text = TA.DocumentNo; ctlTALinkButton.OnClientClick = "window.open('../Programs/DocumentView.aspx?wfid=" + TA.WorkflowID.ToString() + "')"; ctlBusinessChk.Checked = TA.IsBusinessPurpose == null ? false : bool.Parse(TA.IsBusinessPurpose.ToString()); ctlTrainingChk.Checked = TA.IsTrainningPurpose == null ? false : bool.Parse(TA.IsTrainningPurpose.ToString()); ctlOtherChk.Checked = TA.IsOtherPurpose == null ? false : bool.Parse(TA.IsOtherPurpose.ToString()); ctlOther.Text = TA.OtherPurposeDescription.ToString(); ctlFromDateCal.DateValue = UIHelper.ToDateString(TA.FromDate); ctlToDateCal.DateValue = UIHelper.ToDateString(TA.ToDate); ctlCountry.Text = TA.Country; } else { ResetTADataZone(); } this.BindAdvanceGridView(); this.BindRemittanceGridview(); ExpenseDocumentEditor.NotifyPaymentDetailChange(); ctlUpdatePanelExpenseGeneral.Update(); }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { this.TxId = new Guid(Request.QueryString["txId"]); this.ExpDocumentID = Convert.ToInt64(string.IsNullOrEmpty(Request.QueryString["expId"]) ? "-1" : Request.QueryString["expId"]); this.InitialFlag = Request.QueryString["mode"]; long?documentID = string.IsNullOrEmpty(Request.QueryString["docId"]) ? (long?)null : ((Convert.ToInt64(Request.QueryString["docId"]) < 0) ? (long?)null : Convert.ToInt64(Request.QueryString["docId"])); this.VisibleFields = FnExpenseDocumentService.GetVisibleFields(documentID); this.EditableFields = FnExpenseDocumentService.GetEditableFields(documentID); long?perdiemId = null; if (!string.IsNullOrEmpty(Request.QueryString["perdiemId"])) { perdiemId = UIHelper.ParseLong(Request.QueryString["perdiemId"]); } ctlPerdiem.Initialize(this.InitialFlag, perdiemId, this.ExpDocumentID, this.TxId); } }
protected void ctlAdvanceGridview_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName.Equals("DeleteAdvance")) { int rowIndex = ((GridViewRow)((ImageButton)e.CommandSource).NamingContainer).RowIndex; long AdvanceID = UIHelper.ParseLong(ctlAdvanceGridView.DataKeys[rowIndex]["AdvanceID"].ToString()); Literal ctlLblAmount = (Literal)ctlAdvanceGridView.Rows[rowIndex].FindControl("ctlLblAmount"); double totalAmount = FnExpenseDocumentService.DeleteExpenseAdvanceFromTransaction(this.TransactionId, AdvanceID, Convert.ToDouble(ctlLblAmount.Text)); FnExpenseDocumentService.SetTotalAdvance(this.TransactionId, 0, totalAmount); FnExpenseDocumentService.RefreshRemittance(this.TransactionId, this.ExpDocumentID); this.BindAdvanceGridView(); this.BindRemittanceGridview(); this.ExpenseDocumentEditor.NotifyPaymentDetailChange(); this.AdvanceNoTemp = string.Empty; } else if (e.CommandName.Equals("PopupDocument")) { int rowIndex = ((GridViewRow)((LinkButton)e.CommandSource).NamingContainer).RowIndex; long workflowID = UIHelper.ParseLong(ctlAdvanceGridView.DataKeys[rowIndex]["WorkflowID"].ToString()); ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), string.Empty, "window.open('../Programs/DocumentView.aspx?wfid=" + workflowID.ToString() + "')", true); } }
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 } } } } } }
public void UpdateTransactionDocument(Guid TxID, SCGDocument document, bool haveReceiver, bool haveApprover) { Spring.Validation.ValidationErrors errors = new Spring.Validation.ValidationErrors(); try { this.ValidateSCGDocument(document, haveReceiver, haveApprover); } catch (ServiceValidationException ex) { errors.MergeErrors(ex.ValidationErrors); } if (!errors.IsEmpty) { throw new ServiceValidationException(errors); } DataSet ds = TransactionService.GetDS(TxID); DataTable documentTable = ds.Tables["Document"]; if (documentTable.Rows.Count > 0) { DataRow documentRow = documentTable.Rows[0]; documentRow.BeginEdit(); if (document.CompanyID != null) { documentRow["CompanyID"] = document.CompanyID.CompanyID; } if (document.CreatorID != null) { documentRow["CreatorID"] = document.CreatorID.Userid; } if (document.RequesterID != null) { documentRow["RequesterID"] = document.RequesterID.Userid; } if (document.ApproverID != null) { documentRow["ApproverID"] = document.ApproverID.Userid; } if (document.ReceiverID != null) { documentRow["ReceiverID"] = document.ReceiverID.Userid; } //documentRow["DocumentNo"] = document.DocumentNo; if (document.DocumentType != null) { documentRow["DocumentTypeID"] = document.DocumentType.DocumentTypeID; } IList <object> advanceEditableField = AvAdvanceDocumentService.GetEditableFields(document.DocumentID, null); IList <object> expenseEditableField = FnExpenseDocumentService.GetEditableFields(document.DocumentID); IList <object> remittanceEditableField = FnRemittanceService.GetEditableFields(document.DocumentID); IList <object> fixedAdvanceEditableField = FixedAdvanceDocumentService.GetEditableFields(document.DocumentID); if (advanceEditableField.Contains(AdvanceFieldGroup.VerifyDetail) || expenseEditableField.Contains(ExpenseFieldGroup.VerifyDetail) || remittanceEditableField.Contains(RemittanceFieldGroup.VerifyDetail) || fixedAdvanceEditableField.Contains(FixedAdvanceFieldGroup.VerifyDetail)) { //add new field if (!string.IsNullOrEmpty(document.BranchCode)) { documentRow["BranchCode"] = document.BranchCode; } if (!string.IsNullOrEmpty(document.BusinessArea)) { documentRow["BusinessArea"] = document.BusinessArea; } else { documentRow["BusinessArea"] = string.Empty; } if (!string.IsNullOrEmpty(document.Supplementary)) { documentRow["Supplementary"] = document.Supplementary; } else { documentRow["Supplementary"] = string.Empty; } if (document.PaymentMethodID.HasValue && document.PaymentMethodID > 0) { documentRow["PaymentMethodID"] = document.PaymentMethodID.Value; } if (document.PostingDate.HasValue && document.PostingDate.Value != DateTime.MinValue) { documentRow["PostingDate"] = document.PostingDate; } if (document.BaseLineDate.HasValue && document.BaseLineDate.Value != DateTime.MinValue) { documentRow["BaseLineDate"] = document.BaseLineDate; } if (!string.IsNullOrEmpty(document.BankAccount)) { documentRow["BankAccount"] = document.BankAccount; } } if (!string.IsNullOrEmpty(document.ReferenceNo)) { documentRow["ReferenceNo"] = document.ReferenceNo; } else { if (!documentRow["DocumentNo"].ToString().StartsWith("EHR")) { documentRow["ReferenceNo"] = document.ReferenceNo; } } documentRow["IsVerifyImage"] = document.IsVerifyImage; documentRow["Subject"] = document.Subject; documentRow["Memo"] = document.Memo; documentRow["Active"] = document.Active; documentRow["CreBy"] = UserAccount.UserID; documentRow["CreDate"] = DateTime.Now; documentRow["UpdBy"] = UserAccount.UserID; documentRow["UpdDate"] = DateTime.Now; documentRow["UpdPgm"] = UserAccount.CurrentProgramCode; documentRow.EndEdit(); } }
public void ValidateSCGDocument(SCGDocument document, bool haveReceiver, bool haveApprover) { Spring.Validation.ValidationErrors errors = new Spring.Validation.ValidationErrors(); // DocumentSubTypeID = ใบของบประมาณระหว่างงวด. Not use in eAccounting. // Must specific Approver. if (document.CompanyID == null) { errors.AddError("Provider.Error", new Spring.Validation.ErrorMessage("CompanyIsRequired")); } else { DbCompany company = ScgDbQueryProvider.DbCompanyQuery.FindByIdentity(document.CompanyID.CompanyID); if (company == null) { errors.AddError("Provider.Error", new Spring.Validation.ErrorMessage("CompanyIsRequired")); } } if (document.PaymentMethodID == 39) { if (document.RequesterID.Userid != document.ReceiverID.Userid) { errors.AddError("Provider.Error", new Spring.Validation.ErrorMessage("ReceiverCannotBeDifferentRequester")); } } if (string.IsNullOrEmpty(document.Subject)) { errors.AddError("Provider.Error", new Spring.Validation.ErrorMessage("SubjectIsRequired")); } if (haveReceiver) { if (document.ReceiverID == null) { errors.AddError("Provider.Error", new Spring.Validation.ErrorMessage("ReceiverIsRequired")); } else { SuUser receiver = QueryProvider.SuUserQuery.FindByIdentity(document.ReceiverID.Userid); if (document.ReceiverID == null) { errors.AddError("Provider.Error", new Spring.Validation.ErrorMessage("ReceiverIsRequired")); } } } if (haveApprover) { if (document.ApproverID == null) { errors.AddError("Provider.Error", new Spring.Validation.ErrorMessage("ApproverIsRequired")); } else { SuUser approver = QueryProvider.SuUserQuery.FindByIdentity(document.ApproverID.Userid); if (approver == null) { errors.AddError("Provider.Error", new Spring.Validation.ErrorMessage("ApproverIsRequired")); } } } if (document.RequesterID == null) { errors.AddError("Provider.Error", new Spring.Validation.ErrorMessage("RequesterIsRequired")); } else { SuUser requester = QueryProvider.SuUserQuery.FindByIdentity(document.RequesterID.Userid); if (requester == null) { errors.AddError("Provider.Error", new Spring.Validation.ErrorMessage("RequesterIsRequired")); } } //add new field //IList<object> advanceEditableField = AvAdvanceDocumentService.GetEditableFields(document.DocumentID, null); IList <object> expenseEditableField = FnExpenseDocumentService.GetEditableFields(document.DocumentID); IList <object> remittanceEditableField = FnRemittanceService.GetEditableFields(document.DocumentID); if (/*advanceEditableField.Contains(AdvanceFieldGroup.VerifyDetail) ||*/ expenseEditableField.Contains(ExpenseFieldGroup.VerifyDetail) || remittanceEditableField.Contains(RemittanceFieldGroup.VerifyDetail)) { if (string.IsNullOrEmpty(document.BranchCode)) { errors.AddError("Provider.Error", new Spring.Validation.ErrorMessage("BranchCodeIsRequired")); } //if (!document.PaymentMethodID.HasValue) //{ // errors.AddError("Provider.Error", new Spring.Validation.ErrorMessage("PaymentMethodID_IsRequired")); //} if (!document.PostingDate.HasValue) { errors.AddError("Provider.Error", new Spring.Validation.ErrorMessage("PostingDateIsRequired")); } if (!document.BaseLineDate.HasValue) { errors.AddError("Provider.Error", new Spring.Validation.ErrorMessage("BaseLineDateIsRequired")); } } if (!errors.IsEmpty) { throw new ServiceValidationException(errors); } }
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(); } }
public bool ApprovePosting(long DocID, DocumentKind DocKind) { try { bool isSuccess = true; bool ChangeState = false; SCGDocument doc = ScgeAccountingQueryProvider.SCGDocumentQuery.GetSCGDocumentByDocumentID(DocID); if (doc == null) { } else if (!CanApprove(DocID, DocKind.ToString())) { } else if (this.GetPostingService(DocKind.ToString()).GetDocumentStatus(DocID, DocKind.ToString()) == "A") { } else { #region Approve IList <BAPIApproveReturn> bapiReturn = this.GetPostingService(DocKind.ToString()).BAPIApprove(DocID, DocKind.ToString(), this.UserAccount.UserID); if (DocKind.ToString() == DocumentKind.ExpenseRemittance.ToString()) { FnExpenseDocument docExpense = ScgeAccountingQueryProvider.FnExpenseDocumentQuery.GetExpenseDocumentByDocumentID(DocID); if (GetPostingService(DocKind.ToString()).GetDocumentStatus(DocID, DocKind.ToString()) == "A") { docExpense.RemittancePostingStatus = "C"; FnExpenseDocumentService.SaveOrUpdate(docExpense); } else if (GetPostingService(DocKind.ToString()).GetDocumentStatus(DocID, DocKind.ToString()) == "PP") { docExpense.RemittancePostingStatus = "PP"; FnExpenseDocumentService.SaveOrUpdate(docExpense); } } else { if (this.GetPostingService(DocKind.ToString()).GetDocumentStatus(DocID, DocKind.ToString()) == "A") { doc.PostingStatus = "C"; SCGDocumentService.SaveOrUpdate(doc); } else if (this.GetPostingService(DocKind.ToString()).GetDocumentStatus(DocID, DocKind.ToString()) == "PP") { doc.PostingStatus = "PP"; SCGDocumentService.SaveOrUpdate(doc); } } #endregion Approve #region Call WorkFlow for (int i = 0; i < bapiReturn.Count; i++) { if (bapiReturn[i].ApproveStatus != "S") { isSuccess = false; break; } } if (isSuccess) { ChangeState = true; WorkFlowApprove(DocKind.ToString()); } #endregion Call WorkFlow if (ChangeState) { string wfid = System.Web.HttpContext.Current.Request.QueryString["wfid"].ToString(); System.Web.HttpContext.Current.Response.Redirect("SubmitResult.aspx?wfid=" + wfid); } } return(isSuccess); } catch (Exception ex) { throw ex; } }