/// <summary> /// 增加一条数据 /// </summary> public int Add(SchSystem.Model.SchStuInfo model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into SchStuInfo("); strSql.Append("LoginName,Pwd,StuName,StuNo,ClassId,SchId,CardNo,Sex,Birth,ImgUrl,StudyType,Stat,LoginTime,RecTime,RecUser,LastRecTime,LastRecUser)"); strSql.Append(" values ("); strSql.Append("@LoginName,@Pwd,@StuName,@StuNo,@ClassId,@SchId,@CardNo,@Sex,@Birth,@ImgUrl,@StudyType,@Stat,@LoginTime,@RecTime,@RecUser,@LastRecTime,@LastRecUser)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@LoginName", SqlDbType.VarChar, 50), new SqlParameter("@Pwd", SqlDbType.VarChar, 20), new SqlParameter("@StuName", SqlDbType.VarChar, 20), new SqlParameter("@StuNo", SqlDbType.VarChar, 15), new SqlParameter("@ClassId", SqlDbType.Int, 4), new SqlParameter("@SchId", SqlDbType.Int, 4), new SqlParameter("@CardNo", SqlDbType.VarChar, 15), new SqlParameter("@Sex", SqlDbType.TinyInt, 1), new SqlParameter("@Birth", SqlDbType.DateTime), new SqlParameter("@ImgUrl", SqlDbType.VarChar, 200), new SqlParameter("@StudyType", SqlDbType.TinyInt, 1), new SqlParameter("@Stat", SqlDbType.TinyInt, 1), new SqlParameter("@LoginTime", SqlDbType.DateTime), new SqlParameter("@RecTime", SqlDbType.SmallDateTime), new SqlParameter("@RecUser", SqlDbType.VarChar, 50), new SqlParameter("@LastRecTime", SqlDbType.DateTime), new SqlParameter("@LastRecUser", SqlDbType.VarChar, 20) }; parameters[0].Value = model.LoginName; parameters[1].Value = model.Pwd; parameters[2].Value = model.StuName; parameters[3].Value = model.StuNo; parameters[4].Value = model.ClassId; parameters[5].Value = model.SchId; parameters[6].Value = model.CardNo; parameters[7].Value = model.Sex; parameters[8].Value = model.Birth; parameters[9].Value = model.ImgUrl; parameters[10].Value = model.StudyType; parameters[11].Value = model.Stat; parameters[12].Value = model.LoginTime; parameters[13].Value = model.RecTime; parameters[14].Value = model.RecUser; parameters[15].Value = model.LastRecTime; parameters[16].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.SchStuInfo GetModel(int StuId) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 StuId,LoginName,Pwd,StuName,StuNo,ClassId,SchId,CardNo,Sex,Birth,ImgUrl,StudyType,Stat,LoginTime,RecTime,RecUser,LastRecTime,LastRecUser from SchStuInfo "); strSql.Append(" where StuId=@StuId"); SqlParameter[] parameters = { new SqlParameter("@StuId", SqlDbType.Int, 4) }; parameters[0].Value = StuId; SchSystem.Model.SchStuInfo model = new SchSystem.Model.SchStuInfo(); 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 SchSystem.Model.SchStuInfo GetModel(string LoginName) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 StuId,LoginName,Pwd,StuName,StuNo,dutie,ClassId,SchId,CardNo,TestNo,Sex,Birth,TelNo,Addr,ImgUrl,StudyType,Stat,LoginTime,RecTime,RecUser,LastRecTime,LastRecUser,OldClassId from SchStuInfo "); strSql.Append(" where LoginName=@LoginName "); SqlParameter[] parameters = { new SqlParameter("@LoginName", SqlDbType.VarChar, 50) }; parameters[0].Value = LoginName; SchSystem.Model.SchStuInfo model = new SchSystem.Model.SchStuInfo(); 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 schsave(string Genid1, string Genid2, string Unid1, string Unid2, string Stuid, string dotype, string schid, string ClassId, string TestNo, string StuName, string Sex, string CardNo, string StudyType, string TelNo, string LoginName, string Pwd, string Addr, string Stat, string jzGenName1, string jzTelNo1, string jzLoginName1, string jzPwd1, string jzStat1, string jzGenName2, string jzTelNo2, string jzLoginName2, string jzPwd2, string jzStat2, string Relation1, string Relation2, string OldClassName, string OldGradeId, string OldGradeName, string GradeId, string OldClassId, string CurrentTestNo) { string result = ""; //事物返回结果 SchSystem.BLL.SchClassUser bllclassuser = new SchSystem.BLL.SchClassUser(); Com.DataPack.DataRsp <Com.DataPack.UserInfo> rsp = Com.Public.UserFuncSoure(Com.SoureSession.jsid, Com.SoureSession.jstoken); if (rsp.code == "ERROR_TOKEN") { result = "expire"; } else { List <string> LstError = new List <string>(); try { //if (!Com.Public.isVa(schid, "")) //{ // LstError.Add("无跨界权限!" + Environment.NewLine); //} SchSystem.Model.SchStuInfo model_stu = new SchSystem.Model.SchStuInfo(); SchSystem.BLL.SchStuInfo bll_stu = new SchSystem.BLL.SchStuInfo(); #region 收集学生信息 if (Com.SoureSession.Souresystype != "2") { model_stu.SchId = Convert.ToInt32(Com.SoureSession.Soureschid); } else { model_stu.SchId = Convert.ToInt32(schid); } StringBuilder sb = new StringBuilder(); if (GradeId != OldGradeId) { sb.Append(OldGradeName); } if (ClassId != OldClassId) { sb.Append(OldClassName); } string sbstr = sb.ToString(); if (sbstr != "") { model_stu.OldClassId = sbstr; } else { model_stu.OldClassId = ""; } model_stu.ClassId = Convert.ToInt32(ClassId); /* * if (ClassId != OldClassIdstr)//如果班级ID有变化说明是在调班 * { * if (OldClassIdSavestr == "")//如果是第一次调班 * { * model_stu.OldClassId = OldClassIdstr; * } * else//曾经调过班 * { * StringBuilder sb = new StringBuilder(); * sb.Append(OldClassIdSavestr + "," + OldClassIdstr);//班级ID以英文半角的逗号隔开 * model_stu.OldClassId = sb.ToString() ; * } * model_stu.ClassId = Convert.ToInt32(ClassId); * } * else//否则,没有调班 * { * model_stu.ClassId = Convert.ToInt32(ClassId); * } */ model_stu.TestNo = Com.Public.SqlEncStr(TestNo); model_stu.StuName = Com.Public.SqlEncStr(StuName); model_stu.Sex = Convert.ToInt32(Sex); model_stu.Dutie = ""; model_stu.StudyType = Convert.ToInt32(StudyType); model_stu.TelNo = Com.Public.SqlEncStr(TelNo); model_stu.LoginName = Com.Public.SqlEncStr(LoginName); if (Pwd != "") { model_stu.Pwd = Com.Public.StrToMD5(Com.Public.SqlEncStr(Pwd)); } else { model_stu.Pwd = ""; } model_stu.Addr = Com.Public.SqlEncStr(Addr); model_stu.Stat = Convert.ToInt32(Stat); model_stu.Birth = Convert.ToDateTime(DateTime.Now.ToLocalTime().ToString()); model_stu.RecUser = Com.SoureSession.Soureuserid; model_stu.RecTime = Convert.ToDateTime(DateTime.Now.ToLocalTime().ToString()); model_stu.LastRecUser = Com.SoureSession.Soureuserid; model_stu.LastRecTime = Convert.ToDateTime(DateTime.Now.ToLocalTime().ToString()); model_stu.StuNo = Com.Public.SqlEncStr(TestNo); model_stu.CardNo = ""; //(Test)卡地址在前台读取, model_stu.ImgUrl = "00"; //(Test)学生默认头像 if (dotype == "e") { model_stu.StuId = Convert.ToInt32(Stuid); } #endregion #region 收集家长信息 List <SchSystem.Model.SchGenInfo> list_model_gen = new List <SchSystem.Model.SchGenInfo>(); SchSystem.Model.SchGenInfo model_gen = new SchSystem.Model.SchGenInfo(); //if (Convert.ToString(jzGenName1) != "" && Convert.ToString(jzTelNo1) != "") //{ model_gen.GenName = Com.Public.SqlEncStr(jzGenName1); model_gen.TelNo = Com.Public.SqlEncStr(jzTelNo1); model_gen.LoginName = ""; if (Pwd != "") { model_gen.Pwd = Com.Public.StrToMD5(Com.Public.SqlEncStr(jzPwd1)); } else { model_gen.Pwd = ""; } model_gen.Stat = Convert.ToInt32(jzStat1); model_gen.RecUser = Com.SoureSession.Soureuserid; model_gen.RecTime = Convert.ToDateTime(DateTime.Now.ToLocalTime().ToString()); model_gen.LastRecUser = Com.SoureSession.Soureuserid; model_gen.LastRecTime = Convert.ToDateTime(DateTime.Now.ToLocalTime().ToString()); model_gen.ImgUrl = "00";//(Test)学生默认头像 model_gen.Sex = 1; if (Genid1 != "") { if (dotype == "e") { model_gen.GenId = Convert.ToInt32(Genid1); } } list_model_gen.Add(model_gen); //} SchSystem.Model.SchGenInfo model_gen2 = new SchSystem.Model.SchGenInfo(); //if (Convert.ToString(jzGenName2) != "" && Convert.ToString(jzTelNo2) != "") //{ model_gen2.GenName = Com.Public.SqlEncStr(jzGenName2); model_gen2.TelNo = Com.Public.SqlEncStr(jzTelNo2); model_gen2.LoginName = ""; if (Pwd != "") { model_gen2.Pwd = Com.Public.StrToMD5(Convert.ToString(jzPwd2)); } else { model_gen2.Pwd = ""; } model_gen2.Stat = Convert.ToInt32(jzStat2); model_gen2.RecUser = Com.SoureSession.Soureuserid; model_gen2.RecTime = Convert.ToDateTime(DateTime.Now.ToLocalTime().ToString()); model_gen2.LastRecUser = Com.SoureSession.Soureuserid; model_gen2.LastRecTime = Convert.ToDateTime(DateTime.Now.ToLocalTime().ToString()); model_gen2.ImgUrl = "00";//(Test)学生默认头像 model_gen2.Sex = 1; if (dotype == "e") { if (Genid2 == "")//编辑时,如果家长ID为空,则添加 { model_gen2.GenId = 0; } else { model_gen2.GenId = Convert.ToInt32(Genid2); } } list_model_gen.Add(model_gen2); //} #endregion #region 收集学生家长关系信息 List <SchSystem.Model.SchStuGenUn> list_model_stu_gen = new List <SchSystem.Model.SchStuGenUn>(); SchSystem.Model.SchStuGenUn model_stu_gen = new SchSystem.Model.SchStuGenUn(); model_stu_gen.Relation = Com.Public.SqlEncStr(Relation1); model_stu_gen.GenName = Com.Public.SqlEncStr(jzGenName1); if (dotype == "e") { if (Unid1 != "") { model_stu_gen.UnId = Convert.ToInt32(Unid1); } else { model_stu_gen.UnId = 0; } model_stu_gen.StuId = model_stu.StuId; model_stu_gen.GenId = model_gen.GenId; } list_model_stu_gen.Add(model_stu_gen); SchSystem.Model.SchStuGenUn model_stu_gen2 = new SchSystem.Model.SchStuGenUn(); if (Convert.ToString(Relation2) != "") { model_stu_gen2.Relation = Com.Public.SqlEncStr(Relation2); model_stu_gen2.GenName = Com.Public.SqlEncStr(jzGenName2); if (dotype == "e") { if (model_gen2.GenId != 0) { model_stu_gen2.UnId = Convert.ToInt32(Unid2); model_stu_gen2.StuId = model_stu.StuId; model_stu_gen2.GenId = model_gen2.GenId; } else { model_stu_gen2.UnId = 0; } } list_model_stu_gen.Add(model_stu_gen2); } #endregion if (dotype == "a")//操作类型为添加 { if (bll_stu.ExistsStuCode(0, model_stu.TestNo.ToString(), Convert.ToInt32(model_stu.SchId))) { /* * LstError.Add("学(考)号重复 !" + Environment.NewLine);//学(考)号重复 * result = "KHCF";*/ StringBuilder sbExists = new StringBuilder(); string utname = ""; SchSystem.BLL.SchStuInfo ssiBll = new SchSystem.BLL.SchStuInfo(); if (schid == "0") { schid = model_stu.SchId.ToString(); } DataTable dt = ssiBll.ExistsStuNo(TestNo, int.Parse(schid)).Tables[0]; if (dt.Rows.Count > 0) { DataRow[] dr = dt.Select(); foreach (DataRow item in dr) { sbExists.Append(item["StuName"].ToString() + "[" + item["GradeName"].ToString()); sbExists.Append("(" + item["ClassName"].ToString() + ")]"); } //ret += "账号重复!"; return(result = sbExists.ToString()); } } if (LoginName != "") { if (bll_stu.ExistsStuUsername(0, model_stu.LoginName.ToString(), Convert.ToInt32(model_stu.SchId))) { LstError.Add("账号重复 !" + Environment.NewLine);//账号重复 result = "ZHCF"; } } if (LstError.Count == 0) { if (Com.SoureSession.Souresystype == "1" || Com.SoureSession.Souresystype == "2")//超管和学校超管 { result = bll_stu.Add(model_stu, list_model_gen, list_model_stu_gen); } else { //if (ClassId == classidstr) //{ if (bllclassuser.ExistsIsMs(Com.Public.SqlEncStr(ClassId), Com.SoureSession.Soureusertid, Com.SoureSession.Soureschid, 1) == true)//班主任 { result = bll_stu.Add(model_stu, list_model_gen, list_model_stu_gen); } else { result = "BBBZR"; } //} //else if (GradeId == gradecodestr) //{ // if (bll_stu.ExistsGrade(Com.Public.SqlEncStr(GradeId), Com.Session.schid, Com.Session.usertid) == true)//年级主任 // { // result = bll_stu.Add(model_stu, list_model_gen, list_model_stu_gen); // } // else // { // result = "BNJZR"; // } //} } //result = bll_stu.Add(model_stu, list_model_gen, list_model_stu_gen); } } else if (dotype == "e")//操作类型为编辑 { StringBuilder sbExists = new StringBuilder(); string utname = ""; SchSystem.BLL.SchStuInfo ssiBll = new SchSystem.BLL.SchStuInfo(); if (schid == "0") { schid = model_stu.SchId.ToString(); } DataTable dt = ssiBll.ExistsStuNoUpdate(TestNo, int.Parse(schid), CurrentTestNo).Tables[0]; if (dt.Rows.Count > 0) { DataRow[] dr = dt.Select(); foreach (DataRow item in dr) { sbExists.Append(item["StuName"].ToString() + "[" + item["GradeName"].ToString()); sbExists.Append("(" + item["ClassName"].ToString() + ")]"); } //ret += "账号重复!"; return(result = sbExists.ToString()); } //if (bll_stu.ExistsStuCode(0, model_stu.TestNo.ToString(), Convert.ToInt32(model_stu.SchId))) //{ // LstError.Add("学(考)号重复 !" + Environment.NewLine);//学(考)号重复 // result = "KHCF"; //} if (LstError.Count == 0) { result = bll_stu.Update(model_stu, list_model_gen, list_model_stu_gen); } } } catch (Exception) { throw; } } return(result); }
/// <summary> /// 更新一条数据 /// </summary> public bool UpdateStu(SchSystem.Model.SchStuInfo model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update SchStuInfo set "); strSql.Append("StuName=@StuName,"); strSql.Append("StuNo=@StuNo,"); strSql.Append("ClassId=@ClassId,"); strSql.Append("SchId=@SchId,"); strSql.Append("TestNo=@TestNo,"); strSql.Append("Sex=@Sex,"); strSql.Append("Birth=@Birth,"); strSql.Append("TelNo=@TelNo,"); strSql.Append("Addr=@Addr,"); strSql.Append("StudyType=@StudyType,"); strSql.Append("LastRecTime=@LastRecTime,"); strSql.Append("LastRecUser=@LastRecUser,"); strSql.Append("OldClassId=@OldClassId"); strSql.Append(" where StuId=@StuId"); SqlParameter[] parameters = { new SqlParameter("@StuName", SqlDbType.VarChar, 20), new SqlParameter("@StuNo", SqlDbType.VarChar, 15), new SqlParameter("@ClassId", SqlDbType.Int, 4), new SqlParameter("@SchId", SqlDbType.Int, 4), new SqlParameter("@TestNo", SqlDbType.VarChar, 50), new SqlParameter("@Sex", SqlDbType.TinyInt, 1), new SqlParameter("@Birth", SqlDbType.DateTime), new SqlParameter("@TelNo", SqlDbType.VarChar, 50), new SqlParameter("@Addr", SqlDbType.NVarChar, 200), new SqlParameter("@StudyType", SqlDbType.TinyInt, 1), new SqlParameter("@LastRecTime", SqlDbType.DateTime), new SqlParameter("@LastRecUser", SqlDbType.VarChar, 20), new SqlParameter("@OldClassId", SqlDbType.NChar, 50), new SqlParameter("@StuId", SqlDbType.Int, 4) }; parameters[0].Value = model.StuName; parameters[1].Value = model.StuNo; parameters[2].Value = model.ClassId; parameters[3].Value = model.SchId; parameters[4].Value = model.TestNo; parameters[5].Value = model.Sex; parameters[6].Value = model.Birth; parameters[7].Value = model.TelNo; parameters[8].Value = model.Addr; parameters[9].Value = model.StudyType; parameters[10].Value = model.LastRecTime; parameters[11].Value = model.LastRecUser; parameters[12].Value = model.OldClassId; parameters[13].Value = model.StuId; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public SchSystem.Model.SchStuInfo DataRowToModel(DataRow row) { SchSystem.Model.SchStuInfo model = new SchSystem.Model.SchStuInfo(); if (row != null) { if (row["StuId"] != null && row["StuId"].ToString() != "") { model.StuId = int.Parse(row["StuId"].ToString()); } if (row["LoginName"] != null) { model.LoginName = row["LoginName"].ToString(); } if (row["Pwd"] != null) { model.Pwd = row["Pwd"].ToString(); } if (row["StuName"] != null) { model.StuName = row["StuName"].ToString(); } if (row["StuNo"] != null) { model.StuNo = row["StuNo"].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["CardNo"] != null) { model.CardNo = row["CardNo"].ToString(); } if (row["Sex"] != null && row["Sex"].ToString() != "") { model.Sex = int.Parse(row["Sex"].ToString()); } if (row["Birth"] != null && row["Birth"].ToString() != "") { model.Birth = DateTime.Parse(row["Birth"].ToString()); } if (row["ImgUrl"] != null) { model.ImgUrl = row["ImgUrl"].ToString(); } if (row["StudyType"] != null && row["StudyType"].ToString() != "") { model.StudyType = int.Parse(row["StudyType"].ToString()); } if (row["Stat"] != null && row["Stat"].ToString() != "") { model.Stat = int.Parse(row["Stat"].ToString()); } if (row["LoginTime"] != null && row["LoginTime"].ToString() != "") { model.LoginTime = DateTime.Parse(row["LoginTime"].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 Com.DataPack.DataRsp <string> schsave(string Stuid, string dotype, string schid, string ClassId, string TestNo, string StuName, string Sex, string CardNo, string StudyType, string TelNo, string Addr, string jzGenName1, string jzTelNo1, string jzGenName2, string jzTelNo2, string Relation1, string Relation2, string OldClassName, string OldGradeId, string OldGradeName, string GradeId, string OldClassId, string CurrentTestNo) { Com.DataPack.DataRsp <string> rsp = new Com.DataPack.DataRsp <string>(); SchSystem.BLL.SchClassUser bllclassuser = new SchSystem.BLL.SchClassUser(); if (Com.Session.userid == null) { rsp.code = "expire"; rsp.msg = "页面已经过期,请重新登录"; } else { try { SchSystem.Model.SchStuInfo model_stu = new SchSystem.Model.SchStuInfo(); SchSystem.BLL.SchStuInfo bll_stu = new SchSystem.BLL.SchStuInfo(); if (Com.Session.systype != "2") { model_stu.SchId = Convert.ToInt32(Com.Session.schid); } else { model_stu.SchId = Convert.ToInt32(schid); } StringBuilder sb = new StringBuilder(); if (ClassId != OldClassId) { sb.Append(OldGradeName + "(" + OldClassName + ")"); } string sbstr = sb.ToString(); if (sbstr != "") { model_stu.OldClassId = sbstr; } else { model_stu.OldClassId = ""; } model_stu.ClassId = Convert.ToInt32(ClassId); model_stu.TestNo = Com.Public.SqlEncStr(TestNo); model_stu.StuName = Com.Public.SqlEncStr(StuName); model_stu.Sex = Convert.ToInt32(Sex); model_stu.StudyType = Convert.ToInt32(StudyType); model_stu.TelNo = Com.Public.SqlEncStr(TelNo); model_stu.Addr = Com.Public.SqlEncStr(Addr); model_stu.RecUser = Com.Session.userid; model_stu.RecTime = Convert.ToDateTime(DateTime.Now.ToLocalTime().ToString()); model_stu.LastRecUser = Com.Session.userid; model_stu.LastRecTime = Convert.ToDateTime(DateTime.Now.ToLocalTime().ToString()); model_stu.StuNo = Com.Public.SqlEncStr(TestNo); model_stu.CardNo = "";//(Test)卡地址在前台读取, string errorstr = ""; //获取有考号的学生列表,进行添加或者修改判断 int stuids = 0; if (dotype == "e")//根据是否有判断 { model_stu.StuId = Convert.ToInt32(Stuid); stuids = model_stu.StuId; } //判断是否有该学号的学生 StringBuilder sbExists = new StringBuilder(); SchSystem.BLL.SchStuInfo ssiBll = new SchSystem.BLL.SchStuInfo(); //看是否考号被占用 DataTable dt = ssiBll.GetStuNoList(TestNo, model_stu.SchId, stuids).Tables[0]; if (dt.Rows.Count > 0) { DataRow[] dr = dt.Select(); foreach (DataRow item in dr) { sbExists.Append("[" + item["GradeName"].ToString() + item["ClassName"].ToString() + "]" + item["StuName"].ToString() + ";"); } errorstr += "考号被:" + sbExists.ToString() + "占用;"; } if (Com.Session.systype == "0" && !bllclassuser.ExistsIsMs(Com.Public.SqlEncStr(ClassId), Com.Session.usertid, Com.Session.schid, 1) == true)//班主任 { errorstr += "非班主任不能添加学生!"; } if (errorstr == "") { if (dotype == "e") { //更新学生 bll_stu.UpdateStu(model_stu); } else { stuids = bll_stu.AddStu(model_stu); } if (stuids > 0) { //添加家长 //先删除关联表数据 SchSystem.BLL.SchStuGenUn genunBll = new SchSystem.BLL.SchStuGenUn(); genunBll.DeleteStuUn(stuids); SchSystem.BLL.SchGenInfo genBll = new SchSystem.BLL.SchGenInfo(); //对第一个家长资料进行处理 if (Convert.ToString(jzGenName1) != "" && Convert.ToString(jzTelNo1) != "") { int genid = genBll.GetMbId(jzTelNo1); if (genid == 0)//无号码存在,则插数据 { SchSystem.Model.SchGenInfo genmodel = new SchSystem.Model.SchGenInfo(); genmodel.TelNo = jzTelNo1; genmodel.RecUser = Com.Session.userid; genmodel.RecTime = DateTime.Now; genmodel.LastRecUser = Com.Session.userid; genmodel.LastRecTime = DateTime.Now; genid = genBll.Add(genmodel); } if (genid > 0)//插成功或者获取成功,则往关联表插数据 { SchSystem.Model.SchStuGenUn genunmodel = new SchSystem.Model.SchStuGenUn(); genunmodel.StuId = stuids; genunmodel.GenId = genid; genunmodel.GenName = jzGenName1; genunmodel.Relation = Relation1 == "" ? "其他" : Relation1; genunBll.Add(genunmodel); } } //对第二个家长进行处理 if (Convert.ToString(jzGenName2) != "" && Convert.ToString(jzTelNo2) != "") { int genid = genBll.GetMbId(jzTelNo2); if (genid == 0)//无号码存在,则插数据 { SchSystem.Model.SchGenInfo genmodel = new SchSystem.Model.SchGenInfo(); genmodel.TelNo = jzTelNo2; genmodel.RecUser = Com.Session.userid; genmodel.RecTime = DateTime.Now; genmodel.LastRecUser = Com.Session.userid; genmodel.LastRecTime = DateTime.Now; genid = genBll.Add(genmodel); } if (genid > 0)//插成功或者获取成功,则往关联表插数据 { SchSystem.Model.SchStuGenUn genunmodel = new SchSystem.Model.SchStuGenUn(); genunmodel.StuId = stuids; genunmodel.GenId = genid; genunmodel.GenName = jzGenName2; genunmodel.Relation = Relation2 == "" ? "其他" : Relation2; genunBll.Add(genunmodel); } } } rsp.code = "success"; rsp.msg = "保存成功"; } else { rsp.code = "error"; rsp.msg = errorstr; } } catch (Exception ex) { rsp.code = "error"; rsp.msg = ex.Message; } } return(rsp); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(SchSystem.Model.SchStuInfo model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update SchStuInfo set "); strSql.Append("LoginName=@LoginName,"); strSql.Append("Pwd=@Pwd,"); strSql.Append("StuName=@StuName,"); strSql.Append("StuNo=@StuNo,"); strSql.Append("ClassId=@ClassId,"); strSql.Append("SchId=@SchId,"); strSql.Append("CardNo=@CardNo,"); strSql.Append("Sex=@Sex,"); strSql.Append("Birth=@Birth,"); strSql.Append("ImgUrl=@ImgUrl,"); strSql.Append("StudyType=@StudyType,"); //strSql.Append("Stat=@Stat,"); //strSql.Append("LoginTime=@LoginTime,"); //strSql.Append("RecTime=@RecTime,"); //strSql.Append("RecUser=@RecUser,"); strSql.Append("LastRecTime=@LastRecTime,"); strSql.Append("LastRecUser=@LastRecUser"); strSql.Append(" where StuId=@StuId"); SqlParameter[] parameters = { new SqlParameter("@LoginName", SqlDbType.VarChar, 50), new SqlParameter("@Pwd", SqlDbType.VarChar, 20), new SqlParameter("@StuName", SqlDbType.VarChar, 20), new SqlParameter("@StuNo", SqlDbType.VarChar, 15), new SqlParameter("@ClassId", SqlDbType.Int, 4), new SqlParameter("@SchId", SqlDbType.Int, 4), new SqlParameter("@CardNo", SqlDbType.VarChar, 15), new SqlParameter("@Sex", SqlDbType.TinyInt, 1), new SqlParameter("@Birth", SqlDbType.DateTime), new SqlParameter("@ImgUrl", SqlDbType.VarChar, 200), new SqlParameter("@StudyType", SqlDbType.TinyInt, 1), //new SqlParameter("@Stat", SqlDbType.TinyInt,1), //new SqlParameter("@LoginTime", SqlDbType.DateTime), //new SqlParameter("@RecTime", SqlDbType.SmallDateTime), //new SqlParameter("@RecUser", SqlDbType.VarChar,50), new SqlParameter("@LastRecTime", SqlDbType.DateTime), new SqlParameter("@LastRecUser", SqlDbType.VarChar, 20), new SqlParameter("@StuId", SqlDbType.Int, 4) }; parameters[0].Value = model.LoginName; parameters[1].Value = model.Pwd; parameters[2].Value = model.StuName; parameters[3].Value = model.StuNo; parameters[4].Value = model.ClassId; parameters[5].Value = model.SchId; parameters[6].Value = model.CardNo; parameters[7].Value = model.Sex; parameters[8].Value = model.Birth; parameters[9].Value = model.ImgUrl; parameters[10].Value = model.StudyType; //parameters[11].Value = model.Stat; //parameters[12].Value = model.LoginTime; //parameters[13].Value = model.RecTime; //parameters[14].Value = model.RecUser; parameters[11].Value = model.LastRecTime; parameters[12].Value = model.LastRecUser; parameters[13].Value = model.StuId; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }