protected void btnManPowerAdd_Click(object sender, EventArgs e) { msgSuccess.Text = ""; msgErr.Text = ""; msgAlert.Text = ""; string sql_chk = "select * from tbl_manpower where manpower_pos_id = '" + txtAffAdd.SelectedValue + "' and manpower_cpoint_id = '" + txtCpoint.SelectedValue + "'"; MySqlDataReader rs = dBScript.selectSQL(sql_chk); if (!rs.Read()) { string sql = "INSERT INTO tbl_manpower (manpower_pos_id,manpower_full,manpower_cpoint_id,manpower_year) VALUES ('" + txtAffAdd.SelectedValue + "','" + txtFullAdd.Text + "','" + txtCpoint.SelectedValue + "','" + txtYear.SelectedValue + "')"; if (dBScript.actionSql(sql)) { msgSuccess.Text = "เพิ่มอัตรากำลัง " + txtCpoint.SelectedItem + " สำเร็จ<br/>"; txtFullAdd.Text = ""; } else { msgErr.Text = "เพิ่มอัตรากำลัง " + txtCpoint.SelectedItem + " ล้มเหลว<br/>"; } BindData(); } else { msgErr.Text = "เพิ่มอัตรากำลัง " + txtCpoint.SelectedItem + " ล้มเหลว<br/> - " + txtCpoint.SelectedItem + " มีข้อมูลอัตตรากำลัง " + txtAffAdd.SelectedItem + " อยู่แล้ว<br/>"; } }
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(); }
protected void YearGridView_RowDeleting(object sender, GridViewDeleteEventArgs e) { msgSuccess.Text = ""; msgErr.Text = ""; msgAlert.Text = ""; string sql = "DELETE FROM tbl_year WHERE year = '" + YearGridView.DataKeys[e.RowIndex].Value + "'"; if (dbScript.actionSql(sql)) { msgSuccess.Text = "ลบปีงบประมาณสำเร็จ<br/>"; } else { msgErr.Text = "ลบปีงบประมาณล้มเหลว<br/>"; } YearGridView.EditIndex = -1; BindData(); }
protected void CpointGridView_RowUpdating(object sender, GridViewUpdateEventArgs e) { msgSuccess.Text = ""; msgErr.Text = ""; msgAlert.Text = ""; TextBox txtCpointId = (TextBox)CpointGridView.Rows[e.RowIndex].FindControl("txtCpointId"); TextBox txtCpoint = (TextBox)CpointGridView.Rows[e.RowIndex].FindControl("txtCpoint"); string sql = "UPDATE tbl_cpoint SET cpoint_id='" + txtCpointId.Text + "', cpoint_name='" + txtCpoint.Text + "' WHERE cpoint_id = '" + CpointGridView.DataKeys[e.RowIndex].Value + "'"; if (dbScript.actionSql(sql)) { msgSuccess.Text = "แก้ไขด่านฯ สำเร็จ<br/>"; } else { msgErr.Text = "แก้ไขด่านฯ ล้มเหลว<br/>"; } CpointGridView.EditIndex = -1; BindData(); }
protected void UserGridView_RowUpdating(object sender, GridViewUpdateEventArgs e) { msgSuccess.Text = ""; msgErr.Text = ""; msgAlert.Text = ""; TextBox txtEName = (TextBox)UserGridView.Rows[e.RowIndex].FindControl("txtEName"); DropDownList txtEPrivilege = (DropDownList)UserGridView.Rows[e.RowIndex].FindControl("txtEPrivilege"); string sql = "UPDATE tbl_emp_user SET emp_name='" + txtEName.Text + "',emp_user_privilege='" + txtEPrivilege.SelectedValue + "' WHERE emp_user_name = '" + UserGridView.DataKeys[e.RowIndex].Value + "'"; if (dBScript.actionSql(sql)) { msgSuccess.Text = "แก้ไขสำเร็จ<br/>"; } else { msgErr.Text = "แก้ไขล้มเหลว<br/>"; } UserGridView.EditIndex = -1; BindData(); }
protected void btnSave_Click(object sender, EventArgs e) { //Response.Write("<script>alert('" + txtEmp.SelectedValue + "');</script>"); //Response.Write("<script>demo.showNotification('top','center');</script>"); if (txtEmp.SelectedValue != "") { if (txtDateSchedule.Text.Length == 10) { string sql = "INSERT INTO tbl_tmp_cpoint ( tmp_cpoint_emp_id, tmp_cpoint_cpoint_id, tmp_cpoint_date, tmp_cpoint_status,tmp_cpoint_emp_pos,tmp_cpoint_emp_aff,tmp_cpoint_cpoint_old_id ) VALUES ( '" + txtEmp.SelectedValue + "', '" + txtCpoint.SelectedValue + "', '" + txtDateSchedule.Text.Trim() + "', '0','" + dBScript.getEmpData("emp_pos_id", txtEmp.SelectedValue) + "','" + dBScript.getEmpData("emp_affi_id", txtEmp.SelectedValue) + "','" + dBScript.getEmpData("emp_cpoint_id", txtEmp.SelectedValue) + "' )"; if (dBScript.actionSql(sql)) { icon = "add_alert"; alertType = "success"; alert = "บันทึกข้อมูลสำเร็จ"; ClearData(); } else { icon = "error"; alertType = "danger"; alert = "Error : บันทึกล้มเหลว!!"; } } else { icon = "warning"; alertType = "danger"; alert = "รูปแบบวันที่ไม่ถูกต้อง วัน-เดือน-ปี ตัวอย่างรูปแบบวันที่ " + DateTime.Now.ToString("dd-MM") + "-" + (DateTime.Now.Year + 543); } } else { icon = "warning"; alertType = "danger"; alert = "กรุณากรอกชื่อ-สกุล ให้ถูกต้อง"; } BindData(); }
protected void btnAddTitleGuest_Click(object sender, EventArgs e) { if (txtTitle.Text != "" && txtRefer.Text != "") { if (txtGuest_id.Value.ToString() == "") { string sql = "INSERT INTO tbl_guest (guest_title,guest_title_to,guest_refer,guest_refer_date,guest_refer_title,guest_offer_date,guest_status) VALUES ('" + txtTitle.Text + "','" + txtTo.Text + "','" + txtRefer.Text + "','" + txtReferDate.Text + "','" + txtReferTitle.Text + "','" + txtOfferDate.Text + "','0')"; string guest_pk = dBScript.InsertQueryPK(sql); if (guest_pk != "") { ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", "alert('บันทึกสำเร็จ')", true); txtGuest_id.Value = guest_pk; DivAddGuest.Visible = true; BindData(); } else { ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", "alert('Error : ล้มเหลว')", true); } } else { string sql = "UPDATE tbl_guest SET guest_title = '" + txtTitle.Text.Trim() + "',guest_title_to='" + txtTo.Text.Trim() + "',guest_refer = '" + txtRefer.Text.Trim() + "',guest_refer_date = '" + txtReferDate.Text + "',guest_refer_title='" + txtReferTitle.Text.Trim() + "',guest_offer_date='" + txtOfferDate.Text + "' WHERE guest_id = '" + txtGuest_id.Value + "'"; if (dBScript.actionSql(sql)) { ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", "alert('บันทึกสำเร็จ')", true); BindData(); } else { ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", "alert('Error : ล้มเหลว')", true); } } } else { ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", "alert('กรุณากรอกเรื่อง และกรอกข้อมูลอ้างถึงบันทึกของกองฯ ด้วย')", true); } }
protected void btnAddOldEmp_Click(object sender, EventArgs e) { alert = ""; string empId_new = ""; string empId_old = dbScript.getEmpDataIDCard("emp_id", txtIdcard.Text.Trim()); string sql = "SELECT * FROM tbl_emp_profile WHERE emp_id_card = '" + txtIdcard.Text.Trim() + "' AND emp_staus_working <> 1"; MySqlDataReader rs = dbScript.selectSQL(sql); if (rs.Read()) { rs.Close(); empId_new = dbScript.createEmpId(txtStartDate); if (dbScript.actionSql("UPDATE tbl_emp_profile SET emp_id = '" + empId_new + "',emp_staus_working='1',emp_pos_id='" + txtPos.SelectedValue + "',emp_affi_id='" + txtAffi.SelectedValue + "',emp_cpoint_id='" + txtCpoint.SelectedValue + "' WHERE id='" + dbScript.getEmpDataIDCard("id", txtIdcard.Text.Trim()) + "'")) { dbScript.actionSql("DELETE FROM tbl_exp_moterway WHERE emp_id='" + empId_old + "'"); dbScript.actionSql("DELETE FROM tbl_work_history WHERE emp_id='" + empId_old + "'"); string insert_history_text = "history_status_id,history_date,history_note,history_emp_id"; string insert_history_value = "'1','00-00-0000','', '" + dbScript.getEmpDataIDCard("id", txtIdcard.Text.Trim()) + "'"; string insert_history = "INSERT INTO tbl_history (" + insert_history_text + ") VALUES (" + insert_history_value + ")"; dbScript.actionSql(insert_history); Response.Redirect("/Profile/empForm?empID=" + dbScript.getMd5Hash(empId_new)); } else { alert += "บันทึกข้อมูลล้มเหลว ลองใหม่อีกครั้ง<br/>"; alertType = "danger"; icon = "error"; //msgErr.Text = "บันทึกข้อมูลล้มเหลว ลองใหม่อีกครั้ง"; } } else { alert += "ผิดพลาดไม่พบข้อมูล รหัสบัตรประจำตัวประชาชน : " + txtIdcard.Text + "< br/>"; alertType = "danger"; icon = "error"; //msgErr.Text = "ผิดพลาดไม่พบข้อมูล รหัสบัตรประจำตัวประชาชน : " + txtIdcard.Text; } dbScript.CloseConnection(); }
protected void btnProfixAdd_Click(object sender, EventArgs e) { msgSuccess.Text = ""; msgErr.Text = ""; msgAlert.Text = ""; if (txtTypeAdd.Text != "") { string sql = "INSERT INTO tbl_type_add (type_add_name) VALUES ('" + txtTypeAdd.Text + "')"; if (dbScript.actionSql(sql)) { txtTypeAdd.Text = ""; msgSuccess.Text = "เพิ่มประเภทที่อยู่สำเร็จ<br/>"; } else { msgErr.Text = "เพิ่มประเภทที่อยู่ล้มเหลว<br/>"; } BindData(); } else { msgErr.Text = "เพิ่มประเภทที่อยู่ล้มเหลว<br/>- กรุณาใส่ประเภทที่อยู่"; } }
protected void btnAffAdd_Click(object sender, EventArgs e) { msgSuccess.Text = ""; msgErr.Text = ""; msgAlert.Text = ""; if (txtAff.Text != "") { string sql = "INSERT INTO tbl_affiliation (affi_name) VALUES ('" + txtAff.Text + "')"; if (dbScript.actionSql(sql)) { txtAff.Text = ""; msgSuccess.Text = "เพิ่มหน่วยสำเร็จ<br/>"; } else { msgErr.Text = "เพิ่มหน่วยล้มเหลว<br/>"; } BindData(); } else { msgErr.Text = "เพิ่มหน่วยล้มเหลว<br/>- กรุณาใส่หน่วย"; } }
protected void btnDocTypeAdd_Click(object sender, EventArgs e) { msgSuccess.Text = ""; msgErr.Text = ""; msgAlert.Text = ""; if (txtDocType.Text != "") { string sql = "INSERT INTO tbl_type_doc (type_doc_name) VALUES ('" + txtDocType.Text + "')"; if (dbScript.actionSql(sql)) { txtDocType.Text = ""; msgSuccess.Text = "เพิ่มประเภทเอกสารสำเร็จ<br/>"; } else { msgErr.Text = "เพิ่มประเภทเอกสารล้มเหลว<br/>"; } BindData(); } else { msgErr.Text = "เพิ่มประเภทเอกสารล้มเหลว<br/>- กรุณาใส่ประเภทเอกสาร"; } }
protected void btnPosAdd_Click(object sender, EventArgs e) { msgSuccess.Text = ""; msgErr.Text = ""; msgAlert.Text = ""; if (txtPos.Text != "") { string sql = "INSERT INTO tbl_pos (pos_name) VALUES ('" + txtPos.Text + "')"; if (dbScript.actionSql(sql)) { txtPos.Text = ""; msgSuccess.Text = "เพิ่มตำแหน่งสำเร็จ<br/>"; } else { msgErr.Text = "เพิ่มตำแหน่งล้มเหลว<br/>"; } BindData(); } else { msgErr.Text = "เพิ่มตำแหน่งล้มเหลว<br/>- กรุณาใส่ตำแหน่ง"; } }
protected void btnProvinceAdd_Click(object sender, EventArgs e) { msgSuccess.Text = ""; msgErr.Text = ""; msgAlert.Text = ""; if (txtProvince.Text != "") { string sql = "INSERT INTO tbl_province (province_name) VALUES ('" + txtProvince.Text + "')"; if (dbScript.actionSql(sql)) { txtProvince.Text = ""; msgSuccess.Text = "เพิ่มจังหวัดสำเร็จ<br/>"; } else { msgErr.Text = "เพิ่มจังหวัดล้มเหลว<br/>"; } BindData(); } else { msgErr.Text = "เพิ่มจังหวัดล้มเหลว<br/>- กรุณาใส่จังหวัด"; } }
protected void btnStatusAdd_Click(object sender, EventArgs e) { msgSuccess.Text = ""; msgErr.Text = ""; msgAlert.Text = ""; if (txtStatus.Text != "") { string sql = "INSERT INTO tbl_status_working (status_working_name) VALUES ('" + txtStatus.Text + "')"; if (dbScript.actionSql(sql)) { txtStatus.Text = ""; msgSuccess.Text = "เพิ่มสถานะสำเร็จ<br/>"; } else { msgErr.Text = "เพิ่มสถานะล้มเหลว<br/>"; } BindData(); } else { msgErr.Text = "เพิ่มสถานะล้มเหลว<br/>- กรุณาใส่สถานะ"; } }
protected void btnLevelEdu_Click(object sender, EventArgs e) { msgSuccess.Text = ""; msgErr.Text = ""; msgAlert.Text = ""; if (txtLevelEdu.Text != "") { string sql = "INSERT INTO tbl_level_edu (level_edu_name) VALUES ('" + txtLevelEdu.Text + "')"; if (dbScript.actionSql(sql)) { txtLevelEdu.Text = ""; msgSuccess.Text = "เพิ่มระดับการศึกษาสำเร็จ<br/>"; } else { msgErr.Text = "เพิ่มระดับการศึกษาล้มเหลว<br/>"; } BindData(); } else { msgErr.Text = "เพิ่มระดับการศึกษาล้มเหลว<br/>- กรุณาใส่ระดับการศึกษา"; } }
protected void btnSaveLeave_Click(object sender, EventArgs e) { string emp_leave_sick = ""; string emp_leave_relax = ""; string emp_leave_ordain = ""; string emp_leave_maternity = ""; string emp_leave_military = ""; string emp_leave_deduction_wages = ""; string emp_medical_certificate = rbMedicalCertificate.SelectedValue; string emp_leave_date_start = txtStartLeave.Text.Trim(); string emp_leave_date_end = txtEndLeave.Text.Trim(); string emp_leave_emp_id = dBScript.getEmpIDMD5("emp_id", Request.Params["empID"]); string emp_leave_note = txtNote.Text.Trim(); switch (rdTypeLeave.SelectedValue) { case "1": emp_leave_sick = txtTotalDay.Text.Trim(); break; case "2": emp_leave_relax = txtTotalDay.Text.Trim();; break; case "3": emp_leave_maternity = txtTotalDay.Text.Trim(); break; case "4": emp_leave_military = txtTotalDay.Text.Trim(); break; } if (ckTypeLeave.Checked) { emp_leave_ordain = "true"; } else { emp_leave_ordain = "false"; } switch (rbDeductionWages.SelectedValue) { case "0": emp_leave_deduction_wages = "0"; break; case "1": emp_leave_deduction_wages = txtTotalDay.Text.Trim(); break; case "2": emp_leave_deduction_wages = txtDeductionWages.Text.Trim(); break; } string sql = "INSERT INTO tbl_emp_leave ( emp_leave_sick, emp_leave_relax, emp_leave_ordain, emp_leave_maternity, emp_leave_military, emp_leave_deduction_wages, emp_medical_certificate, emp_leave_date_start, emp_leave_date_end, emp_leave_emp_id, emp_leave_year, emp_leave_note ) VALUES ( '" + emp_leave_sick + "', '" + emp_leave_relax + "', '" + emp_leave_ordain + "', '" + emp_leave_maternity + "', '" + emp_leave_military + "', '" + emp_leave_deduction_wages + "', '" + emp_medical_certificate + "', '" + emp_leave_date_start + "', '" + emp_leave_date_end + "', '" + emp_leave_emp_id + "', '" + dBScript.getBudgetYear(emp_leave_date_start) + "', '" + emp_leave_note + "' )"; if (dBScript.actionSql(sql)) { msgError = "บันทึกข้อมูลสำเร็จ"; } else { msgError = "ERROR : บันทึกข้อมูลลมเหลว"; } string script = "alert('" + msgError + "');"; ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", script, true); BindData(); }