public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";

            SchSystem.BLL.SchStuGenUn ssguBll = new SchSystem.BLL.SchStuGenUn();

            string Action = context.Request.Form["Action"];


            if (Action == "List")
            {
                int PageSize  = int.Parse(context.Request.Form["PageSize"]); //页数
                int PageIndex = 1;                                           //当前页面
                if (!string.IsNullOrEmpty(context.Request.Form["PageIndex"]))
                {
                    PageIndex = int.Parse(context.Request.Form["PageIndex"]);
                }

                int RowCount = 0; int PageCount = 0;
                //数据分页:cols,所查询的列;strWhere,所查询的条件;ordercols,排序列;orderby,降序或升序;PageIndex,当前页数;PageSize,每页条数;RowCount,记录总数;PageCount,总页数
                DataSet ds = ssguBll.GetListCols("ssgu.*,ssi.StuName,spi.GenName", "", "", "", PageIndex, PageSize, ref RowCount, ref PageCount);
                //数字分页
                Paging pa    = new Paging(PageSize, RowCount, "StuGenUnList.aspx", PageIndex);
                string pages = pa.GetPageing();
                context.Response.Write(SchManagerInfoSystem.Common.Function.DatasetToJson(ds, -1, pages, PageCount, RowCount, PageIndex));//将返回的DataSet集合转换为JSON对象
            }
            else if (Action == "Delete")
            {
                int StudentId = int.Parse(context.Request.Form["StudentId"]);

                bool result = ssguBll.Delete(StudentId);
                context.Response.Write(result);
            }
        }
Пример #2
0
        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);
        }