public bool TimeList_Bind() { DB db = new DB(); string str = "SELECT jobName,dutyInTime,dutyOutTime FROM dutyTimeTable,JOBSKYER WHERE dutyTimeTable.jobskyerID=JOBSKYER.jobskyerID"; SqlConnection con = new SqlConnection(); con = db.GetCon(); con.Open(); SqlCommand com = new SqlCommand(str, con); SqlDataAdapter da = new SqlDataAdapter(com); DataSet ds = new DataSet(); da.Fill(ds); try { TimeList_Manager.DataSource = ds; TimeList_Manager.DataBind(); } catch (Exception ex) { return(false); } finally { com.Dispose(); con.Close(); } return(true); }
protected void TimeList_Manager_ItemCommand(object source, RepeaterCommandEventArgs e) { if (e.CommandName == "delect") { string jobskyerID = Convert.ToString(e.CommandArgument); string str = "DELETE FROM dutyTimeTable WHERE jobskyerID='" + jobskyerID + "'"; DB db = new DB(); SqlConnection con = new SqlConnection(); SqlCommand com = new SqlCommand(str, con); con.Open(); try { com.ExecuteNonQuery(); } catch (Exception ex) { Response.Write("<script>alert('删除失败!');location.href='DutyTable_Manager.aspx';</script>"); } finally { com.Dispose(); con.Close(); } DB db1 = new DB(); string str1 = "SELECT jobName,dutyInTime,dutyOutTime FROM dutyTimeTable,JOBSKYER WHERE dutyTimeTable.jobskyerID=JOBSKYER.jobskyerID"; SqlConnection con1 = new SqlConnection(); con1 = db.GetCon(); con1.Open(); SqlCommand com1 = new SqlCommand(str1, con1); SqlDataAdapter da = new SqlDataAdapter(com1); DataSet ds = new DataSet(); da.Fill(ds); try { TimeList_Manager.DataSource = ds; TimeList_Manager.DataBind(); } catch (Exception ex) { Response.Write("< script > alert('数据更新失败!'); location.href = 'DutyTable_Manager.aspx';</ script >"); } finally { com.Dispose(); con.Close(); Response.Redirect(Request.Url.ToString()); } } }