温馨提示:代码在线浏览功能只能做为源码浏览参考,不能展示项目的全部,如果想更进一步了解该代码请下载:人才网初学者工具包源码
当前文件路径:JobSiteStarterKit/employer/AddEditPosting.aspx.cs

1using System; 2
using System.Data; 3
using System.Configuration; 4
using System.Web; 5
using System.Web.Security; 6
using System.Web.UI; 7
using System.Web.UI.WebControls; 8
using System.Web.UI.WebControls.WebParts; 9
using System.Web.UI.HtmlControls; 10
using JobSiteStarterKit.BOL; 11
12
public partial class AddEditPosting_aspx : Page 13
{ 14
protected void Page_Load(object sender, EventArgs e) 15
{ 16
if (!Roles.IsUserInRole(ConfigurationManager.AppSettings["employerrolename"])) 17
{ 18
Response.Redirect("~/customerrorpages/NotAuthorized.aspx"); 19
} 20
21
if (!Page.IsPostBack) 22
{ 23
if (Company.GetCompany(User.Identity.Name) == null) 24
{ 25
Response.Redirect("~/customerrorpages/profilenotfound.aspx"); 26
} 27
28
if (Request.QueryString["id"] == null) 29
{ 30
DetailsView1.DefaultMode = DetailsViewMode.Insert; 31
} 32
else 33
{ 34
DetailsView1.DefaultMode = DetailsViewMode.ReadOnly; 35
} 36
} 37
} 38
protected void DetailsView1_ItemInserting(object sender, DetailsViewInsertEventArgs e) 39
{ 40
41
DropDownList ddl; 42
ddl = (DropDownList)DetailsView1.FindControl("ddlStateInsert"); 43
e.Values["StateID"] = ddl.SelectedValue; 44
45
ddl = (DropDownList)DetailsView1.FindControl("ddlCountryInsert"); 46
e.Values["CountryID"] = ddl.SelectedValue; 47
48
ddl = (DropDownList)DetailsView1.FindControl("ddlEduLevelInsert"); 49
e.Values["EducationLevelID"] = ddl.SelectedValue; 50
51
ddl = (DropDownList)DetailsView1.FindControl("ddlJobTypeInsert"); 52
e.Values["JobTypeID"] = ddl.SelectedValue; 53
54
e.Values["PostedBy"] = Profile.UserName; 55
e.Values["CompanyID"]=Profile.Employer.CompanyID.ToString(); 56
e.Values["PostingDate"]= DateTime.Today.ToString("MM/dd/yyyy"); 57
58
} 59
60
protected void DetailsView1_ItemUpdating(object sender, DetailsViewUpdateEventArgs e) 61
{ 62
DropDownList ddl; 63
ddl = (DropDownList)DetailsView1.FindControl("ddlStateUpdate"); 64
e.NewValues["StateID"] = ddl.SelectedValue; 65
66
ddl = (DropDownList)DetailsView1.FindControl("ddlCountryUpdate"); 67
e.NewValues["CountryID"] = ddl.SelectedValue; 68
69
ddl = (DropDownList)DetailsView1.FindControl("ddlEduLevelUpdate"); 70
e.NewValues["EducationLevelID"] = ddl.SelectedValue; 71
72
ddl = (DropDownList)DetailsView1.FindControl("ddlJobTypeUpdate"); 73
e.NewValues["JobTypeID"] = ddl.SelectedValue; 74
75
e.NewValues["PostedBy"] = Profile.UserName; 76
e.NewValues["CompanyID"] = Profile.Employer.CompanyID.ToString(); 77
e.NewValues["PostingDate"] = DateTime.Today.ToString("MM/dd/yyyy"); 78
79
} 80
81
protected void DetailsView1_ItemDeleted(object sender, DetailsViewDeletedEventArgs e) 82
{ 83
Response.Redirect("~/" + ConfigurationManager.AppSettings["employerfolder"] + "/jobpostings.aspx"); 84
} 85
86
protected void ddlCountryUpdate_SelectedIndexChanged(object sender, EventArgs e) 87
{ 88
DropDownList ddl; 89
ddl = (DropDownList)sender; 90
ObjectDataSource2.SelectParameters["countryid"].DefaultValue = ddl.SelectedValue; 91
ObjectDataSource2.Select(); 92
} 93
94
protected void ddlCountryInsert_SelectedIndexChanged(object sender, EventArgs e) 95
{ 96
DropDownList ddl; 97
ddl = (DropDownList)sender; 98
ObjectDataSource2.SelectParameters["countryid"].DefaultValue = ddl.SelectedValue; 99
ObjectDataSource2.Select(); 100
101
} 102
103
protected void DetailsView1_DataBound(object sender, EventArgs e) 104
{ 105
DropDownList ddl; 106
ddl = (DropDownList)DetailsView1.FindControl("ddlCountryUpdate"); 107
if (ddl != null) 108
{ 109
ObjectDataSource2.SelectParameters["countryid"].DefaultValue = ddl.SelectedValue; 110
ObjectDataSource2.Select(); 111
112
} 113
114
} 115
116
} 117





}
}