public IEnumerable <TicketModels> Print(TicketModels newItem) { List <TicketModels> results = new List <TicketModels>(); try { TicketModels valus = new TicketModels(); UserDataContext Con = new UserDataContext(); var User = (from xx in Con.MAS_USERs join yy in Con.MAS_DEPs on xx.D_ID equals yy.DP_ID where xx.STCODE == newItem.STCODE select new { xx, yy }).FirstOrDefault(); newItem.DP = User.xx.D_ID; newItem.DPNAME = User.yy.DPCODE; newItem.FULLNAME = User.xx.FNAME + " " + User.xx.LNAME; using (TicketLEDataContext Context = new TicketLEDataContext()) { var Main = (from xx in Context.VW_TICKETs where xx.ID == newItem.TicketId select xx).FirstOrDefault(); var Sub = (from xx in Context.TASK_SUBs join yy in Context.MAS_DOCs on xx.DOC_ID equals yy.DOC_ID where xx.LE_ID == newItem.TicketId orderby xx.DETEIL_SUB select new { xx, yy }); List <CheckBox> lstSub = new List <CheckBox>(); int row = 1; foreach (var item in Sub) { CheckBox ux = new CheckBox(); ux.row = row; ux.Doc = item.yy.DOC_NAME; ux.NAME = item.xx.DETEIL_SUB; ux.Type = item.yy.TYPE; lstSub.Add(ux); row++; } valus.Detail = lstSub; Ticket lis = new Ticket(); lis.TICKETNO = Main.TICKETNO; lis.DETAIL = Main.DETEIL; lis.CREATEDATE = DateTime.Parse(Main.WORKDATE.ToString()).ToShortDateString(); lis.CREATETIME = DateTime.Parse(Main.WORKDATE.ToString()).ToLongTimeString(); lis.CRE_NICKNAME = Main.NICKNAME; lis.DEP = Main.DPCODE; lis.SSID = Int32.Parse(Main.STATUS); lis.SSNAME = Main.SS_NAME; lis.NAME_OPEN = Main.FNAME + " " + Main.LNAME; lis.DATE_OPEN = DateTime.Parse(Main.WORKDATE.ToString()).ToShortDateString(); lis.NAME_HDEP = Main.HDEP_NAME; if (Main.HDEP_DATE != null) { lis.DATE_HDEP = DateTime.Parse(Main.HDEP_DATE.ToString()).ToShortDateString(); } lis.NAME_RECEIVE = Main.RECEIVE_NAME; if (Main.RECEIVE_DATE != null) { lis.DATE_RECEIVE = DateTime.Parse(Main.RECEIVE_DATE.ToString()).ToShortDateString(); } lis.NAME_CLOSE = Main.CLOSE_NAME; if (Main.CLOSE_DATE != null) { lis.DATE_CLOSE = DateTime.Parse(Main.CLOSE_DATE.ToString()).ToShortDateString(); } valus.TicketSub = lis; } valus.TicNo = newItem.TicketId; results.Add(valus); } catch (Exception ex) { //Detail res = new Detail(); //res.status = "F"; //res.message = ex.Message; //results.Add(res); } return(results.ToArray()); }
public IEnumerable <TicketModels> ApproveTicket(Detail data) { List <TicketModels> results = new List <TicketModels>(); try { IQueryable <WebAPI.DATA.TicketLE.VW_TICKET> View_Ticket; var seach = data.seach; var type = data.type; UserDataContext Con = new UserDataContext(); TicketLEDataContext db = new TicketLEDataContext(); TicketModels value = new TicketModels(); //value.Type = new SelectList(db.MAS_SSes, "SS_ID", "SS_NAME"); var User = (from xx in Con.MAS_USERs join yy in Con.MAS_DEPs on xx.D_ID equals yy.DP_ID where xx.STCODE == data.STCODE select new { xx, yy }).FirstOrDefault(); //value.DP = User.xx.D_ID; using (TicketLEDataContext Context = new TicketLEDataContext()) { View_Ticket = Context.VW_TICKETs.Where(s => s.TICKETNO.Contains(seach) || s.DPCODE.Contains(seach) || s.NICKNAME.Contains(seach)).Where(s => s.STATUS == "1").Where(s => s.FLAG == "1").Where(s => s.APPROVE_ID == 1).Where(s => s.DPCODE == User.yy.DPCODE).OrderBy(s => s.STATUS); List <Ticket> ticketsAns = new List <Ticket>(); foreach (var item in View_Ticket) { Ticket ux = new Ticket(); ux.ID = item.ID; ux.TICKETNO = item.TICKETNO; ux.DETAIL = item.DETEIL; ux.CREATEDATE = DateTime.Parse(item.WORKDATE.ToString()).ToShortDateString(); ux.CREATETIME = DateTime.Parse(item.WORKDATE.ToString()).ToLongTimeString(); ux.CRE_NICKNAME = item.NICKNAME; ux.DEP = item.DPCODE; ux.SSID = Int32.Parse(item.STATUS); ux.SSNAME = item.SS_NAME; ticketsAns.Add(ux); } value.TicketDetail = ticketsAns; } //value.WordSearch = seach; //value.typeSearch = type; results.Add(value); } catch (Exception ex) { //Detail res = new Detail(); //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 <DATA.TicketLE.VW_TICKET> View_Ticket; var seach = data.seach; var type = data.type; UserDataContext Con = new UserDataContext(); TicketLEDataContext db = new TicketLEDataContext(); List <Ticket> lstTicket = new List <Ticket>(); var User = (from xx in Con.MAS_USERs where xx.STCODE == data.STCODE select xx).FirstOrDefault(); using (TicketLEDataContext Context = new TicketLEDataContext()) { View_Ticket = Context.VW_TICKETs.Where(s => s.TICKETNO.Contains(seach) || s.DPCODE.Contains(seach) || s.NICKNAME.Contains(seach)).Where(s => s.FLAG == "1").OrderBy(s => s.STATUS); if (type != "") { View_Ticket = View_Ticket.Where(tik => tik.STATUS == type); } if (User.D_ID != 10) { View_Ticket = View_Ticket.Where(s => s.STCODE == data.STCODE); foreach (var item in View_Ticket) { Ticket ux = new Ticket(); ux.ID = item.ID; ux.TICKETNO = item.TICKETNO; ux.DETAIL = item.DETEIL; ux.CREATEDATE = DateTime.Parse(item.WORKDATE.ToString()).ToShortDateString(); ux.CREATETIME = DateTime.Parse(item.WORKDATE.ToString()).ToLongTimeString(); ux.CRE_NICKNAME = item.NICKNAME; ux.DEP = item.DPCODE; ux.SSID = Int32.Parse(item.STATUS); ux.SSNAME = item.SS_NAME; lstTicket.Add(ux); } } else { if (User.A_ID == 3) { View_Ticket = View_Ticket.Where(s => s.STCODE == data.STCODE); } else { View_Ticket = View_Ticket.Where(s => s.APPROVE_ID >= 2); } foreach (var item in View_Ticket) { Ticket ux = new Ticket(); ux.ID = item.ID; ux.TICKETNO = item.TICKETNO; ux.DETAIL = item.DETEIL; ux.CREATEDATE = DateTime.Parse(item.WORKDATE.ToString()).ToShortDateString(); ux.CREATETIME = DateTime.Parse(item.WORKDATE.ToString()).ToLongTimeString(); ux.CRE_NICKNAME = item.NICKNAME; ux.DEP = item.DPCODE; ux.SSID = Int32.Parse(item.STATUS); ux.SSNAME = item.SS_NAME; lstTicket.Add(ux); } } results = lstTicket; } } catch (Exception ex) { //AnsOP res = new AnsOP(); //res.status = "F"; //res.message = ex.Message; //results.Add(res); } return(results.ToArray()); }