C#代码
- protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
- {
-
- if (e.Row.Cells[1].Text == "0111")
- {
- e.Row.BackColor = System.Drawing.Color.Red;
- }
- else
- {
- e.Row.BackColor = System.Drawing.Color.Gray;
- }
-
- if (e.Row.Cells[1].Text == "0111")
- {
- e.Row.Cells[1].BackColor = System.Drawing.Color.Green;
- }
- }
-
-
-
C#代码
- 21.
- 22. public void bind()
- {
- string sqlstr = "select a.id,b.department,b.name,c.pname,a.wrktime_start,a.wrktime_end,a.check_time,a.Confirmed_add_time,(select CODE_VALUES from jsboth_hrms_codes where code_num=a.add_type and code_type='WOT_TYPE') as add_type,a.add_apply_sid,a.absense_late,a.absense_early,a.absense_time,(select CODE_VALUES from jsboth_hrms_codes where code_num=a.absense_type and code_type='vocation') as absense_type,a.ABSENSE_SID,a.remarks,pm_checked from jsboth_hrms_dailycheck a,jsboth_hrms_baseinfo b,jsboth_hrms_projectinfo c where a.emp_id=b.id and a.project_id=c.id";
- using (SqlConnection conn = new SqlConnection(strCon))
- {
- conn.Open();
- SqlDataAdapter myda = new SqlDataAdapter(sqlstr, conn);
- DataSet myds = new DataSet();
- DropDownList ddlAddType;
- DropDownList ddlAbsenseType;
-
-
- myda.Fill(myds, "jsboth_hrms_dailycheck");
- GridView1.DataSource = myds;
- GridView1.DataKeyNames = new string[] { "id" };
- GridView1.DataBind();
-
-
-
- string sqlGetAllDailyData = "select * from jsboth_hrms_dailycheck";
- SqlDataAdapter getAllDailyDataDa = new SqlDataAdapter(sqlGetAllDailyData, conn);
- DataTable allDailyDt = new DataTable();
- getAllDailyDataDa.Fill(allDailyDt);
-
- for (int i = 0; i < GridView1.Rows.Count; i++)
- {
- DataRowView dailyCheckRow = myds.Tables["jsboth_hrms_dailycheck"].DefaultView[i];
-
-
-
-
- if (Convert.ToString(dailyCheckRow["PM_CHECKED"]) == "0") {
-
-
- GridView1.Rows[i].Cells[3].BackColor = System.Drawing.Color.Red;
- }
-
-
- if ((GridView1.Rows[i].RowState & DataControlRowState.Edit) == DataControlRowState.Edit)
- {
- if (Convert.ToString(dailyCheckRow["ADD_TYPE"]) == "普通")
- {
-
- ddlAddType = (DropDownList)GridView1.Rows[i].FindControl("gvEditDDLAddType");
- ddlAddType.SelectedIndex = 0;
- }
- if (Convert.ToString(dailyCheckRow["ADD_TYPE"]) == "节假日")
- {
- ddlAddType = (DropDownList)GridView1.Rows[i].FindControl("gvEditDDLAddType");
- ddlAddType.SelectedIndex = 1;
- }
-
-
- if (string.IsNullOrEmpty(Convert.ToString(dailyCheckRow["ABSENSE_TYPE"])))
- {
- ddlAbsenseType = (DropDownList)GridView1.Rows[i].FindControl("gvEditDDLAbsenseType");
- ddlAbsenseType.SelectedIndex = 0;
-
- }
- if (Convert.ToString(dailyCheckRow["ABSENSE_TYPE"]) == "病假")
- {
- ddlAbsenseType = (DropDownList)GridView1.Rows[i].FindControl("gvEditDDLAbsenseType");
- ddlAbsenseType.SelectedIndex = 1;
- }
- if (Convert.ToString(dailyCheckRow["ABSENSE_TYPE"]) == "事假")
- {
- ddlAbsenseType = (DropDownList)GridView1.Rows[i].FindControl("gvEditDDLAbsenseType");
- ddlAbsenseType.SelectedIndex = 2;
- }
- if (Convert.ToString(dailyCheckRow["ABSENSE_TYPE"]) == "调休")
- {
- ddlAbsenseType = (DropDownList)GridView1.Rows[i].FindControl("gvEditDDLAbsenseType");
- ddlAbsenseType.SelectedIndex = 3;
- }
- if (Convert.ToString(dailyCheckRow["ABSENSE_TYPE"]) == "婚假")
- {
- ddlAbsenseType = (DropDownList)GridView1.Rows[i].FindControl("gvEditDDLAbsenseType");
- ddlAbsenseType.SelectedIndex = 4;
- }
- if (Convert.ToString(dailyCheckRow["ABSENSE_TYPE"]) == "丧假")
- {
- ddlAbsenseType = (DropDownList)GridView1.Rows[i].FindControl("gvEditDDLAbsenseType");
- ddlAbsenseType.SelectedIndex = 5;
- }
- if (Convert.ToString(dailyCheckRow["ABSENSE_TYPE"]) == "产假")
- {
- ddlAbsenseType = (DropDownList)GridView1.Rows[i].FindControl("gvEditDDLAbsenseType");
- ddlAbsenseType.SelectedIndex = 6;
- }
- if (Convert.ToString(dailyCheckRow["ABSENSE_TYPE"]) == "探亲假")
- {
- ddlAbsenseType = (DropDownList)GridView1.Rows[i].FindControl("gvEditDDLAbsenseType");
- ddlAbsenseType.SelectedIndex = 7;
- }
- if (Convert.ToString(dailyCheckRow["ABSENSE_TYPE"]) == "带薪假")
- {
- ddlAbsenseType = (DropDownList)GridView1.Rows[i].FindControl("gvEditDDLAbsenseType");
- ddlAbsenseType.SelectedIndex = 8;
- }
- if (Convert.ToString(dailyCheckRow["ABSENSE_TYPE"]) == "年假")
- {
- ddlAbsenseType = (DropDownList)GridView1.Rows[i].FindControl("gvEditDDLAbsenseType");
- ddlAbsenseType.SelectedIndex = 9;
- }
- if (Convert.ToString(dailyCheckRow["ABSENSE_TYPE"]) == "公差")
- {
- ddlAbsenseType = (DropDownList)GridView1.Rows[i].FindControl("gvEditDDLAbsenseType");
- ddlAbsenseType.SelectedIndex = 10;
- }
- if (Convert.ToString(dailyCheckRow["ABSENSE_TYPE"]) == "路途")
- {
- ddlAbsenseType = (DropDownList)GridView1.Rows[i].FindControl("gvEditDDLAbsenseType");
- ddlAbsenseType.SelectedIndex = 11;
- }
- if (Convert.ToString(dailyCheckRow["ABSENSE_TYPE"]) == "旷工")
- {
- ddlAbsenseType = (DropDownList)GridView1.Rows[i].FindControl("gvEditDDLAbsenseType");
- ddlAbsenseType.SelectedIndex = 12;
- }
- }
- else {
- if (Convert.ToString(dailyCheckRow["ADD_TYPE"]) == "普通")
- {
-
- ddlAddType = (DropDownList)GridView1.Rows[i].FindControl("gvDDLAddType");
- ddlAddType.SelectedIndex = 0;
- }
- if (Convert.ToString(dailyCheckRow["ADD_TYPE"]) == "节假日")
- {
- ddlAddType = (DropDownList)GridView1.Rows[i].FindControl("gvDDLAddType");
- ddlAddType.SelectedIndex = 1;
- }
-
-
- if (string.IsNullOrEmpty(Convert.ToString(dailyCheckRow["ABSENSE_TYPE"])))
- {
- ddlAbsenseType = (DropDownList)GridView1.Rows[i].FindControl("gvDDLAbsenseType");
- ddlAbsenseType.SelectedIndex = 0;
-
- }
- if (Convert.ToString(dailyCheckRow["ABSENSE_TYPE"]) == "病假")
- {
- ddlAbsenseType = (DropDownList)GridView1.Rows[i].FindControl("gvDDLAbsenseType");
- ddlAbsenseType.SelectedIndex = 1;
- }
- if (Convert.ToString(dailyCheckRow["ABSENSE_TYPE"]) == "事假")
- {
- ddlAbsenseType = (DropDownList)GridView1.Rows[i].FindControl("gvDDLAbsenseType");
- ddlAbsenseType.SelectedIndex = 2;
- }
- if (Convert.ToString(dailyCheckRow["ABSENSE_TYPE"]) == "调休")
- {
- ddlAbsenseType = (DropDownList)GridView1.Rows[i].FindControl("gvDDLAbsenseType");
- ddlAbsenseType.SelectedIndex = 3;
- }
- if (Convert.ToString(dailyCheckRow["ABSENSE_TYPE"]) == "婚假")
- {
- ddlAbsenseType = (DropDownList)GridView1.Rows[i].FindControl("gvDDLAbsenseType");
- ddlAbsenseType.SelectedIndex = 4;
- }
- if (Convert.ToString(dailyCheckRow["ABSENSE_TYPE"]) == "丧假")
- {
- ddlAbsenseType = (DropDownList)GridView1.Rows[i].FindControl("gvDDLAbsenseType");
- ddlAbsenseType.SelectedIndex = 5;
- }
- if (Convert.ToString(dailyCheckRow["ABSENSE_TYPE"]) == "产假")
- {
- ddlAbsenseType = (DropDownList)GridView1.Rows[i].FindControl("gvDDLAbsenseType");
- ddlAbsenseType.SelectedIndex = 6;
- }
- if (Convert.ToString(dailyCheckRow["ABSENSE_TYPE"]) == "探亲假")
- {
- ddlAbsenseType = (DropDownList)GridView1.Rows[i].FindControl("gvDDLAbsenseType");
- ddlAbsenseType.SelectedIndex = 7;
- }
- if (Convert.ToString(dailyCheckRow["ABSENSE_TYPE"]) == "带薪假")
- {
- ddlAbsenseType = (DropDownList)GridView1.Rows[i].FindControl("gvDDLAbsenseType");
- ddlAbsenseType.SelectedIndex = 8;
- }
- if (Convert.ToString(dailyCheckRow["ABSENSE_TYPE"]) == "年假")
- {
- ddlAbsenseType = (DropDownList)GridView1.Rows[i].FindControl("gvDDLAbsenseType");
- ddlAbsenseType.SelectedIndex = 9;
- }
- if (Convert.ToString(dailyCheckRow["ABSENSE_TYPE"]) == "公差")
- {
- ddlAbsenseType = (DropDownList)GridView1.Rows[i].FindControl("gvDDLAbsenseType");
- ddlAbsenseType.SelectedIndex = 10;
- }
- if (Convert.ToString(dailyCheckRow["ABSENSE_TYPE"]) == "路途")
- {
- ddlAbsenseType = (DropDownList)GridView1.Rows[i].FindControl("gvDDLAbsenseType");
- ddlAbsenseType.SelectedIndex = 11;
- }
- if (Convert.ToString(dailyCheckRow["ABSENSE_TYPE"]) == "旷工")
- {
- ddlAbsenseType = (DropDownList)GridView1.Rows[i].FindControl("gvDDLAbsenseType");
- ddlAbsenseType.SelectedIndex = 12;
- }
-
- }
- }
- }
-
- }
文章来源:
http://www.my1984.net/?action=show&id=113MSN:
posted on 2008-07-22 23:57
kylixlu 阅读(2652)
评论(0) 编辑 收藏