/// <summary> /// Method to create new payment unit /// </summary> /// <param name="purchasePrice">Purchase Price model</param> /// <returns>true or false</returns> public bool AddPurchasePrice(PurchasePriceDataModel purchasePrice) { using (OleDbCommand oleDbCommand = new OleDbCommand()) { // Set the command object properties oleDbCommand.Connection = new OleDbConnection(this.ConnectionString); oleDbCommand.CommandType = CommandType.Text; oleDbCommand.CommandText = PurchasePriceScripts.sqlInsertPurchasePrice; // Add the input parameters to the parameter collection oleDbCommand.Parameters.AddWithValue("@DistributorPrice", purchasePrice.DistributorPrice ?? (object)DBNull.Value); oleDbCommand.Parameters.AddWithValue("@Transport", purchasePrice.Transport ?? (object)DBNull.Value); oleDbCommand.Parameters.AddWithValue("@InternalTransport", purchasePrice.InternalTransport ?? (object)DBNull.Value); oleDbCommand.Parameters.AddWithValue("@KosovoCosts", purchasePrice.KosovoCosts ?? (object)DBNull.Value); oleDbCommand.Parameters.AddWithValue("@Other1", purchasePrice.Other1 ?? (object)DBNull.Value); oleDbCommand.Parameters.AddWithValue("@Other2", purchasePrice.Other2 ?? (object)DBNull.Value); oleDbCommand.Parameters.AddWithValue("@TotalPurchase", purchasePrice.TotalPurchase ?? (object)DBNull.Value); // Open the connection, execute the query and close the connection oleDbCommand.Connection.Open(); var rowsAffected = oleDbCommand.ExecuteNonQuery(); oleDbCommand.Connection.Close(); return(rowsAffected > 0); } }
/// <summary> /// Updates the data models /// </summary> private void UpdateDataModels() { _paymentDataModel = _salesManagementService.PaymentDataModel; _productDataModel = _salesManagementService.ProductDataModel; _productDeliveryDataModel = _salesManagementService.ProductDeliveryDataModel; _purchasePriceDataModel = _salesManagementService.PurchasePriceDataModel; _sellingPriceDataModel = _salesManagementService.SellingPriceDataModel; _paymentUnitsTable = _salesManagementService.PaymentUnitsTable; }
/// <summary> /// Converts a Data row from the database table to payment unit model /// </summary> /// <param name="purchasePriceRow"></param> /// <returns></returns> public PurchasePriceDataModel ConvertToDataModel(DataRow purchasePriceRow) { var result = new PurchasePriceDataModel(); result.PurchasePriceID = purchasePriceRow.Field <int>("PurchasePriceID"); result.DistributorPrice = purchasePriceRow.Field <decimal?>("DistributorPrice"); result.Transport = purchasePriceRow.Field <decimal?>("Transport"); result.InternalTransport = purchasePriceRow.Field <decimal?>("InternalTransport"); result.KosovoCosts = purchasePriceRow.Field <decimal?>("KosovoCosts"); result.Other1 = purchasePriceRow.Field <decimal?>("Other1"); result.Other2 = purchasePriceRow.Field <decimal?>("Other2"); result.TotalPurchase = purchasePriceRow.Field <decimal?>("TotalPurchase"); return(result); }
/// <summary> /// Method to update payment unit details /// </summary> /// <param name="purchasePrice">payment unit model</param> /// <returns></returns> public bool UpdatePurchasePrice(PurchasePriceDataModel purchasePrice) { return(purchasePriceAccess.UpdatePurchasePrice(purchasePrice)); }
/// <summary> /// Method to create new payment unit /// </summary> /// <param name="purchasePrice">payment unit model</param> /// <returns>true or false</returns> public bool AddPurchasePrice(PurchasePriceDataModel purchasePrice) { return(purchasePriceAccess.AddPurchasePrice(purchasePrice)); }