public void BindData(string sortDate, string sortType) { string strSeclctEmp = ""; if (txtSearchId.Text != "") { strSeclctEmp += "emp_id LIKE '%" + txtSearchId.Text.Trim() + "%' "; } if (txtSearchName.Text != "") { if (strSeclctEmp != "") { strSeclctEmp += " AND "; } strSeclctEmp += "(profix_name LIKE '%" + txtSearchName.Text.Trim() + "%' OR emp_name LIKE '%" + txtSearchName.Text.Trim() + "%' OR emp_lname LIKE '%" + txtSearchName.Text.Trim() + "%')"; } if (txtSearchCpoint.SelectedValue != "") { if (strSeclctEmp != "") { strSeclctEmp += " AND "; } strSeclctEmp += "cpoint_name LIKE '%" + txtSearchCpoint.SelectedItem + "%' "; } if (txtSearchPos.SelectedValue != "") { if (strSeclctEmp != "") { strSeclctEmp += " AND "; } strSeclctEmp += "pos_name LIKE '%" + txtSearchPos.SelectedItem + "%' "; } if (txtSearchAffi.SelectedValue != "") { if (strSeclctEmp != "") { strSeclctEmp += " AND "; } strSeclctEmp += "affi_name LIKE '%" + txtSearchAffi.SelectedItem + "%' "; } if (strSeclctEmp != "") { strSeclctEmp = "(" + strSeclctEmp + ") AND "; } string sql = "SELECT * FROM tbl_emp_profile JOIN tbl_profix ON emp_profix_id = profix_id JOIN tbl_cpoint ON emp_cpoint_id = cpoint_id JOIN tbl_pos ON emp_pos_id = pos_id JOIN tbl_affiliation ON affi_id = emp_affi_id JOIN tbl_type_emp ON type_emp_id = emp_type_emp_id JOIN tbl_type_add ON type_add_id = emp_add_type WHERE " + strSeclctEmp + " emp_staus_working = '1' ORDER BY " + sortDate + " " + sortType + " LIMIT 0,20"; Session["sqlEmp"] = sql; MySqlDataAdapter da = dbScript.getDataSelect(sql); DataTable ds = new DataTable(); da.Fill(ds); GridViewEmp.DataSource = ds; GridViewEmp.DataBind(); LaGridViewData.Text = "พบข้อมูลจำนวน " + ds.Rows.Count + " แถว"; resultCard.Visible = true; dbScript.CloseConnection(); }
protected void Page_Load(object sender, EventArgs e) { if (!string.IsNullOrEmpty(Request.Params["id"])) { txtGuest_id.Value = Request.Params["id"].ToString(); } if (Session["User"] != null) { if (int.Parse(Session["UserPrivilegeId"].ToString()) > 1) { DivAddGuest.Visible = false; btnAddTitleGuest.Visible = false; txtOfferDate.Enabled = false; txtReferTitle.Enabled = false; txtReferDate.Enabled = false; txtRefer.Enabled = false; txtTo.Enabled = false; txtTitle.Enabled = false; } } else { } if (!this.IsPostBack) { BindData(); dBScript.GetDownList(txtProfix, "select * from tbl_profix", "profix_name", "profix_id"); dBScript.GetDownList(txtPos, "select * from tbl_pos", "pos_name", "pos_id"); dBScript.GetDownList(txtCpoint, "select * from tbl_cpoint", "cpoint_name", "cpoint_id"); dBScript.GetDownList(txtAff, "select * from tbl_affiliation", "affi_name", "affi_id"); txtAff.Items.Insert(0, new ListItem("เลือก", "")); if (txtGuest_id.Value.ToString() == "") { DivAddGuest.Visible = false; btnReport.Visible = false; btnReportCopy.Visible = false; } else { string sql_select_guest = "SELECT * FROM tbl_guest guest WHERE guest_id = '" + txtGuest_id.Value + "'"; MySqlDataReader rs = dBScript.selectSQL(sql_select_guest); if (rs.Read()) { txtTitle.Text = rs.GetString("guest_title"); txtTo.Text = rs.GetString("guest_title_to"); txtRefer.Text = rs.GetString("guest_refer"); txtReferDate.Text = rs.GetString("guest_refer_date"); txtReferTitle.Text = rs.GetString("guest_refer_title"); txtOfferDate.Text = rs.GetString("guest_offer_date"); } rs.Close(); dBScript.CloseConnection(); } } }
protected void btnConfirmPass_Click(object sender, EventArgs e) { msgSuccess.Text = ""; msgErr.Text = ""; msgAlert.Text = ""; if (txtNewPass.Text.Trim() == txtConfirmNewPass.Text.Trim()&& txtNewPass.Text.Trim() != "" && txtConfirmNewPass.Text.Trim() != "") { string sql = "UPDATE tbl_emp_user SET emp_user_pass = '******' WHERE emp_user_name='"+ Session["User"].ToString() + "'"; if (dbScript.actionSql(sql)) { txtNewPass.Text = ""; txtConfirmNewPass.Text = ""; msgSuccess.Text = "เปลี่ยนรหัสผ่านสำเร็จสำเร็จ<br/>"; } else { msgErr.Text = "เปลี่ยนรหัสผ่านสำเร็จล้มเหลว<br/>"; } } else { msgErr.Text ="ใส่ข้อมูลไม่ครบถ้วน หรือ รหัสผ่านใหม่ไม่ตรงกัน"; } dbScript.CloseConnection(); }
void Application_BeginRequest(object sender, EventArgs e) { DBScript dBScript = new DBScript(); string sql = "SELECT SUM(emp_status_login) AS userOnilne FROM tbl_emp_user"; MySqlDataReader rs = dBScript.selectSQL(sql); if (rs.Read()) { if (!rs.IsDBNull(0)) { Application.Lock(); Application["TotalOnlineUsers"] = int.Parse(rs.GetString("userOnilne")); Application.UnLock(); } } rs.Close(); dBScript.userLogOutTimeUpdate(); //อัพเดทการลาออก dBScript.UpdateEmpEx(); //อัพเดทการเปลี่ยนตำแหน่ง dBScript.UpdateEmpPos(); //อัพเดทการย้ายด่านฯ dBScript.UpdateEmpCpoint(); //อัพเดทพนักงานที่ไม่มีประวัติการทำงานภายในฝ่าย dBScript.CreateMotowayWorking(); //อัพเดทพนักงานที่ไม่มีประวัติการทำงานที่ด่านฯ dBScript.CreateCpointWorking(); dBScript.CloseConnection(); }
protected void Page_Load(object sender, EventArgs e) { if (!string.IsNullOrEmpty(Request.Params["add"])) { //Response.Write("<script>$('#ModalCheckEmp').modal('show');</script>"); ScriptManager.RegisterStartupScript(Page, Page.GetType(), "ModalCheckEmp", "$('#ModalCheckEmp').modal('show');", true); } if (int.Parse(Session["UserPrivilegeId"].ToString()) > 2) { btnAddEmp.Visible = false; } if (!this.IsPostBack) { //getSeclctEmp("emp_name", "ASC"); DivEmp.Visible = false; string sql_cpoint = "SELECT * FROM tbl_cpoint"; dbScript.GetDownList(txtCpoint, sql_cpoint, "cpoint_name", "cpoint_id"); dbScript.GetDownList(txtSearchCpoint, sql_cpoint, "cpoint_name", "cpoint_id"); txtSearchCpoint.Items.Insert(0, new ListItem("เลือก", "")); string sql_pos = "SELECT * FROM tbl_pos"; dbScript.GetDownList(txtPos, sql_pos, "pos_name", "pos_id"); dbScript.GetDownList(txtSearchPos, sql_pos, "pos_name", "pos_id"); txtSearchPos.Items.Insert(0, new ListItem("เลือก", "")); string sql_affi = "SELECT * FROM tbl_affiliation"; dbScript.GetDownList(txtAffi, sql_affi, "affi_name", "affi_id"); dbScript.GetDownList(txtSearchAffi, sql_affi, "affi_name", "affi_id"); txtSearchAffi.Items.Insert(0, new ListItem("เลือก", "")); string sql_EmpType = "SELECT * FROM tbl_type_emp"; dbScript.GetDownList(txtSearchType, sql_EmpType, "type_emp_name", "type_emp_id"); txtSearchType.Items.Insert(0, new ListItem("เลือก", "")); } dbScript.CloseConnection(); if (Session["User"] != null) { if (Session["UserPrivilegeId"].ToString() == "5" && Session["emp_login_id"] != null) { Response.Redirect("/Profile/empForm?empID=" + dbScript.getMd5Hash(Session["emp_login_id"].ToString())); } } if (!string.IsNullOrEmpty(Request.Params["pos"]) && !string.IsNullOrEmpty(Request.Params["cpoint"])) { if (Request.Params["cpoint"] == "60") { txtSearchCpoint.Items.Insert(0, new ListItem("ฝ่ายฯ ทั้งหมด", "60")); } txtSearchPos.SelectedValue = Request.Params["pos"]; txtSearchCpoint.SelectedValue = Request.Params["cpoint"]; DivSearch.Visible = false; DivAdd.Visible = false; getSeclctEmp("emp_name", "ASC"); } }
protected void Page_Load(object sender, EventArgs e) { lbUserOnline.Text = int.Parse(Application["TotalOnlineUsers"].ToString()).ToString(" 0 คน"); if (!this.IsPostBack) { string sql = "SELECT COUNT('id') AS EmpSum FROM tbl_emp_profile WHERE emp_staus_working = '1'"; MySqlDataReader rs = dBScript.selectSQL(sql); if (rs.Read()) { lbCountEmp.Text = "ทั้งหมด " + rs.GetString("EmpSum") + " คน"; } rs.Close(); BindDataLeave(); BindRetire(); dBScript.CloseConnection(); string sql_guest = "SELECT guest_offer_date FROM tbl_guest ORDER BY STR_TO_DATE(guest_offer_date, '%d-%m-%Y') DESC "; LabelGuest.Text = "รายการล่าสุด " + dBScript.convertDateShortThai(dBScript.GetSelectData(sql_guest)); lbYear.Text = dBScript.getBudgetYear(); txtYear.Text = dBScript.getBudgetYear(); } if (Session["User"] != null) { if (dBScript.Notallow(new string[] { "5" }, Session["UserPrivilegeId"].ToString())) { Response.Redirect("/Profile/empViwe"); } if (dBScript.Notallow(new string[] { "5", "4", "3" }, Session["UserPrivilegeId"].ToString())) { boxChangPos.Visible = false; boxMigrateEmp.Visible = false; boxResignEmp.Visible = false; } } }
protected void Page_Load(object sender, EventArgs e) { if (!string.IsNullOrEmpty(Request.Params["empID"])) { if (dBScript.CheckPrivilege(Session["UserPrivilegeId"].ToString(), "Assistant")) { Button1.Visible = true; } else { Button1.Visible = false; } if (dBScript.getEmpIDMD5("type_emp_id", Request.Params["empID"]) == "5") { string sql = "SELECT exp_moterway_start FROM tbl_exp_moterway WHERE exp_moterway_emp_id = '" + dBScript.getEmpIDMD5("emp_id", Request.Params["empID"]) + "' AND exp_moterway_end = '00-00-0000'"; MySqlDataReader rs = dBScript.selectSQL(sql); if (rs.Read()) { leave = new Leave(rs.GetString("exp_moterway_start"), true); } else { leave = new Leave(DateTime.Now.ToString("dd-MM-") + (DateTime.Now.Year + 543), true); } rs.Close(); dBScript.CloseConnection(); } else { leave = new Leave(dBScript.getEmpIDMD5("emp_start_working", Request.Params["empID"]), false); } //empId.Text = Request.Params["empID"].ToString().Trim();pos_name leaveUser = new Leave(dBScript.getEmpIDMD5("emp_id", Request.Params["empID"]), int.Parse(dBScript.getBudgetYear())); lbTypeEmp.Text = dBScript.getEmpIDMD5("type_emp_name", Request.Params["empID"]); lbEmpName.Text = dBScript.getEmpIDMD5("emp_id", Request.Params["empID"]) + " " + dBScript.getEmpIDMD5("profix_name", Request.Params["empID"]) + dBScript.getEmpIDMD5("emp_name", Request.Params["empID"]) + " " + dBScript.getEmpIDMD5("emp_lname", Request.Params["empID"]); lbPos.Text = dBScript.getEmpIDMD5("pos_name", Request.Params["empID"]) + " / ด่านฯ : " + dBScript.getEmpIDMD5("cpoint_name", Request.Params["empID"]); lbExp6Month.Text = leave.Date6Month; lbExp1Year.Text = leave.Date1Year; lbStartDate.Text = leave.Date; lbYear.Text = leave.BudgetYear; lbSick.Text = leaveUser.UserSick + " / " + leave.Sick.ToString("0 วัน"); lbSick.CssClass = leaveUser.UserSick > leave.Sick? "text-danger" : ""; lbRelax.Text = leaveUser.UserRelax + " / " + leave.Relax.ToString("0 วัน"); lbRelax.CssClass = leaveUser.UserRelax > leave.Relax ? "text-danger" : ""; lbOrdain.Text = leave.Ordain > 0 ? "มีสิทธิลา" : "ไม่มีสิทธิลา"; lbMaternity.Text = leaveUser.UserMaternity + " / " + leave.Maternity.ToString("0 วัน"); lbMaternity.CssClass = leaveUser.UserMaternity > leave.Maternity ? "text-danger" : ""; lbMilitary.Text = leaveUser.UserMilitary + " / " + leave.Military.ToString("0 วัน"); lbMilitary.CssClass = leaveUser.UserMilitary > leave.Military ? "text-danger" : ""; dBScript.CloseConnection(); } else { Response.Redirect("/LeaveEmp/empLeaveForm"); } if (!this.IsPostBack) { BindData(); } }