Exemplo n.º 1
0
 private void ListOffice()
 {
     try
     {
         grdList.Rows.Clear();
         OfficeDB      dbrecord = new OfficeDB();
         List <office> Offices  = dbrecord.getOffices();
         foreach (office off in Offices)
         {
             grdList.Rows.Add(off.OfficeID, off.name, off.RegionID + "-" + off.RegionName,
                              off.Address1, off.Address2, off.Address3, off.Address4,
                              ComboFIll.getStatusString(off.status));
         }
     }
     catch (Exception)
     {
         MessageBox.Show("Error in Office listing");
     }
     enableBottomButtons();
     pnlOfficeList.Visible = true;
 }
Exemplo 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());
            }
        }