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; } }
//更新 protected void ImageButton1_Click(object sender, ImageClickEventArgs e) { Entity.SchoolGradeEntity model = new Entity.SchoolGradeEntity(); Daiv_OA.BLL.ContactBLL contactBll = new Daiv_OA.BLL.ContactBLL(); Daiv_OA.BLL.SchoolGradeBLL SchoolGradeBll = new Daiv_OA.BLL.SchoolGradeBLL(); model = SchoolGradeBll.GetEntity(Str2Int(q("id"), 0)); model.SchoolID = int.Parse(this.ddlGid.SelectedValue); model.Name = this.Name.Text; Entity.SchoolGradeEntity sgEntity = SchoolGradeBll.GetEntityByNameAndScId(model.Name, model.SchoolID); if (sgEntity != null && sgEntity.ID != model.ID) { FinalMessage("已经存在:此学校的班级:" + model.Name, "SchoolGrade_Edit.aspx?id=" + model.ID + "&shid=" + schId, 0); return; } SchoolGradeBll.Update(model); logHelper.logInfo("修改设备成功!操作人:" + UserId); FinalMessage("操作成功", "SchoolGrade_List.aspx?shid=" + schId, 0); }
//删除数据 protected void lbDel_Click(object sender, CommandEventArgs e) { User_Load("sch-list"); string oname = Getoname(); Daiv_OA.BLL.SchoolGradeBLL SchoolGradeBll = new Daiv_OA.BLL.SchoolGradeBLL(); Daiv_OA.BLL.UserBLL userBll = new BLL.UserBLL(); int sid = Convert.ToInt32(e.CommandArgument); Entity.SchoolGradeEntity SchoolGradeEntity = SchoolGradeBll.GetEntity(sid); SchoolGradeBll.Delete(sid); logHelper.logInfo("删除年级成功!操作人:" + oname); string stuStr = Newtonsoft.Json.JsonConvert.SerializeObject(SchoolGradeEntity); logHelper.logInfo("删除年级:" + stuStr); Adminlogadd(oname); Bind(); }
//添加 protected void ImageButton1_Click(object sender, ImageClickEventArgs e) { Entity.SchoolGradeEntity SchoolGradeEntity = new Entity.SchoolGradeEntity(); Entity.UserEntity parent = new Entity.UserEntity(); Entity.ContactEntity contactEnitty = new Entity.ContactEntity(); //年级实体相关信息保存 SchoolGradeEntity.SchoolID = int.Parse(this.ddlGid.SelectedValue); SchoolGradeEntity.Name = this.Name.Text; SchoolGradeEntity.CreateDate = DateTime.Now; //保存数据 try { new Daiv_OA.BLL.SchoolGradeBLL().Add(SchoolGradeEntity); } catch (Exception ex) { FinalMessage("操作失败!" + ex.Message, "SchoolGrade_List.aspx?shid=" + schId, 1); return; } FinalMessage("操作成功", "SchoolGrade_List.aspx?shid=" + schId, 0); }
/// <summary> /// 更新一条数据 /// </summary> public void Update(Entity.SchoolGradeEntity model) { dal.Update(model); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Entity.SchoolGradeEntity model) { return(dal.Add(model)); }