public string DeleteStudentCourse(string listCourse, string stu_id) { if (string.IsNullOrEmpty(listCourse)) { return(""); } if (listCourse.EndsWith(",")) { listCourse = listCourse.Substring(0, listCourse.Length - 1); } string[] list = listCourse.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); int len = list.Length; int[] cids = new int[len]; for (int i = 0; i < len; i++) { cids[i] = WebUtility.FilterParam(list[i]); if (cids[i] == 0) { return("退费失败,课程获取失败。"); } } int row = dal.DeleteStudentCourse(cids, stu_id); if (row == len) { return("退费成功。"); } else { return("退费失败,请检查。"); } }
/// <summary> /// 报名课程 /// </summary> /// <param name="listCourse"></param> /// <param name="cost"></param> /// <returns></returns> public bool AddStudentCourse(string listCourse, decimal cost, string stu_id) { if (string.IsNullOrEmpty(listCourse)) { return(false); } if (listCourse.EndsWith(",")) { listCourse = listCourse.Substring(0, listCourse.Length - 1); } string[] list = listCourse.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); int len = list.Length; int[] cids = new int[len]; for (int i = 0; i < len; i++) { cids[i] = WebUtility.FilterParam(list[i]); if (cids[i] == 0) { return(false); } } DataSet dsCost = new course().getSUMCost(listCourse); DataTable dtCost = dsCost.Tables[1]; if (dtCost.Rows.Count != len) { return(false); } decimal[] cost_list = new decimal[len]; decimal allCost; decimal per; if (dsCost.Tables[0].Rows.Count == 0) { allCost = 0; per = 0; } else { allCost = (decimal)dsCost.Tables[0].Rows[0][0]; per = cost / allCost; } int thispay; for (int i = 0; i < len; i++) { thispay = (int)((decimal)dtCost.Rows[i]["Course_cost"] * per); cost_list[i] = thispay; allCost = allCost - thispay; } if (allCost != 0) { cost_list[len - 1] = cost_list[len - 1] + allCost; } return(dal.AddStudentCourse(cids, cost_list, stu_id)); }
/// <summary> /// 是否是超级管理员 /// </summary> /// <returns></returns> public bool isSuperAdmin() { int id = 0; if (HttpContext.Current.Session["role_id"] != null) { id = WebUtility.FilterParam(HttpContext.Current.Session["role_id"].ToString()); } return(id == 1); }
/// <summary> /// 获取角色ID /// </summary> /// <returns></returns> public int GetRoleId() { int id = 0; if (HttpContext.Current.Session["role_id"] != null) { id = WebUtility.FilterParam(HttpContext.Current.Session["role_id"].ToString()); } return(id); }
public String Update(string subList, int myrole_id, int role_id) { string[] list = subList.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); if (list == null || list.Length == 0) { return("noselect"); } //查询出当前管理员所管理的科目 DataTable dtRoleSub = GetManagerSubjectByCache(myrole_id); if (dtRoleSub.Rows.Count == 0) { return("nopower"); } //查询传入的科目是否有不包含在当前管理员的科目中的 bool isContain = false; foreach (string sub_id in list) { isContain = false; int subject_id = WebUtility.FilterParam(sub_id); if (subject_id == 0) { return("selecterror"); } foreach (DataRow dr in dtRoleSub.Rows) { if ((int)dr["Subject_id"] == subject_id) { isContain = true; break; } } if (!isContain) { return("nopower"); } } //判断是否有管理该角色的权限 DataTable dtRole = new BLL.sys_role().GetDataTableByCache(); Common.Tree.RoleTree tree = new Common.Tree.RoleTree(dtRole, 0, "Role_parent_id", "Role_id"); tree.Creat(); if (!tree.isParent(myrole_id, role_id)) { return("nopower"); } Model.role_vs_subject modelrvs = new Model.role_vs_subject(); modelrvs.role_id = role_id; modelrvs.sub_list = subList; if (Exists(role_id)) { if (Update(modelrvs)) { return("success"); } else { return("error"); } } else { if (Add(modelrvs)) { return("success"); } else { return("error"); } } }