Example #1
0
        public JsonResult Cashdraws(int? pageIndex = 1)
        {
            Base_Bll bll = new Base_Bll();
            var info = bll.GetInfo<md_cashdraw_app>(1);

            if (pageIndex <= 1)
                pageIndex = 1;
            //状态
            List<SelectListItem> status = (Share.EnumOperate.ToKeyValues(typeof(CashdrawStatus))
                .Select(t => new SelectListItem() { Value = t.Key.ToString(), Text = t.Value, Selected = t.Key == 0 })).ToList();
            ViewBag.status = status;

            string error = string.Empty;
            int record = 0;
            List<md_cashdraw_app> resultlist = new md_cashdraw_app_Bll().SearchCashdrawList(1, null, null, null, null, null, 0, null, null, pageIndex.Value, 2, out record, out error);
            if (resultlist != null)
            {
                PagingResponse<md_cashdraw_app> pagingResponse = new PagingResponse<md_cashdraw_app>();
                pagingResponse.TotalRecord = record;
                pagingResponse.ResultList = resultlist;
                var jsonResult = Json(pagingResponse, JsonRequestBehavior.AllowGet);
                return jsonResult;
            }
            return null;
        }
Example #2
0
        public Model.ResponseMessage Post([FromBody]md_cashdraw_app info)
        {
            md_cashdraw_app_Bll cashdrawBll = new md_cashdraw_app_Bll();
            string error = string.Empty;

            md_cashdraw_app cashdraw = new md_cashdraw_app();
            cashdraw.Initial();
            cashdraw.drid = DoctorID.ToString();
            cashdraw.drawmoney = info.drawmoney;
            cashdraw.in_bank = info.in_bank;
            cashdrawBll.CreateCashdrawApp(cashdraw, out error);

            Model.ResponseMessage result = new ResponseMessage();
            if (!string.IsNullOrEmpty(error))
            {
                result.bSuccess = true;
            }
            else
            {
                result.bSuccess = false;
                result.Message = error;
            }

            return result;
        }
Example #3
0
        public ActionResult UpdateCashdrawList(string idstr)
        {
            if (!string.IsNullOrEmpty(idstr))
            {
                var str = idstr.TrimEnd(',');
                md_cashdraw_app_Bll cashdrawBll = new md_cashdraw_app_Bll();
                md_docter_Bll doctorBll = new md_docter_Bll();
                List<md_cashdraw_app> cashdrawlist = cashdrawBll.GetCashdrawByIds(str);
                string error = string.Empty;
                foreach (var item in cashdrawlist)
                {
                    item.opstatus = (int)Model.ConfigClass.CashdrawStatus.已处理;  ///批注By Andy:更新一次就调用一次数据库连接,对数据库性能有影响,建议传入需要更新的ids,用update语句一次执行
                }
                cashdrawBll.UpdateChashdrawList(cashdrawlist, out error);

                var doctorids = cashdrawlist.Select(m => m.drid).Distinct().ToList();
                var doctorlist = doctorBll.GetDoctorByIds(doctorids);

                List<md_docter> doctors = new List<md_docter>();
                List<md_dr_account> dr_accountlist = new List<md_dr_account>();
                foreach (var item in doctorlist)
                {
                    var list = cashdrawlist.Where(m => m.drid == item.pkid.ToString()).ToList();
                    if (list.Any())
                    {
                        var money = list.Select(m => m.drawmoney).Sum();
                        item.current_income -= money;
                        doctors.Add(item);
                        md_dr_account accountinfo = new md_dr_account();
                        accountinfo.Initial();
                        accountinfo.dr_id = item.pkid;
                        accountinfo.income_type = 0;
                        accountinfo.money = money;
                        dr_accountlist.Add(accountinfo);
                    }
                }
                if (doctors.Any())
                {
                    doctorBll.UpdateChashdrawList(doctors, out error);
                }
                if (dr_accountlist.Any())
                {
                    new md_account_Bll().CreateAccountList(dr_accountlist, out error);
                }

            }

            return View();
        }