public static int ClassDelete(string schid, string schclassid) { int ret = 0; SchSystem.BLL.SchClassInfo classbll = new SchSystem.BLL.SchClassInfo(); bool resultBool = classbll.ExistsClassStuData(int.Parse(schclassid)); if (resultBool)//如果为true说明是班级内有数据 { ret = 0; } else//否则即可删除班级记录 { SchSystem.Model.SchClassInfo classmodel = new SchSystem.Model.SchClassInfo(); classmodel.ClassId = int.Parse(schclassid); classmodel.IsFinish = 2; classmodel.LastRecTime = DateTime.Now; classmodel.LastRecUser = Com.Session.userid; if (classbll.UpdateStat(classmodel)) { //SchSystem.BLL.SchClassUser scuBll = new SchSystem.BLL.SchClassUser(); // bool ecu = scuBll.ExistsClassUser(int.Parse(schid), int.Parse(classid)); //bool scubool = scuBll.Delete(classid, schid); //if (scubool) // { ret = 1; //} } else { ret = 0; } } return(ret); }
public bool UpdateStat(SchSystem.Model.SchClassInfo model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update SchClassInfo set "); strSql.Append("IsFinish=@IsFinish,"); strSql.Append("LastRecTime=@LastRecTime,"); strSql.Append("LastRecUser=@LastRecUser"); strSql.Append(" where ClassId=@ClassId"); SqlParameter[] parameters = { new SqlParameter("@IsFinish", SqlDbType.TinyInt, 1), new SqlParameter("@LastRecTime", SqlDbType.DateTime), new SqlParameter("@LastRecUser", SqlDbType.VarChar, 20), new SqlParameter("@ClassId", SqlDbType.Int, 4) }; parameters[0].Value = model.IsFinish; parameters[1].Value = model.LastRecTime; parameters[2].Value = model.LastRecUser; parameters[3].Value = model.ClassId; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(SchSystem.Model.SchClassInfo model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into SchClassInfo("); strSql.Append("ClassNo,ClassName,GradeId,GradeCode,SchId,IsFinish,RecTime,RecUser)"); //strSql.Append("ClassNo,ClassName,GradeId,SchId,IsFinish,RecTime,RecUser,LastRecTime,LastRecUser)"); strSql.Append(" values ("); strSql.Append("@ClassNo,@ClassName,@GradeId,@GradeCode,@SchId,@IsFinish,@RecTime,@RecUser)"); //strSql.Append("@ClassNo,@ClassName,@GradeId,@SchId,@IsFinish,@RecTime,@RecUser,@LastRecTime,@LastRecUser)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@ClassNo", SqlDbType.VarChar, 10), new SqlParameter("@ClassName", SqlDbType.VarChar, 40), new SqlParameter("@GradeId", SqlDbType.Int, 4), new SqlParameter("@GradeCode", SqlDbType.VarChar, 10), new SqlParameter("@SchId", SqlDbType.Int, 4), new SqlParameter("@IsFinish", SqlDbType.TinyInt, 1), new SqlParameter("@RecTime", SqlDbType.DateTime), new SqlParameter("@RecUser", SqlDbType.VarChar, 20) //, //new SqlParameter("@LastRecTime", SqlDbType.DateTime), //new SqlParameter("@LastRecUser", SqlDbType.VarChar,20) }; parameters[0].Value = model.ClassNo; parameters[1].Value = model.ClassName; parameters[2].Value = model.GradeId; parameters[3].Value = model.GradeCode; parameters[4].Value = model.SchId; parameters[5].Value = model.IsFinish; parameters[6].Value = model.RecTime; parameters[7].Value = model.RecUser; //parameters[7].Value = model.LastRecTime; //parameters[8].Value = model.LastRecUser; object obj = new object(); try { obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); } catch (Exception e) { } if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(SchSystem.Model.SchClassInfo model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update SchClassInfo set "); strSql.Append("ClassNo=@ClassNo,"); strSql.Append("ClassName=@ClassName,"); strSql.Append("GradeId=@GradeId,"); //strSql.Append("SchId=@SchId,"); //strSql.Append("IsFinish=@IsFinish,"); //strSql.Append("RecTime=@RecTime,"); //strSql.Append("RecUser=@RecUser,"); strSql.Append("LastRecTime=@LastRecTime,"); strSql.Append("LastRecUser=@LastRecUser"); strSql.Append(" where ClassId=@ClassId"); SqlParameter[] parameters = { new SqlParameter("@ClassNo", SqlDbType.VarChar, 10), new SqlParameter("@ClassName", SqlDbType.VarChar, 40), new SqlParameter("@GradeId", SqlDbType.Int, 4), //new SqlParameter("@SchId", SqlDbType.Int,4), //new SqlParameter("@IsFinish", SqlDbType.TinyInt,1), //new SqlParameter("@RecTime", SqlDbType.DateTime), //new SqlParameter("@RecUser", SqlDbType.VarChar,20), new SqlParameter("@LastRecTime", SqlDbType.DateTime), new SqlParameter("@LastRecUser", SqlDbType.VarChar, 20), new SqlParameter("@ClassId", SqlDbType.Int, 4) }; parameters[0].Value = model.ClassNo; parameters[1].Value = model.ClassName; parameters[2].Value = model.GradeId; //parameters[3].Value = model.SchId; //parameters[4].Value = model.IsFinish; //parameters[5].Value = model.RecTime; //parameters[6].Value = model.RecUser; parameters[3].Value = model.LastRecTime; parameters[4].Value = model.LastRecUser; parameters[5].Value = model.ClassId; string sql = strSql.ToString(); int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public SchSystem.Model.SchClassInfo DataRowToModel(DataRow row) { SchSystem.Model.SchClassInfo model = new SchSystem.Model.SchClassInfo(); if (row != null) { if (row["ClassId"] != null && row["ClassId"].ToString() != "") { model.ClassId = int.Parse(row["ClassId"].ToString()); } if (row["ClassNo"] != null) { model.ClassNo = row["ClassNo"].ToString(); } if (row["ClassName"] != null) { model.ClassName = row["ClassName"].ToString(); } if (row["GradeId"] != null && row["GradeId"].ToString() != "") { model.GradeId = int.Parse(row["GradeId"].ToString()); } if (row["SchId"] != null && row["SchId"].ToString() != "") { model.SchId = int.Parse(row["SchId"].ToString()); } if (row["IsFinish"] != null && row["IsFinish"].ToString() != "") { model.IsFinish = int.Parse(row["IsFinish"].ToString()); } if (row["RecTime"] != null && row["RecTime"].ToString() != "") { model.RecTime = DateTime.Parse(row["RecTime"].ToString()); } if (row["RecUser"] != null) { model.RecUser = row["RecUser"].ToString(); } if (row["LastRecTime"] != null && row["LastRecTime"].ToString() != "") { model.LastRecTime = DateTime.Parse(row["LastRecTime"].ToString()); } if (row["LastRecUser"] != null) { model.LastRecUser = row["LastRecUser"].ToString(); } } return(model); }
public static int ClassNameSave(string schid, int gradeid, string gradecode, string classnamestr) { int ret = 0;//默认返回值为0,数字1代表成功 SchSystem.BLL.SchClassInfo sciBll = new SchSystem.BLL.SchClassInfo(); SchSystem.Model.SchClassInfo sciModel = new SchSystem.Model.SchClassInfo(); string[] classnamearr = classnamestr.Split(','); int classnamearrlen = classnamearr.Length; foreach (string classname in classnamearr) { DataTable dtRes = sciBll.Exists(schid, gradeid, classname.Replace("班", "")).Tables[0]; if (dtRes.Rows.Count > 0)//如果班级已经存在,则修改状态 { DataRow dr = dtRes.Select()[0]; string classid = dr["ClassId"].ToString(); sciModel.ClassId = int.Parse(classid); sciModel.LastRecTime = DateTime.Now; sciModel.LastRecUser = Com.Session.userid; sciModel.IsFinish = 0; bool resret = sciBll.UpdateStat(sciModel); if (resret) { ret = 1; } } else//否则,添加新班级 { sciModel.SchId = Convert.ToInt32(schid); sciModel.GradeId = gradeid; sciModel.GradeCode = Convert.ToString(gradecode); sciModel.ClassNo = classname.Replace("班", ""); sciModel.ClassName = Convert.ToString(classname); sciModel.RecTime = DateTime.Now; sciModel.RecUser = Com.Session.userid; sciModel.IsFinish = 0; int resret = sciBll.Add(sciModel); if (resret > 0) { ret = 1; } } } return(ret); }
/// <summary> /// 得到一个对象实体 /// </summary> public SchSystem.Model.SchClassInfo GetModel(int ClassId) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 ClassId,ClassNo,ClassName,GradeId,SchId,IsFinish,RecTime,RecUser,LastRecTime,LastRecUser from SchClassInfo "); strSql.Append(" where ClassId=@ClassId"); SqlParameter[] parameters = { new SqlParameter("@ClassId", SqlDbType.Int, 4) }; parameters[0].Value = ClassId; SchSystem.Model.SchClassInfo model = new SchSystem.Model.SchClassInfo(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
public static string udel(string type, string schid, string gradeid, string classid) { schid = Com.Public.SqlEncStr(schid); gradeid = Com.Public.SqlEncStr(gradeid); classid = Com.Public.SqlEncStr(classid); string ret = ""; Com.DataPack.DataRsp <Com.DataPack.UserInfo> rsp = Com.Public.UserFuncSoure(Com.SoureSession.jsid, Com.SoureSession.jstoken); if (rsp.code == "ERROR_TOKEN") { ret = "expire"; } else { try { if (!Com.Public.isVa(schid, "")) { return(ret = "无跨界权限"); } if (schid == Com.Public.getKey("adminschid")) { ret = "此为系统学校,不允许操作"; } else { if (type == "1")//删除年级 { SchSystem.BLL.SchGradeInfo bll = new SchSystem.BLL.SchGradeInfo(); SchSystem.Model.SchGradeInfo model = new SchSystem.Model.SchGradeInfo(); model.GradeId = int.Parse(gradeid); model.IsFinish = 2; model.LastRecTime = DateTime.Now; model.LastRecUser = Com.SoureSession.Soureuserid; if (bll.UpdateStat(model)) { ret = "success"; } else { ret = "操作失败"; } } else if (type == "0")//删除班级 { SchSystem.BLL.SchClassInfo classbll = new SchSystem.BLL.SchClassInfo(); bool resultBool = classbll.ExistsClassStuData(int.Parse(classid)); SchSystem.BLL.SchClassUser classuserbll = new SchSystem.BLL.SchClassUser(); bool resultBoolUser = classuserbll.ExistsClassUser(schid, classid); if (resultBool || resultBoolUser)//如果为true说明是班级内有属性数据 { ret = "success01"; } else//否则即可删除班级记录 { SchSystem.Model.SchClassInfo classmodel = new SchSystem.Model.SchClassInfo(); classmodel.ClassId = int.Parse(classid); classmodel.IsFinish = 2; classmodel.LastRecTime = DateTime.Now; classmodel.LastRecUser = Com.SoureSession.Soureuserid; if (classbll.UpdateStat(classmodel)) { SchSystem.BLL.SchClassUser scuBll = new SchSystem.BLL.SchClassUser(); // bool ecu = scuBll.ExistsClassUser(int.Parse(schid), int.Parse(classid)); bool scubool = scuBll.Delete(classid, schid); //if (scubool) // { ret = "success"; //} } else { ret = "操作失败"; } } } } } catch (Exception ex) { ret = ex.Message; } } return(ret); }
//需要根据不同情况建立或修改的不同学校用户和不同类型的用户,本学校用户唯一,不需要全系统唯一 protected void Page_Load(object sender, EventArgs e) { //if (true)//如果没对应权限,及判断用户类型是否跨界,主要防止非法篡改数据出现 //{ // Response.Write("无对应权限"); // Response.End(); //} if (!IsPostBack) { //先得到操作类型 dotype = Com.Public.SqlEncStr(Request.Params["dotype"].ToString()); schid = Com.Public.SqlEncStr(Request.Params["schid"].ToString()); gradecode = Com.Public.SqlEncStr(Request.Params["gradecode"].ToString()); if (string.IsNullOrEmpty(schid) || string.IsNullOrEmpty(gradecode))//如果没有对应参数中任意一个 { Response.Write("参数错误!"); Response.End(); } if (dotype == "a") { } else if (dotype == "e")//修改,不能修改用户的类型及学校参数 { btnname = "保存"; classid = Com.Public.SqlEncStr(Request.Params["classid"].ToString()); if (string.IsNullOrEmpty(classid)) { Response.Write("无对应修改的记录!"); Response.End(); } //获取修改的对应用户的 SchSystem.BLL.SchClassInfo sgibll = new SchSystem.BLL.SchClassInfo(); SchSystem.Model.SchClassInfo sgimodel = sgibll.GetModel(int.Parse(classid)); if (sgimodel != null && sgimodel.ClassId > 0) { umodelstr = Newtonsoft.Json.JsonConvert.SerializeObject(sgimodel); } else { Response.Write("无该记录!"); Response.End(); } } else//不在添加及修改之内,则返回 { Response.Write("没有可供确认的操作类型!"); Response.End(); } /*//判断跨界操作的可能性 * if (!Com.Public.isVa(schid, systype)) * { * Response.Write("出错,用户非法跨界操作!"); * Response.End(); * }*/ SchSystem.BLL.SchInfo schbll = new SchSystem.BLL.SchInfo(); schname = schbll.GetSchName(int.Parse(schid)); #region 获取当前学校的老师 //当前班级任课老师及班主任 SchSystem.BLL.SchClassUser userclassbll = new SchSystem.BLL.SchClassUser(); DataTable dtclassuser = userclassbll.GetList("UserName id,SubCode subcode,UserTname name,IsMs isms", "ClassId=" + Com.Public.SqlEncStr(classid)).Tables[0]; //当前学校老师 SchSystem.BLL.SchUserDeptV userbll = new SchSystem.BLL.SchUserDeptV(); DataTable dtuser = userbll.GetList("DeptId,DepartName,UserId,UserTname", "Stat=1 and Ustat=1 and SchId=" + Com.Public.SqlEncStr(schid)).Tables[0]; //DataRow[] dtRow = dtuser.Select(); StringBuilder sb = new StringBuilder(); //DataView dv = dtuser.DefaultView; //DataTable datadpt = dv.ToTable(true, "Pid,DeptId,DepartName"); SchSystem.BLL.SchDepartInfo dptbll = new SchSystem.BLL.SchDepartInfo(); DataTable dt = dptbll.GetList(" 'd_'+convert(varchar(20),Pid) pId,'d_'+convert(varchar(20),DepartId) id,DepartName name,'0' isms,'' subcode,'false' checked,'true' nochecks", "SchId=" + schid + " and Stat=1 Order by OrderId,DepartName").Tables[0]; DataTable dtdptuser = dt.Clone(); dtdptuser.Columns["nochecks"].ColumnName = "nocheck"; if (dt.Rows.Count > 0) { //合并人员到部门表 for (int i = 0; i < dt.Rows.Count; i++) { dtdptuser.Rows.Add(dt.Rows[i].ItemArray); //获取该部门下的人员 DataRow[] drss = dtuser.Select("DeptId='" + dt.Rows[i]["id"].ToString().Replace("d_", "") + "'"); if (drss.Length > 0) { foreach (DataRow item in drss) { DataRow dr = dtdptuser.NewRow(); dr["id"] = item["UserId"].ToString(); dr["name"] = item["UserTname"].ToString(); dr["pId"] = "d_" + item["DeptId"].ToString(); dtdptuser.Rows.Add(dr); } } } deptusers = Newtonsoft.Json.JsonConvert.SerializeObject(dtdptuser); //DataRow[] drs = dt.Select("Pid=0"); //foreach (DataRow dr in drs) //{ // string nodeID = dr["ID"].ToString(); // string nodeText = dr["Name"].ToString(); // nodeText = "├" + nodeText; // string blank = " "; // sb.Append("<option value=\"p_" + nodeID + "\">" + nodeText + "</option>"); // DataRow[] drusers = dtuser.Select("DeptId='" + nodeID + "'"); // if (drusers != null && drusers.Length > 0) // { // foreach (DataRow druser in drusers) // { // sb.Append("<option style=\"color:blue\" value=\"u_" + druser["UserId"].ToString() + "\">" + blank + " " + druser["UserTname"].ToString() + "</option>"); // } // } // BindSon(sb, nodeID, dt, blank, dtuser); //} } //depts = sb.ToString(); deptss = Newtonsoft.Json.JsonConvert.SerializeObject(dtclassuser); subsdrp = Com.Public.GetDrp("sub", schid, "1", false, "", ""); #endregion #region 获取年级领导 SchSystem.BLL.SchGradeUsers usergradebll = new SchSystem.BLL.SchGradeUsers(); gradeboss = usergradebll.GetNames("GradeId='" + Com.Public.SqlEncStr(gradecode) + "'"); gradesdrp = Com.Public.GetDrp("grade", schid, "0", false, "", ""); #endregion } }
public static string classsave(string dotype, string schid, string gradecode, string classid, string classname, string tagsusers) { dotype = Com.Public.SqlEncStr(dotype); schid = Com.Public.SqlEncStr(schid); gradecode = Com.Public.SqlEncStr(gradecode); classid = Com.Public.SqlEncStr(classid); classname = Com.Public.SqlEncStr(classname); tagsusers = Com.Public.SqlEncStr(tagsusers); string ret = ""; try { if (!Com.Public.IsOne(Com.Session.userrolestr, 12)) { return(ret = "无操作权限"); } if (!Com.Public.isVa(schid, "")) { return(ret = "无跨界权限"); } if (schid == Com.Public.getKey("adminschid")) { ret = "此为系统学校,不允许操作"; } else if (string.IsNullOrEmpty(schid) || schid == "0") { ret += "非法的学校!"; } SchSystem.BLL.SchClassInfo classbll = new SchSystem.BLL.SchClassInfo(); SchSystem.Model.SchClassInfo classmodel = new SchSystem.Model.SchClassInfo(); classmodel.LastRecTime = DateTime.Now; classmodel.LastRecUser = Com.Session.userid; classmodel.GradeCode = gradecode; classmodel.ClassName = classname; //判断编号及账号是否有重复,生成密码加密 if (dotype == "e") { /*if (userbll.ExistsUserCode(int.Parse(userid), usercode, int.Parse(schid))) * { * ret += "用户编号重复!"; * }*/ } if (dotype == "a") { /*if (userbll.ExistsUserCode(0, usercode, int.Parse(schid))) * { * ret += "用户编号重复!"; * } * if (userbll.ExistsUserCode(0, username, int.Parse(schid))) * { * ret += "账号重复!"; * }*/ } if (ret == "") { if (dotype == "e") { classmodel.ClassId = int.Parse(classid); classbll.Update(classmodel); } if (dotype == "a") { //usermodel.PassWord = SchManagerInfoSystem.Common.DESEncrypt.Encrypt(userpw); classmodel.RecTime = DateTime.Now; classmodel.RecUser = Com.Session.userid; classmodel.IsFinish = 0; classmodel.SchId = int.Parse(schid); classid = classbll.Add(classmodel).ToString(); } //清除关联的老师,再添加或更新关联老师 SchSystem.BLL.SchClassUser classuserbll = new SchSystem.BLL.SchClassUser(); SchSystem.Model.SchClassUser classusermodel; classuserbll.DeleteUserSub("ClassId=" + Com.Public.SqlEncStr(classid)); tagsusers = tagsusers.Replace("u_", "");//UID,UTNAME,SUB,ISMS string[] uss = tagsusers.Split('|'); if (uss.Length > 0) { foreach (string item in uss) { string[] its = item.Split(','); if (its.Length == 4) { classusermodel = new SchSystem.Model.SchClassUser(); classusermodel.ClassId = int.Parse(classid); classusermodel.LastRecTime = DateTime.Now; classusermodel.LastRecUser = Com.Session.userid; classusermodel.RecTime = DateTime.Now; classusermodel.RecUser = Com.Session.userid; classusermodel.UserName = its[0]; classusermodel.SubCode = its[1]; classusermodel.UserTname = its[2]; classusermodel.IsMs = int.Parse(its[3]); classusermodel.SchId = int.Parse(schid); classuserbll.Add(classusermodel); } } } ret = "success"; } } catch (Exception ex) { ret = ex.Message; } return(ret); }
public static string classsave(string dotype, string schid, string gradecode, string classid, string classname, string tagsusers) { dotype = Com.Public.SqlEncStr(dotype); schid = Com.Public.SqlEncStr(schid); gradecode = Com.Public.SqlEncStr(gradecode); classid = Com.Public.SqlEncStr(classid); classname = Com.Public.SqlEncStr(classname); tagsusers = Com.Public.SqlEncStr(tagsusers); string ret = ""; Com.DataPack.DataRsp <Com.DataPack.UserInfo> rsp = Com.Public.UserFuncSoure(Com.SoureSession.jsid, Com.SoureSession.jstoken); if (rsp.code == "ERROR_TOKEN") { ret = "expire"; } else { //字符串匹配验证 string PatternStr = @"^[0-9a-zA-Z\u4e00-\u9fa5]+$"; bool resultStr = Regex.IsMatch(classname, PatternStr); if (resultStr != true) { return(ret = "必填,只能输入中文、数字和字母"); } try { if (!Com.Public.isVa(schid, "")) { return(ret = "无跨界权限"); } if (schid == Com.Public.getKey("adminschid")) { ret = "此为系统学校,不允许操作"; } else if (string.IsNullOrEmpty(schid) || schid == "0") { ret += "非法的学校!"; } SchSystem.BLL.SchClassInfo classbll = new SchSystem.BLL.SchClassInfo(); SchSystem.Model.SchClassInfo classmodel = new SchSystem.Model.SchClassInfo(); classmodel.LastRecTime = DateTime.Now; classmodel.LastRecUser = Com.SoureSession.Soureuserid; classmodel.GradeId = gradecode; classmodel.ClassName = classname; //判断编号及账号是否有重复,生成密码加密 if (dotype == "e") { /*if (userbll.ExistsUserCode(int.Parse(userid), usercode, int.Parse(schid))) * { * ret += "用户编号重复!"; * }*/ } if (dotype == "a") { /*if (userbll.ExistsUserCode(0, usercode, int.Parse(schid))) * { * ret += "用户编号重复!"; * } * if (userbll.ExistsUserCode(0, username, int.Parse(schid))) * { * ret += "账号重复!"; * }*/ } if (ret == "") { if (dotype == "e") { classmodel.ClassId = int.Parse(classid); classbll.Update(classmodel); } if (dotype == "a") { //usermodel.PassWord = SchManagerInfoSystem.Common.DESEncrypt.Encrypt(userpw); classmodel.RecTime = DateTime.Now; classmodel.RecUser = Com.SoureSession.Soureuserid; classmodel.IsFinish = 0; classmodel.SchId = int.Parse(schid); classid = classbll.Add(classmodel).ToString(); } //清除关联的老师,再添加或更新关联老师 SchSystem.BLL.SchClassUser classuserbll = new SchSystem.BLL.SchClassUser(); SchSystem.Model.SchClassUser classusermodel; classuserbll.DeleteUserSub("ClassId=" + Com.Public.SqlEncStr(classid)); tagsusers = tagsusers.Replace("u_", "");//UID,UTNAME,SUB,ISMS string[] uss = tagsusers.Split('|'); if (uss.Length > 0) { foreach (string item in uss) { string[] its = item.Split(','); if (its.Length == 4) { classusermodel = new SchSystem.Model.SchClassUser(); classusermodel.ClassId = int.Parse(classid); classusermodel.LastRecTime = DateTime.Now; classusermodel.SchId = int.Parse(schid); classusermodel.LastRecUser = Com.SoureSession.Soureuserid; classusermodel.RecTime = DateTime.Now; classusermodel.RecUser = Com.SoureSession.Soureuserid; classusermodel.UserName = its[0]; classusermodel.SubCode = its[1]; classusermodel.UserTname = its[2]; classusermodel.IsMs = int.Parse(its[3]); classuserbll.Add(classusermodel); } } } ret = "success"; } } catch (Exception ex) { ret = ex.Message; } } return(ret); }
//需要根据不同情况建立或修改的不同学校用户和不同类型的用户,本学校用户唯一,不需要全系统唯一 protected void Page_Load(object sender, EventArgs e) { //if (true)//如果没对应权限,及判断用户类型是否跨界,主要防止非法篡改数据出现 //{ // Response.Write("无对应权限"); // Response.End(); //} if (!IsPostBack) { //先得到操作类型 dotype = Com.Public.SqlEncStr(Request.Params["dotype"].ToString()); schid = Com.Public.SqlEncStr(Request.Params["schid"].ToString()); gradecode = Com.Public.SqlEncStr(Request.Params["gradecode"].ToString()); if (string.IsNullOrEmpty(schid) || string.IsNullOrEmpty(gradecode))//如果没有对应参数中任意一个 { Response.Write("参数错误!"); Response.End(); } if (dotype == "a") { } else if (dotype == "e")//修改,不能修改用户的类型及学校参数 { btnname = "修改"; classid = Com.Public.SqlEncStr(Request.Params["classid"].ToString()); if (string.IsNullOrEmpty(classid)) { Response.Write("无对应修改的记录!"); Response.End(); } //获取修改的对应用户的 SchSystem.BLL.SchClassInfo sgibll = new SchSystem.BLL.SchClassInfo(); SchSystem.Model.SchClassInfo sgimodel = sgibll.GetModel(int.Parse(classid)); if (sgimodel != null && sgimodel.ClassId > 0) { umodelstr = Newtonsoft.Json.JsonConvert.SerializeObject(sgimodel); } else { Response.Write("无该记录!"); Response.End(); } } else//不在添加及修改之内,则返回 { Response.Write("没有可供确认的操作类型!"); Response.End(); } /*//判断跨界操作的可能性 * if (!Com.Public.isVa(schid, systype)) * { * Response.Write("出错,用户非法跨界操作!"); * Response.End(); * }*/ #region 获取部门人员列表 SchSystem.BLL.SchInfo schbll = new SchSystem.BLL.SchInfo(); schname = schbll.GetSchName(int.Parse(schid)); //获取年级领导 SchSystem.BLL.SchGradeUsers usergradebll = new SchSystem.BLL.SchGradeUsers(); gradeboss = usergradebll.GetNames("GradeId in ( select GradeId from SchGradeInfo where GradeCode=" + Com.Public.SqlEncStr(gradecode) + " and schid=" + schid + ")"); gradesdrp = Com.Public.GetDrp("grade", schid, "0", false, "", ""); SchSystem.BLL.SchDepartInfo sdiBll = new SchSystem.BLL.SchDepartInfo(); //获取部门列表 DataTable dtdpt = sdiBll.GetList("Pid pId,convert(varchar(20),DepartId) id,DepartName name,'false' checked,'true' nochecks,'0' isms,'' subcode", "SchId=" + Com.Public.SqlEncStr(schid) + " and Stat=1 Order by OrderId").Tables[0]; dtdpt.Columns["nochecks"].ColumnName = "nocheck"; DataTable dtdptuser = dtdpt.Clone(); StringBuilder sb = new StringBuilder(); if (dtdpt.Rows.Count > 0) { SchSystem.BLL.SchClassUser userclassbll = new SchSystem.BLL.SchClassUser(); DataTable dtclassuser = userclassbll.GetList("UserName,SubCode,IsMs", "ClassId=" + Com.Public.SqlEncStr(classid)).Tables[0]; //获取该学校的所有人员 SchSystem.BLL.SchUserDeptV userbll = new SchSystem.BLL.SchUserDeptV(); DataTable dtuser = userbll.GetList("DeptId ,UserName,UserTname", "Stat=1 and Ustat=1 and SchId=" + Com.Public.SqlEncStr(schid)).Tables[0]; //合并人员到部门表 for (int i = 0; i < dtdpt.Rows.Count; i++) { dtdptuser.Rows.Add(dtdpt.Rows[i].ItemArray); //获取该部门下的人员 DataRow[] drs = dtuser.Select("DeptId='" + dtdpt.Rows[i]["id"].ToString() + "'"); if (drs.Length > 0) { foreach (DataRow item in drs) { DataRow dr = dtdptuser.NewRow(); dr["id"] = "u_" + item["UserName"].ToString(); dr["name"] = item["UserTname"].ToString(); dr["pId"] = item["DeptId"].ToString(); //如果是被绑定了,则勾选 DataRow[] drsclassuser = dtclassuser.Select("UserName='******'"); if (drsclassuser.Length > 0) { dr["isms"] = drsclassuser[0]["IsMs"].ToString(); dr["subcode"] = drsclassuser[0]["SubCode"].ToString(); dr["checked"] = "true"; } dtdptuser.Rows.Add(dr); } } } } SchSystem.BLL.SchUserInfo sui = new SchSystem.BLL.SchUserInfo(); DataTable dtsui = sui.GetList("*", "Stat=1 and SchId=" + Com.Public.SqlEncStr(schid)).Tables[0]; DataRow[] drsui = dtsui.Select(); foreach (DataRow item in drsui) { sb.Append("<option value=\"u_" + item["UserName"].ToString() + "\">" + item["UserTname"].ToString() + "</option>"); } tec = sb.ToString(); depts = Newtonsoft.Json.JsonConvert.SerializeObject(dtdptuser); subsdrp = Com.Public.GetDrp("sub", schid, "1", false, "", ""); #endregion #region 获取部门人员列表 /*SchSystem.BLL.SchInfo schbll = new SchSystem.BLL.SchInfo(); * schname = schbll.GetSchName(int.Parse(schid)); * //获取年级领导 * SchSystem.BLL.SchGradeUsers usergradebll = new SchSystem.BLL.SchGradeUsers(); * gradeboss = usergradebll.GetNames("GradeId in ( select GradeId from SchGradeInfo where GradeCode=" + Com.Public.SqlEncStr(gradecode) + " and schid=" + schid + ")"); * gradesdrp = Com.Public.GetDrp("grade", schid, "0", false, "", ""); * SchSystem.BLL.SchDepartInfo sdiBll = new SchSystem.BLL.SchDepartInfo(); * //获取部门列表 * DataTable dtdpt = sdiBll.GetList("Pid pId,convert(varchar(20),DepartId) id,DepartName name,'false' checked,'false' checked,'true' nochecks,'0' isms,'' subcode", "SchId=" + Com.Public.SqlEncStr(schid) + " and Stat=1 Order by OrderId").Tables[0]; * dtdpt.Columns["nochecks"].ColumnName = "nocheck"; * DataTable dtdptuser = dtdpt.Clone(); * StringBuilder sb = new StringBuilder(); * if (dtdpt.Rows.Count > 0) * { * SchSystem.BLL.SchClassUser userclassbll = new SchSystem.BLL.SchClassUser(); * DataTable dtclassuser = userclassbll.GetList("UserName,SubCode,IsMs", "ClassId=" + Com.Public.SqlEncStr(classid)).Tables[0]; * //获取该学校的所有人员 * SchSystem.BLL.SchUserDeptV userbll = new SchSystem.BLL.SchUserDeptV(); * DataTable dtuser = userbll.GetList("DeptId ,UserName,UserTname", "Stat=1 and Ustat=1 and SchId=" + Com.Public.SqlEncStr(schid)).Tables[0]; * //合并人员到部门表 * int z = 0; * for (int i = 0; i < dtdpt.Rows.Count; i++) * { * * dtdptuser.Rows.Add(dtdpt.Rows[i].ItemArray); * //获取该部门下的人员 * DataRow[] drs = dtuser.Select("DeptId='" + dtdpt.Rows[i]["id"].ToString() + "'"); * if (drs.Length > 0) * { * foreach (DataRow item in drs) * { * sb.Append("<option value=\"u_"+z+"_" + item["UserName"].ToString() + "\">" + item["UserTname"].ToString() + "</option>"); * DataRow dr = dtdptuser.NewRow(); * dr["id"] = "u_" + z + "_" + item["UserName"].ToString(); * dr["name"] = item["UserTname"].ToString(); * dr["pId"] = item["DeptId"].ToString(); * //如果是被绑定了,则勾选 * DataRow[] drsclassuser = dtclassuser.Select("UserName='******'"); * if (drsclassuser.Length > 0) * { * dr["isms"] = drsclassuser[0]["IsMs"].ToString(); * dr["subcode"] = drsclassuser[0]["SubCode"].ToString(); * dr["checked"] = "true"; * }z++; * dtdptuser.Rows.Add(dr); * * } * } * } * * } * tec = sb.ToString(); * depts = Newtonsoft.Json.JsonConvert.SerializeObject(dtdptuser); * subsdrp = Com.Public.GetDrp("sub", schid, "1", false, "", "");*/ #endregion } }
public static string classsave(string dotype, string schid, string gradecode, string classid, string classname, string tagsusers) { dotype = Com.Public.SqlEncStr(dotype); schid = Com.Public.SqlEncStr(schid); gradecode = Com.Public.SqlEncStr(gradecode); classid = Com.Public.SqlEncStr(classid); classname = Com.Public.SqlEncStr(classname); tagsusers = Com.Public.SqlEncStr(tagsusers); /* * //手机号码验证 * string PatternPhone = @"^(?:13|15\d|15[89])-?\d{5}(\d{3}|\*{3})$"; * bool ResultPhone = Regex.IsMatch(classname, PatternPhone); * if (ResultPhone != true) * { * return "手机号码(格式:15153585510)或固定电话(格式:0531-1234678)格式不正确"; * } */ //字符串匹配验证 string PatternStr = @"^[\u4e00-\u9fa5]+$"; bool resultStr = Regex.IsMatch(classname, PatternStr); if (resultStr != true) { return("只能输入中文名称"); } string ret = ""; try { if (!Com.Public.IsOne(Com.Session.userrolestr, 12)) { return(ret = "无操作权限"); } if (!Com.Public.isVa(schid, "")) { return(ret = "无跨界权限"); } if (schid == Com.Public.getKey("adminschid")) { ret = "此为系统学校,不允许操作"; } else if (string.IsNullOrEmpty(schid) || schid == "0") { ret += "非法的学校!"; } SchSystem.BLL.SchClassInfo classbll = new SchSystem.BLL.SchClassInfo(); SchSystem.Model.SchClassInfo classmodel = new SchSystem.Model.SchClassInfo(); classmodel.LastRecTime = DateTime.Now; classmodel.LastRecUser = Com.Session.userid; classmodel.GradeCode = gradecode; classmodel.ClassName = classname; //判断编号及账号是否有重复,生成密码加密 if (dotype == "e") { /*if (userbll.ExistsUserCode(int.Parse(userid), usercode, int.Parse(schid))) * { * ret += "用户编号重复!"; * }*/ } if (dotype == "a") { /*if (userbll.ExistsUserCode(0, usercode, int.Parse(schid))) * { * ret += "用户编号重复!"; * } * if (userbll.ExistsUserCode(0, username, int.Parse(schid))) * { * ret += "账号重复!"; * }*/ } if (ret == "") { if (dotype == "e") { classmodel.ClassId = int.Parse(classid); classbll.Update(classmodel); } if (dotype == "a") { //usermodel.PassWord = SchManagerInfoSystem.Common.DESEncrypt.Encrypt(userpw); classmodel.RecTime = DateTime.Now; classmodel.RecUser = Com.Session.userid; classmodel.IsFinish = 0; classmodel.SchId = int.Parse(schid); classid = classbll.Add(classmodel).ToString(); } //清除关联的老师,再添加或更新关联老师 SchSystem.BLL.SchClassUser classuserbll = new SchSystem.BLL.SchClassUser(); SchSystem.Model.SchClassUser classusermodel; classuserbll.DeleteUserSub("ClassId=" + Com.Public.SqlEncStr(classid)); tagsusers = tagsusers.Replace("u_", "");//UID,UTNAME,SUB,ISMS string[] uss = tagsusers.Split('|'); if (uss.Length > 0) { foreach (string item in uss) { string[] its = item.Split(','); if (its.Length == 4) { classusermodel = new SchSystem.Model.SchClassUser(); classusermodel.ClassId = int.Parse(classid); classusermodel.IsMs = int.Parse(its[3]); classusermodel.LastRecTime = DateTime.Now; classusermodel.LastRecUser = Com.Session.userid; classusermodel.RecTime = DateTime.Now; classusermodel.RecUser = Com.Session.userid; classusermodel.UserName = its[0]; classusermodel.UserTname = its[1]; classusermodel.SubCode = its[2]; classusermodel.SchId = int.Parse(schid); classuserbll.Add(classusermodel); } } } ret = "success"; } } catch (Exception ex) { ret = ex.Message; } return(ret); }
public static string udel(string type, string schid, string gradeid, string classid) { schid = Com.Public.SqlEncStr(schid); gradeid = Com.Public.SqlEncStr(gradeid); classid = Com.Public.SqlEncStr(classid); string ret = ""; try { if (!Com.Public.IsOne(Com.Session.userrolestr, 13)) { return(ret = "无操作权限"); } if (!Com.Public.isVa(schid, "")) { return(ret = "无跨界权限"); } if (schid == Com.Public.getKey("adminschid")) { ret = "此为系统学校,不允许操作"; } else { if (type == "1")//删除年级 { SchSystem.BLL.SchGradeInfo bll = new SchSystem.BLL.SchGradeInfo(); SchSystem.Model.SchGradeInfo model = new SchSystem.Model.SchGradeInfo(); model.GradeId = int.Parse(gradeid); model.IsFinish = 2; model.LastRecTime = DateTime.Now; model.LastRecUser = Com.Session.userid; if (bll.UpdateStat(model)) { ret = "success"; } else { ret = "操作失败"; } } else if (type == "0")//删除班级 { SchSystem.BLL.SchClassInfo classbll = new SchSystem.BLL.SchClassInfo(); SchSystem.Model.SchClassInfo classmodel = new SchSystem.Model.SchClassInfo(); classmodel.ClassId = int.Parse(classid); classmodel.IsFinish = 2; classmodel.LastRecTime = DateTime.Now; classmodel.LastRecUser = Com.Session.userid; if (classbll.UpdateStat(classmodel)) { ret = "success"; } else { ret = "操作失败"; } } } } catch (Exception ex) { ret = ex.Message; } return(ret); }