예제 #1
0
        public ActionResult EditTransaction(EditTransaction model)
        {
            TransactionTypeTableAdapter tranTypeAdapter = new TransactionTypeTableAdapter();
            DataTable tranTypeDT = tranTypeAdapter.GetData();

            List<SelectListItem> items = new List<SelectListItem>();
            foreach (DataRow row in tranTypeDT.Rows)
            {
                items.Add(new SelectListItem { Text = row["Name"].ToString(), Value = row["TransactionTypeID"].ToString() });
            }
            ViewData["TransType"] = items;

            if (!ModelState.IsValid)
            {
                return View(model);
            }
            int transactionHistoryID = model.TransactionHistoryID;
            string username = model.Username;
            int transactionTypeID = model.TransactionTypeID;
            int value = model.Value;
            string transactionContent = model.TransactionContent;
            int? scheduleMealSetDetailID = model.ScheduleMealSetDetailID;
            Boolean isAuto = model.IsAuto;
            DateTime insertedDate = model.InsertedDate;
            string updatedBy = model.UpdatedBy;
            DateTime lastUpdated = DateTime.Now;
            TransactionHistoryTableAdapter transAdapter = new TransactionHistoryTableAdapter();
            try
            {
                transAdapter.UpdateTransactionHistory(username, transactionTypeID, value, transactionContent
                    , scheduleMealSetDetailID, isAuto, insertedDate, AccountInfo.GetUserName(Request), lastUpdated
                    , transactionHistoryID);
                XmlSync.SaveTransactionHistoryXml(transactionHistoryID, username, transactionTypeID, value, transactionContent
                    , scheduleMealSetDetailID, isAuto, insertedDate, AccountInfo.GetUserName(Request), lastUpdated, null);
            }
            catch (Exception ex)
            {
                Log.ErrorLog(ex.Message);
            }

            return RedirectToAction("ListTransaction", "Transaction");
        }