Пример #1
0
 protected void btnCheckEmp_Click(object sender, EventArgs e)
 {
     try
     {
         txtEmp_id.Text = txtEmp.SelectedValue.ToString();
         lbCpoint.Text  = dBScript.getEmpData("cpoint_name", txtEmp_id.Text);
         lbPos.Text     = dBScript.getEmpData("pos_name", txtEmp_id.Text);
         if (txtEmp_id.Text != "")
         {
             btnSave.Visible = true;
         }
         else
         {
             btnSave.Visible = false;
         }
     }
     catch { }
 }
Пример #2
0
        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();
        }
Пример #3
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);
     }
 }
Пример #4
0
        protected void GridViewEmp_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            string date_start = (string)DataBinder.Eval(e.Row.DataItem, "emp_start_working");
            bool   empfun     = false;

            if (dbScript.getEmpData("type_emp_id", (string)DataBinder.Eval(e.Row.DataItem, "emp_id")) == "5")
            {
                empfun = true;
                string          sql = "SELECT exp_moterway_start FROM tbl_exp_moterway WHERE exp_moterway_emp_id = '" + (string)DataBinder.Eval(e.Row.DataItem, "emp_id") + "' AND exp_moterway_end = '00-00-0000'";
                MySqlDataReader rs  = dbScript.selectSQL(sql);
                if (rs.Read())
                {
                    date_start = rs.GetString("exp_moterway_start");
                }
                else
                {
                    date_start = DateTime.Now.ToString("dd-MM-") + (DateTime.Now.Year + 543);
                }
                rs.Close();
                dbScript.CloseConnection();
            }
            if (date_start == null)
            {
                date_start = DateTime.Now.ToString("dd-MM-") + (DateTime.Now.Year + 543);
            }

            Leave leave     = new Leave(date_start, empfun);
            Leave leaveUser = new Leave((string)DataBinder.Eval(e.Row.DataItem, "emp_id"), int.Parse(dbScript.getBudgetYear()));

            Label lbSick = (Label)(e.Row.FindControl("lbSick"));

            if (lbSick != null)
            {
                if (leaveUser.UserSick <= leave.Sick)
                {
                    lbSick.Text = leaveUser.UserSick + " / " + leave.Sick;
                }
                else
                {
                    lbSick.CssClass = "text-danger";
                    lbSick.Text     = leaveUser.UserSick + " / " + leave.Sick;
                }
            }

            Label lbRelax = (Label)(e.Row.FindControl("lbRelax"));

            if (lbRelax != null)
            {
                if (leaveUser.UserRelax <= leave.Relax)
                {
                    lbRelax.Text = leaveUser.UserRelax + " / " + leave.Relax;
                }
                else
                {
                    lbRelax.CssClass = "text-danger";
                    lbRelax.Text     = leaveUser.UserRelax + " / " + leave.Relax;
                }
            }

            Label lbMaternity = (Label)(e.Row.FindControl("lbMaternity"));

            if (lbMaternity != null)
            {
                if (leaveUser.UserMaternity <= leave.Maternity)
                {
                    lbMaternity.Text = leaveUser.UserMaternity + " / " + leave.Maternity;
                }
                else
                {
                    lbMaternity.CssClass = "text-danger";
                    lbMaternity.Text     = leaveUser.UserMaternity + " / " + leave.Maternity;
                }
            }

            Label lbOrdain = (Label)(e.Row.FindControl("lbOrdain"));

            if (lbOrdain != null)
            {
                if (leave.Ordain > 0)
                {
                    lbOrdain.CssClass = "text-success";
                    lbOrdain.Text     = leaveUser.UserOrdain + " / มีสิทธิลา";
                }
                else
                {
                    lbOrdain.CssClass = "text-danger";
                    lbOrdain.Text     = leaveUser.UserOrdain + " / ไม่มีสิทธิลา";
                }
            }

            Label lbMilitary = (Label)(e.Row.FindControl("lbMilitary"));

            if (lbMilitary != null)
            {
                if (leaveUser.UserMilitary <= leave.Military)
                {
                    lbMilitary.Text = leaveUser.UserMilitary + " / " + leave.Military;
                }
                else
                {
                    lbMilitary.CssClass = "text-danger";
                    lbMilitary.Text     = leaveUser.UserMilitary + " / " + leave.Military;
                }
            }

            Label lbStartDate = (Label)(e.Row.FindControl("lbStartDate"));

            if (lbStartDate != null)
            {
                string[] data      = date_start.Split('-');
                DateTime dateStart = DateTime.ParseExact(data[0] + "-" + data[1] + "-" + (int.Parse(data[2]) - 543), "dd-MM-yyyy", CultureInfo.InvariantCulture);

                if (dateStart.Date <= DateTime.Now.Date)
                {
                    if (dateStart.Date.ToString("dd-MM-yyyy") == DateTime.Now.Date.ToString("dd-MM-yyyy"))
                    {
                        lbStartDate.CssClass = "text-danger";
                        lbStartDate.Text     = leave.Date.ToString() + " / " + new DateDifference(dateStart).ToString();
                    }
                    else
                    {
                        lbStartDate.Text = leave.Date.ToString() + " / " + new DateDifference(dateStart).ToString();
                    }
                }
                else
                {
                    lbStartDate.Text = leave.Date.ToString() + " / <span class='badge badge-pill badge-danger'>ข้อมูลวันเริ่มงานผิดพลาด</span>";
                }
            }

            Label lbYear = (Label)(e.Row.FindControl("lbYear"));

            if (lbYear != null)
            {
                lbYear.Text = leave.BudgetYear.ToString();
            }

            Label lbEmpType = (Label)(e.Row.FindControl("lbEmpType"));

            if (lbEmpType != null)
            {
                lbEmpType.Text = (string)DataBinder.Eval(e.Row.DataItem, "type_emp_name");
            }

            LinkButton btnView = (LinkButton)(e.Row.FindControl("btnView"));

            if (btnView != null)
            {
                btnView.CommandArgument = (string)DataBinder.Eval(e.Row.DataItem, "emp_id");
            }

            dbScript.CloseConnection();
        }