static public TableError CreateIVBatch(string batch)//create or update batch { //byte exist = ROW_NOT_FOUND; TableError lastError; BatchHeadersTable BatchHeadersTable = Microsoft.Dexterity.Applications.Dynamics.Tables.BatchHeaders; BatchHeadersTable.Key = 1; //BatchHeadersTable.Clear(); BatchHeadersTable.BatchSource.Value = "IV_Trxent"; BatchHeadersTable.BatchNumber.Value = "ISSUE SEMENTARA"; lastError = BatchHeadersTable.Change(); if (lastError == TableError.NoError)//found { //unconditional update to correct value BatchHeadersTable.Series.Value = 5; BatchHeadersTable.BatchFrequency.Value = 1; BatchHeadersTable.PostToGl.Value = true; BatchHeadersTable.Origin.Value = 1; } else //notfound { BatchHeadersTable.Clear(); BatchHeadersTable.BatchSource.Value = "IV_Trxent"; BatchHeadersTable.BatchNumber.Value = "ISSUE SEMENTARA"; BatchHeadersTable.Series.Value = 5; BatchHeadersTable.BatchFrequency.Value = 1; BatchHeadersTable.PostToGl.Value = true; BatchHeadersTable.Origin.Value = 1; } lastError = BatchHeadersTable.Save(); BatchHeadersTable.Close(); return(lastError); }
/* void TotalTax_Change(object sender, EventArgs e) * { * MessageBox.Show(VATInWindow.DocumentAmount.Value.ToString()); * MessageBox.Show(VATInWindow.TotalTax.Value.ToString()); * } * * void VatTotalPpn_Change(object sender, EventArgs e) * { * MessageBox.Show("TotalPpn" + VATInWindow.VatTotalPpn.Value.ToString()); * } */ void PostButton_ClickAfterOriginal(object sender, EventArgs e) { TableError lastError; string trxsource = "", functionalCurrency = "";; DateTime postedDate = new DateTime(1900, 1, 1); short functionalCurrencyIndex = 0; PmTransactionOpenTable PMTrxOpenTable = Vat.Tables.PmTransactionOpen; PmTransactionWorkTable PMTrxWorkTable = Vat.Tables.PmTransactionWork; PmTaxWorkTable PMTaxWorkTable = Vat.Tables.PmTaxWork; PmDistributionWorkOpenTable PMDistributionWorkOpenTable = Vat.Tables.PmDistributionWorkOpen; PmKeyMstrTable PMKeyMstrTable = Vat.Tables.PmKeyMstr; BatchHeadersTable BatchHeadersTable = Vat.Tables.BatchHeaders; if (batchNumber != "") //get relevant data to update PM10100 if batchNumber is set { PMTrxOpenTable.Key = 2; PMTrxOpenTable.Clear(); PMTrxOpenTable.DocumentType.Value = 1; PMTrxOpenTable.VoucherNumber.Value = batchNumber; lastError = PMTrxOpenTable.Get(); if (lastError == TableError.NoError) { postedDate = PMTrxOpenTable.PostedDate.Value; trxsource = PMTrxOpenTable.TrxSource.Value; } PMTrxOpenTable.Close(); MCSetupTable.Key = 1; lastError = MCSetupTable.GetFirst(); //this table is only 1 row if (lastError == TableError.NoError) { functionalCurrency = MCSetupTable.FunctionalCurrency.Value; functionalCurrencyIndex = MCSetupTable.FunctionalCurrencyIndex.Value; } MCSetupTable.Close(); } if (batchNumber != "" && trxsource != "" && functionalCurrencyIndex != 0)//prepare to cleanup when batchnumber is set and relevant data is retrievable { //PM10000 PMTrxWorkTable.Key = 1; PMTrxWorkTable.Clear(); PMTrxWorkTable.BatchSource.Value = "PM_Trxent"; PMTrxWorkTable.BatchNumber.Value = batchNumber; PMTrxWorkTable.VoucherNumberWork.Value = batchNumber; PMTrxWorkTable.Change(); PMTrxWorkTable.Remove(); //PM10500 PMTaxWorkTable.Key = 1; PMTaxWorkTable.RangeClear(); PMTaxWorkTable.Clear(); PMTaxWorkTable.VoucherNumber.Value = batchNumber; PMTaxWorkTable.TrxSource.Value = ""; PMTaxWorkTable.RangeStart(); PMTaxWorkTable.Fill(); PMTaxWorkTable.VoucherNumber.Value = batchNumber; PMTaxWorkTable.TrxSource.Value = ""; PMTaxWorkTable.RangeEnd(); PMTaxWorkTable.RangeRemove(); //PM10100 PMDistributionWorkOpenTable.Key = 5; PMDistributionWorkOpenTable.RangeClear(); PMDistributionWorkOpenTable.Clear(); PMDistributionWorkOpenTable.VoucherNumber.Value = batchNumber; PMDistributionWorkOpenTable.RangeStart(); PMDistributionWorkOpenTable.Fill(); PMDistributionWorkOpenTable.VoucherNumber.Value = batchNumber; PMDistributionWorkOpenTable.RangeEnd(); lastError = PMDistributionWorkOpenTable.ChangeFirst(); while (lastError == TableError.NoError) { PMDistributionWorkOpenTable.PostingStatus.Value = 1; PMDistributionWorkOpenTable.TrxSource.Value = trxsource; PMDistributionWorkOpenTable.PostingDate.Value = postedDate; PMDistributionWorkOpenTable.CurrencyId.Value = functionalCurrency; PMDistributionWorkOpenTable.CurrencyIndex.Value = functionalCurrencyIndex; PMDistributionWorkOpenTable.OriginatingCreditAmount.Value = 0; PMDistributionWorkOpenTable.OriginatingDebitAmount.Value = 0; PMDistributionWorkOpenTable.ExchangeRate.Value = 1; PMDistributionWorkOpenTable.Save(); lastError = PMDistributionWorkOpenTable.ChangeNext(); } //PM00400 PMKeyMstrTable.Key = 1; PMKeyMstrTable.Clear(); PMKeyMstrTable.ControlType.Value = 0; PMKeyMstrTable.ControlNumber.Value = batchNumber; PMKeyMstrTable.Change(); PMKeyMstrTable.DocumentStatus.Value = 2; PMKeyMstrTable.Save(); //SY00500 BatchHeadersTable.Key = 1; BatchHeadersTable.Clear(); BatchHeadersTable.BatchSource.Value = "PM_Trxent"; BatchHeadersTable.BatchNumber.Value = batchNumber; BatchHeadersTable.Change(); BatchHeadersTable.Remove(); PMTrxWorkTable.Close(); PMTaxWorkTable.Close(); PMDistributionWorkOpenTable.Close(); PMKeyMstrTable.Close(); BatchHeadersTable.Close(); } batchNumber = ""; //clear batchNumber unconditionally }