Пример #1
0
        public ActionResult Record()
        {
            FormsAuthenticationTicket authentication = MvcApplication.GetAuthenticationTicket();
            int mana_id = authentication == null ? 0 : Convert.ToInt32(authentication.Name);

            RecordModel model = new RecordModel();
            model.record_type_list = record_type_service.Table().ToList();
            model.summary_list = summary_service.SearchByManagerID(mana_id).ToList();
            model.loan_type_list = loan_type_service.Table().ToList();
            return View(model);
        }
Пример #2
0
 public ActionResult Record(RecordModel model)
 {
     if (ModelState.IsValid)
     {
         string check_result = CheckRecord(model);
         if (!string.IsNullOrEmpty(check_result))
         {
             return Content(ReturnMessageAndRedirect(check_result, "Main", "Record"));
         }
         else
         {
             T_Summary_Record summary_record = CreateSummaryRecord(model);
             summary_record_service.Insert(summary_record);
         }
     }
     else
     {
         model.record_type_list = record_type_service.Table().ToList();
         model.summary_list = summary_service.Table().ToList();
         model.loan_type_list = loan_type_service.Table().ToList();
         return View(model);
     }
     return RedirectToAction("Record", "Main");
 }
Пример #3
0
        private string CheckRecord(RecordModel model)
        {
            string result = "";
            #region 常规检查
            T_Record_Type record_type = record_type_service.SearchByCode(model.record_type_code).FirstOrDefault();
            if (record_type == null)
            {
                result = "错误记账类型";
            }
            else
            {
                T_Summary summary = summary_service.GetByID(model.summary_id);

                if (summary == null)
                {
                    result = "错误账号类型";
                }
                else
                {
                    if (model.record_amount <= 0)
                    {
                        result = "错误记账金额(大于0)";
                    }
                    else
                    {
                        if (model.remark != null && model.remark.Length > 100)
                        {
                            result = "备注长度过长,不能超过100个字符";
                        }
                    }
                }
            }

            #endregion
            #region 特殊字段检查
            if (model.record_type_code == WebCont.RECORD_TYPE_TRANSFER)
            {
                T_Summary summary_transfer = summary_service.GetByID(model.summary_transfer_id);
                if (summary_transfer == null)
                {
                    result = "错误转账账号类型";
                }
            }
            else
            {
                model.summary_transfer_id = 0;
            }

            if (model.record_type_code == WebCont.RECORD_TYPE_LOAN)
            {
                T_Loan_Type loan_type = loan_type_service.SearchByCode(model.loan_type_code).FirstOrDefault();
                if (loan_type == null)
                {
                    result = "错误借贷类型";
                }
            }
            else
            {
                model.loan_type_code = 0;
            }
            #endregion
            return result;
        }
Пример #4
0
 private T_Summary_Record CreateSummaryRecord(RecordModel model,
                                             FormsAuthenticationTicket authentication,
                                             decimal record_amount,
                                             decimal tran_record_amount,
                                             bool is_deal
                                             )
 {
     T_Summary_Record insert = new T_Summary_Record();
     insert.mana_id = authentication == null ? 0 : Convert.ToInt32(authentication.Name);
     insert.reco_type_code = model.record_type_code;
     insert.summ_id = model.summary_id;
     insert.summ_tran_id = model.summary_transfer_id;
     insert.loan_type_code = model.loan_type_code;
     insert.amount = record_amount;
     insert.tran_amount = tran_record_amount;
     insert.remark = model.remark == null ? "" : model.remark.Trim();
     insert.add_time = model.add_time;
     insert.is_deal = is_deal;
     return insert;
 }
Пример #5
0
        private T_Summary_Record CreateSummaryRecord(RecordModel model)
        {
            T_Summary_Record insert = null;
            FormsAuthenticationTicket authentication = MvcApplication.GetAuthenticationTicket();

            if (model.record_type_code == WebCont.RECORD_TYPE_PAY)
            {
                insert = CreateSummaryRecord(model, authentication, -model.record_amount,0,true);
            }
            else if (model.record_type_code == WebCont.RECORD_TYPE_INCOME)
            {
                insert = CreateSummaryRecord(model, authentication, model.record_amount, 0, true);
            }
            else if (model.record_type_code == WebCont.RECORD_TYPE_TRANSFER)
            {
                insert = CreateSummaryRecord(model, authentication, -model.record_amount, model.record_amount, true);
            }
            else if (model.record_type_code == WebCont.RECORD_TYPE_LOAN)
            {
                if (model.loan_type_code == WebCont.LOAN_TYPE_BORROW_IN || model.loan_type_code == WebCont.LOAN_TYPE_REPAY_IN)
                {
                    insert = CreateSummaryRecord(model, authentication, model.record_amount, 0,false);
                }
                else if (model.loan_type_code == WebCont.LOAN_TYPE_BORROW_OUT || model.loan_type_code == WebCont.LOAN_TYPE_REPAY_OUT)
                {
                    insert = CreateSummaryRecord(model, authentication, -model.record_amount, 0, false);
                }
            }
            return insert;
        }