public bool WtrieData(BoughtItem obj) { AccountBook result; int amounttt; DateTime dateee; if (int.TryParse(obj.Price.ToString(), out amounttt) && String.IsNullOrWhiteSpace(obj.ItemCategory) == false && DateTime.TryParseExact(obj.ItemDate, "yyyy-MM-dd", DateTimeFormatInfo.CurrentInfo, DateTimeStyles.None, out dateee) && String.IsNullOrWhiteSpace(obj.Remark) == false) { result = new AccountBook() { Categoryyy = obj.ItemCategory == "支出" ? 0 : 1, Amounttt = amounttt, Dateee = dateee, Remarkkk = obj.Remark }; if (accountBookRes.WriteData(result)) { __hmw.SaveChanges(); return(true); } } return(false); }