Exemplo n.º 1
0
 public static List<CashTransaction> GetCashTransactions(DateTime fromDate, DateTime toDate, string xmlFileName)
 {
     List<CashTransaction> cashTransactions = new List<CashTransaction>();
     XmlDocument xdoc = new XmlDocument();
     xdoc.Load(xmlFileName);
     XmlNodeList cashNodes = xdoc.SelectNodes("//Cash//Entry");
     foreach (XmlNode item in cashNodes)
     {
         if ((DateTime.Parse(item.Attributes["PostedDate"].InnerText) >= fromDate) && (DateTime.Parse(item.Attributes["PostedDate"].InnerText) <= toDate))
         {
             var t = new CashTransaction();
             t.PostedDate = item.Attributes["PostedDate"].InnerText;
             t.Id = item.Attributes["Id"].InnerText;
             t.TransactionType = item.Attributes["TransactionType"].InnerText;
             t.Amount = ""; t.Amount2 = "";
             if (t.TransactionType == "DEPOSIT")
                 t.Amount = item.Attributes["Amount"].InnerText;
             else
                 t.Amount2 = item.Attributes["Amount"].InnerText;
             t.LedgerAccount = xdoc.SelectSingleNode("//Refs/refItem[@refCode='" + item.Attributes["LedgerAccount"].InnerText + "']").Attributes["refDescription"].InnerText;
             if (item.Attributes["LedgerAccount"].InnerText == "DUE")
             {
                 var personId = xdoc.SelectSingleNode("//Members/Member[@MasonId='" + item.Attributes["PayTo"].InnerText + "']").Attributes["PersonId"].InnerText;
                 var personNode = xdoc.SelectSingleNode("//People/Person[@PersonId='" + personId + "']");
                 t.PayTo = personNode.Attributes["FirstName"].InnerText + " " + personNode.Attributes["LastName"].InnerText;
             }
             else
                 t.PayTo = item.Attributes["PayTo"].InnerText;
             t.Memo = item.ChildNodes[0].InnerText;
             cashTransactions.Add(t);
         }
     }
     return cashTransactions;
 }
Exemplo n.º 2
0
 public string PostDeposit(CashTransaction deposit)
 {
     deposit.TransactionType = "DEPOSIT";
     string lodgeFileName = Server.MapPath("\\App_Data\\") + MasonMasterData.GetUserProfile(User.Identity.Name).DatabaseName;
     string success = CashDataXml.PostCashTransaction(deposit, lodgeFileName);
     return success;
 }
Exemplo n.º 3
0
 public static string PostCashTransaction(CashTransaction transaction, XmlDocument xdoc)
 {
     string success = "ok";
     try
     {
         XmlNode cashNode = xdoc.SelectSingleNode("//Cash");
         XmlNode entryNode = null;
         if (transaction.Id != null)
             entryNode = cashNode.SelectSingleNode("//Entry[@Id='" + transaction.Id + "']");
         if (entryNode == null)
         {
             if (transaction.Id == null)
                 transaction.Id = Guid.NewGuid().ToString();
             entryNode = xdoc.CreateElement("Entry");
             XmlAttribute EntryId = xdoc.CreateAttribute("Id"); EntryId.Value = transaction.Id; entryNode.Attributes.Append(EntryId);
             XmlAttribute TransactionType = xdoc.CreateAttribute("TransactionType"); TransactionType.Value = transaction.TransactionType; entryNode.Attributes.Append(TransactionType);
             XmlAttribute Amount = xdoc.CreateAttribute("Amount"); Amount.Value = transaction.Amount; entryNode.Attributes.Append(Amount);
             XmlAttribute PostedDate = xdoc.CreateAttribute("PostedDate"); PostedDate.Value = transaction.PostedDate.ToString(); entryNode.Attributes.Append(PostedDate);
             XmlAttribute LedgerAccount = xdoc.CreateAttribute("LedgerAccount"); LedgerAccount.Value = transaction.LedgerAccount; entryNode.Attributes.Append(LedgerAccount);
             XmlAttribute PayTo = xdoc.CreateAttribute("PayTo"); PayTo.InnerText = transaction.PayTo; entryNode.Attributes.Append(PayTo);
             XmlCDataSection Memo = xdoc.CreateCDataSection(transaction.Memo); entryNode.AppendChild(Memo);
             cashNode.AppendChild(entryNode);
         }
         else
         {
             entryNode.Attributes["TransactionType"].InnerText = transaction.TransactionType;
             entryNode.Attributes["Amount"].InnerText = transaction.Amount;
             entryNode.Attributes["PostedDate"].InnerText = transaction.PostedDate.ToString();
             entryNode.Attributes["LedgerAccount"].InnerText = transaction.LedgerAccount;
             entryNode.Attributes["PayTo"].InnerText = transaction.PayTo;
             entryNode.ChildNodes[0].Value = transaction.Memo;
         }
     }
     catch (Exception ex)
     {
         success = ex.Message;
     }
     return success;
 }
Exemplo n.º 4
0
 public static string PostCashTransaction(CashTransaction transaction, string xmlFileName)
 {
     XmlDocument xdoc = new XmlDocument();
     xdoc.Load(xmlFileName);
     string success = PostCashTransaction(transaction, xdoc);
     if (success == "ok")
         xdoc.Save(xmlFileName);
     return success;
 }
Exemplo n.º 5
0
 public string PostPayment(CashTransaction payment)
 {
     payment.TransactionType = "PAYMENT";
     string lodgeFileName = Server.MapPath("\\App_Data\\") + MasonMasterData.GetUserProfile(User.Identity.Name).DatabaseName;
     string success = CashDataXml.PostCashTransaction(payment, lodgeFileName);
     return success;
 }