Exemple #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            User_Load("student-add");
            //班级ID
            string cid = Request["cid"];

            if (!string.IsNullOrEmpty(cid))
            {
                try
                {
                    classId = Convert.ToInt32(cid);
                }
                catch (Exception)
                {
                }
            }

            //设置班级
            SchClassId = classId;
            //设置年级
            Entity.GradeEntity       cmodel = new BLL.GradeBLL().GetEntity(SchClassId);
            Entity.SchoolGradeEntity gmodel = null;
            if (cmodel != null)
            {
                SchGradeId = cmodel.GgradeID;
                //获取学校对象
                gmodel = new BLL.SchoolGradeBLL().GetEntity(SchGradeId);
            }
            //设置学校
            if (gmodel != null)
            {
                SchID = gmodel.SchoolID;
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            User_Load("student-list");

            //班级ID
            string cid = Request["cid"];

            if (!string.IsNullOrEmpty(cid))
            {
                try
                {
                    classId = Convert.ToInt32(cid);
                }
                catch (Exception)
                {
                }
            }
            //设置班级
            SchClassId = classId;
            //设置年级
            Entity.GradeEntity cmodel = new BLL.GradeBLL().GetEntity(SchClassId);
            if (cmodel != null)
            {
                SchGradeId = cmodel.GgradeID;
            }

            if (!this.Page.IsPostBack)
            {
                this.user_repeater.DataSource = pds();
                this.user_repeater.DataBind();
            }
        }
Exemple #3
0
        /// <summary>
        /// 获取学生数据
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public ResponeDataEntity GetStudentData(HttpContext context, JObject ob)
        {
            string user      = Convert.ToString(context.Session["UserName"]);
            string pagesize  = ob["pageSize"].ToString();
            string pageindex = ob["pageIndex"].ToString();
            string mPhone    = ob["mPhone"].ToString();

            ResponeDataEntity entity = new ResponeDataEntity();

            entity.Status = 1;
            StudentViewModel svmodel = new StudentViewModel();

            try
            {
                logHelper.logInfo(" GetStudentData params:pagesize:" + pagesize + " pageindex:" + pageindex + " mPhone:" + mPhone);
                IList <Hashtable>           list        = stubll.List(Convert.ToInt32(pageindex), Convert.ToInt32(pagesize), mPhone);
                List <Entity.ContactEntity> contactList = null;
                MechanicalEntity            mechEntity  = new BLL.MechanicalBLL().GetEntityByImei(mPhone);
                Entity.GradeEntity          gEntity     = new BLL.GradeBLL().GetEntity(mechEntity.Gid);
                if (gEntity == null)
                {
                    throw new Exception("请检查设备所在班级,无此设备的班级数据!");
                }
                if (list != null && list.Count > 0)
                {
                    contactList = new BLL.ContactBLL().GetEntitysBySids(list.Select(l => Convert.ToInt32(l["Sid"])).ToArray());
                    List <object> reuslts            = new List <object>();
                    List <Entity.ContactEntity> temp = null;
                    foreach (var item in list)
                    {
                        temp = contactList.Where(c => c.Sid == Convert.ToInt32(item["Sid"])).ToList();
                        if (temp == null)
                        {
                            temp = new List <ContactEntity>();
                        }
                        reuslts.Add(
                            new {
                            Sname   = item["Sname"].ToString(),
                            Snumber = item["Snumber"].ToString(),
                            Gid     = item["Gid"].ToString(),
                            Cphone  = temp.Select(t => new { name = t.CPhoneName, phone = t.Cphone })
                        });
                    }
                    //entity.Data = reuslts;
                    svmodel.Student   = reuslts;
                    svmodel.MechPhone = mechEntity.MechPhone;
                    svmodel.ClassName = gEntity.Gname;
                }
            }
            catch (Exception ex)
            {
                entity.Status = 0;
                entity.Msg    = ex.Message;
            }
            entity.Data = svmodel;
            return(entity);
        }
Exemple #4
0
        //数据绑定
        void Bind()
        {
            int gid = Str2Int(q("id"), 0);

            Daiv_OA.Entity.StudentEntity model = new Daiv_OA.Entity.StudentEntity();
            model               = new Daiv_OA.BLL.StudentBLL().GetEntity(gid);
            this.Snumber.Text   = model.Snumber;
            this.Sname.Text     = model.Sname;
            this.Sbirthday.Text = model.Sbirthday.ToString("yyyy-MM-dd");
            //绑定家长联系电话
            List <Daiv_OA.Entity.ContactEntity> cModels = new Daiv_OA.BLL.ContactBLL().GetEntitysBySid(model.Sid);
            StringBuilder sbuilder = new StringBuilder();

            sbuilder.AppendLine("<table id = \"contactTable\"  class=\"ipt\" width=\"280px;\" >");
            sbuilder.AppendLine("<thead><tr><td>名称</td><td>电话号码</td><td>操作<input type=\"button\" id =\"contactAdd\" value =\"添加\" /></td></tr></thead>");
            int index = 0;

            if (cModels != null && cModels.Count > 0)
            {
                foreach (var item in cModels)
                {
                    sbuilder.AppendLine("<tr class=\"contactTr\">");
                    sbuilder.AppendLine("<td><input type = \"text\" name =\"contactName\" value =\"" + item.CPhoneName + "\" maxlength=\"32\"  onkeyup =\"value = value.replace(/[^\\a-\\z\\-\\Z0-9\\u4E00-\\u9FA5]/g, '')\" onpaste =\"return false\" oncontextmenu =\"return false; \" /></td>");
                    sbuilder.AppendLine("<td ><input type = \"text\" name =\"contactPhone\" value =\"" + item.Cphone + "\" style =\"width:120px;\" onkeyup=\"value = value.replace(/[^0-9]/g,'')\" onpaste=\"return false\" oncontextmenu=\"return false; \" /></td>");
                    sbuilder.AppendLine("<td><input type = \"button\" class=\"contactDelete\" value =\"删除\"  style =\"" + (index == 0? "display:none;" : "") + "\" /></td>");
                    sbuilder.AppendLine("</tr>");
                    index++;
                }
            }
            else
            {
                sbuilder.AppendLine("<tr class=\"contactTr\">");
                sbuilder.AppendLine("<td><input type = \"text\" name =\"contactName\" value =\"\" style =\"width:60px;\" /></td>");
                sbuilder.AppendLine("<td ><input type = \"text\" name =\"contactPhone\" value =\"\" style =\"width:120px;\" /></td>");
                sbuilder.AppendLine("<td><input type = \"button\" class=\"contactDelete\" value =\"删除\"  style =\"display:none;\" /></td>");
                sbuilder.AppendLine("</tr>");
            }
            sbuilder.AppendLine("</table>");
            this.ltMasterSetting.Text = sbuilder.ToString();

            //设置班级
            SchClassId = model.Gid;
            //设置年级
            Entity.GradeEntity       cmodel = new BLL.GradeBLL().GetEntity(SchClassId);
            Entity.SchoolGradeEntity gmodel = null;
            if (cmodel != null)
            {
                SchGradeId = cmodel.GgradeID;
                //获取学校对象
                gmodel = new BLL.SchoolGradeBLL().GetEntity(SchGradeId);
            }
            //设置学校
            if (gmodel != null)
            {
                SchID = gmodel.SchoolID;
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            User_Load("student-add");
            //班级ID
            string cid = Request["cid"];

            if (!string.IsNullOrEmpty(cid))
            {
                try
                {
                    classId = Convert.ToInt32(cid);
                }
                catch (Exception)
                {
                }
            }

            if (!this.IsPostBack)
            {
                //string sql = "";
                //Daiv_OA.BLL.GradeBLL dp = new Daiv_OA.BLL.GradeBLL();
                //DataSet ds = dp.GetList(sql);
                //for (int j = 0; j < ds.Tables[0].Rows.Count; j++)
                //{
                //    ListItem listItem = new ListItem();
                //    listItem.Text = ds.Tables[0].Rows[j]["Gname"].ToString();
                //    listItem.Value = ds.Tables[0].Rows[j]["Gid"].ToString();
                //    this.ddlGid.Items.Add(listItem);
                //}
                //ds.Clear();
            }

            //设置班级
            SchClassId = classId;
            //设置年级
            Entity.GradeEntity       cmodel = new BLL.GradeBLL().GetEntity(SchClassId);
            Entity.SchoolGradeEntity gmodel = null;
            if (cmodel != null)
            {
                SchGradeId = cmodel.GgradeID;
                //获取学校对象
                gmodel = new BLL.SchoolGradeBLL().GetEntity(SchGradeId);
            }
            //设置学校
            if (gmodel != null)
            {
                SchID = gmodel.SchoolID;
            }
        }
Exemple #6
0
        //更新
        protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
        {
            Entity.StudentEntity   model      = new Entity.StudentEntity();
            Daiv_OA.BLL.ContactBLL contactBll = new Daiv_OA.BLL.ContactBLL();
            Daiv_OA.BLL.StudentBLL studentBll = new Daiv_OA.BLL.StudentBLL();
            Daiv_OA.BLL.GradeBLL   gradeBll   = new BLL.GradeBLL();
            string uuid = Guid.NewGuid().ToString("N");
            //修改联系电话
            //保存上传文件
            string      fName  = UploadFile(uuid);
            string      path   = Path.Combine(Server.MapPath("/"), "upload/" + DateTime.Now.ToString("yyyy/MM").Replace("/", "").Substring(0, 6));
            ImportExcel import = new ImportExcel();

            import.LoadFile(path + "/" + fName);
            DataSet   ds        = import.GetAllTables(true);
            DataTable dataTable = ds.Tables[0];
            //获取班级数据
            List <Entity.GradeEntity> glist = gradeBll.GetModelList("");

            if (glist == null || glist.Count <= 0)
            {
                logHelper.logInfo("未添加任何班级数据!");
                FinalMessage("导入失败,请先添加班级数据!", "", 0);
            }
            #region 验证表格
            //验证表格
            if (dataTable.Rows.Count <= 0)
            {
                logHelper.logInfo(fName + ",未填写任何学生数据!");
                FinalMessage(fName + ",未填写任何学生数据!", "", 0);
                return;
            }
            for (int i = 0; i < colmun.Length; i++)
            {
                if (colmun[i] != dataTable.Columns[i].ColumnName)
                {
                    FinalMessage("导入的excel表与模板excel表不符合!", "", 0);
                    message.Visible = true;
                    return;
                }
            }
            //验证班级数据
            int    tbCount   = dataTable.Rows.Count;
            string tempCName = string.Empty;
            if (Request["schClassgcid"] == null || string.IsNullOrEmpty(Request["schClassgcid"].ToString()))
            {
                FinalMessage("没有选择班级,请重新选择!", "", 0);
                return;
            }
            try
            {
                SchClassId = int.Parse(Request["schClassgcid"].ToString());
            }
            catch (Exception ex)
            {
                FinalMessage("班级转换失败,请重新选择!", "", 0);
                return;
            }
            //for (int j = 0; j < tbCount; j++)
            //{
            //    tempCName = Convert.ToString(dataTable.Rows[j][colmun[2]]);
            //    if (glist.Where(g=>g.Gname == tempCName).FirstOrDefault() == null)
            //    {
            //        logHelper.logInfo(tempCName + " 未匹配到此班级名称!");
            //        FinalMessage(tempCName + " 未匹配到此班级名称!", "", 0);
            //        message.Visible = true;
            //        return;
            //    }
            //}
            //验证时间的有效性
            for (int i = 0; i < tbCount; i++)
            {
                try
                {
                    Convert.ToDateTime(dataTable.Rows[i][colmun[3]]);
                }
                catch (Exception)
                {
                    logHelper.logInfo(string.Format("'{0}' 出生年月日无效!", tempCName));
                    FinalMessage(Convert.ToString(dataTable.Rows[i][colmun[1]]) + "学生出生时间无效!", "", 0);
                    message.Visible = true;
                    return;
                }

                //验证学号
                //验证学生序号是否存在
                string snumbertemp           = Convert.ToString(dataTable.Rows[i][colmun[0]]);
                bool   exixt                 = new Daiv_OA.BLL.StudentBLL().Exists(snumbertemp);
                Daiv_OA.BLL.ContactBLL ctBll = new Daiv_OA.BLL.ContactBLL();
                if (exixt)
                {
                    FinalMessage(snumbertemp + "相同的学生学号已经存在", "", 0);
                    message.Visible = true;
                    return;
                }
            }


            #endregion

            //遍历表格
            Entity.StudentEntity studentEntity = null;
            Entity.UserEntity    parent        = null;
            Entity.ContactEntity contactEnitty = null;
            for (int i = 0; i < tbCount; i++)
            {
                studentEntity = new Entity.StudentEntity();
                parent        = new Entity.UserEntity();
                contactEnitty = new Entity.ContactEntity();
                //保存数据
                try
                {
                    //学生实体相关信息保存
                    studentEntity.Gname     = glist.Where(g => g.Gid == SchClassId).FirstOrDefault().Gname; //班级名称 列索引:2
                    studentEntity.Gid       = glist.Where(g => g.Gid == SchClassId).FirstOrDefault().Gid;
                    studentEntity.Snumber   = Convert.ToString(dataTable.Rows[i][colmun[0]]);               //学生学号 列索引:0
                    studentEntity.Sname     = Convert.ToString(dataTable.Rows[i][colmun[1]]);               //学生名称 列索引:1
                    studentEntity.Sbirthday = Convert.ToDateTime(dataTable.Rows[i][colmun[3]]);             //出生年月日 列索引:3
                                                                                                            //家长实体相关信息保存
                    parent.Uname = studentEntity.Snumber;
                    string pwd = studentEntity.Sbirthday.ToString("yy") + studentEntity.Sbirthday.ToString("MM") + studentEntity.Sbirthday.ToString("dd");
                    parent.Upwd     = Daiv_OA.Utils.MD5.Lower32(pwd);
                    parent.Pid      = 4;
                    parent.Did      = 0;
                    parent.Position = "家长";
                    parent.Mphone   = "";
                    Entity.PowerEntity powerEntity = new BLL.PowerBLL().GetEntity(parent.Pid);
                    parent.Setting = powerEntity.Setting;
                    //联系电话实体相关信息保存
                    contactEnitty.Cphone  = Convert.ToString(dataTable.Rows[i][colmun[4]]); //家长联系电话1 列索引:4
                    contactEnitty.Cphone2 = Convert.ToString(dataTable.Rows[i][colmun[5]]); //家长联系电话2 列索引:5
                    contactEnitty.Cphone3 = Convert.ToString(dataTable.Rows[i][colmun[6]]); //家长联系电话3 列索引:6
                    contactEnitty.Cphone4 = Convert.ToString(dataTable.Rows[i][colmun[7]]); //家长联系电话4 列索引:7

                    List <Entity.ContactEntity> contactList = new List <Entity.ContactEntity>();
                    contactList.Add(new Entity.ContactEntity()
                    {
                        CPhoneName = "家长1", Cphone = contactEnitty.Cphone
                    });
                    contactList.Add(new Entity.ContactEntity()
                    {
                        CPhoneName = "家长2", Cphone = contactEnitty.Cphone2
                    });
                    contactList.Add(new Entity.ContactEntity()
                    {
                        CPhoneName = "家长3", Cphone = contactEnitty.Cphone3
                    });
                    contactList.Add(new Entity.ContactEntity()
                    {
                        CPhoneName = "家长4", Cphone = contactEnitty.Cphone4
                    });

                    //当前操作人对象
                    Entity.UserEntity opera = new Daiv_OA.BLL.UserBLL().GetEntity(UserId);
                    new Daiv_OA.BLL.StudentBLL().Add(studentEntity, parent, contactList, opera);
                }
                catch (Exception ex)
                {
                    FinalMessage("操作失败!" + ex.Message, "Student_List.aspx", 1);
                    return;
                }

                // FinalMessage("操作成功", "Student_List.aspx", 0);
            }
            logHelper.logInfo("导入成功!操作人:" + UserId);
            FinalMessage("导入成功", "Student_List.aspx", 0);
        }