protected void dlEmployee_ItemDataBound(object sender, DataListItemEventArgs e) { DropDownList ddlcheckin, ddlcheckout; ddlcheckin = (DropDownList)e.Item.FindControl("ddlCheckIn"); ddlcheckout = (DropDownList)e.Item.FindControl("ddlCheckOut"); //default value CommonUtil.SetDropDownSelectedByText(ddlcheckin, "11:00"); CommonUtil.SetDropDownSelectedByText(ddlcheckout, "19:30"); CheckBox chkIsLeave; TextBox txtAnnual, txtSick, txtOther; chkIsLeave = (CheckBox)e.Item.FindControl("chkIsLeave"); txtAnnual = (TextBox)e.Item.FindControl("txtAnnualLeave"); txtSick = (TextBox)e.Item.FindControl("txtSickLeave"); txtOther = (TextBox)e.Item.FindControl("txtOtherLeave"); //check db saved data vw_Employee emp = (vw_Employee)e.Item.DataItem; DataTable dt = eh.getReservationTime(emp.employeeNum, (DateTime)DateSelector1.DateValue); if (dt != null && dt.Rows.Count == 1) { CommonUtil.SetDropDownSelectedByText(ddlcheckin, dt.Rows[0]["checkinTime"].ToString()); CommonUtil.SetDropDownSelectedByText(ddlcheckout, dt.Rows[0]["checkoutTime"].ToString()); chkIsLeave.Checked = (bool)dt.Rows[0]["isLeave"]; txtAnnual.Text = dt.Rows[0]["AnnualLeave"].ToString(); txtSick.Text = dt.Rows[0]["SickLeave"].ToString(); txtOther.Text = dt.Rows[0]["OtherLeave"].ToString(); } }
protected void rptEmp_ItemDataBound(object sender, RepeaterItemEventArgs e) { DropDownList ddlcheckin, ddlcheckout; CheckBox chkIsLeave, chkSel; TextBox txtAnnual, txtSick, txtOther; chkIsLeave = (CheckBox)e.Item.FindControl("chkIsLeave"); chkSel = (CheckBox)e.Item.FindControl("chkSel"); txtAnnual = (TextBox)e.Item.FindControl("txtAnnualLeave"); txtSick = (TextBox)e.Item.FindControl("txtSickLeave"); txtOther = (TextBox)e.Item.FindControl("txtOtherLeave"); ddlcheckin = (DropDownList)e.Item.FindControl("ddlCheckIn"); ddlcheckout = (DropDownList)e.Item.FindControl("ddlCheckOut"); //default value CommonUtil.SetDropDownSelectedByText(ddlcheckin, "11:00"); CommonUtil.SetDropDownSelectedByText(ddlcheckout, "19:30"); //check db saved data vw_Employee emp = (vw_Employee)e.Item.DataItem; DataTable dt = eh.getReservationTime(emp.employeeNum, (DateTime)DateSelector1.DateValue); if (dt != null && dt.Rows.Count == 1) { CommonUtil.SetDropDownSelectedByText(ddlcheckin, dt.Rows[0]["checkinTime"].ToString()); CommonUtil.SetDropDownSelectedByText(ddlcheckout, dt.Rows[0]["checkoutTime"].ToString()); chkIsLeave.Checked = (bool)dt.Rows[0]["isLeave"]; txtAnnual.Text = dt.Rows[0]["AnnualLeave"].ToString(); txtSick.Text = dt.Rows[0]["SickLeave"].ToString(); txtOther.Text = dt.Rows[0]["OtherLeave"].ToString(); //選中員工 if (dt.Rows[0]["workStore"].ToString() == ddlStoreNum.SelectedValue) { chkSel.Checked = true; } } else { //在未定義當天的時間錶時,原来店面定义了下属员工,默认被选中. if (emp.storeNum == ddlStoreNum.SelectedValue) { chkSel.Checked = true; } } }
private void bindEmpByStore(string strStoreNum) { DataTable dt = resvh.LoadAllEmployeeForReservation(); CommonUtil.BindDropDownListAndSelect(ddlStoreNum, emph.LoadStoreInfo(), "storeName", "storeNum"); CommonUtil.BindDropDownList(ddlEmployee, dt, "employeeNum", "employeeNum"); if (strStoreNum != "") { CommonUtil.SetDropDownSelectedByValue(ddlStoreNum, strStoreNum); CommonUtil.BindDropDownList(ddlEmployee, resvh.LoadEmployeeDataByStoreNum(strStoreNum), "employeeNum", "employeeNum"); } if (Request["emp"] != null) { CommonUtil.SetDropDownSelectedByValue(ddlEmployee, Request["emp"]); vw_Employee emp = emph.Loadvw_EmployeeByNum(Request["emp"]); CommonUtil.SetDropDownSelectedByValue(ddlStoreNum, emp.storeNum); } }