Exemplo n.º 1
0
        public async Task <ActionResult> Delete(int id)
        {
            FundsFlow flow = await _mediator.Send(new GetFundsFlowByIdQuery(id)
            {
                IncludeBuildingObject = true,
                IncludeEmployee       = true,
                IncludeOrganization   = true
            });

            FundsFlowListItemModel model = null;

            if (flow != null)
            {
                model = new FundsFlowListItemModel()
                {
                    Date               = flow.Date,
                    Description        = flow.Description,
                    Income             = flow.Income,
                    Outgo              = flow.Outgo,
                    PayType            = flow.PayType,
                    Id                 = flow.Id,
                    EmployeeName       = flow.Employee == null ? flow.OneTimeEmployeeName : flow.Employee.FullName,
                    EmployeeId         = flow.EmployeeId,
                    OrganizationName   = flow.Organization == null ? null : flow.Organization.Name,
                    OrganizationId     = flow.OrganizationId,
                    BuildingObjectName = flow.BuildingObject == null ? null : flow.BuildingObject.Name,
                    BuildingObjectId   = flow.BuildingObjectId
                };
            }

            return(View(model));
        }
        protected override async Task Handle(DeteteFundsFlowCommand request, CancellationToken cancellationToken)
        {
            var itemToDelete = new FundsFlow()
            {
                Id = request.Id
            };

            _context.Entry(itemToDelete).State = EntityState.Deleted;
            await _context.SaveChangesAsync(cancellationToken);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 调整报名课时
        /// </summary>
        /// <param name="enid"></param>
        /// <returns></returns>
        public static bool AjustmentEnroll(string ENID, int ClassHour, decimal Price, string userid)
        {
            DBRepository db = new DBRepository(DBKeys.PRX);

            try
            {
                db.BeginTransaction();
                Enroll en = db.GetById <Enroll>(ENID);
                if (en == null)
                {
                    return(false);
                }
                //增加调整课时日志
                TransferRecord tr = new TransferRecord();//添加日志记录
                tr.StudentID   = en.StudentID;
                tr.BeforeHours = en.ClassHour - en.UsedHour;
                tr.AfterHours  = en.ClassHour - en.UsedHour + +decimal.Parse(ClassHour.ToString());
                tr.TypeID      = 8;//调整报名课时
                tr.CreateTime  = DateTime.Now;
                tr.CreatorId   = userid;
                tr.ENID        = en.ID;
                tr.ClassID     = en.ClassID;
                db.Insert(tr);

                //增加资金日志
                FundsFlow fundsflow = new FundsFlow();//添加日志记录
                fundsflow.TypeID     = 5;
                fundsflow.Amount     = Price;
                fundsflow.KeyID      = ENID;
                fundsflow.CreatorId  = userid;
                fundsflow.CreateTime = DateTime.Now;
                fundsflow.StateID    = 0;
                db.Insert(fundsflow);

                //增加报名费用
                en.Price      = en.Price + Price;         //金额
                en.Paid       = en.Paid + Price;
                en.ClassHour  = en.ClassHour + ClassHour; //课时
                en.UpdateTime = DateTime.Now;
                en.UpdatorId  = userid;
                db.Update(en);


                db.Commit();
                db.Dispose();
                return(true);
            }
            catch (Exception ex)
            {
                db.Rollback();
                db.Dispose();
                throw new Exception(ex.Message);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 批量新增报名记录
        /// </summary>
        /// <param name="list"></param>
        /// <returns></returns>
        public static int AddList(List <Enroll> list)
        {
            int ret = 0;//初始

            foreach (var obj in list)
            {
                int haveenroll = EnrollData.getEnrollByStuidCalssid(obj.StudentID, obj.ClassID);
                if (haveenroll > 0)
                {
                    ret = -1;//重复报名
                    return(ret);
                }
            }
            DBRepository db = new DBRepository(DBKeys.PRX);

            db.BeginTransaction();
            try
            {
                foreach (var obj in list)
                {
                    obj.ID = CommonData.DPGetTableMaxId("EN", "ID", "Enroll", 8, db);//走同一个事务
                    db.Insert <Enroll>(obj);
                    Appointment ap = db.GetById <Appointment>(obj.APID);
                    ap.ApStateID = 3;//已报名
                    db.Update <Appointment>(ap);

                    FundsFlow fl = new FundsFlow(); //资金流水
                    fl.TypeID     = 1;              //类型1报名
                    fl.Amount     = obj.Paid;
                    fl.KeyID      = obj.ID;
                    fl.CreateTime = DateTime.Now;
                    fl.CreatorId  = obj.CreatorId;
                    db.Insert(fl);

                    //Classes ca = ClassesData.GetClassesByID(obj.ClassID);
                    //ca.PresentEnroll = ca.PresentEnroll + 1;
                    //MsSqlMapperHepler.Update<Classes>(ca, DBKeys.PRX);//报名数加1
                }
                ret = 1;//成功
                db.Commit();
            }
            catch (Exception ex)
            {
                db.Rollback();
                db.Dispose();
                throw new Exception(ex.Message);
            }
            return(ret);
        }
Exemplo n.º 5
0
        public async Task <ActionResult> Edit(int id)
        {
            FundsFlow ff = await _mediator.Send(new GetFundsFlowByIdQuery(id));

            var model = new EditFundsFlowModel
            {
                Id = ff.Id,
                BuildingObjectId    = ff.BuildingObjectId,
                Date                = ff.Date,
                Description         = ff.Description,
                EmployeeId          = ff.EmployeeId,
                OneTimeEmployeeName = ff.OneTimeEmployeeName,
                UseOneTimeEmployee  = !string.IsNullOrWhiteSpace(ff.OneTimeEmployeeName),
                OrganizationId      = ff.OrganizationId,
                Income              = ff.Income,
                Outgo               = ff.Outgo,
                OutgoType           = ff.OutgoType,
                PayType             = ff.PayType,
                Employees           = (await _mediator.Send(new ListEmployeesQuery())).Select(item => new SelectListItem
                {
                    Text  = item.FullName,
                    Value = item.Id.ToString()
                }),
                BuildingObjects = (await _mediator.Send(new ListBuildingObjectsQuery())).Select(item => new SelectListItem
                {
                    Value = item.Id.ToString(),
                    Text  = item.Name
                }),
                Organizations = (await _mediator.Send(new ListOrganizationsQuery())).Select(item => new SelectListItem
                {
                    Value = item.Id.ToString(),
                    Text  = item.Name
                }),
            };

            return(View(model));
        }
Exemplo n.º 6
0
        /// <summary>
        /// 升班的操作
        /// </summary>
        /// <param name="oldclassid"></param>
        /// <param name="newclassid"></param>
        /// <param name="ja"></param>
        /// <param name="operateid"></param>
        /// <returns></returns>
        public static bool UpClass(string oldclassid, string newclassid, JArray ja, string operateid)
        {
            bool         ret = false;
            DBRepository db  = new DBRepository(DBKeys.PRX);

            db.BeginTransaction();
            try
            {
                foreach (var item in ja)
                {
                    string         enid         = ((JObject)item)["enid"].ToString();                        //报名记录id
                    decimal        newclasshour = decimal.Parse(((JObject)item)["newclasshour"].ToString()); //转换后的课时
                    decimal        upprice      = decimal.Parse(((JObject)item)["upprice"].ToString());;     //升班差价
                    Enroll         en           = db.GetById <Enroll>(enid);                                 //获取学员的报名记录
                    TransferRecord tf           = new TransferRecord();                                      //转移记录
                    tf.StudentID   = en.StudentID;
                    tf.TypeID      = 2;                                                                      //升班
                    tf.BeforeHours = en.ClassHour - en.UsedHour;
                    tf.AfterHours  = newclasshour;
                    tf.CreateTime  = DateTime.Now;
                    tf.CreatorId   = operateid;
                    tf.Remark      = "升班:原报名号:" + enid + " 原班级号:" + oldclassid + " 新班级:" + newclassid;
                    db.Insert(tf);
                    //生成新的报名记录
                    Enroll upen = new Enroll();
                    upen.ID         = CommonData.DPGetTableMaxId("EN", "ID", "Enroll", 8, db);
                    upen.APID       = "";
                    upen.StudentID  = en.StudentID;
                    upen.ClassID    = newclassid;
                    upen.ClassHour  = newclasshour;
                    upen.UsedHour   = 0;//改变所消耗课时
                    upen.Price      = 0;
                    upen.Paid       = 0;
                    upen.CreatorId  = operateid;
                    upen.CreateTime = DateTime.Now;
                    upen.StateID    = 1;//无需审核

                    upen.UpPrice = upprice;

                    db.Insert(upen);

                    FundsFlow fl = new FundsFlow(); //资金流水
                    fl.TypeID     = 4;              //类型为升班
                    fl.Amount     = upprice;
                    fl.KeyID      = upen.ID;
                    fl.CreateTime = DateTime.Now;
                    fl.CreatorId  = operateid;
                    db.Insert(fl);

                    Classes ca = db.GetById <Classes>(oldclassid);
                    ca.StateID = 4;//原来班级状态
                    db.Update(ca);

                    //原课时清零
                    en.UsedHour = en.ClassHour;
                    db.Update(en);
                }
                ret = true;
                db.Commit();
                db.Dispose();
            }
            catch (Exception ex)
            {
                db.Rollback();
                db.Dispose();//资源释放
                throw new Exception(ex.Message);
            }
            return(ret);
        }
Exemplo n.º 7
0
        /// <summary>
        /// 审核通过
        /// </summary>
        /// <param name="btn"></param>
        /// <returns></returns>
        public static int Audited(EnrollAudit erau)
        {
            int          ret = 0;
            DBRepository db  = new DBRepository(DBKeys.PRX);

            db.BeginTransaction();//事务开始
            try
            {
                UpdateEnrollAudit(erau.APID, erau.StateID, erau.UpdateTime, erau.UpdatorId, db);



                string sql        = "select * from EnrollAudit where APID=@APID";
                var    parameters = new DynamicParameters();
                parameters.Add("@APID", erau.APID);
                List <EnrollAudit> List = db.Query <EnrollAudit>(sql, parameters).ToList();

                Enroll er = new Enroll();
                foreach (var en in List)
                {
                    er.ID             = CommonData.DPGetTableMaxId("EN", "ID", "Enroll", 8, db);
                    er.APID           = en.APID;
                    er.ApprovedBy     = en.ApprovedBy;
                    er.ApprovedRemark = en.ApprovedRemark;
                    er.ApprovedTime   = en.ApprovedTime;
                    er.ClassHour      = en.ClassHour;
                    er.ClassID        = en.ClassID;
                    er.CreateTime     = en.CreateTime;
                    er.CreatorId      = en.CreatorId;
                    er.DiscountID     = en.DiscountID;
                    er.DiscountPrice  = en.DiscountPrice;
                    er.Paid           = en.Paid;
                    er.Price          = en.Price;
                    er.Remark         = en.Remark;
                    er.StateID        = en.StateID;
                    er.StudentID      = en.StudentID;
                    er.UpdateTime     = en.UpdateTime;
                    er.UpdatorId      = en.UpdatorId;
                    er.UsedHour       = en.UsedHour;

                    er.CollectionRec = en.CollectionRec;

                    db.Insert <Enroll>(er);         //复制 EnrollAudit表数据到报名表

                    FundsFlow fl = new FundsFlow(); //资金流水
                    fl.TypeID     = 1;              //类型1报名
                    fl.Amount     = er.Paid;
                    fl.KeyID      = er.ID;
                    fl.CreateTime = DateTime.Now;
                    fl.CreatorId  = er.CreatorId;
                    db.Insert(fl);

                    //如果所报名的班级意见排课了,需要重新生成排课记录
                    Classes cl = db.GetById <Classes>(er.ClassID);
                    if (cl.StateID.Value == 2 || cl.StateID.Value == 3)//如果班级状态是已排课,或已上课,生成课程表AttendanceRecord
                    {
                        List <vw_ClassAttendanceList> clist = new List <vw_ClassAttendanceList>();
                        clist = db.Query <vw_ClassAttendanceList>("select * from vw_ClassAttendanceList where ClassID = '" + cl.ID + "'", null).ToList();
                        int aa = Convert.ToInt32(er.ClassHour) < clist.Count() ? Convert.ToInt32(er.ClassHour) : clist.Count();//取较小数做循环
                        for (int i = 0; i < aa; i++)
                        {
                            AttendanceRecord attend = new AttendanceRecord();
                            attend.CreateTime       = DateTime.Now; //创建时间
                            attend.CreatorId        = en.UpdatorId; //创建人
                            attend.ClassID          = en.ClassID;   //班级编号
                            attend.ClassIndex       = i + 1;        //班次序号,也就是班级生成的集体上课记录
                            attend.AttendanceTypeID = 1;            //上课状态,默认为1,未考勤
                            attend.StudentID        = en.StudentID; //学员号
                            db.Insert <AttendanceRecord>(attend);   //增加上课记录表数据
                        }
                    }
                }
                ret = UpdateAppointment(erau.APID, erau.StateID, erau.UpdateTime, erau.UpdatorId, db);  //最后修改Appointment状态为3,3为已报名


                db.Commit();  //事务提交
                db.Dispose(); //资源释放
            }
            catch (Exception ex)
            {
                db.Rollback();
                db.Dispose();
                throw new Exception(ex.Message + "。" + ex.InnerException.Message);
            }
            return(ret);
        }