Пример #1
0
        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();
            }
        }