Ejemplo n.º 1
0
        public ActionResult RecordAdjust(RecordAdjustModel model)
        {
            FormsAuthenticationTicket authentication = MvcApplication.GetAuthenticationTicket();
            int mana_id = authentication == null ? 0 : Convert.ToInt32(authentication.Name);
            model.summary_list = summary_service.SearchByManagerID(mana_id).ToList();
            List<T_Summary_Record> summary_record_list = summary_record_service.Table().ToList();
            model.summary_count_list = CreateCountSummaryRecord(model.summary_list, summary_record_list);

            if (ModelState.IsValid)
            {
                string check_result =  CheckRecordAdjust(model);
                if (!string.IsNullOrEmpty(check_result))
                {
                    return Content(ReturnMessageAndRedirect(check_result, "Main", "RecordAdjust"));
                }
                else
                {
                    for (int i= 0; i<  model.summ_id.Count();i++)
                    {
                        int id = model.summ_id[i];
                        decimal adjust_amount = model.adjust_amont[i];
                        SummaryCountModel summary_count = model.summary_count_list.Where(M => M.summary_id == id).FirstOrDefault();
                        if (summary_count != null)
                        {
                            //如果调整数和数据库记录数不一致,则需要插入数据
                            decimal diff = adjust_amount - summary_count.summary_sum_amount;
                            if (diff != 0)
                            {
                                T_Summary_Record insert = new T_Summary_Record();
                                insert.mana_id = authentication == null ? 0 : Convert.ToInt32(authentication.Name);
                                insert.summ_id = id;
                                insert.summ_tran_id = 0;
                                insert.loan_type_code = 0;
                                insert.amount = diff;
                                insert.tran_amount = 0;
                                insert.remark = "资金调整,自动插入";
                                insert.add_time = DateTime.Now;
                                insert.is_deal = true;
                                if (diff > 0)
                                {
                                    insert.reco_type_code = WebCont.RECORD_TYPE_INCOME;
                                }
                                else
                                {
                                    insert.reco_type_code = WebCont.RECORD_TYPE_PAY;
                                }
                                summary_record_service.DelayInsert(insert);
                            }
                        }
                    }
                    summary_record_service.DelaySubmit();
                }
            }
            else
            {
                return View(model);
            }
            return RedirectToAction("RecordAdjust", "Main");

        }
Ejemplo n.º 2
0
        private string CheckRecordAdjust(RecordAdjustModel model)
        {
            string result = "";

            foreach (int id in model.summ_id)
            {
                T_Summary summary = model.summary_list.Where(M=>M.summ_id == id).FirstOrDefault();
                if (summary == null)
                {
                    result = "存在无效记账类型";
                }
            }
            return result;
        }
Ejemplo n.º 3
0
        public ActionResult RecordAdjust()
        {
            FormsAuthenticationTicket authentication = MvcApplication.GetAuthenticationTicket();
            int mana_id = authentication == null ? 0 : Convert.ToInt32(authentication.Name);

            RecordAdjustModel model = new RecordAdjustModel();
            model.summary_list = summary_service.SearchByManagerID(mana_id).ToList();
            List<T_Summary_Record> summary_record_list = summary_record_service.Table().ToList();
            model.summary_count_list = CreateCountSummaryRecord(model.summary_list, summary_record_list);
            return View(model);
        }