protected void Page_Load(object sender, EventArgs e) { if (Session["user"] == null) { Response.Redirect("/"); } if (txtETime.Text == "") { txtETime.Text = DateTime.Now.ToString("HH.mm"); } if (!this.IsPostBack) { BindData(""); string sql = ""; if (function.CheckLevel("Department", Session["UserPrivilegeId"].ToString())) { sql = "SELECT * FROM tbl_cpoint ORDER BY cpoint_id"; function.getListItem(txtCpointSearch, sql, "cpoint_name", "cpoint_id"); txtCpointSearch.Items.Insert(0, new ListItem("ทั้งหมด", "")); } else { sql = "SELECT * FROM tbl_cpoint WHERE cpoint_id = '" + Session["UserCpoint"].ToString() + "'"; function.getListItem(txtCpointSearch, sql, "cpoint_name", "cpoint_id"); //txtCpointSearch.Items.Insert(0, new ListItem("ทั้งหมด", "")); } } }
protected void Page_Load(object sender, EventArgs e) { if (Session["user"] == null) { Response.Redirect("/"); } if (!this.IsPostBack) { string sql = ""; if (function.CheckLevel("Department", Session["UserPrivilegeId"].ToString())) { sql = "SELECT * FROM tbl_cpoint ORDER BY cpoint_id"; function.getListItem(txtCpoint, sql, "cpoint_name", "cpoint_id"); function.getListItem(txtCpointSearch, sql, "cpoint_name", "cpoint_id"); txtCpointSearch.Items.Insert(0, new ListItem("ทั้งหมด", "")); } else { sql = "SELECT * FROM tbl_cpoint WHERE cpoint_id = '" + Session["UserCpoint"].ToString() + "'"; function.getListItem(txtCpoint, sql, "cpoint_name", "cpoint_id"); function.getListItem(txtCpointSearch, sql, "cpoint_name", "cpoint_id"); //txtCpointSearch.Items.Insert(0, new ListItem("ทั้งหมด", "")); } string sql_Device = "SELECT * FROM tbl_device ORDER BY device_name"; function.getListItem(txtDeviceAdd, sql_Device, "device_name", "device_id"); txtDeviceAdd.Items.Insert(0, new ListItem("", "")); txtSTime.Text = DateTime.Now.ToString("HH.mm"); BindData(""); if (Request["ref"] != null) { txtRef.Value = Request["ref"].ToString(); sql = "SELECT * FROM tbl_cm_detail WHERE cm_detail_id = '" + txtRef.Value + "'"; MySqlDataReader rs = function.MySqlSelect(sql); if (rs.Read()) { txtCpoint.SelectedValue = rs.GetString("cm_cpoint"); txtPoint.Text = rs.GetString("cm_point"); txtChannel.Text = rs.GetString("cm_detail_channel"); txtSDate.Text = rs.GetString("cm_detail_sdate"); txtSTime.Text = rs.GetString("cm_detail_stime"); txtDeviceAdd.SelectedValue = rs.GetString("cm_detail_driver_id"); txtProblem.Text = rs.GetString("cm_detail_problem"); txtNote.Text = rs.GetString("cm_detail_note"); } rs.Close(); function.Close(); btnSaveCM.Visible = false; btnEditCM.Visible = true; btnCancelCM.Visible = true; if (function.CheckLevel("Techno", Session["UserPrivilegeId"].ToString())) { btnDeleteCM.Visible = true; } else { btnDeleteCM.Visible = false; } } else { btnSaveCM.Visible = true; btnEditCM.Visible = false; btnCancelCM.Visible = false; btnDeleteCM.Visible = false; } } }