/// <summary> /// Handles the RowCreated event of the GBatchList control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="GridViewRowEventArgs"/> instance containing the event data.</param> private void GBatchList_RowCreated(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow && e.Row.DataItem != null) { var batch = e.Row.DataItem as FinancialBatch; if (batch != null) { var batchRow = new BatchRow { Id = batch.Id, BatchStartDateTime = batch.BatchStartDateTime.Value, Name = batch.Name, AccountingSystemCode = batch.AccountingSystemCode, TransactionCount = batch.Transactions.Count(), ControlAmount = batch.ControlAmount, CampusName = batch.Campus != null ? batch.Campus.Name : "", Status = batch.Status, UnMatchedTxns = batch.Transactions.Any(t => !t.AuthorizedPersonAliasId.HasValue), BatchNote = batch.Note, AccountSummaryList = batch.Transactions .SelectMany(t => t.TransactionDetails) .GroupBy(d => d.AccountId) .Select(s => new BatchAccountSummary { AccountId = s.Key, Amount = s.Sum(d => (decimal?)d.Amount) ?? 0.0M }) .ToList() }; e.Row.DataItem = batchRow; } } }
internal static BatchDto MapToBatch(BatchRow pBatchRow, InventoryLotRow pInventoryLotRow, GenerationRequestRow pGenerationRequestRow) { if (pBatchRow == null || pInventoryLotRow == null || pGenerationRequestRow == null) { return(null); } var _batch = new BatchDto(); _batch.BatchId = pBatchRow.Batch_id; _batch.InventoryStatus = pBatchRow.InventoryStatus; _batch.BoxId = pBatchRow.Box_id; _batch.CustomerAcctId = pBatchRow.Customer_acct_id; _batch.FirstSerial = pBatchRow.First_serial; _batch.LastSerial = pBatchRow.Last_serial; _batch.RequestId = pBatchRow.Request_id; _batch.Selected = false; _batch.LotId = pInventoryLotRow.Lot_id; _batch.ServiceId = pInventoryLotRow.Service_id; _batch.Denomination = pInventoryLotRow.Denomination; _batch.NumberOfBatches = pGenerationRequestRow.Number_of_batches; _batch.BatchSize = pGenerationRequestRow.Batch_size; _batch.DateRequested = pGenerationRequestRow.Date_requested; _batch.DateToProcess = pGenerationRequestRow.Date_to_process; _batch.DateCopleted = pGenerationRequestRow.Date_completed; return(_batch); }
internal static BatchRow MapToBatchRow(BatchDto pBatch) { if (pBatch == null) { return(null); } var _batchRow = new BatchRow(); _batchRow.Batch_id = pBatch.BatchId; _batchRow.InventoryStatus = pBatch.InventoryStatus; _batchRow.First_serial = pBatch.FirstSerial; _batchRow.Last_serial = pBatch.LastSerial; _batchRow.Request_id = pBatch.RequestId; if (pBatch.BoxId > 0) { _batchRow.Box_id = pBatch.BoxId; } if (pBatch.CustomerAcctId > 0) { _batchRow.Customer_acct_id = pBatch.CustomerAcctId; } return(_batchRow); }
/// <summary> /// Handles the DataBound event of the lBatchStatus control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="RowEventArgs"/> instance containing the event data.</param> protected void lBatchStatus_DataBound(object sender, RowEventArgs e) { Literal lBatchStatus = sender as Literal; BatchRow batchRow = e.Row.DataItem as BatchRow; lBatchStatus.Text = string.Format("<span class='{0}'>{1}</span>", batchRow.StatusLabelClass, batchRow.StatusText); }
/// <summary> /// Adds a new record into the <c>Batch</c> table. /// </summary> /// <param name="value">The <see cref="BatchRow"/> object to be inserted.</param> public virtual void Insert(BatchRow value) { string sqlStr = "INSERT INTO [dbo].[Batch] (" + "[batch_id], " + "[status], " + "[first_serial], " + "[last_serial], " + "[request_id], " + "[box_id], " + "[customer_acct_id]" + ") VALUES (" + _db.CreateSqlParameterName("Batch_id") + ", " + _db.CreateSqlParameterName("Status") + ", " + _db.CreateSqlParameterName("First_serial") + ", " + _db.CreateSqlParameterName("Last_serial") + ", " + _db.CreateSqlParameterName("Request_id") + ", " + _db.CreateSqlParameterName("Box_id") + ", " + _db.CreateSqlParameterName("Customer_acct_id") + ")"; IDbCommand cmd = _db.CreateCommand(sqlStr); AddParameter(cmd, "Batch_id", value.Batch_id); AddParameter(cmd, "Status", value.Status); AddParameter(cmd, "First_serial", value.First_serial); AddParameter(cmd, "Last_serial", value.Last_serial); AddParameter(cmd, "Request_id", value.Request_id); AddParameter(cmd, "Box_id", value.IsBox_idNull ? DBNull.Value : (object)value.Box_id); AddParameter(cmd, "Customer_acct_id", value.IsCustomer_acct_idNull ? DBNull.Value : (object)value.Customer_acct_id); cmd.ExecuteNonQuery(); }
/// <summary> /// Reads data from the provided data reader and returns /// an array of mapped objects. /// </summary> /// <param name="reader">The <see cref="System.Data.IDataReader"/> object to read data from the table.</param> /// <param name="startIndex">The index of the first record to map.</param> /// <param name="length">The number of records to map.</param> /// <param name="totalRecordCount">A reference parameter that returns the total number /// of records in the reader object if 0 was passed into the method; otherwise it returns -1.</param> /// <returns>An array of <see cref="BatchRow"/> objects.</returns> protected virtual BatchRow[] MapRecords(IDataReader reader, int startIndex, int length, ref int totalRecordCount) { if (0 > startIndex) { throw new ArgumentOutOfRangeException("startIndex", startIndex, "StartIndex cannot be less than zero."); } if (0 > length) { throw new ArgumentOutOfRangeException("length", length, "Length cannot be less than zero."); } int batch_idColumnIndex = reader.GetOrdinal("batch_id"); int statusColumnIndex = reader.GetOrdinal("status"); int first_serialColumnIndex = reader.GetOrdinal("first_serial"); int last_serialColumnIndex = reader.GetOrdinal("last_serial"); int request_idColumnIndex = reader.GetOrdinal("request_id"); int box_idColumnIndex = reader.GetOrdinal("box_id"); int customer_acct_idColumnIndex = reader.GetOrdinal("customer_acct_id"); System.Collections.ArrayList recordList = new System.Collections.ArrayList(); int ri = -startIndex; while (reader.Read()) { ri++; if (ri > 0 && ri <= length) { BatchRow record = new BatchRow(); recordList.Add(record); record.Batch_id = Convert.ToInt32(reader.GetValue(batch_idColumnIndex)); record.Status = Convert.ToByte(reader.GetValue(statusColumnIndex)); record.First_serial = Convert.ToInt64(reader.GetValue(first_serialColumnIndex)); record.Last_serial = Convert.ToInt64(reader.GetValue(last_serialColumnIndex)); record.Request_id = Convert.ToInt32(reader.GetValue(request_idColumnIndex)); if (!reader.IsDBNull(box_idColumnIndex)) { record.Box_id = Convert.ToInt32(reader.GetValue(box_idColumnIndex)); } if (!reader.IsDBNull(customer_acct_idColumnIndex)) { record.Customer_acct_id = Convert.ToInt16(reader.GetValue(customer_acct_idColumnIndex)); } if (ri == length && 0 != totalRecordCount) { break; } } } totalRecordCount = 0 == totalRecordCount ? ri + startIndex : -1; return((BatchRow[])(recordList.ToArray(typeof(BatchRow)))); }
public static bool AddLot(RetailAccountGenResponse pResponse, PersonDto pPerson) { bool _result = false; using (var _db = new Rbr_Db()) { _db.BeginTransaction(); try { InventoryLotRow _lotRow = _db.InventoryLotCollection.GetByServiceIdDenomination(pResponse.Request.ServiceId, pResponse.Request.Denomination); if (_lotRow == null) { _lotRow = new InventoryLotRow(); _lotRow.Service_id = pResponse.Request.ServiceId; _lotRow.Denomination = pResponse.Request.Denomination; _db.InventoryLotCollection.Insert(_lotRow); } var _requestRow = new GenerationRequestRow(); _requestRow.Date_requested = DateTime.Now; _requestRow.Date_completed = DateTime.Now; _requestRow.Date_to_process = DateTime.Now; _requestRow.Number_of_batches = pResponse.Request.NumberOfBatches; _requestRow.Batch_size = pResponse.Request.BatchSize; _requestRow.Lot_id = _lotRow.Lot_id; _db.GenerationRequestCollection.Insert(_requestRow); foreach (var _batch in pResponse.BatchList) { var _batchRow = new BatchRow(); _batchRow.Batch_id = _batch.BatchId; _batchRow.First_serial = _batch.FirstSerial; _batchRow.Last_serial = _batch.LastSerial; _batchRow.Request_id = _requestRow.Request_id; //_batchRow.Box_id = ???? xxx; NOT SET for now //_batchRow.Customer_acct_id = WILL BE SET ON LOAD/ACTIVATE; _batchRow.InventoryStatus = InventoryStatus.Generated; _db.BatchCollection.Insert(_batchRow); logInventoryHistory(_db, pPerson, DateTime.Now, _lotRow.Service_id, _lotRow.Denomination, _batchRow.Batch_id, _batchRow.NumberOfCards, InventoryCommand.Generate, 0, //CustomerAcctId - N/A FOR THIS COMMAND 0, //ResellerPartnerId - N/A FOR THIS COMMAND 0 //ResellerAgentId - N/A FOR THIS COMMAND ); } _db.CommitTransaction(); _result = true; } catch (Exception _ex) { _db.RollbackTransaction(); TimokLogger.Instance.LogRbr(LogSeverity.Critical, "InventoryController.AddLot", string.Format("Exception: {0}", _ex)); } } return(_result); }
private List <BatchRow> GetReceiptSelectedItems(out bool isReceiptMandatoryBatches) { var receiptBatchRowsList = new List <BatchRow>(); isReceiptMandatoryBatches = false; for (int i = 1; i <= mtxItems.RowCount; i++) { var issItem = mtxItems.GetCellValue("rec_Item", i).ToString(); var batchItem = B1Helper.DiCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oItems) as SAPbobsCOM.Items; batchItem.GetByKey(issItem); if (batchItem.ManageBatchNumbers == SAPbobsCOM.BoYesNoEnum.tYES) { //BatchesManaged = ChechIfReceiptBatchesManaged(); isReceiptMandatoryBatches = true; var batchRows = receiptBatchRowsList.Where(x => x.ItemCode == mtxItems.GetCellValue("rec_Item", i).ToString() && x.WhsCode == mtxItems.GetCellValue("ToWhs", i).ToString()); if (batchRows.Count() > 0) { batchRows.First().Quantity += Convert.ToDouble(mtxItems.GetCellValue("Quantity", i)); batchRows.First().AddAmount += Convert.ToDouble(mtxItems.GetCellValue("AddAmount", i)); } else { BatchRow bRow = new BatchRow() { ItemCode = mtxItems.GetCellValue("rec_Item", i).ToString(), WhsCode = mtxItems.GetCellValue("ToWhs", i).ToString(), Quantity = Convert.ToDouble(mtxItems.GetCellValue("Quantity", i)), AvgPrice = Convert.ToDouble(mtxItems.GetCellValue("AvgPrice", i)), AddAmount = Convert.ToDouble(mtxItems.GetCellValue("AddAmount", i)) }; receiptBatchRowsList.Add(bRow); } } else { TransferItem tItem = new TransferItem() { AddCost = Convert.ToDouble(mtxItems.GetCellValue("AddAmount", i)), IssueItemCode = mtxItems.GetCellValue("to_Item", i).ToString(), ReceiptItemCode = mtxItems.GetCellValue("rec_Item", i).ToString(), Quantity = mtxItems.GetCellValue("Quantity", i).ToString() == string.Empty ? 1 : Convert.ToDouble(mtxItems.GetCellValue("Quantity", i)), FromWhs = mtxItems.GetCellValue("FromWhs", i).ToString(), ToWhs = mtxItems.GetCellValue("ToWhs", i).ToString(), AvgCost = Convert.ToDouble(mtxItems.GetCellValue("AvgPrice", i)) }; recTransferItemsList.Add(tItem); } } if (receiptBatchRowsList.Count != SelectedRecBatchDataSources.Count) { BatchesManaged = null; } return(receiptBatchRowsList); }
public BatchRow AddBatchRow(string ConnString, string ScriptsDirectory, string BatchName) { BatchRow rowBatchRow = ((BatchRow)(this.NewRow())); rowBatchRow.ItemArray = new object[] { null, ConnString, ScriptsDirectory, BatchName }; this.Rows.Add(rowBatchRow); return(rowBatchRow); }
/// <summary> /// Converts <see cref="System.Data.DataRow"/> to <see cref="BatchRow"/>. /// </summary> /// <param name="row">The <see cref="System.Data.DataRow"/> object to be mapped.</param> /// <returns>A reference to the <see cref="BatchRow"/> object.</returns> protected virtual BatchRow MapRow(DataRow row) { BatchRow mappedObject = new BatchRow(); DataTable dataTable = row.Table; DataColumn dataColumn; // Column "Batch_id" dataColumn = dataTable.Columns["Batch_id"]; if (!row.IsNull(dataColumn)) { mappedObject.Batch_id = (int)row[dataColumn]; } // Column "Status" dataColumn = dataTable.Columns["Status"]; if (!row.IsNull(dataColumn)) { mappedObject.Status = (byte)row[dataColumn]; } // Column "First_serial" dataColumn = dataTable.Columns["First_serial"]; if (!row.IsNull(dataColumn)) { mappedObject.First_serial = (long)row[dataColumn]; } // Column "Last_serial" dataColumn = dataTable.Columns["Last_serial"]; if (!row.IsNull(dataColumn)) { mappedObject.Last_serial = (long)row[dataColumn]; } // Column "Request_id" dataColumn = dataTable.Columns["Request_id"]; if (!row.IsNull(dataColumn)) { mappedObject.Request_id = (int)row[dataColumn]; } // Column "Box_id" dataColumn = dataTable.Columns["Box_id"]; if (!row.IsNull(dataColumn)) { mappedObject.Box_id = (int)row[dataColumn]; } // Column "Customer_acct_id" dataColumn = dataTable.Columns["Customer_acct_id"]; if (!row.IsNull(dataColumn)) { mappedObject.Customer_acct_id = (short)row[dataColumn]; } return(mappedObject); }
/// <summary> /// Handles the DataBound event of the lVarianceAmount control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="RowEventArgs"/> instance containing the event data.</param> protected void lVarianceAmount_DataBound(object sender, RowEventArgs e) { Literal lVarianceAmount = sender as Literal; BatchRow batchRow = e.Row.DataItem as BatchRow; if (batchRow.AmountVariance != 0.00M) { lVarianceAmount.Text = string.Format("<span class='label label-danger'>{0}</span>", batchRow.AmountVariance.FormatAsCurrency()); } else { lVarianceAmount.Text = string.Format("<span class=''>{0}</span>", batchRow.AmountVariance.FormatAsCurrency()); } }
/// <summary> /// Handles the DataBound event of the lVarianceItemCount control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="RowEventArgs"/> instance containing the event data.</param> protected void lVarianceItemCount_DataBound(object sender, RowEventArgs e) { Literal lVarianceItemCount = sender as Literal; BatchRow batchRow = e.Row.DataItem as BatchRow; if (batchRow.ItemCountVariance.HasValue) { if (batchRow.ItemCountVariance != 0) { lVarianceItemCount.Text = string.Format("<span class='label label-danger'>{0}</span>", batchRow.ItemCountVariance); } else { lVarianceItemCount.Text = string.Format("<span class=''>{0}</span>", batchRow.ItemCountVariance); } } else { // doesn't apply lVarianceItemCount.Text = "-"; } }
/// <summary> /// Updates a record in the <c>Batch</c> table. /// </summary> /// <param name="value">The <see cref="BatchRow"/> /// object used to update the table record.</param> /// <returns>true if the record was updated; otherwise, false.</returns> public virtual bool Update(BatchRow value) { string sqlStr = "UPDATE [dbo].[Batch] SET " + "[status]=" + _db.CreateSqlParameterName("Status") + ", " + "[first_serial]=" + _db.CreateSqlParameterName("First_serial") + ", " + "[last_serial]=" + _db.CreateSqlParameterName("Last_serial") + ", " + "[request_id]=" + _db.CreateSqlParameterName("Request_id") + ", " + "[box_id]=" + _db.CreateSqlParameterName("Box_id") + ", " + "[customer_acct_id]=" + _db.CreateSqlParameterName("Customer_acct_id") + " WHERE " + "[batch_id]=" + _db.CreateSqlParameterName("Batch_id"); IDbCommand cmd = _db.CreateCommand(sqlStr); AddParameter(cmd, "Status", value.Status); AddParameter(cmd, "First_serial", value.First_serial); AddParameter(cmd, "Last_serial", value.Last_serial); AddParameter(cmd, "Request_id", value.Request_id); AddParameter(cmd, "Box_id", value.IsBox_idNull ? DBNull.Value : (object)value.Box_id); AddParameter(cmd, "Customer_acct_id", value.IsCustomer_acct_idNull ? DBNull.Value : (object)value.Customer_acct_id); AddParameter(cmd, "Batch_id", value.Batch_id); return(0 != cmd.ExecuteNonQuery()); }
//--------------------------------- Privates ----------------------------------- private static void executeLoadCommand(Rbr_Db pDb, BackgroundWorker pBackgroundWorker, DoWorkEventArgs pEvtArg, InventoryCommandRequest pInventoryCommandRequest) { pBackgroundWorker.ReportStatus(string.Format("Loading {0} Batches", pInventoryCommandRequest.Batches)); foreach (var _batch in pInventoryCommandRequest.Batches) { string _batchFilePath = Configuration.Instance.Folders.GetInventoryBatchFilePath(_batch.ServiceId, _batch.Denomination, _batch.BatchId); pBackgroundWorker.ReportStatus("Loading Batch File: " + _batchFilePath); using (var _sr = new StreamReader(_batchFilePath)) { _batch.CustomerAcctId = pInventoryCommandRequest.CustomerAcctId; if (pInventoryCommandRequest.ActivateOnLoad) { _batch.InventoryStatus = InventoryStatus.Activated; } else { _batch.InventoryStatus = InventoryStatus.Loaded; } try { int _cardCount = 0; string _line; while ((_line = _sr.ReadLine()) != null) { //pBackgroundWorker.ReportStatus(string.Format("{0}", _line)); if (pBackgroundWorker.CancellationPending) { pBackgroundWorker.ReportStatus("Canceled"); pEvtArg.Cancel = true; return; } string[] _fields = _line.Split(FieldDelimiter); long _serial = long.Parse(_fields[0]); long _pin = long.Parse(_fields[1]); loadPhoneCardAndRetailAccount(pDb, _serial, _pin, pInventoryCommandRequest); pBackgroundWorker.ReportProgress(++_cardCount * 100 / _batch.BatchSize); } } catch (Exception _ex) { pBackgroundWorker.ReportStatus(string.Format("Exception:\r\n{0}", _ex)); pEvtArg.Cancel = true; return; } BatchRow _batchRow = MapToBatchRow(_batch); pBackgroundWorker.ReportStatus(string.Format("Mapped BatchId={0}", _batch.BatchId)); pBackgroundWorker.ReportStatus(string.Format("Updated BatchId={0}", _batch.BatchId)); pDb.BatchCollection.Update(_batchRow); logInventoryHistory(pDb, pInventoryCommandRequest.Person, DateTime.Now, pInventoryCommandRequest.ServiceId, _batch.Denomination, _batch.BatchId, _batch.BatchSize, InventoryCommand.Load, pInventoryCommandRequest.CustomerAcctId, 0, //TODO: !!! ResellerPartnerId - N/A FOR NOW 0 //TODO: !!! ResellerAgentId - N/A FOR NOW ); pBackgroundWorker.ReportStatus("Logged Inventory History"); if (pInventoryCommandRequest.ActivateOnLoad) { logInventoryHistory(pDb, pInventoryCommandRequest.Person, DateTime.Now.AddMilliseconds(11), //Just to make sure that time is different from prev History entry pInventoryCommandRequest.ServiceId, _batch.Denomination, _batch.BatchId, _batch.BatchSize, InventoryCommand.Activate, pInventoryCommandRequest.CustomerAcctId, 0, //TODO: !!! SalesRepAcctId - N/A FOR NOW 0 //TODO: !!! ResellerAgentId - N/A FOR NOW ); } pBackgroundWorker.ReportStatus("Finished Loading Batch File: " + _batchFilePath); } } }
/// <summary> /// Deletes the specified object from the <c>Batch</c> table. /// </summary> /// <param name="value">The <see cref="BatchRow"/> object to delete.</param> /// <returns>true if the record was deleted; otherwise, false.</returns> public bool Delete(BatchRow value) { return(DeleteByPrimaryKey(value.Batch_id)); }
public void RemoveBatchRow(BatchRow row) { this.Rows.Remove(row); }
public void AddBatchRow(BatchRow row) { this.Rows.Add(row); }
public ScriptsListRow AddScriptsListRow(string ScriptPath, string ScriptName, string ScriptExt, bool WillExecute, int SortOrder, BatchRow parentBatchRowByBatch_ScriptsList) { ScriptsListRow rowScriptsListRow = ((ScriptsListRow)(this.NewRow())); rowScriptsListRow.ItemArray = new object[] { ScriptPath, ScriptName, ScriptExt, WillExecute, null, SortOrder, parentBatchRowByBatch_ScriptsList[0] }; this.Rows.Add(rowScriptsListRow); return(rowScriptsListRow); }
public BatchRowChangeEvent(BatchRow row, System.Data.DataRowAction action) { this.eventRow = row; this.eventAction = action; }