void leaveofficemapping() { option = 3; try { grdList.Rows.Clear(); LeaveSettingsdb record = new LeaveSettingsdb(); List <Leave> leavetype = record.getleaveofficemappingList(); 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["lOfficeID"].Value = leave.officeID; grdList.Rows[grdList.RowCount - 1].Cells["OfficeName"].Value = leave.officeName; grdList.Rows[grdList.RowCount - 1].Cells["lMaxDays"].Value = leave.MaxDays; grdList.Rows[grdList.RowCount - 1].Cells["lRowID"].Value = leave.rowid; } setvisiblity(option); closeAllPanels(); pnlLeaveList.Visible = true; enableBottomButtons(); pnlBottomButtons.Visible = true; } catch (Exception ex) { } }
void leavesanctionlimit() { option = 2; try { grdList.Rows.Clear(); LeaveSettingsdb record = new LeaveSettingsdb(); List <Leave> leavetype = record.getSanctionLimitList(); 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["lDesignation"].Value = leave.designation; grdList.Rows[grdList.RowCount - 1].Cells["lMaxSanctionLimit"].Value = leave.MaxAccrual; grdList.Rows[grdList.RowCount - 1].Cells["lRowID"].Value = leave.rowid; } setvisiblity(option); closeAllPanels(); pnlLeaveList.Visible = true; enableBottomButtons(); pnlBottomButtons.Visible = true; } catch (Exception ex) { } }
private void initVariables() { //249, 29 pnlLeaveSanctionLimitOuter.Location = new Point(249, 20); pnlLeaveTypeOuter.Location = new Point(249, 20); pnlLeaveOfficeMapOuter.Location = new Point(249, 20); pnlLeaveSanctionLimitOuter.Parent = pnlUI; pnlLeaveTypeOuter.Parent = pnlUI; pnlLeaveOfficeMapOuter.Parent = pnlUI; pnlLeaveSanctionLimitInner.Parent = pnlLeaveSanctionLimitOuter; pnlLeaveTypeInner.Parent = pnlLeaveTypeOuter; pnlLeaveOfficeMapInner.Parent = pnlLeaveOfficeMapOuter; OfficeDB.fillOfficeComboNew(cmbLomOffice); CatalogueValueDB.fillCatalogValueComboNew(cmbLslDesignation, "Designation"); CatalogueValueDB.fillCatalogValueComboNew(cmbGender, "Gender"); LeaveSettingsdb.fillLeaveComboNew(cmbLomLeaveID); LeaveSettingsdb.fillLeaveComboNew(cmbLslLeaveID); cmbGender.Items.Add("All"); btnNew.Visible = false; pnlLeaveOfficeMapOuter.Visible = false; pnlLeaveSanctionLimitOuter.Visible = false; pnlLeaveTypeOuter.Visible = false; }
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) { } }
private void btnLeaveOfficeMapping_Click(object sender, EventArgs e) { OfficeDB.fillOfficeComboNew(cmbLomOffice); CatalogueValueDB.fillCatalogValueComboNew(cmbLslDesignation, "Designation"); CatalogueValueDB.fillCatalogValueComboNew(cmbGender, "Gender"); LeaveSettingsdb.fillLeaveComboNew(cmbLomLeaveID); cmbGender.Items.Add("All"); LeaveSettingsdb.fillLeaveComboNew(cmbLslLeaveID); leaveofficemapping(); }
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); }
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); }
private void btnLomSave_Click(object sender, EventArgs e) { try { Leave leave = new Leave(); LeaveSettingsdb leaveDB = new LeaveSettingsdb(); if (option == 3) { leave.leaveID = ((Structures.ComboBoxItem)cmbLomLeaveID.SelectedItem).HiddenValue; leave.officeID = ((Structures.ComboBoxItem)cmbLomOffice.SelectedItem).HiddenValue; leave.MaxDays = Convert.ToInt32(txtLomMaxDays.Text); if (leaveDB.ValidateLeaveOfficeMapping(leave)) { if (btnLomSave.Text.Equals("Update")) { if (prevoff != cmbLomOffice.SelectedItem.ToString()) { if (leaveDB.Validatemapping(leave)) { leave.rowid = rowid; if (leaveDB.UpdateLeaveOfficeMapping(leave)) { MessageBox.Show("LeaveOfficeMapping updated"); closeAllPanels(); leaveofficemapping(); } else { MessageBox.Show("Failed to update LeaveOfficeMapping"); } } else { MessageBox.Show("Mapping Already Exists"); } } else { leave.rowid = rowid; if (leaveDB.UpdateLeaveOfficeMapping(leave)) { MessageBox.Show("LeaveOfficeMapping updated"); closeAllPanels(); leaveofficemapping(); } else { MessageBox.Show("Failed to update LeaveOfficeMapping"); } } } else if (btnLomSave.Text.Equals("Save")) { if (leaveDB.Validatemapping(leave)) { if (leaveDB.InsertLeaveofficeMapping(leave)) { MessageBox.Show("LeaveOfficeMapping Value Added"); closeAllPanels(); leaveofficemapping(); } else { MessageBox.Show("Failed to Insert LeaveOfficeMapping"); } } else { MessageBox.Show("Mapping already Exists!!!!"); } } } else { MessageBox.Show("LeaveOfficeMapping Data Validation failed"); } } } catch (Exception) { MessageBox.Show("Failed Adding / Editing User Data"); } }
private void btnLslSave_Click(object sender, EventArgs e) { try { Leave leave = new Leave(); LeaveSettingsdb leaveDB = new LeaveSettingsdb(); if (option == 2) { leave.leaveID = ((Structures.ComboBoxItem)cmbLslLeaveID.SelectedItem).HiddenValue; leave.designation = ((Structures.ComboBoxItem)cmbLslDesignation.SelectedItem).HiddenValue; leave.MaxAccrual = Convert.ToInt32(txtLslMaxSanctionLimit.Text.ToString()); if (leaveDB.ValidateLeaveSanctionLimit(leave)) { if (btnLslSave.Text.Equals("Update")) { if (prevdesig != cmbLslDesignation.SelectedItem.ToString()) { if (leaveDB.validateSanctionLimitList(leave)) { leave.rowid = rowid; if (leaveDB.UpdateLeaveSanctionLimit(leave)) { MessageBox.Show("LeaveSanctionLimit updated"); closeAllPanels(); leavesanctionlimit(); } else { MessageBox.Show("Failed to update LeaveSanctionLimit"); } } else { MessageBox.Show("Sanction Limit for this data Already Exists!!!"); } } else { leave.rowid = rowid; if (leaveDB.UpdateLeaveSanctionLimit(leave)) { MessageBox.Show("LeaveSanctionLimit updated"); closeAllPanels(); leavesanctionlimit(); } else { MessageBox.Show("Failed to update LeaveSanctionLimit"); } } } else if (btnLslSave.Text.Equals("Save")) { if (leaveDB.validateSanctionLimitList(leave)) { if (leaveDB.InsertLeaveSanctionLimit(leave)) { MessageBox.Show("LeaveSanctionLimit Value Added"); closeAllPanels(); leavesanctionlimit(); } else { MessageBox.Show("Failed to Insert LeaveSanctionLimit"); } } else { MessageBox.Show("Sanction Limit for this data Already Exists!!!"); } } } else { MessageBox.Show("LeaveSanctionLimit Data Validation failed"); } } } catch (Exception ex) { MessageBox.Show("Failed Adding / Editing User Data"); } }
private void btnSave_Click(object sender, EventArgs e) { try { Leave leave = new Leave(); LeaveSettingsdb leaveDB = new LeaveSettingsdb(); if (option == 1) { leave.leaveID = txtLeaveID.Text; leave.description = txtlDescription.Text; leave.MaxAccrual = Convert.ToInt32(txtMaxSanctionLimit.Text); leave.SanctionType = status(cmbSanctionType.SelectedItem.ToString()); leave.ahead = Convert.ToInt32(txtDaysAhead.Text); leave.Delay = Convert.ToInt32(txtDaysDelayed.Text); leave.CarryForward = getcarryforwardint(cmbCarryForward.SelectedItem.ToString()); if (cmbGender.SelectedItem.ToString() == "All") { leave.Gender = cmbGender.SelectedItem.ToString(); } else { leave.Gender = ((Structures.ComboBoxItem)cmbGender.SelectedItem).HiddenValue; } if (leaveDB.ValidateLeaveType(leave)) { if (btnSave.Text.Equals("Update")) { if (leaveDB.UpdateLeaveType(leave)) { MessageBox.Show("LeaveType updated"); closeAllPanels(); leavetype(); } else { MessageBox.Show("Failed to update LeaveType"); } } else if (btnSave.Text.Equals("Save")) { if (leaveDB.validateLeaveType(leave)) { if (leaveDB.InsertLeaveType(leave)) { MessageBox.Show("LeaveType Value Added"); closeAllPanels(); leavetype(); } else { MessageBox.Show("Failed to Insert LeaveType"); } } else { MessageBox.Show("Leave Type Already exists!!!"); } } } else { MessageBox.Show("LeaveType Data Validation failed"); } } } catch (Exception) { MessageBox.Show("Failed Adding / Editing User Data"); } }