Beispiel #1
0
        public void loginAccount()
        {
            dbFile db          = new dbFile();
            string return_page = "";

            //try
            //{
            using (SqlConnection conn = new SqlConnection(db.sqlConnection))
            {
                conn.Open();

                SqlCommand cmd = new SqlCommand("SELECT * FROM tab_emp ep INNER JOIN  view_employee vm on vm.ep_id = ep.ep_id " +
                                                "  LEFT JOIN tab_emp_profile_img mg on mg.img_ref_emp_id = ep.ep_id" +
                                                " where  vm.position_active = 'Y' and ep.ep_code = '" + username + "' and ep_pw = '" + password + "'", conn);

                SqlDataReader rdr = cmd.ExecuteReader();


                Boolean flag = false;     // กำหนดให้ flag = เท็จ
                while (rdr.Read())
                {
                    user_id = rdr.GetInt32(0);
                    flag    = true;

                    username     = rdr["ps_name_full"].ToString();
                    emp_id       = rdr["ep_id"].ToString();
                    admin_status = rdr["ep_end"].ToString();    //  Session["username"] = name;
                    emp_img      = rdr["img_name"].ToString();
                    emp_name     = rdr["prefix_name_th"] + "" + rdr["ps_name_full"];
                    emp_code     = rdr["ep_code"].ToString();
                    emp_type     = rdr["type_name"].ToString();
                    emp_position = rdr["post_name"].ToString();
                    emp_dept     = rdr["dept_name"].ToString();
                    emp_sect     = rdr["Section_name"].ToString();
                    emp_comp     = rdr["T_Company"].ToString();
                    emp_comp_id  = rdr["position_comp_id"].ToString();
                }


                if (flag == true)     // ถ้าเป็นจริงให้ทำ...
                {
                    action = "T";
                }
                else
                {
                    action = "F";
                }

                conn.Close();
            }
        }
Beispiel #2
0
        public void ConvertMd5()
        {
            dbFile db = new dbFile();

            using (SqlConnection conn = new SqlConnection(db.sqlConnection)) {
                conn.Open();

                SqlCommand    cmd = new SqlCommand("Select CONVERT(VARCHAR(32), HashBytes('MD5', '" + txt + "'), 2) as MD5Hash", conn);
                SqlDataReader rdr = cmd.ExecuteReader();
                while (rdr.Read())
                {
                    md = rdr["MD5Hash"].ToString();
                }

                conn.Close();
            }
        }