public ActionResult Transfer(int id) { try { if (Session["UserName"] == null) { return(RedirectToAction("Index", "Account")); } ViewBag.ReportTitle = "Transfer Fund To Landlord"; OperationRecord model = OperationRecordManager.GetExpenseByRentID(id); model = OperationRecordManager.GetExpenseByID(model.ID); model.AllBankAccount = GetSelectListItems((short)Helpers.Helpers.ListType.bankaccount); model.AllTenant = GetSelectListItems((short)Helpers.Helpers.ListType.allTenantWithUnit); model.AllCategory = GetSelectListItems((short)Helpers.Helpers.ListType.allExpenseCategory); model.AllStatus = GetSelectListItems((short)Helpers.Helpers.ListType.allStatus); return(View(model)); } catch (Exception ex) { LogException(ex.Message); return(View()); } }
public ActionResult Transfer(OperationRecord model) { if (Session["UserName"] == null) { return(RedirectToAction("Index", "Account")); } if (String.IsNullOrEmpty(model.TransferedFinancialBankAccountID)) { return(ExecutionError("Please select either Tenant or Unit")); } model.UploadBy = Int32.Parse(Session["UserID"].ToString()); Tenant tenant = TenantManager.GetByID(model.TenantID); model.ContractorID = tenant.UserID; model.UnitID = tenant.UnitId; OperationRecordManager.Reimburse(model); //send email to end user if (model.IsEmailReceipt) { Email.EmailPayment(model.ID, model.ContractorID, model.UnitID, model.CompleteDate, model.FinancialBankAccountID, model.DueAmount, model.Payment, (int)Helpers.Helpers.EmailType.Invoice); } return(RedirectToAction("Index")); }
/// <summary> /// Save in operation history of given account the operation record /// </summary> /// <param name="accountId">account id (from database)</param> /// <param name="operationRecord">operation record to save</param> public void SaveOperationToHistory(int accountId, OperationRecord operationRecord) { using (var db = new DbBank()) { db.Insert(new DbOperationRecord(accountId, operationRecord)); } }
public ActionResult Add() { // add new user if (Session["UserName"] == null) { return(RedirectToAction("Index", "Account")); } ViewBag.ReportTitle = "Create new expense"; // Get the users from the DB for the drop-down listbox var allUsers = GetList((short)Helpers.Helpers.ListType.allUser); //ViewBag.AllTenants = new MultiSelectList(allUsers, "id", "description"); var allBankAccount = GetList((short)Helpers.Helpers.ListType.bankaccount); // ViewBag.bankAccounts = new MultiSelectList(allBankAccount, "id", "description"); var allUnits = GetList((short)Helpers.Helpers.ListType.unit); // ViewBag.allUnits = new MultiSelectList(allUnits, "id", "description"); OperationRecord model = new OperationRecord(); model.AllTenant = GetSelectListItems((short)Helpers.Helpers.ListType.allUser); model.AllUnits = GetSelectListItems((short)Helpers.Helpers.ListType.unit); model.AllBankAccount = GetSelectListItems((short)Helpers.Helpers.ListType.bankaccount); model.AllCategory = GetSelectListItems((short)Helpers.Helpers.ListType.allExpenseCategory); model.AllStatus = GetSelectListItems((short)Helpers.Helpers.ListType.allStatus); return(View(model)); }
public void InsertOptRecord(OperationRecord record) { var command = CreateCommand(); command.CommandText = $"insert into {OperationRecordTableName}" + $" values(null,{(int)record.Type},{record.OriginText},{record.Key},{record.ResultText},{DateTime.Now.ToString()})"; command.ExecuteNonQuery(); }
public DbOperationRecord(int accountId, OperationRecord operationRecord) { AccountId = accountId; Debet = operationRecord.Debet; Credit = operationRecord.Credit; BalanceAfterOperation = operationRecord.BalanceAfterOperation; Source = operationRecord.Source; Title = operationRecord.Title; }
public ucRegistrationQuick() { InitializeComponent(); record = new OperationRecord(); apply = new OperationAppllication(); opsTableMgr = new Neusoft.HISFC.BizLogic.Operation.OpsTableManage(); InitControl(); }
private static DbOperationRecord GetSavedOperation(OperationRecord operationRecord) { using (var db = new DbBank()) { var query = from p in db.OperationRecord where p.Title == operationRecord.Title select p; return(query.ToList().FirstOrDefault()); } }
public ActionResult AddAndTransferFund(OperationRecord model) { if (Session["UserName"] == null) { return(RedirectToAction("Index", "Account")); } ViewBag.ReportTitle = "Transfer Fund To Other Bank"; OperationRecordManager.AddAndTransferFund(model); return(RedirectToAction("Index")); }
public ActionResult Edit(OperationRecord model) { if (Session["UserName"] == null) { return(RedirectToAction("Index", "Account")); } ViewBag.ReportTitle = "Edit Bank Record"; OperationRecordManager.Edit(model); return(RedirectToAction("Index")); }
public ActionResult Add(OperationRecord model) { if (Session["UserName"] == null) { return(RedirectToAction("Index", "Account")); } ViewBag.ReportTitle = "Add new bank record"; int invoiceID = OperationRecordManager.CreateOperationRecord(model); return(RedirectToAction("Index")); }
public ActionResult ReceiveRent(OperationRecord model) { if (Session["UserName"] == null) { return(RedirectToAction("Index", "Account")); } model.IsCredit = true; model.UploadBy = Int32.Parse(Session["UserID"].ToString()); OperationRecordManager.ReceiveRent(model); //redirect return(RedirectToAction("Index")); }
public ActionResult Add() { // add new user if (Session["UserName"] == null) { return(RedirectToAction("Index", "Account")); } ViewBag.ReportTitle = "Add Rent"; OperationRecord model = new OperationRecord(); model.AllTenant = GetSelectListItems((short)Helpers.Helpers.ListType.allTenantWithUnit); model.AllBankAccount = GetSelectListItems((short)Helpers.Helpers.ListType.bankaccount); return(View(model)); }
public ActionResult Edit(OperationRecord model) { if (Session["UserName"] == null) { return(RedirectToAction("Index", "Account")); } ViewBag.ReportTitle = "Edit Expense"; if (String.IsNullOrEmpty(model.FinancialBankAccountID)) { model.FinancialBankAccountID = "0"; } OperationRecordManager.Edit(model); //send email to end user return(RedirectToAction("Index")); }
/// <summary> /// 后台管理员修改账户金额 /// </summary> /// <param name="info"></param> /// <returns></returns> public dynamic EditMoney(dynamic info) { try { Account item = dataAccess.Find <Account>(Guid.Parse(info.id.ToString())); decimal money = decimal.Parse(info.money.ToString()); Boolean opertype = Boolean.Parse(info.type.ToString()); decimal beforeMoney = item.Amount; if (opertype) { item.Amount += money; } else { if (item.Amount < money) { return(new { status = 1, message = "输入金额小于当前账户余额,无法减去!" }); } item.Amount -= money; } decimal afterMoney = item.Amount; OperationRecord recordItem = new OperationRecord(); recordItem.Id = Guid.NewGuid(); recordItem.IsAdd = opertype; recordItem.Money = money; recordItem.UserId = item.Id; recordItem.UserName = item.UserName; recordItem.OperUserId = Guid.Parse(UserAuth.Current.Id); recordItem.OperUserName = UserAuth.Current.Name; recordItem.CreateTime = DateTime.Now; recordItem.BeforeMoney = beforeMoney; recordItem.AfterMoney = afterMoney; dataAccess.Update <Account>(item); dataAccess.Add <OperationRecord>(recordItem); dataAccess.SaveChanges(); return(new { status = 0, message = "保存成功!" }); } catch (Exception ex) { Common.LogHelper.WriteLog(this.GetType(), ex.Message); return(new { status = 1, message = ex.Message }); } }
public ActionResult Reimburse(int id) { if (Session["UserName"] == null) { return(RedirectToAction("Index", "Account")); } ViewBag.ReportTitle = "Reimburse Expense"; OperationRecord model = OperationRecordManager.GetExpenseByID(id); model.AllUnits = GetSelectListItems((short)Helpers.Helpers.ListType.unit); model.AllBankAccount = GetSelectListItems((short)Helpers.Helpers.ListType.bankaccount); model.AllTenant = GetSelectListItems((short)Helpers.Helpers.ListType.allUser); model.AllStatus = GetSelectListItems((short)Helpers.Helpers.ListType.allStatus); model.AllCategory = GetSelectListItems((short)Helpers.Helpers.ListType.allExpenseCategory); return(View(model)); }
public ActionResult AddAndTransferFund() { if (Session["UserName"] == null) { return(RedirectToAction("Index", "Account")); } ViewBag.ReportTitle = "Add and Transfer Fund To Other Bank"; OperationRecord model = new OperationRecord(); model.AllTenant = GetSelectListItems((short)Helpers.Helpers.ListType.allUser); model.AllUnits = GetSelectListItems((short)Helpers.Helpers.ListType.unit); model.AllBankAccount = GetSelectListItems((short)Helpers.Helpers.ListType.bankaccount); model.AllCategory = GetSelectListItems((short)Helpers.Helpers.ListType.allExpenseCategory); model.AllStatus = GetSelectListItems((short)Helpers.Helpers.ListType.allStatus); return(View(model)); }
public ActionResult Add(OperationRecord model, string actionName) { if (Session["UserName"] == null) { return(RedirectToAction("Index", "Account")); } ViewBag.ReportTitle = "Add new supply request"; model.StatusID = 3; model.UploadBy = (int)Session["UserID"]; model.CategoryID = 18; SqlConnection sqlConn = new SqlConnection(ConfigurationManager.ConnectionStrings["SunriseConnectionString"].ConnectionString); SqlCommand cmd = sqlConn.CreateCommand(); DataTable dtSearchResult = new DataTable(); SqlDataAdapter daSearchResult = new SqlDataAdapter(); try { sqlConn.Open(); if (model.CompleteDate == null) { model.CompleteDate = model.DueDate; } int invoiceID = 0; foreach (int unitID in model.SelectedUnitIDs) { model.UnitID = unitID; invoiceID = OperationRecordManager.CreateOperationRecord(model); } if (model.IsEmailReceipt) { Email.EmailInvoice(invoiceID); } } catch (Exception ex) { LogException(ex.Message); } finally { sqlConn.Close(); } return(RedirectToAction("Index")); }
public ActionResult Edit(OperationRecord model) { if (Session["UserName"] == null) { return(RedirectToAction("Index", "Account")); } OperationRecord oldOp = OperationRecordManager.GetExpenseByRentID(Int32.Parse(model.LinkedRentID)); ViewBag.ReportTitle = "Edit Rent Record"; model.UploadBy = Int32.Parse(Session["UserID"].ToString()); model.ID = oldOp.ID; //the tenantid is stored in the contractorid Tenant tenant = TenantManager.GetByID(model.TenantID); model.ContractorID = tenant.UserID; model.UnitID = tenant.UnitId; OperationRecordManager.EditRent(model); return(RedirectToAction("Index")); }
public ActionResult ReceiveRent(int id) { if (Session["UserName"] == null) { return(RedirectToAction("Index", "Account")); } ViewBag.ReportTitle = "Receive Rent"; OperationRecord model = OperationRecordManager.GetExpenseByRentID(id); model.CompleteDate = DateTime.Now; model.UploadBy = Int32.Parse(Session["UserID"].ToString()); model.StatusID = (int)Helpers.Helpers.StatusType.Close; model.AllUnits = GetSelectListItems((short)Helpers.Helpers.ListType.unit); model.AllBankAccount = GetSelectListItems((short)Helpers.Helpers.ListType.bankaccount); model.AllTenant = GetSelectListItems((short)Helpers.Helpers.ListType.allUser); model.AllStatus = GetSelectListItems((short)Helpers.Helpers.ListType.allStatus); return(View(model)); }
public void SaveOperationRecord_validAccountId_savesData() { var operationRecord = new OperationRecord { BalanceAfterOperation = ExpectedBalanceValue, Debet = ExpectedAmount, Source = ValidInnerAccountNumber, Title = NewOperationTitle }; Assert.IsNull(GetSavedOperation(operationRecord)); _dataSaver.SaveOperationToHistory(ValidAccountId, operationRecord); var savedRecord = GetSavedOperation(operationRecord); Assert.IsNotNull(savedRecord); Assert.AreEqual(ExpectedBalanceValue, savedRecord.BalanceAfterOperation); Assert.AreEqual(ExpectedAmount, savedRecord.Debet); Assert.AreEqual(0, savedRecord.Credit); Assert.AreEqual(ValidInnerAccountNumber, savedRecord.Source); Assert.AreEqual(NewOperationTitle, savedRecord.Title); }
public ActionResult Add() { // add new user if (Session["UserName"] == null) { return(RedirectToAction("Index", "Account")); } ViewBag.ReportTitle = "Request new supply request"; // Get the users from the DB for the drop-down listbox var allUsers = GetList((short)Helpers.Helpers.ListType.allUser); //ViewBag.AllTenants = new MultiSelectList(allUsers, "id", "description"); var units = GetList((short)Helpers.Helpers.ListType.unit); ViewBag.units = new MultiSelectList(units, "id", "description"); OperationRecord model = new OperationRecord(); model.AllUnits = GetSelectListItems((short)Helpers.Helpers.ListType.unit); return(View(model)); }
protected override bool CheckWalletValue(WalletRecord wallet, OperationRecord operation) => true;
private async void RunOperation(OperationContext operationContext) { CancellationTokenSource source = new CancellationTokenSource(); cancellationTokens.Add(operationContext.Operation.Name + operationContext.RunDate.ToShortDateString(), source); DateTime startTime = DateTime.Now; StringBuilder logBuilder = new StringBuilder(); #if Debug void LogMessage(String s) { logBuilder.AppendLine($"[{DateTime.Now:MM/dd/yyyy h:mm:ss.fff tt}] {s}"); Console.WriteLine(s); } #else void LogMessage(String s) => logBuilder.AppendLine(string.Format("[{0:MM/dd/yyyy h:mm:ss.fff tt}] {1}", DateTime.Now, s)); #endif using (IDatabaseRepository <IHarvesterDataContext> harvester = RepositoryFactory.CreateHarvesterRepository(repositories["Harvester"])) { LogMessage($"Connected to database '{harvester.Name}' ({harvester.ConnectionString})"); Operation operation = harvester.DataContext.Operations.FirstOrDefault(x => x.Name == operationContext.Operation.Name); if (operation == null) { operation = new Operation { Name = operationContext.Operation.Name }; harvester.DataContext.Operations.InsertOnSubmit(operation); harvester.DataContext.SubmitChanges(); operationContext.Operation.OperationID = operation.ID; } else { operationContext.Operation.OperationID = operation.ID; if (operation.OperationRecords.Any(x => x.RunDate.Date == operationContext.RunDate.Date)) { skippedOperations++; WriteQueueManagerChanges($"Operation {operationContext.Operation.Name.PadRight(33)} Has already Run"); harvester.DataContext.SubmitChanges(); return; } } } LogMessage($"Starting operation '{operationContext.Operation.Name}' with run date of {operationContext.RunDate:MM/dd/yyyy h:mm:ss.fff tt}"); TrackOperationsByDate(operationContext.Operation.OperationID); Task task = Task.Run(async() => { source.Token.ThrowIfCancellationRequested(); await IsTooManyOperationsRunning(operationContext, LogMessage); await ReachedMaximumRunsPerDay(operationContext, LogMessage); await IsTooManyConcurrentlyRunning(operationContext, LogMessage); lock (RunningOperations) { RunningOperations.Add(operationContext); } WriteCurrentStatus(); startTime = DateTime.Now; source.Token.ThrowIfCancellationRequested(); WriteQueueManagerChanges($"operation {operationContext.Operation.Name.PadRight(33)} Began Executing"); operationContext.Operation.Execute(operationContext.RunDate, LogMessage, source.Token); }); Exception exception = null; try { LogMessage($"Awaiting operation {operationContext.Operation.Name}"); await task; } catch (Exception ex) { exception = ex; LogMessage(ex.ToString()); } finally { TotalOperationsRun++; lock (RunningOperations) { RunningOperations.Remove(operationContext); } cancellationTokens.Remove(operationContext.Operation.Name + operationContext.RunDate.ToShortDateString()); DateTime endDate = DateTime.Now; char statusLetter; switch (task.Status) { case TaskStatus.Canceled: WriteQueueManagerChanges($"operation {operationContext.Operation.Name.PadRight(33)} canceled"); LogMessage("The operation was cancelled."); CanceledOperations.Add(operationContext); statusLetter = 'C'; break; case TaskStatus.Faulted: WriteQueueManagerChanges($"operation {operationContext.Operation.Name.PadRight(33)} Faulted"); LogMessage("The operation encountered an error."); FailedOperations.Add(operationContext); statusLetter = 'F'; break; case TaskStatus.RanToCompletion: WriteQueueManagerChanges($"operation {operationContext.Operation.Name.PadRight(33)} Ran to Completion"); LogMessage("The operation completed successfully."); SuccessfulOperations.Add(operationContext); statusLetter = 'S'; using (IDatabaseRepository <IHarvesterDataContext> harvester = RepositoryFactory.CreateHarvesterRepository(repositories["Harvester"])) { OperationRecord operationRecord = new OperationRecord { OperationID = operationContext.Operation.OperationID, RunDate = operationContext.RunDate, ExecutedDate = DateTime.Now }; LogMessage($"Updated Harvester with Operation Record {JsonConvert.SerializeObject(operationRecord)}"); harvester.DataContext.OperationRecords.InsertOnSubmit(operationRecord); harvester.DataContext.SubmitChanges(); } break; default: WriteQueueManagerChanges($"operation {operationContext.Operation.Name} has an unexpected task status of: {task.Status}"); throw new NotImplementedException($"operation {operationContext.Operation.Name} has an unexpected task status of: {task.Status}"); } RetriedOperations.Remove(operationContext); LogMessage("The operation took " + endDate.Subtract(startTime)); string filename = $"{baseDirectory}Logs\\" + $"({statusLetter}) " + $"{operationContext.Operation.Name} " + $"({operationContext.RunDate:yyyy-MM-dd}) " + $"{(operationContext.CurrentRetry == 0 ? "" : "(" + operationContext.CurrentRetry + ")")} " + $"{Guid.NewGuid()}.txt"; HarvesterService.WriteToFile(filename, logBuilder.ToString()); logBuilder.Clear(); WriteCurrentStatus(); WriteOperations(); switch (task.Status) { #pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed case TaskStatus.Faulted: Task.Run(async() => { if (exception?.GetType() == typeof(RepositoryIOException)) { await Task.Delay(TimeSpan.FromSeconds(((RepositoryIOException)exception).RetryWaitTime), source.Token); } else { await Task.Delay(TimeSpan.FromDays(1), source.Token); } RetriedOperations.Add(operationContext); RunOperation(operationContext.GetRetry()); }); break; #pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed case TaskStatus.RanToCompletion: case TaskStatus.Canceled: break; default: WriteQueueManagerChanges($"operation {operationContext.Operation.Name} has an unexpected task status of: {task.Status}"); throw new NotImplementedException($"operation {operationContext.Operation.Name} has an unexpected task status of: {task.Status}"); } } }
/// <summary> /// Guff查询 /// </summary> /// <param name="category">类别,可选,支持 text、image、audio、video、me(我的)、melaud(我点赞的)、mereply(我回复的)</param> /// <param name="q">搜索</param> /// <param name="nv">分类名/分类值</param> /// <param name="tag">标签</param> /// <param name="obj">对象</param> /// <param name="OwnerId">所属用户</param> /// <param name="UserId">登录用户</param> /// <param name="page">页码</param> /// <returns></returns> public static PageVM GuffQuery(string category, string q, string nv, string tag, string obj, int OwnerId, int UserId, int page = 1) { var ctype = EnumService.ConnectionType.GuffRecord.ToString(); using var db = new ContextBase(); IQueryable <GuffRecord> query = null; switch (category?.ToLower()) { case "melaud": { query = from c in db.UserConnection join a in db.GuffRecord on c.UconnTargetId equals a.GrId join b in db.UserInfo on a.Uid equals b.UserId where c.Uid == UserId && c.UconnTargetType == ctype && c.UconnAction == 1 && a.GrStatus == 1 orderby c.UconnCreateTime descending select new GuffRecord { GrId = a.GrId, GrTypeName = a.GrTypeName, GrTypeValue = a.GrTypeValue, GrObject = a.GrObject, GrContent = a.GrContent, GrContentMd = a.GrContentMd, GrImage = a.GrImage, GrAudio = a.GrAudio, GrVideo = a.GrVideo, GrFile = a.GrFile, GrRemark = a.GrRemark, GrTag = a.GrTag, GrCreateTime = a.GrCreateTime, GrUpdateTime = a.GrUpdateTime, GrOpen = a.GrOpen, GrReadNum = a.GrReadNum, GrReplyNum = a.GrReplyNum, GrLaud = a.GrLaud, GrMark = a.GrMark, Uid = a.Uid, //已点赞 Spare1 = "laud", //是我的 Spare2 = a.Uid == UserId ? "owner" : "", //昵称 Spare3 = b.Nickname }; } break; case "mereply": { query = from c in db.UserReply join a in db.GuffRecord on c.UrTargetId equals a.GrId join b in db.UserInfo on a.Uid equals b.UserId where c.Uid == UserId && c.UrTargetType == ctype && a.GrStatus == 1 orderby c.UrCreateTime descending select new GuffRecord { GrId = a.GrId, GrTypeName = a.GrTypeName, GrTypeValue = a.GrTypeValue, GrObject = a.GrObject, GrContent = a.GrContent, GrContentMd = a.GrContentMd, GrImage = a.GrImage, GrAudio = a.GrAudio, GrVideo = a.GrVideo, GrFile = a.GrFile, GrRemark = a.GrRemark, GrTag = a.GrTag, GrCreateTime = a.GrCreateTime, GrUpdateTime = a.GrUpdateTime, GrOpen = a.GrOpen, GrReadNum = a.GrReadNum, GrReplyNum = a.GrReplyNum, GrLaud = a.GrLaud, GrMark = a.GrMark, Uid = a.Uid, Spare2 = a.Uid == UserId ? "owner" : "", Spare3 = b.Nickname }; } break; case "me": case "top": case "text": case "image": case "audio": case "video": default: { query = from a in db.GuffRecord join b in db.UserInfo on a.Uid equals b.UserId where a.GrStatus == 1 select new GuffRecord { GrId = a.GrId, GrTypeName = a.GrTypeName, GrTypeValue = a.GrTypeValue, GrObject = a.GrObject, GrContent = a.GrContent, GrContentMd = a.GrContentMd, GrImage = a.GrImage, GrAudio = a.GrAudio, GrVideo = a.GrVideo, GrFile = a.GrFile, GrRemark = a.GrRemark, GrTag = a.GrTag, GrCreateTime = a.GrCreateTime, GrUpdateTime = a.GrUpdateTime, GrOpen = a.GrOpen, GrReadNum = a.GrReadNum, GrReplyNum = a.GrReplyNum, GrLaud = a.GrLaud, GrMark = a.GrMark, Uid = a.Uid, Spare2 = a.Uid == UserId ? "owner" : "", Spare3 = b.Nickname }; } break; } query = (category?.ToLower()) switch { "top" => query.OrderByDescending(x => x.GrLaud), "text" => query.OrderByDescending(x => x.GrCreateTime).Where(x => !string.IsNullOrEmpty(x.GrContent) && string.IsNullOrEmpty(x.GrImage) && string.IsNullOrEmpty(x.GrAudio) && string.IsNullOrEmpty(x.GrVideo)), "image" => query.OrderByDescending(x => x.GrCreateTime).Where(x => !string.IsNullOrEmpty(x.GrImage)), "audio" => query.OrderByDescending(x => x.GrCreateTime).Where(x => !string.IsNullOrEmpty(x.GrAudio)), "video" => query.OrderByDescending(x => x.GrCreateTime).Where(x => !string.IsNullOrEmpty(x.GrVideo)), _ => query.OrderByDescending(x => x.GrCreateTime), }; //所属用户 if (OwnerId != 0) { query = query.Where(x => x.Uid == OwnerId); } //未登录 if (UserId == 0) { query = query.Where(x => x.GrOpen == 1); } else { //已登录:公开&登录用户的所有 query = query.Where(x => x.GrOpen == 1 || x.Uid == UserId); } //分类名/分类值 if (!string.IsNullOrWhiteSpace(nv)) { if (!nv.Contains("/")) { nv += "/"; } var nvs = nv.Split('/').ToList(); var n = nvs.FirstOrDefault(); var v = nvs.LastOrDefault(); //分类名 if (!string.IsNullOrWhiteSpace(n)) { query = query.Where(x => x.GrTypeName == n); } //分类值 if (!string.IsNullOrWhiteSpace(v)) { query = query.Where(x => x.GrTypeValue == v); } } //标签 if (!string.IsNullOrWhiteSpace(tag)) { query = query.Where(x => x.GrTag.Contains(tag)); } //标签 if (!string.IsNullOrWhiteSpace(tag)) { query = query.Where(x => x.GrTag.Contains(tag)); } //对象 if (!string.IsNullOrWhiteSpace(obj)) { query = query.Where(x => x.GrObject.Contains(obj)); } if (!string.IsNullOrWhiteSpace(q)) { query = query.Where(x => x.GrContent.Contains(q) || x.GrTag.Contains(q)); } var pag = new PaginationVM { PageNumber = Math.Max(page, 1), PageSize = 18 }; var dicQs = new Dictionary <string, string> { { "q", q } }; pag.Total = query.Count(); var list = query.Skip((pag.PageNumber - 1) * pag.PageSize).Take(pag.PageSize).ToList(); var listid = list.Select(x => x.GrId).ToList(); //点赞查询 if (category != "melaud") { var listtid = db.UserConnection.Where(x => listid.Contains(x.UconnTargetId) && x.Uid == UserId && x.UconnTargetType == ctype && x.UconnAction == 1).Select(x => x.UconnTargetId).ToList(); foreach (var item in list) { if (listtid.Contains(item.GrId)) { item.Spare1 = "laud"; } } } //查询记录 var ormo = new OperationRecord() { OrId = Core.UniqueTo.LongId().ToString(), OrType = ctype, OrAction = "query", OrSource = string.Join(",", listid), OrCreateTime = DateTime.Now, OrMark = "default" }; db.OperationRecord.Add(ormo); db.SaveChanges(); PageVM pageSet = new PageVM() { Rows = list, Pag = pag, QueryString = dicQs }; return(pageSet); }
public PartialViewResult ReportView(string startDate, string endDate, string[] unitIDs, string[] statusIDs, string[] contractorIDs) { Session["startDate"] = startDate; Session["endDate"] = endDate; Session["selectedUnitIDs"] = unitIDs; Session["selectedStatusIDs"] = statusIDs; Session["selectedContractorIDs"] = contractorIDs; DateTime start = DateTime.Parse(startDate); DateTime end = DateTime.Parse(endDate); double totalPayment = 0; double totalDeposit = 0; double totalBalace = 0; StringBuilder sbOperation = new StringBuilder(); sbOperation.Append("Select distinct ID, [tblUnitOperation].DueDate, FinishDate, PaidBy.FirstName +' ' + PaidBy.LastName as PaidBy, "); sbOperation.Append("tblUnitOperation.Notes,[tblUnitOperation].LinkedExpenseID, Amount, tblAccount.AccountName, tblProperty.Address, tblPropertyUnit.UnitName, IsCredit, "); sbOperation.Append(" DueAmount, [tblUnitOperation].StatusID, cStatusType.Name as StatusName, cExpenseCategory.CategoryName,tblUnitOperation.BankTracking from tblUnitOperation "); sbOperation.Append(" inner join tblPropertyUnit on tblPropertyUnit.UnitID = tblUnitOperation.UnitID "); sbOperation.Append(" INNER JOIN tblProperty ON tblProperty.PropertyID = tblPropertyUnit.PropertyID "); sbOperation.Append(" INNER JOIN mCompanyProperty on mCompanyProperty.PropertyID = tblProperty.PropertyID "); sbOperation.Append(" LEFT OUTER JOIN cUser as PaidBy on PaidBy.UserID = tblUnitOperation.ContractorID "); sbOperation.Append(" LEFT OUTER JOIN cStatusType on cStatusType.StatusTypeID = tblUnitOperation.StatusID "); sbOperation.Append(" LEFT OUTER JOIN cExpenseCategory on cExpenseCategory.CategoryID = tblUnitOperation.CategoryID "); sbOperation.Append(" LEFT OUTER JOIN tblAccount as tblAccount on tblAccount.FinancialAccountID = tblUnitOperation.FinancialAccountID "); StringBuilder whereClause = new StringBuilder(); if (!String.IsNullOrEmpty(startDate)) { start = DateTime.Parse(startDate); whereClause.Append(" and [tblUnitOperation].FinishDate>='" + start.ToShortDateString() + "' "); } if (!String.IsNullOrEmpty(endDate)) { end = DateTime.Parse(endDate); whereClause.Append(" and [tblUnitOperation].FinishDate<='" + end.ToShortDateString() + "'"); } //get the companys only the owner can access whereClause.Append(" AND mCompanyProperty.CompanyID IN (" + GetUserManagedCompanyString() + ")"); // Add modality id to the where clause if appropriate if (unitIDs != null && unitIDs.Count() > 0 && !string.IsNullOrEmpty(unitIDs[0])) { whereClause.Append(" AND tblPropertyUnit.UnitID IN (" + String.Join(",", unitIDs) + ")"); } if (statusIDs != null && statusIDs.Count() > 0 && !string.IsNullOrEmpty(statusIDs[0])) { whereClause.Append(" AND [tblUnitOperation].StatusID IN (" + String.Join(",", statusIDs) + ")"); } if (contractorIDs != null && contractorIDs.Count() > 0 && !string.IsNullOrEmpty(contractorIDs[0])) { whereClause.Append(" AND [tblUnitOperation].ContractorID IN (" + String.Join(",", contractorIDs) + ")"); } whereClause.Append(" AND [tblUnitOperation].CategoryID IN (18)"); sbOperation.Append(whereClause.Remove(0, 4).Insert(0, " where ")); sbOperation.Append(" Order by DueDate"); // Create a list of our result class to hold the data from the query // Please ensure you instatiate the class for this controller and not a different controller List <OperationRecord> result = new List <OperationRecord>(); // Execute the SQL query and get the results using (SqlDataAdapter adapter = new SqlDataAdapter(sbOperation.ToString(), Helpers.Helpers.GetAppConnectionString())) { DataSet ds = new DataSet(); adapter.Fill(ds); DataTable tb = (DataTable)ds.Tables[0]; if (tb != null && tb.Rows.Count > 0) { for (int i = 0; i < tb.Rows.Count; i++) { DataRow dr = tb.Rows[i]; OperationRecord row = new OperationRecord(); if (dr["DueDate"] != DBNull.Value) { row.DueDate = DateTime.Parse(dr["DueDate"].ToString()); } if (dr["FinishDate"] != DBNull.Value) { row.CompleteDate = DateTime.Parse(dr["FinishDate"].ToString()); } row.PaidBy = dr["PaidBy"].ToString(); if (dr["BankTracking"] != DBNull.Value) { row.Memo = dr["Notes"].ToString() + " " + dr["BankTracking"].ToString(); } else { row.Memo = dr["Notes"].ToString(); } if (dr["Amount"] != DBNull.Value) { row.Payment = double.Parse(dr["Amount"].ToString()); } row.BankAccountName = dr["AccountName"].ToString(); row.Address = dr["Address"].ToString() + " -- " + dr["UnitName"].ToString(); if (dr["DueAmount"] != DBNull.Value) { row.DueAmount = double.Parse(dr["DueAmount"].ToString()); } row.ID = int.Parse(dr["ID"].ToString()); if (dr["StatusID"] != DBNull.Value) { row.StatusID = short.Parse(dr["StatusID"].ToString()); row.StatusName = dr["StatusName"].ToString(); } if (dr["LinkedExpenseID"] != DBNull.Value) { row.LinkedExpenseID = Int32.Parse(dr["LinkedExpenseID"].ToString()); } row.CategoryName = dr["CategoryName"].ToString(); result.Add(row); totalDeposit += row.Payment; totalPayment += row.DueAmount; totalBalace += row.DueAmount + row.Payment; } } } bool isStartNull = start.Equals(DateTime.MinValue); bool isEndNull = end.Equals(DateTime.MinValue); ViewBag.TableCaption = reporttitle + " Expense: "; if (!start.Equals(DateTime.MinValue)) { ViewBag.TableCaption += " fromt " + start.ToString("g"); } if (!end.Equals(DateTime.MinValue)) { ViewBag.TableCaption += " thru " + end.ToString("g"); } ViewBag.TotalPayment = totalPayment; ViewBag.TotalDeposit = totalDeposit; ViewBag.TotalBalace = totalBalace; return(PartialView("ReportView", result)); }
/// <summary> /// {CB2F6DC4-F9C6-4756-A118-CEDB907C39EC} /// </summary> /// <param name="obj"></param> /// <returns></returns> private int ValidInstate(Neusoft.FrameWork.Models.NeuObject obj) { Neusoft.HISFC.BizProcess.Integrate.RADT radtIntegrate = new Neusoft.HISFC.BizProcess.Integrate.RADT(); Neusoft.HISFC.Models.RADT.PatientInfo patientInfo = null; if (obj is OperationRecord) { OperationRecord tempObj = obj as OperationRecord; if (tempObj.OperationAppllication.PatientSouce == "2") { patientInfo = radtIntegrate.GetPatientInfomation(tempObj.OperationAppllication.PatientInfo.ID); if (patientInfo == null) { MessageBox.Show(radtIntegrate.Err); return(-1); } //if ((Neusoft.HISFC.Models.Base.EnumInState)this.patientInfo.PVisit.InState.ID == Neusoft.HISFC.Models.Base.EnumInState.N // || (Neusoft.HISFC.Models.Base.EnumInState)this.patientInfo.PVisit.InState.ID == Neusoft.HISFC.Models.Base.EnumInState.O) if (patientInfo.PVisit.InState.ID.ToString() == Neusoft.HISFC.Models.Base.EnumInState.N.ToString() || patientInfo.PVisit.InState.ID.ToString() == Neusoft.HISFC.Models.Base.EnumInState.O.ToString()) { Neusoft.FrameWork.WinForms.Classes.Function.Msg("该患者已经出院!", 111); return(-1); } } } if (obj is OperationAppllication) { OperationAppllication tempOA = obj as OperationAppllication; if (tempOA.PatientSouce == "2") { patientInfo = radtIntegrate.GetPatientInfomation(tempOA.PatientInfo.ID); if (patientInfo == null) { MessageBox.Show(radtIntegrate.Err); return(-1); } //if ((Neusoft.HISFC.Models.Base.EnumInState)this.patientInfo.PVisit.InState.ID == Neusoft.HISFC.Models.Base.EnumInState.N // || (Neusoft.HISFC.Models.Base.EnumInState)this.patientInfo.PVisit.InState.ID == Neusoft.HISFC.Models.Base.EnumInState.O) if (patientInfo.PVisit.InState.ID.ToString() == Neusoft.HISFC.Models.Base.EnumInState.N.ToString() || patientInfo.PVisit.InState.ID.ToString() == Neusoft.HISFC.Models.Base.EnumInState.O.ToString()) { Neusoft.FrameWork.WinForms.Classes.Function.Msg("该患者已经出院!", 111); return(-1); } } } return(1); }
private void neuTreeView1_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e) { TreeNode select = this.tvList.SelectedNode; this.ucRegistrationForm1.HandInput = false; if (select == null) { return; } if (select.Tag == null) { return; } TreeNode parent = select.Parent; if (parent == null) { //this.ucRegistrationForm1.OperationApplication = new OperationAppllication(); this.ucRegistrationForm1.OperationRecord = new OperationRecord(); return; } if (parent.Tag.ToString() == "NO_Register" || parent.Tag.ToString() == "Cancel") { //this.ucQueryInpatientNo1.txtInputCode.Text = // (select.Tag as neusoft.HISFC.Object.Operator.OpsApplication).PatientInfo.PID.PatientNo; //by zlw 2006-5-24 //this.ucRecord1.Dept = tvList.SelectedNode.Text.Substring(tvList.SelectedNode.Text.IndexOf('[') + 1, tvList.SelectedNode.Text.IndexOf(']') - 1); this.ucRegistrationForm1.HandInput = false; if (parent.Tag.ToString() == "NO_Register") { this.ucRegistrationForm1.IsNew = true; this.ucRegistrationForm1.IsCancled = false; } else if (parent.Tag.ToString() == "Cancel") { this.ucRegistrationForm1.IsCancled = true; this.ucRegistrationForm1.IsNew = false; } // {CB2F6DC4-F9C6-4756-A118-CEDB907C39EC} OperationAppllication operationAppllication = select.Tag as OperationAppllication; int returnValue = ValidInstate(select.Tag as OperationAppllication); if (returnValue < 0) { //this.ucRegistrationForm1.OperationApplication = new OperationAppllication(); this.ucRegistrationForm1.Clear(); return; } //this.ucRegistrationForm1.OperationApplication = select.Tag as OperationAppllication; this.ucRegistrationForm1.OperationApplication = operationAppllication; this.ucRegistrationForm1.Focus(); } else if (parent.Tag.ToString() == "Register") { //by zlw 2006-5-24 //this.ucRecord1.Dept = tvList.SelectedNode.Text.Substring(tvList.SelectedNode.Text.IndexOf('[') + 1, tvList.SelectedNode.Text.IndexOf(']') - 1); //this.ucQueryInpatientNo1.txtInputCode.Text = // (select.Tag as OperatorRecord).m_objOpsApp.PatientInfo.Patient.PID.PatientNo; this.ucRegistrationForm1.HandInput = false; this.ucRegistrationForm1.IsNew = false; this.ucRegistrationForm1.IsCancled = false; // {CB2F6DC4-F9C6-4756-A118-CEDB907C39EC} //this.ucRegistrationForm1.OperationRecord = select.Tag as OperationRecord; OperationRecord operationRecord = select.Tag as OperationRecord; int returnValue = ValidInstate(select.Tag as OperationRecord); if (returnValue < 0) { //this.ucRegistrationForm1.OperationRecord = new OperationRecord(); this.ucRegistrationForm1.Clear(); return; } this.ucRegistrationForm1.OperationRecord = operationRecord; this.ucRegistrationForm1.Focus(); } }
/// <summary> /// Default constructor /// </summary> /// <param name="accountNumber">accout number on which operation will be performed</param> /// <param name="record">operation record</param> protected BankOperation(AccountNumber accountNumber, OperationRecord record) { OperationRecord = record; AccountNumber = accountNumber; }
protected override bool CheckWalletValue(WalletRecord wallet, OperationRecord operation) => wallet.Value > operation.Value + operation.Commission;