protected void Page_Load(object sender, EventArgs e) { if (Session["UserInfo"] == null) { Response.Redirect("../Mutual/UserEntry.aspx"); } if (!IsPostBack) { OleDbConnection conn = new OleDbConnection(Dal.OleDbHlper.ConnectionString); conn.Open(); InitDdlProfession(); string strGroupID = Request["GroupID"]; if (!string.IsNullOrEmpty(strGroupID)) { Dal.Models.ExpertGroup ExpertGroup = BLL.ExpertGroup.GetExpertGroup(Convert.ToInt32(strGroupID), conn); ddlSpecialty.SelectedValue = ExpertGroup.SpecialtyID.ToString(); txtExpertGroupName.Text = ExpertGroup.GroupName; txtExpertGroupLeader.Text = ExpertGroup.GroupLeader.ToString(); txtExpertGroupLeaderText.Value = ExpertGroup.LeaderName; txtDeputyLeader.Text = ExpertGroup.DeputyIDs; txtDeputyLeaderText.Value = ExpertGroup.DeputyNames; hfParentID.Value = ExpertGroup.ParentID == null ? "0" : ExpertGroup.ParentID.ToString(); } } }
protected void btnSaveExpertGroup_Click(object sender, EventArgs e) { OleDbConnection conn = new OleDbConnection(Dal.OleDbHlper.ConnectionString); conn.Open(); string strActivityType = Session["ActivityType"].ToString(); Dal.Models.Activity activity = BLL.Activity.GetActivity(strActivityType, conn); if (activity == null) { hdMsg.Value = "当前活动已关闭,请联系活动管理人员!"; return; } Dal.Models.ExpertGroup expertGroup = new Dal.Models.ExpertGroup(); string strGroupID = Request["GroupID"]; if (!string.IsNullOrEmpty(strGroupID)) { expertGroup.GroupID = Convert.ToInt32(strGroupID); } if (hfParentID.Value != "0" && hfParentID.Value != "") { expertGroup.ParentID = Convert.ToInt32(hfParentID.Value); } expertGroup.GroupName = txtExpertGroupName.Text; expertGroup.ActivityID = activity.ActivityID; expertGroup.SpecialtyID = Convert.ToInt32(ddlSpecialty.SelectedValue); // 组长 if (!string.IsNullOrEmpty(txtExpertGroupLeader.Text.Trim())) { expertGroup.GroupLeader = Convert.ToInt32(txtExpertGroupLeader.Text.Trim()); } else { hdMsg.Value = "专家组必须要有一个组长!"; return; } // 副组长 expertGroup.DeputyIDs = txtDeputyLeader.Text.Trim(); Dal.Models.UserInfo user = (Dal.Models.UserInfo)Session["UserInfo"]; OleDbTransaction tran = conn.BeginTransaction(); try { BLL.ExpertGroup.CreateExpertGroup(expertGroup, user, conn, tran); tran.Commit(); hdMsg.Value = "保存成功!"; } catch (Exception ex) { tran.Rollback(); hdMsg.Value = ex.Message; conn.Close(); return; } conn.Close(); }