コード例 #1
0
ファイル: AjaxController.cs プロジェクト: nhonduyen/OJT
        public JsonResult UpdateHistory(int ID, string COLUMN, string VALUE)
        {
            HISTORY his    = new HISTORY();
            var     result = his.Update(ID, COLUMN, VALUE);

            return(Json(result));
        }
コード例 #2
0
        public FolderManager2(HeaderControl hcCurrent, HeaderControl hcRevision)
        {
            hc[CURRENT.Value()]  = hcCurrent;
            hc[REVISION.Value()] = hcRevision;

            hc[CURRENT.Value()].FolderRoute.PathChange += OnCurrentPathChangeEvent;

            this.hcCurrent  = hcCurrent;
            this.hcRevision = hcRevision;

            hcCurrent.FolderRoute.PathChange += OnCurrentPathChangeEvent;

//			hcCurrent.SetPathChangeEventHandler(OnRevisionPathChangeEvent);
//			hcCurrent.SetSelectFolderEventHandler(OnRevisionSelectFolderEvent);
//			hcCurrent.SetFavoritesEventHandler(OnRevisionFavoriteEvent);
//			hcCurrent.SetHistoryEventHandler(OnRevisionHistoryEvent);
//
//			hcRevision.SetPathChangeEventHandler(OnRevisionPathChangeEvent);
//			hcRevision.SetSelectFolderEventHandler(OnRevisionSelectFolderEvent);
//			hcRevision.SetFavoritesEventHandler(OnRevisionFavoriteEvent);
//			hcRevision.SetHistoryEventHandler(OnRevisionHistoryEvent);

            ConfigSavedFolders();

            SavedFoldersDebugSupport.Instance.
            ConfigSavedFoldersDebugSupport(svfMgr[HISTORY.Value()], svfMgr[FAVORITES.Value()]);

            getPriorFolder();

            configHeader(this.hcCurrent);
            configHeader(this.hcRevision);
        }
コード例 #3
0
ファイル: AjaxController.cs プロジェクト: nhonduyen/OJT
        public JsonResult Assign(string MENTOR, int COURSE_ID, List <EMPLOYEE> IDS)
        {
            var        result = 0;
            HISTORY    his    = new HISTORY();
            HIS_DETAIL detail = new HIS_DETAIL();
            EMPLOYEE   em     = new EMPLOYEE();

            foreach (var id in IDS)
            {
                HISTORY last     = his.GetLastId(COURSE_ID, id.ID, MENTOR);
                int     isMentor = em.IsMentor(COURSE_ID, id.ID);
                if (last == null && isMentor == 0)
                {
                    result = his.Insert(COURSE_ID, id.ID, MENTOR);
                    if (result > 0)
                    {
                        last = his.GetLastId(COURSE_ID, id.ID, MENTOR);
                        if (last != null)
                        {
                            for (int i = 0; i < 5; i++)
                            {
                                result = detail.Insert(last.ID, COURSE_ID, id.ID, MENTOR, "Unconfirmed", id.DEPARTMENT);
                            }
                        }
                    }
                }
            }
            return(Json(result));
        }
コード例 #4
0
        public IHttpActionResult GetMyHistory(HISTORY dateRange)
        {
            if (HttpContext.Current.Request.Cookies.AllKeys.Contains("sid"))
            {
                try
                {
                    response = identity.Auth(HttpContext.Current.Request.Cookies.Get("sid").Value);
                }
                catch
                {
                    return(BadRequest("Invalid token. Login in again!"));
                }
            }
            else
            {
                return(BadRequest("You are not logged in. Please login and try again."));
            }

            var            id = response.UserId;
            List <CV_ITEM> items;
            DateTime       from = (DateTime)dateRange.from;
            DateTime       to   = (DateTime)dateRange.to;

            try
            {
                items = db.CV_ITEM.Where(c => c.CV_TABLE_ID_CV == id && c.DATE_CREATED >= from && c.DATE_CREATED <= to).ToList();
            }
            catch (Exception e)
            {
                return(InternalServerError(e));
            }


            return(Ok(items));
        }
コード例 #5
0
        public ActionResult DeleteConfirmed(int id)
        {
            HISTORY hISTORY = db.HISTORies.Find(id);

            db.HISTORies.Remove(hISTORY);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #6
0
        /// <summary>
        /// Create a new HISTORY object.
        /// </summary>
        /// <param name="id">Initial value of ID.</param>
        /// <param name="hDATE">Initial value of HDATE.</param>
        public static HISTORY CreateHISTORY(int id, global::System.DateTime hDATE)
        {
            HISTORY hISTORY = new HISTORY();

            hISTORY.ID    = id;
            hISTORY.HDATE = hDATE;
            return(hISTORY);
        }
コード例 #7
0
        private void ConfigSavedFolders()
        {
            if (svfMgr[0] == null)
            {
                svfMgr[HISTORY.Value()] = new SavedFolderManager(HISTORY);

                svfMgr[FAVORITES.Value()] = new SavedFolderManager(FAVORITES);
            }
        }
コード例 #8
0
    void Start()
    {
        m_winInfo    = (hglWindowInfo)hgca.FindAscendantComponent(gameObject, typeof(hglWindowInfo));
        m_renderInfo = GetComponent <hglHtmlRenderInfo>();
        m_xmlScript  = GetComponent <xmlScriptMan>();
        m_history    = new HISTORY();

        var file = hglConfig.GetResourceFrom(m_winInfo.m_ResourceFrom) + m_winInfo.m_url;

        Browse(file);
    }
コード例 #9
0
        // GET: History/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            HISTORY hISTORY = db.HISTORies.Find(id);

            if (hISTORY == null)
            {
                return(HttpNotFound());
            }
            return(View(hISTORY));
        }
コード例 #10
0
ファイル: DAL_HISTORY.cs プロジェクト: hoanvu9495/FaceID
 public static bool INSERT(HISTORY obj)
 {
     try
     {
         DBEntities db = new DBEntities();
         db.HISTORies.Add(obj);
         db.SaveChanges();
         db.Dispose();
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
コード例 #11
0
        // GET: History/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            HISTORY hISTORY = db.HISTORies.Find(id);

            if (hISTORY == null)
            {
                return(HttpNotFound());
            }
            ViewBag.DOG_ID = new SelectList(db.DOGs, "ID", "NAME", hISTORY.DOG_ID);
            return(View(hISTORY));
        }
コード例 #12
0
ファイル: DAL_HISTORY.cs プロジェクト: hoanvu9495/FaceID
 public static bool UPDATE(HISTORY obj)
 {
     try
     {
         var db   = new DBEntities();
         var temp = db.HISTORies.Where(x => x.ID == obj.ID).SingleOrDefault();
         if (temp != null)
         {
             db.SaveChanges();
         }
         return(true);
     }
     catch (SqlException ex)
     {
         return(false);
     }
 }
コード例 #13
0
 public ActionResult Edit([Bind(Include = "ID,DOG_ID,ADOPTER_NAME,HISTORY1,PICTURE")] HISTORY hISTORY, HttpPostedFileBase file)
 {
     if (ModelState.IsValid)
     {
         if (file != null)
         {
             string ImageName    = System.IO.Path.GetFileName(file.FileName);
             string physicalPath = Server.MapPath("~/Content/img/history/" + ImageName);
             file.SaveAs(physicalPath);
             hISTORY.PICTURE = ImageName;
         }
         db.Entry(hISTORY).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.DOG_ID = new SelectList(db.DOGs, "ID", "NAME", hISTORY.DOG_ID);
     return(View(hISTORY));
 }
コード例 #14
0
        public async Task <IActionResult> CreateHistory([FromBody] HistoryView model)
        {
            if (ModelState.IsValid)
            {
                var UserId = _userManager.GetUserId(User);

                var history = new HISTORY
                {
                    ID_RESULTH = model.H.ID_RESULTH,
                    ID_TYPE    = model.H.ID_TYPE,
                    ID_USER    = UserId
                };

                await historyService.Add(history);

                return(Ok(history));
            }
            return(BadRequest(ModelState));
        }
コード例 #15
0
        public ActionResult Export(int COURSE_ID = 0, string MENTOR = "", string EMP_ID = "")
        {
            if (Session["Username"] == null)
            {
                return(RedirectToAction("Login", "Home"));
            }
            var      fileName = DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx";
            var      template = Server.MapPath("~/Upload/Template/Export/OJT_EXP1.xlsx");
            var      dept     = "";
            HISTORY  his      = new HISTORY();
            EMPLOYEE em       = new EMPLOYEE();

            if (Convert.ToInt32(Session["Role"].ToString()) == 0)
            {
                var isMentee = em.IsMentee(COURSE_ID, Session["Username"].ToString());
                var isMentor = em.IsMentor(COURSE_ID, Session["Username"].ToString());
                if (isMentee == 1 && string.IsNullOrWhiteSpace(EMP_ID))
                {
                    EMP_ID = Session["Username"].ToString();
                    MENTOR = em.GetListMentor(COURSE_ID).FirstOrDefault().ID;
                }
                else if (isMentor == 1 && string.IsNullOrWhiteSpace(MENTOR))
                {
                    MENTOR = Session["Username"].ToString();
                }
                else
                {
                    EMP_ID = "0";
                    MENTOR = "0";
                }
            }
            if (Convert.ToInt32(Session["Role"].ToString()) == 2)
            {
                dept = Session["Dept"].ToString();
            }

            var lstHis = his.GetHistoryExport(MENTOR, EMP_ID, COURSE_ID, dept);

            using (ExcelPackage package = new ExcelPackage(new FileInfo(template)))
            {
                ExcelWorksheet ws = package.Workbook.Worksheets.FirstOrDefault();
                for (int i = 0; i < lstHis.Count; i++)
                {
                    var step = i;

                    var history    = lstHis[i];
                    var startIndex = i + 4;
                    ws.Cells["B" + startIndex].Value = history.EMP_ID;
                    ws.Cells["C" + startIndex].Value = history.EMP_NAME;
                    ws.Cells["D" + startIndex].Value = history.DEPARTMENT;
                    ws.Cells["E" + startIndex].Value = history.PERIOD;
                    ws.Cells["F" + startIndex].Value = history.STATUS;
                    ws.Cells["G" + startIndex].Value = history.SUBJECT;
                    ws.Cells["H" + startIndex].Value = history.SUB_LEVEL;
                    ws.Cells["I" + startIndex].Value = history.START_DT == null ? "" : history.START_DT.ToString("yyyy-MM-dd");
                    ws.Cells["J" + startIndex].Value = history.END_DT == null ? "" : history.END_DT.ToString("yyyy-MM-dd");
                    ws.Cells["K" + startIndex].Value = history.APPROVE;
                    ws.Cells["L" + startIndex].Value = history.REC_START_DT == null ? "" : history.REC_START_DT.ToString("yyyy-MM-dd");
                    ws.Cells["M" + startIndex].Value = history.REC_END_DT == null ? "" : history.REC_END_DT.ToString("yyyy-MM-dd");
                    ws.Cells["N" + startIndex].Value = history.MANAGER_CMT;
                    ws.Cells["O" + startIndex].Value = history.HR_CMT;
                    ws.Cells["P" + startIndex].Value = history.TEST_TIME == null ? "" : history.TEST_TIME.ToString("yyyy-MM-dd");
                    ws.Cells["Q" + startIndex].Value = history.SCORE;
                    ws.Cells["R" + startIndex].Value = history.RESULT_LEVEL;
                    ws.Cells["S" + startIndex].Value = history.ARCHIEVEMENT;
                }
                for (int i = 0; i < lstHis.Count; i++)
                {
                    int count   = 0;
                    var history = lstHis[i];
                    for (int j = 0; j < lstHis.Count; j++)
                    {
                        if (history.EMP_ID.Equals(lstHis[j].EMP_ID))
                        {
                            count++;
                        }
                    }

                    var startIndex = i + 4;
                    ws.Cells["B" + startIndex + ":B" + (startIndex + count - 1).ToString()].Merge = true;
                    ws.Cells["B" + startIndex].Value = history.EMP_ID;
                    ws.Cells["C" + startIndex + ":C" + (startIndex + count - 1).ToString()].Merge = true;
                    ws.Cells["C" + startIndex].Value = history.EMP_NAME;
                    ws.Cells["D" + startIndex + ":D" + (startIndex + count - 1).ToString()].Merge = true;
                    ws.Cells["D" + startIndex].Value = history.DEPARTMENT;
                    ws.Cells["S" + startIndex + ":S" + (startIndex + count - 1).ToString()].Merge = true;
                    ws.Cells["S" + startIndex].Value = history.ARCHIEVEMENT;
                    i += count - 1;
                }
                for (int i = 0; i < lstHis.Count; i++)
                {
                    var cntCourse  = 0;
                    var history    = lstHis[i];
                    var startIndex = i + 4;

                    for (int j = 0; j < lstHis.Count; j++)
                    {
                        if (history.COURSE_ID.Equals(lstHis[j].COURSE_ID) && history.EMP_ID.Equals(lstHis[j].EMP_ID))
                        {
                            cntCourse++;
                        }
                    }
                    ws.Cells["E" + startIndex + ":E" + (startIndex + cntCourse - 1).ToString()].Merge = true;
                    ws.Cells["E" + startIndex].Value = history.PERIOD;
                    ws.Cells["Q" + startIndex + ":Q" + (startIndex + cntCourse - 1).ToString()].Merge = true;
                    ws.Cells["Q" + startIndex].Value = history.SCORE;
                    ws.Cells["R" + startIndex + ":R" + (startIndex + cntCourse - 1).ToString()].Merge = true;
                    ws.Cells["R" + startIndex].Value = history.RESULT_LEVEL;
                    i += cntCourse - 1;
                }
                //buffer = package.Stream as MemoryStream;
                Byte[] fileBytes = package.GetAsByteArray();
                Response.ClearContent();
                Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
                Response.AddHeader("content-disposition", "attachment;  filename=" + fileName);
                Response.BinaryWrite(fileBytes);
                Response.Flush();
                Response.End();
            }

            return(RedirectToAction("Index"));
        }
コード例 #16
0
        async Task <HISTORY> IService <HISTORY, int> .Update(HISTORY entity)
        {
            var History = await db.History.Update(entity);

            return(History);
        }
コード例 #17
0
ファイル: Service.cs プロジェクト: hoanvu9495/FaceID
        public void Recognize(/* Bitmap src*/)
        {
            //while (m_isReadCamera)
            //  {
            try
            {
                updatedTracking = false;
                if (m_isFaceTrack && m_bitmap_to_tracking != null)
                {
                    m_faceTracking.update(m_bitmap_to_tracking);
                    //nhan dang tai day
                    if (m_faceTracking.getSize() > 0)
                    {
                        for (int i = 0; i < m_faceTracking.getSize(); i++)
                        {
                            if (!m_faceTracking.getRecognize_status(i))
                            {
                                Bitmap bmp = null;
                                if (m_faceTracking.getFaceImage(i, ref bmp))
                                {
                                    m_faceTracking.setRecognize_status(i, true);
                                    m_time_list.Add(m_faceTracking.getStartTime(i));
                                    m_bitmap_list.Add(bmp);
                                    int n = 0;
                                }
                            }
                        }
                    }
                }
                if (m_bitmap_list.Count > 0)
                {
                    if (m_bitmap_face != null)
                    {
                        m_bitmap_face.Dispose();
                    }
                    m_bitmap_face = (Bitmap)m_bitmap_list[0].Clone();

                    double confident = 0;
                    String name      = "";
                    int    id        = -1;
                    m_face_recog.recognizeFromImage(m_bitmap_face, out confident, out id, out name);
                    m_panel_result.Invoke(new Action(() =>
                    {
                        Graphics g = Graphics.FromHwnd(m_panel_result.Handle);
                        g.DrawImage(m_bitmap_face, 4, 4, m_panel_result.Width - 8, m_panel_result.Height - 8);
                        g.Dispose();
                    }));
                    m_text_confident.Invoke(new Action(() =>
                    {
                        m_text_confident.Text = Math.Floor(confident * 100).ToString();
                    }));
                    m_text_name.Invoke(new Action(() =>
                    {
                        m_text_name.Text = name;
                    }));
                    m_text_time.Invoke(new Action(() =>
                    {
                        m_text_time.Text = m_time_list[0].ToString();
                    }));
                    if (confident < m_nguongphanloai)
                    {
                        name = "Unknown";
                    }
                    //luu tru tai day
                    if (name != "Unknown")
                    {
                        string fullname = DAL_EMPLOYEE.GetFullName(int.Parse(name));
                        m_text_name.Invoke(new Action(() =>
                        {
                            m_text_name.Text = fullname;
                        }));
                        DateTime time = m_time_list[0];
                        String   s    = m_folder_know_Image + "/" + time.Year.ToString();
                        if (!Directory.Exists(s))
                        {
                            Directory.CreateDirectory(s);
                        }
                        s += "/" + time.Month.ToString();
                        if (!Directory.Exists(s))
                        {
                            Directory.CreateDirectory(s);
                        }
                        s += "/" + time.Day.ToString();
                        if (!Directory.Exists(s))
                        {
                            Directory.CreateDirectory(s);
                        }
                        s += "/" + name + "_" + time.Hour.ToString("00") + time.Minute.ToString("00") + time.Second.ToString("00") + ".jpg";
                        //string imgSave = saveImg(/* Bitmap(s), */name);
                        m_bitmap_list[0].Save(s);

                        HISTORY his = new HISTORY();
                        his.ID          = DAL_HISTORY.getIDNew();
                        his.ID_PER      = int.Parse(name);
                        his.IMG_FACE    = s;
                        his.IMG         = s;
                        his.IN_OUT      = false;
                        his.TIME_UPDATE = DateTime.Now;
                        DAL_HISTORY.INSERT(his);
                        if (DAL_ATTENDANCE.Check(int.Parse(name), his.TIME_UPDATE))
                        {
                            ATTENDANCE att = new ATTENDANCE();
                            att.ID       = DAL_ATTENDANCE.getIDNew();
                            att.ID_EMP   = int.Parse(name);
                            att.DATE_ATT = DateTime.Now.Date;
                            att.TIME_IN  = DateTime.Now.TimeOfDay;
                            att.IMG_IN   = s;
                            DAL_ATTENDANCE.INSERT(att);
                        }
                        else
                        {
                            DAL_ATTENDANCE.updateTimeOut(int.Parse(name), s);
                        }
                        //m_bitmap_list[0].Save(s);
                        m_listView_Thumb.Invoke(new Action(() =>
                        {
                            Image img = Image.FromFile(s);
                            String s_ = "0";
                            imageList.Images.Add(s_, img);
                            ListViewItem lvitem = new ListViewItem();
                            lvitem.ImageIndex   = imageList.Images.Count - 1;
                            if (listItemCur.Count > 8)
                            {
                                listItemCur.Dequeue();
                            }
                            listItemCur.Enqueue(lvitem);
                            //lvitem.Text = name + ":" + confident.ToString();
                            lvitem.Text = fullname;
                            m_listView_Thumb.Items.Clear();
                            var rsv = listItemCur.ToArray();
                            for (int i = rsv.Length - 1; i >= 0; i--)
                            {
                                m_listView_Thumb.Items.Insert(0, (ListViewItem)rsv[i]);
                            }
                            m_listView_Thumb.Refresh();
                        }));

                        //add thong tin vao report
                        string[] arr = new string[6];
                        arr[0] = name;
                        arr[1] = fullname;
                        arr[2] = DateTime.Now.ToString("dd-MMM-yy");
                        arr[3] = DateTime.Now.Hour.ToString("00") + ":" + DateTime.Now.Minute.ToString("00");
                        arr[4] = "";
                        arr[5] = "1";
                        ListViewItem itm = new ListViewItem(arr);
                        //kiem tra ra

                        listView_report.Invoke(new Action(() =>
                        {
                            int index = -1;
                            for (int i = 0; i < listView_report.Items.Count; i++)
                            {
                                if (listView_report.Items[i].SubItems[0].Text == name)
                                {
                                    index = i;
                                    break;
                                }
                            }
                            if (index == -1)
                            {
                                listView_report.Items.Add(itm);
                            }
                            else
                            {
                                listView_report.Items[index].SubItems[4].Text = DateTime.Now.Hour.ToString("00") + ":" + DateTime.Now.Minute.ToString("00");
                            }
                        }));
                    }
                    else
                    {
                        DateTime time = m_time_list[0];
                        String   s    = m_folder_unknow_Image + "/" + time.Year.ToString();
                        if (!Directory.Exists(s))
                        {
                            Directory.CreateDirectory(s);
                        }
                        s += "/" + time.Month.ToString();
                        if (!Directory.Exists(s))
                        {
                            Directory.CreateDirectory(s);
                        }
                        s += "/" + time.Day.ToString();
                        if (!Directory.Exists(s))
                        {
                            Directory.CreateDirectory(s);
                        }
                        s += "/" + name + "_" + time.Hour.ToString("00") + time.Minute.ToString("00") + time.Second.ToString("00") + ".jpg";
                        m_bitmap_list[0].Save(s);
                        m_listView_Thumb.Invoke(new Action(() =>
                        {
                            Image img = Image.FromFile(s);
                            String s_ = "0";
                            imageList.Images.Add(s_, img);
                            //imageList.Images.Add()

                            ListViewItem lvitem = new ListViewItem();
                            lvitem.ImageIndex   = imageList.Images.Count - 1;
                            //lvitem.Text = name + ":" + confident.ToString();
                            lvitem.Text = name;
                            lvitem.Name = s;
                            if (listItemCur.Count > 8)
                            {
                                listItemCur.Dequeue();
                            }
                            listItemCur.Enqueue(lvitem);
                            m_listView_Thumb.Items.Clear();
                            var rsv = listItemCur.ToArray();
                            for (int i = rsv.Length - 1; i >= 0; i--)
                            {
                                m_listView_Thumb.Items.Insert(0, (ListViewItem)rsv[i]);
                            }
                            m_listView_Thumb.Refresh();
                        }));
                    }
                    m_time_list.RemoveAt(0);
                    m_bitmap_list.RemoveAt(0);
                }
            }
            catch (Exception ex)
            {
                updatedTracking = true;
            }
            updatedTracking = true;
            //}
            //bmp.Save("face.png");
            //bmp.Dispose();
        }
コード例 #18
0
        public ActionResult Manage(int COURSE_ID = 0, string MENTOR = "", string EMP_ID = "", int PAGE = 1)
        {
            if (Session["Username"] == null)
            {
                return(RedirectToAction("Login", "Home"));
            }
            HISTORY       his     = new HISTORY();
            EMPLOYEE      em      = new EMPLOYEE();
            COURSE        course  = new COURSE();
            List <COURSE> courses = course.Select();

            ViewBag.COURSE = courses;
            var DEPARTMENT = "";

            if (Convert.ToInt32(Session["Role"].ToString()) == 0)
            {
                var isMentee = em.IsMentee(COURSE_ID, Session["Username"].ToString());
                var isMentor = em.IsMentor(COURSE_ID, Session["Username"].ToString());
                if (isMentee == 1 && string.IsNullOrWhiteSpace(EMP_ID))
                {
                    return(RedirectToAction("Index", "Home"));
                }
                else if (isMentor == 1 && string.IsNullOrWhiteSpace(MENTOR))
                {
                    MENTOR = Session["Username"].ToString();
                }
                else
                {
                    EMP_ID = "0";
                    MENTOR = "0";
                }
            }
            if (Convert.ToInt32(Session["Role"].ToString()) == 2)
            {
                DEPARTMENT = Session["Dept"].ToString();
            }
            var lstHis        = his.GetHistorySimple(MENTOR, EMP_ID, COURSE_ID, DEPARTMENT, PAGE);
            var cnt           = his.CountHistorySimpleTotal(MENTOR, EMP_ID, DEPARTMENT, COURSE_ID);
            var listCntCourse = new DataTable();

            listCntCourse.Columns.Add("COURSE_ID");
            listCntCourse.Columns.Add("CNT_COURSE");
            foreach (var item in lstHis)
            {
                var count1 = 0;
                foreach (var item1 in lstHis)
                {
                    if (item.COURSE_ID.Equals(item1.COURSE_ID))
                    {
                        count1++;
                    }
                    else
                    {
                        continue;
                    }
                }
                bool exists2 = listCntCourse.Select().ToList().Exists(row => Convert.ToInt32(row["COURSE_ID"].ToString()) == item.COURSE_ID);

                if (exists2)
                {
                    var rowsToUpdate = listCntCourse.AsEnumerable().Where(r => r.Field <string>("COURSE_ID") == item.COURSE_ID.ToString());

                    foreach (var row in rowsToUpdate)
                    {
                        row.SetField("CNT_COURSE", count1);
                    }
                }
                else
                {
                    DataRow r = listCntCourse.NewRow();
                    r[0] = item.COURSE_ID;
                    r[1] = count1;
                    listCntCourse.Rows.Add(r);
                }
            }
            ViewBag.HIS     = lstHis;
            ViewBag.Total   = cnt;
            ViewBag.CNT     = listCntCourse;
            ViewBag.MENTORS = em.GetListMentor(COURSE_ID);
            ViewBag.MENTEES = em.GetListMentee(COURSE_ID, MENTOR);
            return(View());
        }
コード例 #19
0
        public ActionResult ExportCourse(int COURSE_ID = -1, string MENTOR = "", string EMP_ID = "")
        {
            if (Session["Username"] == null)
            {
                return(RedirectToAction("Login", "Home"));
            }
            var      fileName   = DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx";
            var      template   = Server.MapPath("~/Upload/Template/Export/OJT_EXP2.xlsx");
            HISTORY  his        = new HISTORY();
            EMPLOYEE em         = new EMPLOYEE();
            var      DEPARTMENT = "";

            if (Convert.ToInt32(Session["Role"].ToString()) == 0)
            {
                var isMentee = em.IsMentee(COURSE_ID, Session["Username"].ToString());
                var isMentor = em.IsMentor(COURSE_ID, Session["Username"].ToString());
                if (isMentee == 1 && string.IsNullOrWhiteSpace(EMP_ID))
                {
                    return(RedirectToAction("Index", "Home"));
                }
                else if (isMentor == 1 && string.IsNullOrWhiteSpace(MENTOR))
                {
                    MENTOR = Session["Username"].ToString();
                }
                else
                {
                    EMP_ID = "0";
                    MENTOR = "0";
                }
            }
            if (Convert.ToInt32(Session["Role"].ToString()) == 2)
            {
                DEPARTMENT = Session["Dept"].ToString();
            }
            var lstHis = his.GetHistorySimpleExport(MENTOR, EMP_ID, COURSE_ID, DEPARTMENT);

            using (ExcelPackage package = new ExcelPackage(new FileInfo(template)))
            {
                ExcelWorksheet ws = package.Workbook.Worksheets.FirstOrDefault();
                for (int i = 0; i < lstHis.Count; i++)
                {
                    var history    = lstHis[i];
                    var startIndex = i + 3;
                    ws.Cells["B" + startIndex].Value = history.ROWNUM;
                    ws.Cells["C" + startIndex].Value = history.COURSE;
                    ws.Cells["D" + startIndex].Value = history.ID;
                    ws.Cells["E" + startIndex].Value = history.DEPARTMENT;
                    ws.Cells["F" + startIndex].Value = history.NAME;
                    ws.Cells["G" + startIndex].Value = history.RESULT_LEVEL;
                    ws.Cells["H" + startIndex].Value = history.SCORE;
                }
                for (int i = 0; i < lstHis.Count; i++)
                {
                    int count      = 0;
                    var history    = lstHis[i];
                    var startIndex = i + 3;
                    for (int j = i; j < lstHis.Count; j++)
                    {
                        if (history.COURSE_ID == lstHis[j].COURSE_ID)
                        {
                            count++;
                        }
                    }
                    ws.Cells["C" + startIndex + ":C" + (startIndex + count - 1).ToString()].Merge = true;
                    ws.Cells["C" + startIndex].Value = history.COURSE;
                    i += count - 1;
                }
                Byte[] fileBytes = package.GetAsByteArray();
                Response.ClearContent();
                Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
                Response.AddHeader("content-disposition", "attachment;  filename=" + fileName);
                Response.BinaryWrite(fileBytes);
                Response.Flush();
                Response.End();
            }
            return(RedirectToAction("Manage", "Home"));
        }
コード例 #20
0
        //
        // GET: /Home/

        public ActionResult Index(int COURSE_ID = -1, string MENTOR = "", string EMP_ID = "", int PAGE = 1)
        {
            if (Session["Username"] == null)
            {
                return(RedirectToAction("Login", "Home"));
            }
            var      dept   = "";
            HISTORY  his    = new HISTORY();
            COURSE   course = new COURSE();
            EMPLOYEE em     = new EMPLOYEE();

            List <COURSE> courses = course.Select();

            if (COURSE_ID == -1)
            {
                if (course != null && courses.Count > 0)
                {
                    COURSE_ID = courses[0].ID;
                }
                else
                {
                    COURSE_ID = 0;
                }
            }
            if (Convert.ToInt32(Session["Role"].ToString()) == 0)
            {
                var isMentee = em.IsMentee(COURSE_ID, Session["Username"].ToString());
                var isMentor = em.IsMentor(COURSE_ID, Session["Username"].ToString());
                if (isMentee == 1 && string.IsNullOrWhiteSpace(EMP_ID))
                {
                    EMP_ID = Session["Username"].ToString();
                    MENTOR = em.GetListMentor(COURSE_ID).FirstOrDefault().ID;
                }
                else if (isMentor == 1 && string.IsNullOrWhiteSpace(MENTOR))
                {
                    MENTOR = Session["Username"].ToString();
                }
                else
                {
                    EMP_ID = "0";
                    MENTOR = "0";
                }
            }
            if (Convert.ToInt32(Session["Role"].ToString()) == 2)
            {
                dept = Session["Dept"].ToString();
            }

            var lstHis        = his.GetHistory(MENTOR, EMP_ID, COURSE_ID, dept, PAGE);
            var lstCntEm      = new DataTable();
            var listCntCourse = new DataTable();

            lstCntEm.Columns.Add("EMP_ID");
            lstCntEm.Columns.Add("CNT_EMP");
            listCntCourse.Columns.Add("EMP_ID");
            listCntCourse.Columns.Add("COURSE_ID");
            listCntCourse.Columns.Add("CNT_COURSE");
            foreach (var item in lstHis)
            {
                var count1 = 0;
                var count2 = 0;
                foreach (var item1 in lstHis)
                {
                    if (item.EMP_ID.Equals(item1.EMP_ID))
                    {
                        count1++;
                        if (item.COURSE_ID.Equals(item1.COURSE_ID))
                        {
                            count2++;
                        }
                    }
                    else
                    {
                        continue;
                    }
                }
                bool exists1 = lstCntEm.Select().ToList().Exists(row => row["EMP_ID"].ToString().ToUpper() == item.EMP_ID);
                bool exists2 = listCntCourse.Select().ToList().Exists(row => row["EMP_ID"].ToString().ToUpper() == item.EMP_ID &&
                                                                      Convert.ToInt32(row["COURSE_ID"].ToString()) == item.COURSE_ID);
                if (exists1)
                {
                    var rowsToUpdate = lstCntEm.AsEnumerable().Where(r => r.Field <string>("EMP_ID") == item.EMP_ID);

                    foreach (var row in rowsToUpdate)
                    {
                        row.SetField("CNT_EMP", count1);
                    }
                }
                else
                {
                    DataRow r = lstCntEm.NewRow();
                    r[0] = item.EMP_ID;
                    r[1] = count1;
                    lstCntEm.Rows.Add(r);
                }
                if (exists2)
                {
                    var rowsToUpdate = listCntCourse.AsEnumerable().Where(r => r.Field <string>("EMP_ID") == item.EMP_ID &&
                                                                          r.Field <string>("COURSE_ID") == item.COURSE_ID.ToString());

                    foreach (var row in rowsToUpdate)
                    {
                        row.SetField("CNT_COURSE", count2);
                    }
                }
                else
                {
                    DataRow r = listCntCourse.NewRow();
                    r[0] = item.EMP_ID;
                    r[1] = item.COURSE_ID;
                    r[2] = count2;
                    listCntCourse.Rows.Add(r);
                }
            }
            // var countEmp = his.GetCountByEmp(MENTOR, EMP_ID, COURSE_ID, dept);
            //var countCourse = his.GetCountByCourse(MENTOR, EMP_ID, COURSE_ID, dept);

            ViewBag.COURSE        = courses;
            ViewBag.HIS           = lstHis;
            ViewBag.CNT_EMP       = lstCntEm;
            ViewBag.CNT_COURSE    = listCntCourse;
            ViewBag.TOTAL         = his.CountHistory(MENTOR, EMP_ID, COURSE_ID, dept);
            ViewBag.MENTORS       = em.GetListMentor(COURSE_ID);
            ViewBag.MENTEES       = em.GetListMentee(COURSE_ID, MENTOR);
            ViewBag.SELECT_COURSE = COURSE_ID;
            return(View());
        }
コード例 #21
0
 public HistoryView(HISTORY h)
 {
     H = h;
 }
コード例 #22
0
 /// <summary>
 /// There are no comments for HISTORY in the schema.
 /// </summary>
 public void AddToHISTORY(HISTORY hISTORY)
 {
     base.AddObject("HISTORY", hISTORY);
 }