示例#1
0
        private void fillGriddetailRow()
        {
            try
            {
                if (lblEmployeeiD.Text.Trim().Length == 0)
                {
                    MessageBox.Show("Error : Employee ID is Empty");
                    return;
                }
                if (cmbLeaveYear.SelectedIndex == -1)
                {
                    MessageBox.Show("select Leave Year");
                    return;
                }
                grdEmpWiseLeaveOB.Rows.Clear();
                LeaveOBDB      lobDB   = new LeaveOBDB();
                List <leaveob> lobList = lobDB.getLeaveOBDetails(lblEmployeeiD.Text, Convert.ToInt32(cmbLeaveYear.SelectedItem));

                foreach (var item in LeaveDict)
                {
                    string leaveGender = LeaveOBDB.getGenderForLeaveType(item.Key);
                    string empGender   = LeaveOBDB.getGenderForEmployee(lblEmployeeiD.Text);
                    if (leaveGender.Equals("All") || leaveGender.Equals(empGender))
                    {
                        grdEmpWiseLeaveOB.Rows.Add();
                        leaveob lob = lobList.FirstOrDefault(leave => leave.LeaveID == item.Key);
                        grdEmpWiseLeaveOB.Rows[grdEmpWiseLeaveOB.RowCount - 1].Cells["LeaveID"].Value     = item.Key;
                        grdEmpWiseLeaveOB.Rows[grdEmpWiseLeaveOB.RowCount - 1].Cells["Description"].Value = item.Value;
                        if (lob != null)
                        {
                            grdEmpWiseLeaveOB.Rows[grdEmpWiseLeaveOB.RowCount - 1].Cells["LeaveCount"].Value = lob.LeaveCount;
                        }
                        else
                        {
                            grdEmpWiseLeaveOB.Rows[grdEmpWiseLeaveOB.RowCount - 1].Cells["LeaveCount"].Value = "0";
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error in Filling Leave OB Detail GridView");
            }
        }
示例#2
0
        private DataGridView getDynamicGridRows(DataGridView grdlistShowDemo)
        {
            try
            {
                List <employeeposting> EMPList = LeaveOBDB.getEmployeePostingListForLeaveOB();
                foreach (employeeposting empPost in EMPList)
                {
                    List <string> strList = new List <string>();
                    strList.Add(empPost.empID.ToString());
                    strList.Add(empPost.empName);
                    strList.Add(empPost.officeName);

                    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;
                    foreach (DataGridViewColumn col in collection)
                    {
                        string leaveColID = (LeaveDict.FirstOrDefault(pair => col.Name == pair.Key.Replace(" ", ""))).Key;
                        if (leaveColID != null)
                        {
                            leaveob lob = lobList.FirstOrDefault(listItem => listItem.LeaveID == leaveColID);
                            if (lob != null)
                            {
                                grdlistShowDemo.Rows[grdlistShowDemo.RowCount - 1].Cells[col.Name].Value = lob.LeaveCount;
                            }
                            else
                            {
                                grdlistShowDemo.Rows[grdlistShowDemo.RowCount - 1].Cells[col.Name].Value = 0;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
            }
            return(grdlistShowDemo);
        }
示例#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);
        }