Esempio n. 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)
     {
     }
 }
Esempio n. 2
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());
            }
        }