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();
        }
Beispiel #2
0
        protected void GridViewGuestList_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            Label lbGueatName = (Label)(e.Row.FindControl("lbGueatName"));

            if (lbGueatName != null)
            {
                lbGueatName.Text = DataBinder.Eval(e.Row.DataItem, "profix_name").ToString() + DataBinder.Eval(e.Row.DataItem, "guest_list_name").ToString() + " " + DataBinder.Eval(e.Row.DataItem, "guest_list_lname").ToString();
            }

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

            if (lbGuestPos != null)
            {
                lbGuestPos.Text = DataBinder.Eval(e.Row.DataItem, "pos_name").ToString();
            }

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

            if (lbGuestCpoint != null)
            {
                lbGuestCpoint.Text = DataBinder.Eval(e.Row.DataItem, "cpoint_name").ToString();
            }

            HyperLink LabelAddEmp = (HyperLink)(e.Row.FindControl("LabelAddEmp"));

            if (LabelAddEmp != null)
            {
                LabelAddEmp.Text = "รายงานตัวเรียบร้อยแล้ว";
            }

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

            if (btnAddEmp != null)
            {
                btnAddEmp.CommandName = DataBinder.Eval(e.Row.DataItem, "guest_list_id").ToString();
                if (DataBinder.Eval(e.Row.DataItem, "guest_list_idcard").ToString() != "")
                {
                    btnAddEmp.Visible       = false;
                    LabelAddEmp.NavigateUrl = "/Profile/empForm?empID=" + dBScript.getMd5Hash(dBScript.getEmpDataIDCard("emp_id", DataBinder.Eval(e.Row.DataItem, "guest_list_idcard").ToString()));
                }
                else
                {
                    DateTime date;
                    date = dBScript.DateCalculationK(DataBinder.Eval(e.Row.DataItem, "guest_offer_date").ToString(), 5);

                    if (DateTime.Now.Date <= date.Date.AddDays(5))
                    {
                        LabelAddEmp.Visible = false;
                        btnAddEmp.Visible   = true;
                    }
                    else
                    {
                        if (int.Parse(Session["UserPrivilegeId"].ToString()) > 1)
                        {
                            LabelAddEmp.Visible  = true;
                            LabelAddEmp.Text     = "ไม่มารายงานตัว";
                            LabelAddEmp.CssClass = "badge badge-danger";
                            btnAddEmp.Visible    = false;
                        }
                        else
                        {
                            //LabelAddEmp.Visible = false;
                            LabelAddEmp.Visible  = true;
                            LabelAddEmp.Text     = "เกินกำหนด";
                            LabelAddEmp.CssClass = "badge badge-danger";
                        }
                    }
                }
            }
        }