コード例 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(Request.Params["id"]))
            {
                txtGuest_id.Value = Request.Params["id"].ToString();
            }
            if (Session["User"] != null)
            {
                if (int.Parse(Session["UserPrivilegeId"].ToString()) > 1)
                {
                    DivAddGuest.Visible      = false;
                    btnAddTitleGuest.Visible = false;
                    txtOfferDate.Enabled     = false;
                    txtReferTitle.Enabled    = false;
                    txtReferDate.Enabled     = false;
                    txtRefer.Enabled         = false;
                    txtTo.Enabled            = false;
                    txtTitle.Enabled         = false;
                }
            }
            else
            {
            }

            if (!this.IsPostBack)
            {
                BindData();
                dBScript.GetDownList(txtProfix, "select * from tbl_profix", "profix_name", "profix_id");
                dBScript.GetDownList(txtPos, "select * from tbl_pos", "pos_name", "pos_id");
                dBScript.GetDownList(txtCpoint, "select * from tbl_cpoint", "cpoint_name", "cpoint_id");
                dBScript.GetDownList(txtAff, "select * from tbl_affiliation", "affi_name", "affi_id");
                txtAff.Items.Insert(0, new ListItem("เลือก", ""));

                if (txtGuest_id.Value.ToString() == "")
                {
                    DivAddGuest.Visible   = false;
                    btnReport.Visible     = false;
                    btnReportCopy.Visible = false;
                }
                else
                {
                    string          sql_select_guest = "SELECT * FROM tbl_guest guest WHERE guest_id = '" + txtGuest_id.Value + "'";
                    MySqlDataReader rs = dBScript.selectSQL(sql_select_guest);
                    if (rs.Read())
                    {
                        txtTitle.Text      = rs.GetString("guest_title");
                        txtTo.Text         = rs.GetString("guest_title_to");
                        txtRefer.Text      = rs.GetString("guest_refer");
                        txtReferDate.Text  = rs.GetString("guest_refer_date");
                        txtReferTitle.Text = rs.GetString("guest_refer_title");
                        txtOfferDate.Text  = rs.GetString("guest_offer_date");
                    }
                    rs.Close();
                    dBScript.CloseConnection();
                }
            }
        }
コード例 #2
0
ファイル: index.aspx.cs プロジェクト: chinnaphat25/HRSProject
        public void GetDownList(DropDownList list, string sql, string text, string value)
        {
            MySqlDataReader rs = dBScript.selectSQL(sql);

            using (var reader = dBScript.selectSQL(sql))
            {
                if (reader.HasRows)
                {
                    list.DataSource     = reader;
                    list.DataValueField = value;
                    list.DataTextField  = text;
                    list.DataBind();
                }
            }
        }
コード例 #3
0
        void Application_BeginRequest(object sender, EventArgs e)
        {
            DBScript        dBScript = new DBScript();
            string          sql      = "SELECT SUM(emp_status_login) AS userOnilne FROM tbl_emp_user";
            MySqlDataReader rs       = dBScript.selectSQL(sql);

            if (rs.Read())
            {
                if (!rs.IsDBNull(0))
                {
                    Application.Lock();
                    Application["TotalOnlineUsers"] = int.Parse(rs.GetString("userOnilne"));
                    Application.UnLock();
                }
            }
            rs.Close();
            dBScript.userLogOutTimeUpdate();

            //อัพเดทการลาออก
            dBScript.UpdateEmpEx();

            //อัพเดทการเปลี่ยนตำแหน่ง
            dBScript.UpdateEmpPos();

            //อัพเดทการย้ายด่านฯ
            dBScript.UpdateEmpCpoint();

            //อัพเดทพนักงานที่ไม่มีประวัติการทำงานภายในฝ่าย
            dBScript.CreateMotowayWorking();
            //อัพเดทพนักงานที่ไม่มีประวัติการทำงานที่ด่านฯ
            dBScript.CreateCpointWorking();

            dBScript.CloseConnection();
        }
コード例 #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            lbUserOnline.Text = int.Parse(Application["TotalOnlineUsers"].ToString()).ToString(" 0 คน");

            if (!this.IsPostBack)
            {
                string          sql = "SELECT COUNT('id') AS EmpSum FROM tbl_emp_profile WHERE emp_staus_working = '1'";
                MySqlDataReader rs  = dBScript.selectSQL(sql);
                if (rs.Read())
                {
                    lbCountEmp.Text = "ทั้งหมด " + rs.GetString("EmpSum") + " คน";
                }
                rs.Close();
                BindDataLeave();
                BindRetire();
                dBScript.CloseConnection();

                string sql_guest = "SELECT guest_offer_date FROM  tbl_guest ORDER BY STR_TO_DATE(guest_offer_date, '%d-%m-%Y') DESC ";
                LabelGuest.Text = "รายการล่าสุด " + dBScript.convertDateShortThai(dBScript.GetSelectData(sql_guest));

                lbYear.Text  = dBScript.getBudgetYear();
                txtYear.Text = dBScript.getBudgetYear();
            }
            if (Session["User"] != null)
            {
                if (dBScript.Notallow(new string[] { "5" }, Session["UserPrivilegeId"].ToString()))
                {
                    Response.Redirect("/Profile/empViwe");
                }

                if (dBScript.Notallow(new string[] { "5", "4", "3" }, Session["UserPrivilegeId"].ToString()))
                {
                    boxChangPos.Visible   = false;
                    boxMigrateEmp.Visible = false;
                    boxResignEmp.Visible  = false;
                }
            }
        }
コード例 #5
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();
            }
        }
コード例 #6
0
ファイル: Login.aspx.cs プロジェクト: chinnaphat25/HRSProject
        private void btnSubmit_Click(Object sender, EventArgs e)
        {
            string mess = "";

            if (txtUser.Text.Trim() == "")
            {
                mess += "- กรุณาป้อน Username<br/>";
            }

            if (txtPass.Text.Trim() == "")
            {
                mess += "- กรุณาป้อน Password<br/>";
            }

            if (mess == "")
            {
                string          sql = "SELECT * FROM tbl_emp_user join tbl_privilege on privilege_id = emp_user_privilege WHERE emp_user_name ='" + txtUser.Text.Trim() + "' AND emp_user_pass = '******'";
                MySqlDataReader rs  = dBScript.selectSQL(sql);
                if (rs.Read())
                {
                    if (!rs.IsDBNull(0))
                    {
                        //if (rs.GetString("emp_status_login") != "1")
                        //{
                        // Storee Session
                        Session.Add("User", txtUser.Text);
                        Session.Add("UserName", rs.GetString("emp_name"));
                        Session.Add("UserPrivilegeId", rs.GetString("privilege_id"));
                        Session.Add("UserPrivilege", rs.GetString("privilege_name"));
                        if (rs.GetString("privilege_id") == "5")
                        {
                            Session.Add("emp_login_id", rs.GetString("emp_user_id"));
                        }
                        else
                        {
                            Session.Add("emp_login_id", null);
                        }
                        Session.Timeout = 600;

                        // now Storing Cookies & config.
                        HttpCookie newCookie = new HttpCookie("HRSLogin");
                        newCookie["User"]            = txtUser.Text;
                        newCookie["UserName"]        = rs.GetString("emp_name");
                        newCookie["UserPrivilegeId"] = rs.GetString("privilege_id");
                        newCookie["UserPrivilege"]   = rs.GetString("privilege_name");
                        if (rs.GetString("privilege_id") == "5")
                        {
                            newCookie["emp_login_id"] = rs.GetString("emp_user_id");
                        }
                        else
                        {
                            newCookie["emp_login_id"] = null;
                        }
                        newCookie.Expires = DateTime.Now.AddDays(1);
                        Response.Cookies.Add(newCookie);

                        //Page.ClientScript.RegisterStartupScript(Page.GetType(), "Message Box", "<script language = 'javascript'>alert('dd')</script>");
                        dBScript.userLoginUpdate(txtUser.Text);
                        Response.Redirect("/");

                        /*}
                         * else
                         * {
                         *  mess += "- ***ไม่อนุญาติให้มีการเข้าใช้งานด้วยรหัสเดียวกันซ้ำ";
                         * }*/
                    }
                    else
                    {
                        mess += "- Username หรือ Password ไม่ถูกต้อง";
                    }
                }
                else
                {
                    mess += "- Username หรือ Password ไม่ถูกต้อง";
                }
            }

            if (mess != "")
            {
                MsgBox(mess);
            }
            else
            {
                msgBox.Text = "";
            }
        }
コード例 #7
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();
        }
コード例 #8
0
        protected void GridViewEmp_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            //รหัสบุคคล
            Label lbempID = (Label)(e.Row.FindControl("lbempID"));

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


            // ชื่อ - สกุล
            Label lbempName = (Label)(e.Row.FindControl("lbempName"));

            if (lbempName != null)
            {
                lbempName.Text = (string)DataBinder.Eval(e.Row.DataItem, "profix_name") + (string)DataBinder.Eval(e.Row.DataItem, "emp_name") + "  " + (string)DataBinder.Eval(e.Row.DataItem, "emp_lname");
            }

            // สังกัดด่านฯ
            Label lbempCpoint = (Label)(e.Row.FindControl("lbempCpoint"));

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

            // ตำแหน่ง
            Label lbempPos = (Label)(e.Row.FindControl("lbempPos"));

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

            // หน่วย
            Label lbempAff = (Label)(e.Row.FindControl("lbempAff"));

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

            // ประเภทพนักงาน
            Label lbempType = (Label)(e.Row.FindControl("lbempType"));

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

            // อายุงาน
            Label lbempAgeWork = (Label)(e.Row.FindControl("lbempAgeWork"));

            if (lbempAgeWork != null)
            {
                string[] data      = DataBinder.Eval(e.Row.DataItem, "emp_start_working").ToString().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)
                {
                    DateDifference dDiff = new DateDifference(dateStart);
                    lbempAgeWork.Text = dDiff.ToString();
                }
                else
                {
                    lbempAgeWork.Text = "<span class='badge badge-pill badge-danger'>ข้อมูลวันเริ่มงานผิดพลาด</span>";
                }
            }

            // อายุงาน
            Label lbempAgeWorkNow = (Label)(e.Row.FindControl("lbempAgeWorkNow"));

            if (lbempAgeWorkNow != null)
            {
                try
                {
                    string          sql = "SELECT * 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())
                    {
                        string[] data      = rs.GetString("exp_moterway_start").ToString().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)
                        {
                            DateDifference dDiff = new DateDifference(dateStart);
                            lbempAgeWorkNow.Text = dDiff.ToString();
                        }
                        else
                        {
                            lbempAgeWorkNow.Text = "<span class='badge badge-pill badge-danger'>ข้อมูลวันเริ่มงานตำแหน่งปัจจุบันผิดพลาด</span>";
                        }
                        rs.Close();
                    }
                    else
                    {
                        lbempAgeWorkNow.Text = "-";
                    }
                }
                catch { lbempAgeWorkNow.Text = "มีข้อผิดพลาด"; }
            }

            Button txtEmpViwe = (Button)(e.Row.FindControl("txtEmpViwe"));

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