public static void update(Guid id, Guid pettyCashRecordsCategories_Id, decimal amount, string notes) { PettyCashRecord objOld = new PettyCashRecord(id); string log = ""; log = ActivityLog.appendChange(log, objOld.PettyCashRecordsCategories_Name, new PettyCashRecordsCategory(pettyCashRecordsCategories_Id).Name, "Category: '{0}' to '{1}'"); log = ActivityLog.appendChange(log, objOld.Amount, amount, "Amount: '{0:N2}' to '{1:N2}'"); log = ActivityLog.appendChange(log, objOld.Notes, notes, "Notes: '{0}' to '{1}'"); if (!string.IsNullOrEmpty(log)) { SqlQueryResult result = DBConnection.query( false, DBConnection.ActiveSqlConnection, QueryTypes.ExecuteNonQuery, "PettyCashRecords_update", new SqlQueryParameter(COL_DB_Id, SqlDbType.UniqueIdentifier, id), new SqlQueryParameter(COL_DB_PettyCashRecordsCategories_Id, SqlDbType.UniqueIdentifier, pettyCashRecordsCategories_Id), new SqlQueryParameter(COL_DB_Amount, SqlDbType.Decimal, amount), new SqlQueryParameter(COL_DB_Notes, SqlDbType.VarChar, Util.wrapNullable(notes)) ); if (result.IsSuccessful) { if (GlobalData.UserAccount.role != Roles.Super) { ActivityLog.submit(id, "UPDATE: " + log, (int)Roles.Super); } else { ActivityLog.submit(id, "UPDATE: " + log); } } } }
public static void update_ShippingExpense(Guid Id, Guid PettyCashRecordsCategories_Id, int Amount, string Notes) { Sale objOld = new Sale(Id); string log = ""; log = ActivityLog.appendChange(log, objOld.ShippingExpense, Amount, "Shipping Expense: '{0}' to '{1}'"); if (!string.IsNullOrEmpty(log)) { int PettyCashRecords_Amount = -1 * Amount; string PettyCashRecords_Notes = string.Format("Expense for Invoice {0}", objOld.barcode); //if there is previous amount value, adjust amount so petty cash is still correct. if (objOld.ShippingExpense > 0) { PettyCashRecords_Amount += objOld.ShippingExpense; PettyCashRecords_Notes += string.Format(" (Update {0:N0} to {1:N0})", objOld.ShippingExpense, Amount); } //transport information if (objOld.TransportName != null) { PettyCashRecords_Notes += string.Format(", Angkutan {0}", objOld.TransportName); } if (!string.IsNullOrWhiteSpace(Notes)) { PettyCashRecords_Notes += ", " + Notes; } Guid?PettyCashRecords_Id = PettyCashRecord.add(PettyCashRecordsCategories_Id, PettyCashRecords_Amount, PettyCashRecords_Notes); if (PettyCashRecords_Id != null) { log += string.Format(", Petty Cash {0} Amount: {1:N0}", new PettyCashRecord((Guid)PettyCashRecords_Id).No, PettyCashRecords_Amount); SqlQueryResult result = DBConnection.query( false, DBConnection.ActiveSqlConnection, QueryTypes.ExecuteNonQuery, "Sales_update_ShippingExpense", new SqlQueryParameter(COL_ID, SqlDbType.UniqueIdentifier, Id), new SqlQueryParameter(COL_DB_ShippingExpense, SqlDbType.Int, Amount) ); if (result.IsSuccessful) { ActivityLog.submit(Id, String.Format("Updated: {0}", log)); } } } }