public IEnumerable <AddComment> TicketDetail(Detail data)
        {
            List <AddComment> results = new List <AddComment>();

            try
            {
                AddComment addComment = new AddComment();
                IQueryable <VW_TICKET_DETAIL> View_Ticket;

                TicketOPDataContext Context = new TicketOPDataContext();

                List <Ticket> lstTicket = new List <Ticket>();

                View_Ticket = Context.VW_TICKET_DETAILs
                              .Where(tik => tik.TK_ID == data.Ticket_ID);

                foreach (var ux in View_Ticket)
                {
                    Ticket _ticket = new Ticket();

                    _ticket.TK_ID        = ux.TK_ID;
                    _ticket.TICKETNO     = ux.TICKETNO;
                    _ticket.WHCODE       = ux.WHCODE;
                    _ticket.WHNAME       = ux.WHNAME;
                    _ticket.AREA         = ux.AREA;
                    _ticket.DETAIL       = ux.DETAIL;
                    _ticket.SS_ID        = ux.SS_ID;
                    _ticket.ST_NAME      = ux.TNAME;
                    _ticket.CREATEDATE   = DateTime.Parse(ux.CREATEDATE.ToString()).ToShortDateString();
                    _ticket.CREATETIME   = ux.CREATETIME.ToString();
                    _ticket.REC_NICKNAME = ux.NICKNAME;

                    _ticket.ORDERNO   = ux.ORDERNO;
                    _ticket.TK_MESAGE = ux.TK_MESAGE;
                    _ticket.US_ID     = ux.Expr1;

                    //_ticket.POS_NAME = ux.POS_NICKNAME;
                    _ticket.POSTDATE = ux.DETAILDATE.ToString();

                    //_ticket.FLS = flsPath(ux.TK_ID, 1);
                    ////_ticket.FLS_I = flsPath(ux.TK_ID, 1, (Int16)ux.ORDERNO);
                    //_ticket.FLS_H_1 = flsPath(ux.TK_ID, 1);
                    //_ticket.FLS_H_2 = flsPath(ux.TK_ID, 2);
                    //_ticket.FLS_H_3 = flsPath(ux.TK_ID, 3);

                    //try
                    //{
                    //    _ticket.FLS_H_1_Name = _ticket.FLS_H_1.Substring(14, _ticket.FLS_H_1.Length - 14);
                    //    String[] substrings_1 = _ticket.FLS_H_1.Split('.');
                    //    int num_1 = substrings_1.Length;
                    //    string check_1 = substrings_1[num_1 - 1];
                    //    var sql_1 = (from xx in Context.DEV_TASK_FLAGs
                    //                 where xx.Type_name == check_1
                    //                 select xx).FirstOrDefault();
                    //    if (sql_1.FLAG == 1)
                    //    {
                    //        _ticket.FLAG_1 = "1";
                    //    }
                    //    else
                    //    {
                    //        _ticket.FLAG_1 = "2";
                    //        _ticket.IMG_1 = sql_1.File_img;
                    //    }

                    //    _ticket.FLS_H_2_Name = _ticket.FLS_H_2.Substring(14, _ticket.FLS_H_2.Length - 14);
                    //    String[] substrings_2 = _ticket.FLS_H_2.Split('.');
                    //    int num_2 = substrings_2.Length;
                    //    string check_2 = substrings_2[num_2 - 1];
                    //    var sql_2 = (from xx in Context.DEV_TASK_FLAGs
                    //                 where xx.Type_name == check_2
                    //                 select xx).FirstOrDefault();
                    //    if (sql_2.FLAG == 1)
                    //    {
                    //        _ticket.FLAG_2 = "1";
                    //    }
                    //    else
                    //    {
                    //        _ticket.FLAG_2 = "2";
                    //        _ticket.IMG_2 = sql_2.File_img;
                    //    }

                    //    _ticket.FLS_H_3_Name = _ticket.FLS_H_3.Substring(14, _ticket.FLS_H_3.Length - 14);
                    //    String[] substrings_3 = _ticket.FLS_H_3.Split('.');
                    //    int num_3 = substrings_3.Length;
                    //    string check_3 = substrings_3[num_3 - 1];
                    //    var sql_3 = (from xx in Context.DEV_TASK_FLAGs
                    //                 where xx.Type_name == check_3
                    //                 select xx).FirstOrDefault();
                    //    if (sql_3.FLAG == 1)
                    //    {
                    //        _ticket.FLAG_3 = "1";
                    //    }
                    //    else
                    //    {
                    //        _ticket.FLAG_3 = "2";
                    //        _ticket.IMG_3 = sql_3.File_img;
                    //    }
                    //}
                    //catch
                    //{

                    //}


                    lstTicket.Add(_ticket);
                    addComment.TK_ID    = ux.TK_ID;
                    addComment.TICKETNO = ux.TICKETNO;
                    addComment.SS_ID    = ux.SS_ID;
                }
                addComment.ticket = lstTicket;

                results.Add(addComment);
            }
            catch (Exception ex)
            {
                //AnsOP res = new AnsOP();
                //res.status = "F";
                //res.message = ex.Message;
                //results.Add(res);
            }

            return(results.ToArray());
        }
        public IEnumerable <Ticket> Ticketlist(Detail data)
        {
            List <Ticket> results = new List <Ticket>();

            try
            {
                IQueryable <VW_TICKET> View_Ticket;

                var seach = data.seach.Trim();
                var type  = data.type.Trim();

                TicketOPDataContext Context = new TicketOPDataContext();
                UserDataContext     C_user  = new UserDataContext();

                List <Ticket> lstTicket = new List <Ticket>();

                //string a = userOnline;
                if (data.Pos == "1")
                {
                    var queryX = Context.MAS_WHs.Where(x => x.WHCODE == data.STCODE).FirstOrDefault();

                    //ViewBag.BRAND = queryX.BRAND;

                    View_Ticket = Context.VW_TICKETs
                                  .Where(tik => tik.WHCODE == data.STCODE)
                                  .Where(tik => tik.AREA.Contains(seach) || tik.WHNAME.Contains(seach) || tik.TICKETNO.Contains(seach))
                                  .Where(tik => tik.FLAG == "0")
                                  .OrderBy(tik => tik.SS_ID);
                }
                else
                {
                    var sql = C_user.VW_USER_ALLs.Where(x => x.STCODE == data.STCODE).FirstOrDefault();
                    //ViewBag.BRAND = sql.DPCODE;

                    View_Ticket = Context.VW_TICKETs
                                  .Where(tik => tik.BRAND == sql.DPCODE)
                                  .Where(tik => tik.AREA.Contains(seach) || tik.WHNAME.Contains(seach) || tik.TICKETNO.Contains(seach))
                                  .Where(tik => tik.FLAG == "0")
                                  .OrderBy(tik => tik.SS_ID);
                }

                if (type != "")
                {
                    View_Ticket = View_Ticket.Where(tik => tik.TNAME == type);
                }

                foreach (var ux in View_Ticket)
                {
                    Ticket _ticket = new Ticket();

                    _ticket.TK_ID        = ux.TK_ID;
                    _ticket.TICKETNO     = ux.TICKETNO;
                    _ticket.WHCODE       = ux.WHCODE;
                    _ticket.WHNAME       = ux.WHNAME;
                    _ticket.AREA         = ux.AREA;
                    _ticket.DETAIL       = ux.DETAIL;
                    _ticket.SS_ID        = ux.SS_ID;
                    _ticket.ST_NAME      = ux.TNAME;
                    _ticket.REC_NICKNAME = ux.NICKNAME;
                    _ticket.CREATEDATE   = DateTime.Parse(ux.CREATEDATE.ToString()).ToShortDateString();
                    _ticket.CREATETIME   = ux.CREATETIME.ToString();

                    lstTicket.Add(_ticket);
                }
                results = lstTicket;
            }
            catch (Exception ex)
            {
                //AnsOP res = new AnsOP();
                //res.status = "F";
                //res.message = ex.Message;
                //results.Add(res);
            }

            return(results.ToArray());
        }