public ResponseMessage Post([FromBody]md_docter value) { Model.ResponseMessage result = new ResponseMessage(); try { string error = string.Empty; Base_Bll bll = new Base_Bll(); md_docter info = bll.GetInfo<md_docter>(DoctorID); string encryptKey = string.Empty; var password = BaseTool.EncryptDES(value.oldpwd, encryptKey); if (info.login_pwd == password) { var newpassword = BaseTool.EncryptDES(value.login_pwd, encryptKey); info.login_pwd = newpassword; info = new md_docter_Bll().UpdateDocter(info, out error); if (string.IsNullOrEmpty(error)) { result.bSuccess = true; result.Message = "修改成功"; } else { result.bSuccess = false; result.Message = error; } } } catch(Exception ex) { result.bSuccess=false; } return result; }
// GET api/<controller> public Model.ResponseMessage Get(string loginname, string loginpwd) { string error = string.Empty; string keyvalue = string.Empty; md_docter_Bll bll = new md_docter_Bll(); Model.ResponseMessage result = new ResponseMessage(); if (!string.IsNullOrEmpty(loginname) && !string.IsNullOrEmpty(loginpwd)) { bll.LoginUtil(loginname, loginpwd, keyvalue, out error); if (string.IsNullOrEmpty(error)) { result.bSuccess = true; result.Message = "登录成功"; } else { result.bSuccess = false; result.Message = error; } } return result; }
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(); }
// PUT api/< >/5 public ResponseMessage Put(int id, [FromBody]md_docter value) { Model.ResponseMessage result = new ResponseMessage(); string error = string.Empty; Base_Bll bll = new Base_Bll(); var info = bll.GetInfo<md_docter>(DoctorID); info.login_pwd=value.oldpwd; md_docter_Bll docbll = new md_docter_Bll(); docbll.UpdateDocter(info, out error); if (string.IsNullOrEmpty(error)) { result.bSuccess = true; result.Message = "修改成功"; } else { result.bSuccess = false; result.Message = error; } return result; }