/// <summary> /// Converts <see cref="System.Data.DataRow"/> to <see cref="InventoryLotRow"/>. /// </summary> /// <param name="row">The <see cref="System.Data.DataRow"/> object to be mapped.</param> /// <returns>A reference to the <see cref="InventoryLotRow"/> object.</returns> protected virtual InventoryLotRow MapRow(DataRow row) { InventoryLotRow mappedObject = new InventoryLotRow(); DataTable dataTable = row.Table; DataColumn dataColumn; // Column "Lot_id" dataColumn = dataTable.Columns["Lot_id"]; if (!row.IsNull(dataColumn)) { mappedObject.Lot_id = (int)row[dataColumn]; } // Column "Service_id" dataColumn = dataTable.Columns["Service_id"]; if (!row.IsNull(dataColumn)) { mappedObject.Service_id = (short)row[dataColumn]; } // Column "Denomination" dataColumn = dataTable.Columns["Denomination"]; if (!row.IsNull(dataColumn)) { mappedObject.Denomination = (decimal)row[dataColumn]; } return(mappedObject); }
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 BatchDto[] MapToBatches(BatchRow[] pBatchRows, InventoryLotRow pInventoryLotRow, GenerationRequestRow pGenerationRequestRow) { var _list = new ArrayList(); foreach (var _batchRow in pBatchRows) { _list.Add(MapToBatch(_batchRow, pInventoryLotRow, pGenerationRequestRow)); } return((BatchDto[])_list.ToArray(typeof(BatchDto))); }
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); }
/// <summary> /// Updates a record in the <c>InventoryLot</c> table. /// </summary> /// <param name="value">The <see cref="InventoryLotRow"/> /// object used to update the table record.</param> /// <returns>true if the record was updated; otherwise, false.</returns> public virtual bool Update(InventoryLotRow value) { string sqlStr = "UPDATE [dbo].[InventoryLot] SET " + "[service_id]=" + _db.CreateSqlParameterName("Service_id") + ", " + "[denomination]=" + _db.CreateSqlParameterName("Denomination") + " WHERE " + "[lot_id]=" + _db.CreateSqlParameterName("Lot_id"); IDbCommand cmd = _db.CreateCommand(sqlStr); AddParameter(cmd, "Service_id", value.Service_id); AddParameter(cmd, "Denomination", value.Denomination); AddParameter(cmd, "Lot_id", value.Lot_id); return(0 != cmd.ExecuteNonQuery()); }
/// <summary> /// Adds a new record into the <c>InventoryLot</c> table. /// </summary> /// <param name="value">The <see cref="InventoryLotRow"/> object to be inserted.</param> public virtual void Insert(InventoryLotRow value) { string sqlStr = "INSERT INTO [dbo].[InventoryLot] (" + "[lot_id], " + "[service_id], " + "[denomination]" + ") VALUES (" + _db.CreateSqlParameterName("Lot_id") + ", " + _db.CreateSqlParameterName("Service_id") + ", " + _db.CreateSqlParameterName("Denomination") + ")"; IDbCommand cmd = _db.CreateCommand(sqlStr); AddParameter(cmd, "Lot_id", value.Lot_id); AddParameter(cmd, "Service_id", value.Service_id); AddParameter(cmd, "Denomination", value.Denomination); 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="InventoryLotRow"/> objects.</returns> protected virtual InventoryLotRow[] 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 lot_idColumnIndex = reader.GetOrdinal("lot_id"); int service_idColumnIndex = reader.GetOrdinal("service_id"); int denominationColumnIndex = reader.GetOrdinal("denomination"); System.Collections.ArrayList recordList = new System.Collections.ArrayList(); int ri = -startIndex; while (reader.Read()) { ri++; if (ri > 0 && ri <= length) { InventoryLotRow record = new InventoryLotRow(); recordList.Add(record); record.Lot_id = Convert.ToInt32(reader.GetValue(lot_idColumnIndex)); record.Service_id = Convert.ToInt16(reader.GetValue(service_idColumnIndex)); record.Denomination = Convert.ToDecimal(reader.GetValue(denominationColumnIndex)); if (ri == length && 0 != totalRecordCount) { break; } } } totalRecordCount = 0 == totalRecordCount ? ri + startIndex : -1; return((InventoryLotRow[])(recordList.ToArray(typeof(InventoryLotRow)))); }
/// <summary> /// Deletes the specified object from the <c>InventoryLot</c> table. /// </summary> /// <param name="value">The <see cref="InventoryLotRow"/> object to delete.</param> /// <returns>true if the record was deleted; otherwise, false.</returns> public bool Delete(InventoryLotRow value) { return(DeleteByPrimaryKey(value.Lot_id)); }