Beispiel #1
0
 void leavetype()
 {
     option = 1;
     try
     {
         grdList.Rows.Clear();
         LeaveSettingsdb record    = new LeaveSettingsdb();
         List <Leave>    leavetype = record.getLeaveTypeList();
         foreach (Leave leave in leavetype)
         {
             grdList.Rows.Add();
             grdList.Rows[grdList.RowCount - 1].Cells["lSerialNo"].Value         = grdList.Rows.Count;
             grdList.Rows[grdList.RowCount - 1].Cells["LeaveID"].Value           = leave.leaveID;
             grdList.Rows[grdList.RowCount - 1].Cells["lDescription"].Value      = leave.description;
             grdList.Rows[grdList.RowCount - 1].Cells["lMaxSanctionLimit"].Value = leave.MaxAccrual;
             grdList.Rows[grdList.RowCount - 1].Cells["lSanctionType"].Value     = strstatus(leave.SanctionType);
             grdList.Rows[grdList.RowCount - 1].Cells["lGender"].Value           = leave.Gender;
             grdList.Rows[grdList.RowCount - 1].Cells["lRowID"].Value            = leave.rowid;
             grdList.Rows[grdList.RowCount - 1].Cells["DaysAhead"].Value         = leave.ahead;
             grdList.Rows[grdList.RowCount - 1].Cells["DaysDelayed"].Value       = leave.Delay;
             grdList.Rows[grdList.RowCount - 1].Cells["Carryforward"].Value      = getcarryforwardstr(leave.CarryForward);
         }
         setvisiblity(option);
         closeAllPanels();
         pnlLeaveList.Visible = true;
         enableBottomButtons();
         pnlBottomButtons.Visible = true;
     }
     catch (Exception ex)
     {
     }
 }
Beispiel #2
0
        private Dictionary <string, string> getLeaveIDList()
        {
            Dictionary <string, string> idict = new Dictionary <string, string>();
            LeaveSettingsdb             lvDB  = new LeaveSettingsdb();
            List <Leave> lvlist = lvDB.getLeaveTypeList();

            foreach (Leave lv in lvlist)
            {
                idict.Add(lv.leaveID, lv.description);
            }
            return(idict);
        }
Beispiel #3
0
        private DataGridView getDynamicGridRows(DataGridView grdlistShowDemo)
        {
            try
            {
                List <leaveob> lvaob = new List <leaveob>();
                leaveob        lva   = new leaveob();
                cmbListYear.SelectedItem = cmbLeaveYear.SelectedItem;
                List <employeeposting> EMPList = LeaveOBDB.getEmployeePostingListForLeaveOB();
                grdlistShowDemo.Rows.Clear();
                foreach (employeeposting empPost in EMPList)
                {
                    if (empPost.empID == 2)
                    {
                        int a = 0;
                    }
                    int           bal        = 0;
                    int           leavetaken = 0;
                    int           total      = 0;
                    int           val        = 0;
                    List <string> strList    = new List <string>();
                    strList.Add(empPost.empID.ToString());
                    strList.Add(empPost.empName);
                    strList.Add(empPost.officeName);
                    LeaveApproveDB lvAppDB = new LeaveApproveDB();
                    LeaveOBDB      lobDB   = new LeaveOBDB();
                    List <leaveob> lobList = lobDB.getLeaveOBDetails(empPost.empID.ToString(), Convert.ToInt32(cmbListYear.SelectedItem));
                    grdlistShowDemo.Rows.Add();
                    grdlistShowDemo.Rows[grdlistShowDemo.RowCount - 1].Cells["EmployeeID"].Value   = empPost.empID.ToString();
                    grdlistShowDemo.Rows[grdlistShowDemo.RowCount - 1].Cells["EmployeeName"].Value = empPost.empName;
                    grdlistShowDemo.Rows[grdlistShowDemo.RowCount - 1].Cells["Office"].Value       = empPost.officeName;
                    DataGridViewColumnCollection collection = grdlistShowDemo.Columns;
                    List <leaveob> officemax   = lobDB.getOfficeMax(empPost.officeID);
                    int            prevYear    = Convert.ToInt32(cmbListYear.SelectedItem);
                    List <leaveob> lobListPrev = lobDB.getLeaveOBDetailsnew(empPost.empID.ToString(), prevYear);

                    //Gives Carry Forward LEave Types
                    LeaveSettingsdb lvDB       = new LeaveSettingsdb();
                    List <Leave>    carryAvail = lvDB.getLeaveTypeList().Where(w => w.CarryForward == 1).ToList();

                    foreach (DataGridViewColumn col in collection)
                    {
                        leavetaken = 0;
                        string leaveColID = (LeaveDict.FirstOrDefault(pair => col.Name == pair.Key.Replace(" ", ""))).Key;
                        if (leaveColID != null)
                        {
                            leaveob             lob      = lobList.FirstOrDefault(listItem => listItem.LeaveID == leaveColID);
                            List <leaveapprove> lvremain = lobDB.getLeaveRemainYearWise(empPost.empID.ToString(), leaveColID, prevYear);
                            foreach (leaveapprove lv in lvremain)
                            {
                                leavetaken += lv.leavepending;
                                leavetaken += 1;
                            }
                            int     prevLVAvail = 0;
                            leaveob lobPrev     = lobListPrev.FirstOrDefault(leave => leave.LeaveID == leaveColID);
                            if (lobPrev != null)
                            {
                                prevLVAvail = lobPrev.LeaveCount;
                            }
                            bal = prevLVAvail - leavetaken;

                            leaveob offmax = officemax.FirstOrDefault(leave => leave.LeaveID == leaveColID);
                            if (offmax != null)
                            {
                                total = bal + offmax.maxdays;
                            }
                            else
                            {
                                total = bal;
                            }
                            if (lob != null)
                            {
                                Leave lvCarry = carryAvail.FirstOrDefault(lv => lv.leaveID == leaveColID);

                                if (lvCarry != null) // carry forward 1
                                {
                                    //int finaltotal = total + lob.LeaveCount;
                                    if (lvCarry.MaxAccrual > total)
                                    {
                                        grdlistShowDemo.Rows[grdlistShowDemo.RowCount - 1].Cells[col.Name].Value = total;
                                        val = total;
                                    }
                                    else
                                    {
                                        grdlistShowDemo.Rows[grdlistShowDemo.RowCount - 1].Cells[col.Name].Value = lvCarry.MaxAccrual;
                                        val = lvCarry.MaxAccrual;
                                    }
                                }
                                else
                                {
                                    if (offmax != null)
                                    {
                                        grdlistShowDemo.Rows[grdlistShowDemo.RowCount - 1].Cells[col.Name].Value = offmax.maxdays;
                                        val = offmax.maxdays;
                                    }
                                    else
                                    {
                                        grdlistShowDemo.Rows[grdlistShowDemo.RowCount - 1].Cells[col.Name].Value = lob.LeaveCount;
                                        val = lob.LeaveCount;
                                    }
                                }
                            }
                            else
                            {
                                Leave lvCarry = carryAvail.FirstOrDefault(lv => lv.leaveID == leaveColID);

                                if (lvCarry != null) // carry forward 1
                                {
                                    if (lvCarry.MaxAccrual > total)
                                    {
                                        grdlistShowDemo.Rows[grdlistShowDemo.RowCount - 1].Cells[col.Name].Value = total;
                                        val = total;
                                    }
                                    else
                                    {
                                        grdlistShowDemo.Rows[grdlistShowDemo.RowCount - 1].Cells[col.Name].Value = lvCarry.MaxAccrual;
                                        val = lvCarry.MaxAccrual;
                                    }
                                }
                                else
                                {
                                    if (offmax != null)
                                    {
                                        grdlistShowDemo.Rows[grdlistShowDemo.RowCount - 1].Cells[col.Name].Value = offmax.maxdays;
                                        val = offmax.maxdays;
                                    }
                                    else
                                    {
                                        grdlistShowDemo.Rows[grdlistShowDemo.RowCount - 1].Cells[col.Name].Value = 0;
                                        val = 0;
                                    }
                                }
                            }
                            lva            = new leaveob();
                            lva.EmployeeID = empPost.empID.ToString();
                            lva.LeaveID    = leaveColID;
                            lva.LeaveCount = val;
                            lvaob.Add(lva);
                        }
                    }
                }
                insert(lvaob);
            }
            catch (Exception ex)
            {
            }
            return(grdlistShowDemo);
        }