Exemple #1
0
 protected void btnCheckEmp_Click(object sender, EventArgs e)
 {
     if (dBScript.checkIDCard(txtNewIDCard.Text.Trim()))
     {
         if (dBScript.checkDupicalIDCard(txtNewIDCard.Text.Trim()))
         {
             if (txtNationality.Text != "" && txtRace.Text != "" && txtReligion.Text != "" && txtBookBank.Text != "" && txtStatusRd.SelectedValue != "" && txtAff.SelectedValue != "")
             {
                 string emp_id = dBScript.createEmpId(txtOfferDate);
                 string text   = "emp_id, emp_profix_id, emp_name, emp_lname, emp_pos_id, emp_affi_id, emp_cpoint_id, emp_type_emp_id, emp_start_working, emp_birth_date, emp_origin, emp_nationality, emp_religion, emp_id_card, emp_status, emp_book_bank_no,emp_img_profile";
                 string value  = "'" + emp_id + "', '" + hdProfix.Value + "', '" + hdName.Value + "', '" + hdLname.Value + "', '" + hdPos.Value + "', '" + txtAff.SelectedValue + "', '" + hdCpoint.Value + "', '2', '" + txtOfferDate.Text + "', '" + txtBirdthDay.Text + "', '" + txtRace.Text + "', '" + txtNationality.Text + "', '" + txtReligion.Text + "', '" + txtNewIDCard.Text + "', '" + txtStatusRd.SelectedValue + "', '" + txtBookBank.Text + "',''";
                 string sql    = "INSERT INTO tbl_emp_profile (" + text + ") VALUES (" + value + ")";
                 if (dBScript.actionSql("UPDATE tbl_guest_list SET guest_list_idcard = '" + txtNewIDCard.Text.Trim() + "' WHERE guest_list_id = '" + hdGuest_list_id.Value + "'"))
                 {
                     if (dBScript.actionSql(sql))
                     {
                         string insert_history_text  = "history_status_id,history_date,history_note,history_emp_id";
                         string insert_history_value = "'1','00-00-0000','', '" + dBScript.getEmpData("id", emp_id) + "'";
                         string insert_history       = "INSERT INTO tbl_history (" + insert_history_text + ") VALUES (" + insert_history_value + ")";
                         dBScript.actionSql(insert_history);
                         ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", "alert('บันทึก ประวัติส่วนตัว สำเร็จ')", true);
                         BindData();
                     }
                     else
                     {
                         ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", "alert('Error : บันทึก ประวัติส่วนตัว ล้มเหลว')", true);
                         BindData();
                     }
                 }
                 else
                 {
                     ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", "alert('Error : ล้มเหลว')", true);
                 }
             }
             else
             {
                 ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", "alert('กรุณาใส่ข้อมูลให้ครบถ้วน')", true);
             }
         }
         else
         {
             ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", "alert('เลขบัตรประจำตัวประชาชน ซ้ำกับพนักงานที่ทำงานอยู่ในปัจจุบัน กรุณณาตรวจสอบ')", 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();
        }