/// <summary> /// 得到一个对象实体 /// </summary> public SchSystem.Model.SchSubLeader DataRowToModel(DataRow row) { SchSystem.Model.SchSubLeader model = new SchSystem.Model.SchSubLeader(); if (row != null) { if (row["AutoId"] != null && row["AutoId"].ToString() != "") { model.AutoId = int.Parse(row["AutoId"].ToString()); } if (row["ClassId"] != null && row["ClassId"].ToString() != "") { model.ClassId = int.Parse(row["ClassId"].ToString()); } if (row["SchId"] != null && row["SchId"].ToString() != "") { model.SchId = int.Parse(row["SchId"].ToString()); } if (row["SubId"] != null && row["SubId"].ToString() != "") { model.SubId = int.Parse(row["SubId"].ToString()); } if (row["SubCode"] != null) { model.SubCode = row["SubCode"].ToString(); } if (row["UserName"] != null) { model.UserName = row["UserName"].ToString(); } if (row["UserTname"] != null) { model.UserTname = row["UserTname"].ToString(); } if (row["Stat"] != null && row["Stat"].ToString() != "") { model.Stat = int.Parse(row["Stat"].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); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(SchSystem.Model.SchSubLeader model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update SchSubLeader set "); strSql.Append("ClassId=@ClassId,"); strSql.Append("SchId=@SchId,"); strSql.Append("SubId=@SubId,"); strSql.Append("SubCode=@SubCode,"); strSql.Append("UserName=@UserName,"); strSql.Append("UserTname=@UserTname,"); strSql.Append("Stat=@Stat,"); strSql.Append("RecTime=@RecTime,"); strSql.Append("RecUser=@RecUser,"); strSql.Append("LastRecTime=@LastRecTime,"); strSql.Append("LastRecUser=@LastRecUser"); strSql.Append(" where AutoId=@AutoId"); SqlParameter[] parameters = { new SqlParameter("@ClassId", SqlDbType.Int, 4), new SqlParameter("@SchId", SqlDbType.Int, 4), new SqlParameter("@SubId", SqlDbType.Int, 4), new SqlParameter("@SubCode", SqlDbType.VarChar, 10), new SqlParameter("@UserName", SqlDbType.VarChar, 30), new SqlParameter("@UserTname", SqlDbType.VarChar, 20), new SqlParameter("@Stat", 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("@AutoId", SqlDbType.Int, 4) }; parameters[0].Value = model.ClassId; parameters[1].Value = model.SchId; parameters[2].Value = model.SubId; parameters[3].Value = model.SubCode; parameters[4].Value = model.UserName; parameters[5].Value = model.UserTname; parameters[6].Value = model.Stat; parameters[7].Value = model.RecTime; parameters[8].Value = model.RecUser; parameters[9].Value = model.LastRecTime; parameters[10].Value = model.LastRecUser; parameters[11].Value = model.AutoId; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(SchSystem.Model.SchSubLeader model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into SchSubLeader("); strSql.Append("ClassId,SchId,SubId,SubCode,UserName,UserTname,Stat,RecTime,RecUser,LastRecTime,LastRecUser)"); strSql.Append(" values ("); strSql.Append("@ClassId,@SchId,@SubId,@SubCode,@UserName,@UserTname,@Stat,@RecTime,@RecUser,@LastRecTime,@LastRecUser)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@ClassId", SqlDbType.Int, 4), new SqlParameter("@SchId", SqlDbType.Int, 4), new SqlParameter("@SubId", SqlDbType.Int, 4), new SqlParameter("@SubCode", SqlDbType.VarChar, 10), new SqlParameter("@UserName", SqlDbType.VarChar, 30), new SqlParameter("@UserTname", SqlDbType.VarChar, 20), new SqlParameter("@Stat", 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.ClassId; parameters[1].Value = model.SchId; parameters[2].Value = model.SubId; parameters[3].Value = model.SubCode; parameters[4].Value = model.UserName; parameters[5].Value = model.UserTname; parameters[6].Value = model.Stat; parameters[7].Value = model.RecTime; parameters[8].Value = model.RecUser; parameters[9].Value = model.LastRecTime; parameters[10].Value = model.LastRecUser; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public SchSystem.Model.SchSubLeader GetModel(int AutoId) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 AutoId,ClassId,SchId,SubId,SubCode,UserName,UserTname,Stat,RecTime,RecUser,LastRecTime,LastRecUser from SchSubLeader "); strSql.Append(" where AutoId=@AutoId"); SqlParameter[] parameters = { new SqlParameter("@AutoId", SqlDbType.Int, 4) }; parameters[0].Value = AutoId; SchSystem.Model.SchSubLeader model = new SchSystem.Model.SchSubLeader(); 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 gradesave(string dotype, string schid, string gradename, string gradeid, string tagsusers) { dotype = Com.Public.SqlEncStr(dotype); schid = Com.Public.SqlEncStr(schid); gradename = Com.Public.SqlEncStr(gradename); //科目名称 gradeid = Com.Public.SqlEncStr(gradeid); //科目ID tagsusers = Com.Public.SqlEncStr(tagsusers); //科目组长ID string ret = ""; if (Com.Session.userid == null) { ret = "expire"; } else { //字符串匹配验证 //if (gradename != "") //{ // string PatternStr = @"^[\u4e00-\u9fa5]+$"; // bool resultStr = Regex.IsMatch(gradename, PatternStr); // if (resultStr != true) // { // return ret = "只能输入中文名称"; // } //} try { if (string.IsNullOrEmpty(schid) || schid == "0") { ret += "非法的学校!"; } //SchSystem.BLL.SchGradeInfo userbll = new SchSystem.BLL.SchGradeInfo(); SchSystem.Model.SchSubLeader sslModel = new SchSystem.Model.SchSubLeader(); //SchSystem.Model.SchGradeInfo usermodel = new SchSystem.Model.SchGradeInfo(); sslModel.LastRecTime = DateTime.Now; sslModel.LastRecUser = Com.Session.userid; /* * //判断编号及账号是否有重复,生成密码加密 * if (dotype == "e") * { * if (userbll.ExistsGradeCode(int.Parse(gradeid), Com.Public.SqlEncStr(gradename), int.Parse(schid))) * { * ret += "年级编号重复!"; * } * * } * if (dotype == "a") * { * if (userbll.ExistsGradeCode(0, Com.Public.SqlEncStr(gradename), int.Parse(schid))) * { * ret += "年级编号重复!"; * } * if (userbll.ExistsGradeCode(0, Com.Public.SqlEncStr(gradename), int.Parse(schid))) * { * ret += "年级重复!"; * } * * }*/ if (ret == "") { if (!Com.Public.isVa(schid, "")) { return(ret = "无跨界权限"); } if (schid == Com.Public.getKey("adminschid")) { ret = "此为系统学校,不允许操作"; } else if (dotype == "e") { sslModel.SubCode = gradeid; sslModel.SchId = int.Parse(schid); sslModel.LastRecTime = DateTime.Now; sslModel.LastRecUser = Com.Session.userid; //userbll.UpdateGrade(sslModel); } //tagsusers = Com.Public.SqlEncStr(tagsusers); //添加或更新关联年级 SchSystem.BLL.SchSubLeader sslBll = new SchSystem.BLL.SchSubLeader(); //SchSystem.BLL.SchGradeUsers userdeptbll = new SchSystem.BLL.SchGradeUsers(); if (tagsusers == null || tagsusers == "") { tagsusers = ""; } else { tagsusers = "'" + tagsusers.Replace(",", "','").Replace("sub_", "") + "'"; } sslBll.DoUserSubLeader(gradeid, Com.Session.userid, schid, tagsusers); ret = "success"; } } catch (Exception ex) { ret = ex.Message; } } return(ret); }