Beispiel #1
0
        public List <RequestDATA> GetRequestByUserId(string userid)
        {
            List <RequestDATA> listData = new List <RequestDATA>();

            SqlCommand    command    = new SqlCommand();
            SqlDataReader dataReader = null;

            #region Connection Database
            SqlConnection connection = new SqlConnection();
            connection         = this.ManageConnection();
            command.Connection = connection;
            #endregion

            #region Send Query
            command.CommandType = CommandType.Text;
            command.CommandText = "select u.USERID, u.FIRSTNAME, u.LASTNAME, u.DEPARTMENT, u.POSITION, q.REQCODE, q.TITLE, q.DESCRIPTION from TBLUSERPROFILE as u, TBLREQUEST as q where u.USERID = q.USERID and u.USERID = '" + userid + "'";

            #endregion

            #region Return Data
            dataReader = command.ExecuteReader();

            if (dataReader != null && dataReader.HasRows)
            {
                while (dataReader.Read())
                {
                    RequestDATA requestDATA = new RequestDATA();

                    requestDATA.USERID      = dataReader["USERID"].ToString();
                    requestDATA.FIRSTNAME   = dataReader["FIRSTNAME"].ToString();
                    requestDATA.LASTNAME    = dataReader["LASTNAME"].ToString();
                    requestDATA.DEPARTMENT  = dataReader["DEPARTMENT"].ToString();
                    requestDATA.POSITION    = dataReader["POSITION"].ToString();
                    requestDATA.REQCODE     = dataReader["REQCODE"].ToString();
                    requestDATA.TITLE       = dataReader["TITLE"].ToString();
                    requestDATA.DESCRIPTION = dataReader["DESCRIPTION"].ToString();

                    listData.Add(requestDATA);
                }
            }
            #endregion

            return(listData);
        }
Beispiel #2
0
        // GET: WF
        public ActionResult Index()
        {
            EmployeeDATA employeeDATA = new EmployeeDATA();
            RequestDATA  requestDATA  = new RequestDATA();

            if (Session["userid"] != null)
            {
                string userid = Session["userid"].ToString();

                EmployeeDAL employeeDAL = new EmployeeDAL();

                employeeDATA = employeeDAL.GetUserInfo(userid);

                if (employeeDATA != null)
                {
                    RequestDAL requestDAL = new RequestDAL();

                    List <RequestDATA> listData = requestDAL.GetRequestByUserId(userid);

                    requestDATA.LSTREQ = listData;

                    //แปลงเป็น JSON
                    string json = JsonConvert.SerializeObject(requestDATA);
                    requestDATA.JSON = json;

                    //แปลงเป็น OBJECT
                    requestDATA = JsonConvert.DeserializeObject <RequestDATA>(json);

                    if (requestDATA.LSTREQ.Count > 0)
                    {
                        ViewData["REQDATA"] = requestDATA.LSTREQ;
                    }
                }
            }

            return(View(employeeDATA));
        }