Beispiel #1
0
 private void grdList_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
 {
     ////MessageBox.Show("grdList_CellDoubleClick()");
     try
     {
         if (e.RowIndex < 0)
         {
             return;
         }
         string       offName = grdList.Rows[e.RowIndex].Cells["OfficeID"].Value.ToString();
         string       offdesc = grdList.Rows[e.RowIndex].Cells["Office"].Value.ToString();
         string       stat    = grdList.Columns[e.ColumnIndex].Name;
         AttendanceDB Adb     = new AttendanceDB();
         dgvAttendenceDetails.Rows.Clear();
         List <attendance> emplst = Adb.getEmployeeoffceList(offName, stat);
         foreach (attendance emp in emplst)
         {
             dgvAttendenceDetails.Rows.Add();
             dgvAttendenceDetails.Rows[dgvAttendenceDetails.RowCount - 1].Cells["EmployeeID"].Value   = Convert.ToInt32(emp.EmployeeID);
             dgvAttendenceDetails.Rows[dgvAttendenceDetails.RowCount - 1].Cells["EmployeeName"].Value = emp.EmployeeName;
             dgvAttendenceDetails.Rows[dgvAttendenceDetails.RowCount - 1].Cells["Status"].Value       = emp.AttendenceStatus;
             dgvAttendenceDetails.Rows[dgvAttendenceDetails.RowCount - 1].Cells["Office"].Value       = emp.officeName;
         }
         closeAllPanels();
         pnlLeaveDetailOuter.Visible = true;
         pnlLeaveDetailInner.Visible = true;
     }
     catch (Exception ex)
     {
     }
 }
Beispiel #2
0
 public int getLastID()
 {
     attendance   = new Attendance();
     attendanceDB = new AttendanceDB();
     attendanceDB.selectLastID(attendance);
     return(attendance.getID());
 }
Beispiel #3
0
 // Get Random Module
 private int GetRandomModuleId(AttendanceDB Context)
 {
     return(Context.Modules.Select(s => new { s.id, order = Guid.NewGuid() })
            .OrderBy(o => o.order)
            .Select(s => s.id)
            .First());
 }
Beispiel #4
0
 private void btnSave_Click_1(object sender, EventArgs e)
 {
     try
     {
         foreach (DataGridViewRow cb in grdList.Rows)
         {
             if (cb.Cells[3].Value == null)
             {
                 MessageBox.Show("Please enter attendence for all Employees!!!");
                 return;
             }
         }
         attendance        att        = new attendance();
         List <attendance> attlstnew  = new List <attendance>();
         List <attendance> attlstupdt = new List <attendance>();
         AttendanceDB      docDB      = new AttendanceDB();
         foreach (DataGridViewRow dgvrw in grdList.Rows)
         {
             if (changedval.ContainsKey(dgvrw.Cells[1].Value.ToString()))
             {
                 if (Initval.ContainsKey(dgvrw.Cells[1].Value.ToString()))
                 {
                     att                  = new attendance();
                     att.EmployeeID       = dgvrw.Cells[1].Value.ToString();
                     att.AttendenceStatus = dgvrw.Cells[3].Value.ToString();
                     attlstupdt.Add(att);
                 }
                 else
                 {
                     att                  = new attendance();
                     att.EmployeeID       = dgvrw.Cells[1].Value.ToString();
                     att.AttendenceStatus = dgvrw.Cells[3].Value.ToString();
                     attlstnew.Add(att);
                 }
             }
         }
         DateTime dt = UpdateTable.getSQLDateTime();
         if (Main.itemPriv[2])
         {
             dt = dtpdate.Value;
         }
         if (docDB.UpdateAttendance(attlstupdt, attlstnew, empstatuslist, dt))
         {
             MessageBox.Show("Attendance Status Updated");
             changedval.Clear();
             Initval.Clear();
             ListEmployee();
         }
         else
         {
             MessageBox.Show("Error Updating Attendance Status");
         }
     }
     catch (Exception)
     {
         MessageBox.Show("Failed Adding / Editing User Data");
     }
 }
Beispiel #5
0
    public void insert(int month, int year, string locationName)
    {
        locationControl = new LocationControl();
        attendance      = new Attendance();
        attendanceDB    = new AttendanceDB();
        int locationID = locationControl.getID(locationName);

        attendance.setMonth(month);
        attendance.setYear(year);
        attendance.setLocationID(locationID);
        attendanceDB.insert(attendance);
    }
Beispiel #6
0
        public Task_13ViewModel()
        {
            InitViewProperties();
            InitCommands();

            InformationData = new AttendanceDB();

            InformationData.Init();
            InformationData.SetDefaultStructure();
            InformationData.ReloadTables();
            OnPropertyChanged(nameof(InformationData));
        }
Beispiel #7
0
    public int getID(int month, int year, string locationName)
    {
        locationControl = new LocationControl();
        attendance      = new Attendance();
        attendanceDB    = new AttendanceDB();
        int locationID = locationControl.getID(locationName);

        attendance.setMonth(month);
        attendance.setYear(year);
        attendance.setLocationID(locationID);
        attendanceDB.selectID(attendance);
        return(attendance.getID());
    }
Beispiel #8
0
        public ActionResult FileUpload(HttpPostedFileBase file)
        {
            if (ModelState.IsValid)
            {
                if (file == null)
                {
                    ModelState.AddModelError("File", "Please Upload Your file");
                }
                else if (file.ContentLength > 0)
                {
                    int      MaxContentLength      = 1024 * 1024 * 3; //3 MB
                    string[] AllowedFileExtensions = new string[] { ".jpg", ".gif", ".png", ".pdf" };

                    if (!AllowedFileExtensions.Contains(file.FileName.Substring(file.FileName.LastIndexOf('.'))))
                    {
                        ModelState.AddModelError("File", "Please file of type: " + string.Join(", ", AllowedFileExtensions));
                    }

                    else if (file.ContentLength > MaxContentLength)
                    {
                        ModelState.AddModelError("File", "Your file is too large, maximum allowed size is: " + MaxContentLength + " MB");
                    }
                    else
                    {
                        using (AttendanceDB ucok = new AttendanceDB())
                        {
                            var        userId       = User.Identity.GetUserId();
                            var        fileName     = Path.GetFileName(file.FileName);
                            var        pathdatabase = Path.Combine(("~/Content/Upload"), fileName);
                            var        path         = Path.Combine(Server.MapPath("~/Content/Upload"), fileName);
                            var        fileSize     = file.ContentLength;
                            FileUpload jin          = new FileUpload {
                                FileName = fileName, FilePath = pathdatabase, UserId = userId
                            };



                            ViewBag.Message = "File uploaded successfully";
                            ucok.FileUploads.Add(jin);
                            ucok.SaveChanges();
                            file.SaveAs(path);
                            ModelState.Clear();
                        }


                        //TO:DO
                    }
                }
            }
            return(View());
        }
Beispiel #9
0
    public bool checkIfLocationAttendanceSubmitted(int month, int year, string locationName)
    {
        locationControl = new LocationControl();
        attendance      = new Attendance();
        attendanceDB    = new AttendanceDB();
        int locationID = locationControl.getID(locationName);

        attendance.setMonth(month);
        attendance.setYear(year);
        attendance.setLocationID(locationID);
        bool flag = attendanceDB.checkIfLocationAttendanceSubmitted(attendance);

        return(flag);
    }
Beispiel #10
0
    public void fillDataGridViewLocationAttendance(DataGridView dataGridView, string locationName, int month, int year)
    {
        locationControl = new LocationControl();
        attendance      = new Attendance();
        attendanceDB    = new AttendanceDB();
        int locationID = locationControl.getID(locationName);

        attendance.setLocationID(locationID);
        attendance.setMonth(month);
        attendance.setYear(year);
        SqlDataAdapter adapter   = attendanceDB.fillDataGridViewLocationAttendance(attendance);
        DataTable      dataTable = new DataTable();

        adapter.Fill(dataTable);
        dataGridView.DataSource = dataTable;
    }
Beispiel #11
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
#if DEBUG
            Database.SetInitializer(new AppplicationDBInitializer());
            ApplicationDbContext db = new ApplicationDbContext();
            db.Database.Initialize(true);

            Database.SetInitializer(new AttendDbInitializer());
            AttendanceDB att_db = new AttendanceDB();
            att_db.Database.Initialize(true);
#endif
            GlobalConfiguration.Configure(WebApiConfig.Register);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
        }
 public AttendanceTrackerRepo(AttendanceDB context)
 {
     this.context = context;
 }
Beispiel #13
0
        private void ListEmployee()
        {
            try
            {
                grdList.Visible = true;
                grdList.Rows.Clear();
                AttendanceDB      dbrecord     = new AttendanceDB();
                List <attendance> emplist      = new List <attendance>();
                List <attendance> empleavelist = new List <attendance>();
                List <attendance> empbiolist   = new List <attendance>();
                List <attendance> empMRlist    = new List <attendance>();
                int opt = 0;
                empstatuslist = new List <attendance>();
                if (Main.itemPriv[2])
                {
                    if (cmbfilterOffice.SelectedIndex != -1)
                    {
                        string officeid = ((Structures.ComboBoxItem)cmbfilterOffice.SelectedItem).HiddenValue;
                        emplist = dbrecord.getEmployeeListforoffice(officeid).OrderBy(x => x.EmployeeName).ToList();
                        if (dtpdate.Value.Date <= UpdateTable.getSQLDateTime().Date)
                        {
                            empstatuslist = dbrecord.getEmployeestatusListforoffice(officeid, dtpdate.Value);
                            if (empstatuslist.Count == 0)
                            {
                                empleavelist = dbrecord.getEmployeeLeaveList(dtpdate.Value);
                                empbiolist   = dbrecord.getEmployeeBiometricList(dtpdate.Value);
                                empMRlist    = dbrecord.getMrEmployeeList(dtpdate.Value);
                            }
                        }
                        else if (dtpdate.Value.Date > UpdateTable.getSQLDateTime().Date)
                        {
                            pnlEditButtons.Visible = false;
                            MessageBox.Show("Please select the date equal to or less than today!!!");
                            return;
                        }
                    }
                }
                else
                {
                    emplist       = dbrecord.getEmployeeList().OrderBy(x => x.EmployeeName).ToList();
                    empstatuslist = dbrecord.getEmployeestatusListforoffice(emplOfficeID, UpdateTable.getSQLDateTime());
                    if (empstatuslist.Count == 0)
                    {
                        empleavelist = dbrecord.getEmployeeLeaveList(UpdateTable.getSQLDateTime());
                        empbiolist   = dbrecord.getEmployeeBiometricList(UpdateTable.getSQLDateTime());
                        empMRlist    = dbrecord.getMrEmployeeList(UpdateTable.getSQLDateTime());
                    }
                }

                foreach (attendance elst in emplist)
                {
                    grdList.Rows.Add();
                    int kount = grdList.RowCount;
                    grdList.Rows[kount - 1].Cells["RowID"].Value        = kount;
                    grdList.Rows[kount - 1].Cells["EmployeeID"].Value   = Convert.ToInt32(elst.EmployeeID);
                    grdList.Rows[kount - 1].Cells["EmployeeName"].Value = elst.EmployeeName;
                    DataGridViewComboBoxCell cmbAttendanceStatus = (DataGridViewComboBoxCell)(grdList.Rows[kount - 1].Cells["AttendanceStatus"]);
                    CatalogueValueDB.fillCatalogValueGridViewComboNew(cmbAttendanceStatus, "AttendanceStatus");
                    attendance empstatlst = empstatuslist.FirstOrDefault(x => x.EmployeeID == elst.EmployeeID);
                    if (empstatlst == null)
                    {
                        attendance emplvlst  = empleavelist.FirstOrDefault(x => x.EmployeeID == elst.EmployeeID);
                        attendance empbiolst = empbiolist.FirstOrDefault(x => x.EmployeeID == elst.EmployeeID);
                        attendance empMRlst  = empMRlist.FirstOrDefault(x => x.EmployeeID == elst.EmployeeID);
                        if (emplvlst != null)
                        {
                            grdList.Rows[kount - 1].Cells["AttendanceStatus"].Value = "Leave";
                            Initval.Add(emplvlst.EmployeeID, "Leave");
                            changedval.Add(emplvlst.EmployeeID, "Leave");
                        }
                        else
                        {
                            if (empbiolst != null)
                            {
                                grdList.Rows[kount - 1].Cells["AttendanceStatus"].Value = "Present";
                                Initval.Add(empbiolst.EmployeeID, "Present");
                                changedval.Add(empbiolst.EmployeeID, "Present");
                            }
                            else if (empMRlst != null)
                            {
                                grdList.Rows[kount - 1].Cells["AttendanceStatus"].Value = "LocalTravel";
                                Initval.Add(empMRlst.EmployeeID, "LocalTravel");
                                changedval.Add(empMRlst.EmployeeID, "LocalTravel");
                            }
                        }
                    }
                    else
                    {
                        grdList.Rows[kount - 1].Cells["AttendanceStatus"].Value = empstatlst.AttendenceStatus;
                        Initval.Add(empstatlst.EmployeeID, empstatlst.AttendenceStatus);
                    }
                }
                pnlEditButtons.Visible = false;
                if (!Main.itemPriv[2])
                {
                    if (grdList.RowCount > 0 && UpdateTable.getSQLDateTime().Hour < 13)
                    {
                        pnlEditButtons.Visible = true;
                    }
                }
                else if (grdList.RowCount > 0)
                {
                    pnlEditButtons.Visible = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this.ToString() + "-" + System.Reflection.MethodBase.GetCurrentMethod().Name + "() : Error");
            }
            enableBottomButtons();
            pnlMenuList.Visible = true;
        }
 public ModulesController()
 {
     _attendanceDb = new AttendanceDB();
 }
Beispiel #15
0
        private void ListFilteredLeave(int opt, string officeID)
        {
            try
            {
                DateTime dttemp = DateTime.Now;
                grdList.Rows.Clear();
                grdList.Columns.Clear();

                AttendanceDB Adb      = new AttendanceDB();
                OfficeDB     dbrecord = new OfficeDB();
                grdList.Columns.Add("OfficeID", "OfficeID");
                grdList.Columns.Add("Office", "Office");
                grdList.Columns["OfficeID"].Frozen  = true;
                grdList.Columns["OfficeID"].Visible = false;
                grdList.Columns["Office"].Frozen    = true;
                List <catalogue> statuslist = Adb.getCatalogues();
                List <office>    Offices    = dbrecord.getOffices().Where(w => w.status == 1).ToList();
                foreach (catalogue stat in statuslist)
                {
                    grdList.Columns.Add(stat.catalogueID, stat.description);
                    grdList.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
                    //////grdList.Columns.cell = "Double click for details";
                }
                grdList.Columns.Add("Total", "Total");
                grdList.Columns["Total"].Width = 70;
                List <attendance> emptotlst = Adb.getEmployeeoffceList("Total", "Total");
                foreach (office off in Offices)
                {
                    if (off.RegionID.Equals("Overseas"))
                    {
                        continue;
                    }
                    grdList.Rows.Add();
                    grdList.Rows[grdList.Rows.Count - 1].Cells["OfficeID"].Value = off.OfficeID;
                    grdList.Rows[grdList.Rows.Count - 1].Cells["Office"].Value   = off.name;
                    List <attendance> emplst = emptotlst.Where(x => x.officeID == off.OfficeID).ToList();
                    int colcount             = 0;
                    foreach (DataGridViewColumn cl in grdList.Columns)
                    {
                        if (cl.Name != "Office" && cl.Name != "OfficeID")
                        {
                            int emplstcount = emplst.Where(x => x.AttendenceStatus == cl.Name).Count();
                            grdList.Rows[grdList.Rows.Count - 1].Cells[cl.Name].Value       = emplstcount;
                            grdList.Rows[grdList.Rows.Count - 1].Cells[cl.Name].ToolTipText = "Double click for details";
                            colcount += Convert.ToInt32(grdList.Rows[grdList.Rows.Count - 1].Cells[cl.Name].Value);
                        }
                    }
                    grdList.Rows[grdList.RowCount - 1].Cells["Total"].Value       = colcount;
                    grdList.Rows[grdList.RowCount - 1].Cells["Total"].ToolTipText = "Double click for details";
                }

                grdList.Rows.Add();
                grdList.Rows[grdList.Rows.Count - 1].Cells["OfficeID"].Value = "Total";
                grdList.Rows[grdList.Rows.Count - 1].Cells["Office"].Value   = "Total";
                foreach (DataGridViewColumn dgc in grdList.Columns)
                {
                    int rowcount = 0;
                    foreach (DataGridViewRow dgr in grdList.Rows)
                    {
                        if (dgc.Name != "Office" && dgc.Name != "OfficeID")
                        {
                            rowcount += Convert.ToInt32(dgr.Cells[dgc.Name].Value);
                        }
                    }
                    if (dgc.Name != "Office" && dgc.Name != "OfficeID")
                    {
                        grdList.Rows[grdList.RowCount - 1].Cells[dgc.Name].Value       = rowcount;
                        grdList.Rows[grdList.RowCount - 1].Cells[dgc.Name].ToolTipText = "Double click for details";
                    }
                }

                grdList.CurrentCell.Selected = false;
                grdList.Visible    = true;
                pnlgrdList.Visible = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error 3 : ListFilteredLeave() - " + ex.ToString());
            }
        }
Beispiel #16
0
 public StudentsController()
 {
     _attendanceDb = new AttendanceDB();
 }
        private void ListFilteredAttendanceList(DateTime month, string officeID)
        {
            try
            {
                grdList.Rows.Clear();
                grdList.Columns.Clear();
                AttendanceDB      Adb     = new AttendanceDB();
                List <DateTime>   dates   = GetDates(dtMonth.Value.Month, dtMonth.Value.Year); // get days for selected month and year
                List <attendance> AttStat = Adb.getEmployeeAttendanceList(month, officeID);
                if (AttStat.Count <= 0)
                {
                    MessageBox.Show("No data to show");
                    return;
                }
                grdList.Columns.Add("Slno", "Slno");
                grdList.Columns.Add("EmployeeID", "ID");
                grdList.Columns.Add("EmployeeName", "Employee Name");
                grdList.Columns.Add("Office", "Office");
                grdList.Columns["Slno"].Frozen         = true;
                grdList.Columns["EmployeeID"].Frozen   = true;
                grdList.Columns["EmployeeName"].Frozen = true;
                grdList.Columns["Office"].Frozen       = true;
                grdList.Columns["Slno"].Width          = 30;
                grdList.Columns["EmployeeID"].Width    = 50;
                foreach (DateTime dt in dates)
                {
                    //if (dt.Date < DateTime.Now)
                    //{
                    grdList.Columns.Add(dt.Date.ToString("yyyy-MM-dd"), dt.Date.ToString("dd"));
                    grdList.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
                    grdList.Columns[dt.Date.ToString("yyyy-MM-dd")].Width = 25;
                    //}
                }
                var emplst = AttStat.GroupBy(G => G.EmployeeID).Select(A => new
                {
                    EmployeeID   = A.Key,
                    EmployeeName = A.First().EmployeeName,
                    officeName   = A.First().officeName
                });
                foreach (var att in emplst)
                {
                    grdList.Rows.Add();
                    grdList.Rows[grdList.RowCount - 1].Cells["Slno"].Value         = grdList.RowCount;
                    grdList.Rows[grdList.RowCount - 1].Cells["EmployeeID"].Value   = Convert.ToInt32(att.EmployeeID);
                    grdList.Rows[grdList.RowCount - 1].Cells["EmployeeName"].Value = att.EmployeeName;
                    grdList.Rows[grdList.RowCount - 1].Cells["Office"].Value       = att.officeName;

                    foreach (DataGridViewColumn dgvc in grdList.Columns)
                    {
                        List <attendance> lst = AttStat.Where(x => x.EmployeeID == att.EmployeeID).ToList();
                        foreach (attendance lt in lst)
                        {
                            if (dgvc.Name == lt.StatusDate.ToString("yyyy-MM-dd"))
                            {
                                grdList.Rows[grdList.RowCount - 1].Cells[dgvc.Name].Value = getAtstatus(lt.AttendenceStatus);
                            }
                        }
                    }
                }

                if (grdList.Rows.Count != 0 && Main.itemPriv[1] == true && (Main.itemPriv[2] == true || Main.itemPriv[3] == true))
                {
                    btnExportToExcel.Visible = true;
                }
                else
                {
                    btnExportToExcel.Visible = false;
                }
                grdList.Visible    = true;
                pnlgrdList.Visible = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error 3 : ListFilteredAttendanceListLeave() - " + ex.ToString());
            }
        }