コード例 #1
0
        /// <summary>
        /// 新增指定数量评委.
        /// </summary>
        /// <param name="expertCount">评委数.</param>
        /// <param name="projectName">项目名称.</param>
        /// <param name="projectId">项目编号.</param>
        public void AddExpert(int expertCount, string projectName, int projectId)
        {
            List <Expert> list = new List <Expert>();

            for (int i = 1; i <= expertCount; i++)
            {
                Expert expert = new Expert
                {
                    Account   = i.ToString(),
                    Name      = projectName + "-" + i + "号评委",
                    ProjectId = projectId,
                    Status    = "未投票",
                    Password  = GetRandomString.GenerateRandomNumber(),
                };
                expert.CodePath = CreateCodePath(expert.Account, expert.Password, expert.Name);
                list.Add(expert);
            }

            Db.Insertable(list).ExecuteCommand();
        }
コード例 #2
0
        /// <summary>
        /// 新建病历.
        /// </summary>
        /// <param name="recordDTO">传入数据.</param>
        /// <returns>Json.</returns>
        public ActionResult AddRecord(RecordDTO recordDTO)
        {
            Record record = new Record
            {
                Id           = recordDTO.Id,
                Name         = recordDTO.Name,
                Sex          = recordDTO.Sex,
                Age          = recordDTO.Age,
                Phone        = recordDTO.Phone,
                DepartmentId = int.Parse(recordDTO.Department.Split(' ')[0]),
                BedId        = int.Parse(recordDTO.Bed.Split(' ')[0]),
                MedicalCost  = recordDTO.MedicalCost,
                Deposit      = recordDTO.Deposit,
                Status       = recordDTO.Status,
                InTime       = DateTime.Now.ToString(),
                Account      = GetRandomString.GenerateRandomNumber(),
                PassWord     = "******",
            };

            // 自增列用法
            int recordId = Db.Insertable(record).ExecuteReturnIdentity();

            // 生成日志
            Log log = new Log
            {
                Id      = 0,
                Time    = DateTime.Now.ToString(),
                Content = "病历号:" + recordId + "-姓名:" + record.Name + "办理入院登记",
            };

            // 自增列用法
            Db.Insertable(log).ExecuteReturnIdentity();

            // 生成账单
            Bill bill = new Bill
            {
                Id       = 0,
                RecordId = recordId,
                Time     = DateTime.Now.ToString(),
                Status   = "待支付",
            };

            bill.Type = "押金";
            bill.Cost = record.Deposit;
            Db.Insertable(bill).ExecuteReturnIdentity();
            bill.Type = "医疗费";
            bill.Cost = record.MedicalCost;
            Db.Insertable(bill).ExecuteReturnIdentity();
            bill.Type = "床位费";
            var department = Db.Queryable <Department>().Where(it => it.Id == record.DepartmentId).Single();

            bill.Cost = department.Cost;
            Db.Insertable(bill).ExecuteReturnIdentity();

            // 更新病床和科室
            department.FreeBedNum--;
            var bed = Db.Queryable <Bed>().Where(it => it.Id == record.BedId).Single();

            bed.IsFree   = "已占用";
            bed.RecordId = recordId;
            Db.Updateable(department).ExecuteCommand();
            Db.Updateable(bed).ExecuteCommand();

            // 新增家属
            AddUser(record, recordId);

            return(Json(new { code = 200 }, JsonRequestBehavior.AllowGet));
        }