666 lines
27 KiB
C#
666 lines
27 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
using Payroll.BO;
|
|
using Ease.CoreV35.Model;
|
|
using Ease.CoreV35.Utility;
|
|
using Ease.CoreV35;
|
|
|
|
namespace Payroll.UI
|
|
{
|
|
public partial class fFixedWorkPlan : BaseFormTest
|
|
{
|
|
#region Declaration
|
|
fSearchEmployee _FSearchEmp = null;
|
|
ObjectsTemplate<WorkPlanGroup> _WorkPlanGroups = null;
|
|
ObjectsTemplate<EmployeeWorkPlanSetup> _EmployeeWorkPlanSetups = null;
|
|
ObjectsTemplate<EmployeeWorkPlanSetup> _EmployeeWorkPlanSetupsForSave = null;
|
|
EmployeeWorkPlanSetup _EmpWorkPlanSetup = null;
|
|
Employee _employee = null;
|
|
private bool _isDesignationFromDescriptionText;
|
|
#endregion
|
|
|
|
#region Constructor & Frm_Load
|
|
|
|
public fFixedWorkPlan()
|
|
{
|
|
InitializeComponent();
|
|
_isDesignationFromDescriptionText = ConfigurationManager.GetBoolValue("designation", "desigfromdescriptiontext", EnumConfigurationType.Logic);
|
|
}
|
|
|
|
private void fFixedWPlan_Load(object sender, EventArgs e)
|
|
{
|
|
RefreshCbo();
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Methods
|
|
|
|
private void RefreshCbo()
|
|
{
|
|
RefreshcboShift(cboShiftSaturday);
|
|
RefreshcboShift(cboShiftSunday);
|
|
RefreshcboShift(cboShiftMonday);
|
|
RefreshcboShift(cboShiftTuesday);
|
|
RefreshcboShift(cboShiftWednesday);
|
|
RefreshcboShift(cboShiftThursday);
|
|
RefreshcboShift(cboShiftFriday);
|
|
|
|
RefreshcboHoliday(cboWHolidayOne);
|
|
RefreshcboHoliday(cboWHolidayTwo);
|
|
|
|
cboGroup.Items.Clear();
|
|
|
|
_WorkPlanGroups = WorkPlanGroup.Get(EnumWorkPlanGroup.Fixed);
|
|
if (_WorkPlanGroups != null)
|
|
{
|
|
foreach (WorkPlanGroup oWPlanGroup in _WorkPlanGroups)
|
|
{
|
|
cboGroup.Items.Add(oWPlanGroup.Name);
|
|
}
|
|
}
|
|
}
|
|
|
|
private void RefreshcboHoliday(ComboBox cbo)
|
|
{
|
|
cbo.Items.Clear();
|
|
cbo.DisplayMember = "Title";
|
|
cbo.ValueMember = "Value";
|
|
|
|
var dtSource = Enum.GetValues(typeof(DayOfWeek)).Cast<DayOfWeek>()
|
|
.Select(x => new { Title = x.ToString(), Value = (int)x }).ToList();
|
|
dtSource.Add(new { Title = "None", Value = -1 });
|
|
cbo.DataSource = dtSource.OrderBy(x => x.Value).ToList();
|
|
|
|
//cbo.DataSource = EnumFormatter.GetObjects(typeof(DayOfWeek));
|
|
//cbo.DisplayMember = "FriendlyName";
|
|
//cbo.ValueMember = "Value";
|
|
cbo.SelectedIndex = 0;
|
|
}
|
|
|
|
private void RefreshcboShift(ComboBox cbo)
|
|
{
|
|
List<Shift> _Shifts = CalcullateShift();
|
|
cbo.Items.Clear();
|
|
cbo.DisplayMember = "ShortName";
|
|
cbo.DataSource = _Shifts;
|
|
}
|
|
|
|
private List<Shift> CalcullateShift()
|
|
{
|
|
List<Shift> _Shifts = new ObjectsTemplate<Shift>();
|
|
List<ShiftRotation> tempShiftRotation = ShiftRotation.Get(EnumStatus.Active);
|
|
|
|
List<Shift> tempShifts = Shift.Get();
|
|
|
|
if (tempShiftRotation != null)
|
|
{
|
|
_Shifts.Add(new Shift { ShortName = "Empty" });
|
|
foreach (Shift oShift in tempShifts)
|
|
{
|
|
if (tempShiftRotation.Where(o => o.ShiftID.Integer == oShift.ID.Integer).Any())
|
|
continue;
|
|
_Shifts.Add(oShift);
|
|
|
|
}
|
|
}
|
|
|
|
return _Shifts;
|
|
}
|
|
|
|
private void RefreshEmployeeWorkplanDataFromCombo(EmployeeWorkPlanSetup empWPSetup)
|
|
{
|
|
empWPSetup.SaturdayShiftID = empWPSetup.SundayShiftID = empWPSetup.MondayShiftID =
|
|
empWPSetup.TuesdayShiftID = empWPSetup.WednesdayShiftID = empWPSetup.ThursdayShiftID =
|
|
empWPSetup.FridayShiftID = null;
|
|
|
|
empWPSetup.WeekEndOn = empWPSetup.WeekEndOn2 = null;
|
|
|
|
if ((cboShiftSaturday.SelectedItem as Shift).ShortName != "Empty")
|
|
{
|
|
empWPSetup.SaturdayShiftID = (cboShiftSaturday.SelectedItem as Shift).ID.Integer;
|
|
}
|
|
if ((cboShiftSunday.SelectedItem as Shift).ShortName != "Empty")
|
|
{
|
|
empWPSetup.SundayShiftID = (cboShiftSunday.SelectedItem as Shift).ID.Integer;
|
|
}
|
|
if ((cboShiftMonday.SelectedItem as Shift).ShortName != "Empty")
|
|
{
|
|
empWPSetup.MondayShiftID = (cboShiftMonday.SelectedItem as Shift).ID.Integer;
|
|
}
|
|
if ((cboShiftTuesday.SelectedItem as Shift).ShortName != "Empty")
|
|
{
|
|
empWPSetup.TuesdayShiftID = (cboShiftTuesday.SelectedItem as Shift).ID.Integer;
|
|
}
|
|
if ((cboShiftWednesday.SelectedItem as Shift).ShortName != "Empty")
|
|
{
|
|
empWPSetup.WednesdayShiftID = (cboShiftWednesday.SelectedItem as Shift).ID.Integer;
|
|
}
|
|
if ((cboShiftThursday.SelectedItem as Shift).ShortName != "Empty")
|
|
{
|
|
empWPSetup.ThursdayShiftID = (cboShiftThursday.SelectedItem as Shift).ID.Integer;
|
|
}
|
|
if ((cboShiftFriday.SelectedItem as Shift).ShortName != "Empty")
|
|
{
|
|
empWPSetup.FridayShiftID = (cboShiftFriday.SelectedItem as Shift).ID.Integer;
|
|
}
|
|
if (Convert.ToInt32(cboWHolidayOne.SelectedValue) != -1)
|
|
empWPSetup.WeekEndOn = (DayOfWeek)cboWHolidayOne.SelectedValue;
|
|
if (Convert.ToInt32(cboWHolidayTwo.SelectedValue) != -1)
|
|
empWPSetup.WeekEndOn2 = (DayOfWeek)cboWHolidayTwo.SelectedValue;
|
|
|
|
empWPSetup.WorkPlanGroupID = _WorkPlanGroups[cboGroup.SelectedIndex].ID;
|
|
|
|
|
|
}
|
|
|
|
//private void EnableShiftCombo()
|
|
//{
|
|
// cboShiftFriday.Enabled = true;
|
|
// cboShiftSaturday.Enabled = true;
|
|
// cboShiftSunday.Enabled = true;
|
|
// cboShiftMonday.Enabled = true;
|
|
// cboShiftThursday.Enabled = true;
|
|
// cboShiftTuesday.Enabled = true;
|
|
// cboShiftWednesday.Enabled = true;
|
|
//}
|
|
|
|
//private void DisableShiftCombo(DayOfWeek dOfWeek)
|
|
//{
|
|
// switch (dOfWeek)
|
|
// {
|
|
// case DayOfWeek.Friday:
|
|
// cboShiftFriday.Enabled = false;
|
|
// cboShiftFriday.SelectedIndex = 0;
|
|
// break;
|
|
// case DayOfWeek.Monday:
|
|
// cboShiftMonday.Enabled = false;
|
|
// cboShiftMonday.SelectedIndex = 0;
|
|
// break;
|
|
// case DayOfWeek.Saturday:
|
|
// cboShiftSaturday.Enabled = false;
|
|
// cboShiftSaturday.SelectedIndex = 0;
|
|
// break;
|
|
// case DayOfWeek.Sunday:
|
|
// cboShiftSunday.Enabled = false;
|
|
// cboShiftSunday.SelectedIndex = 0;
|
|
// break;
|
|
// case DayOfWeek.Thursday:
|
|
// cboShiftThursday.Enabled = false;
|
|
// cboShiftThursday.SelectedIndex = 0;
|
|
// break;
|
|
// case DayOfWeek.Tuesday:
|
|
// cboShiftTuesday.Enabled = false;
|
|
// cboShiftTuesday.SelectedIndex = 0;
|
|
// break;
|
|
// case DayOfWeek.Wednesday:
|
|
// cboShiftWednesday.Enabled = false;
|
|
// cboShiftWednesday.SelectedIndex = 0;
|
|
// break;
|
|
// default:
|
|
// break;
|
|
// }
|
|
//}
|
|
|
|
private void RefreshList()
|
|
{
|
|
lsvFixedWP.Items.Clear();
|
|
ListViewItem oItem = null;
|
|
if (_EmployeeWorkPlanSetups == null) return;
|
|
|
|
ObjectsTemplate<Shift> shifts = Shift.Get();
|
|
//ObjectsTemplate<WorkPlanGroup> workPlanGroups = WorkPlanGroup.Get();
|
|
ObjectsTemplate<Employee> employees = Employee.Get();
|
|
var deptList = Department.Get().Select(x => new { Id = x.ID, Name = x.Name }).ToList();
|
|
var designationList = Designation.Get(EnumStatus.Regardless).Select(x => new { Id = x.ID, Name = x.Name }).ToList();
|
|
|
|
int count = 0;
|
|
|
|
string ShiftName = string.Empty;
|
|
string WeekEnd1 = string.Empty;
|
|
string WeekEnd2 = string.Empty;
|
|
|
|
if (_EmployeeWorkPlanSetups.Count > 0)
|
|
{
|
|
ShiftName = _EmployeeWorkPlanSetups[0].ShiftsName;
|
|
WeekEnd1 = _EmployeeWorkPlanSetups[0].WeekEndOn.HasValue ? _EmployeeWorkPlanSetups[0].WeekEndOn.Value.ToString() : "Empty";
|
|
WeekEnd2 = _EmployeeWorkPlanSetups[0].WeekEndOn2.HasValue ? _EmployeeWorkPlanSetups[0].WeekEndOn2.Value.ToString() : "Empty";
|
|
}
|
|
|
|
var ListItems = employees
|
|
.GroupJoin(deptList,
|
|
e => e.DepartmentID,
|
|
dpt => dpt.Id,
|
|
(e, g1) => g1.Select(dpt => new { EmpID = e.ID.Integer, EmpNo = e.EmployeeNo, EmpName = e.Name, Department = dpt.Name, DesignationID = e.DesignationID, DescriptionText = e.DescriptionText })
|
|
.DefaultIfEmpty(new { EmpID = e.ID.Integer, EmpNo = e.EmployeeNo, EmpName = e.Name, Department = string.Empty, DesignationID = e.DesignationID, DescriptionText = e.DescriptionText }))
|
|
.SelectMany(g1 => g1)
|
|
.GroupJoin(designationList,
|
|
g1 => g1.DesignationID,
|
|
des => des.Id,
|
|
(g1, g2) => g2.Select(des => new { EmpID = g1.EmpID, EmpNo = g1.EmpNo, EmpName = g1.EmpName, Department = g1.Department, DesignationName = _isDesignationFromDescriptionText? g1.DescriptionText:des.Name }) // })
|
|
.DefaultIfEmpty(new { EmpID = g1.EmpID, EmpNo = g1.EmpNo, EmpName = g1.EmpName, Department = g1.Department, DesignationName = _isDesignationFromDescriptionText ? g1.DescriptionText : string.Empty }))
|
|
.SelectMany(g2=>g2)
|
|
.Join(_EmployeeWorkPlanSetups,
|
|
g2 => g2.EmpID,
|
|
wps=> wps.EmployeeID.Integer,
|
|
(g2,wps)=> new { SWPSetup = wps, listItem = new ListViewItem(new[] { g2.EmpNo, g2.EmpName, g2.Department, g2.DesignationName,ShiftName,WeekEnd1,WeekEnd2 })});
|
|
|
|
|
|
|
|
ListViewItem[] oItems = new ListViewItem[ListItems.Count()];
|
|
|
|
foreach (var item in ListItems)
|
|
{
|
|
item.listItem.Tag = item.SWPSetup;
|
|
oItems[count++] = item.listItem;
|
|
}
|
|
|
|
lsvFixedWP.Items.AddRange(oItems);
|
|
|
|
lblNoOfEmp.Text = count.ToString();
|
|
}
|
|
|
|
private bool Validate()
|
|
{
|
|
if (cboGroup.SelectedIndex < 0)
|
|
{
|
|
cboGroup.Focus();
|
|
MessageBox.Show("Select Work Group.", "Save Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
return false;
|
|
}
|
|
|
|
if (cboShiftSaturday.SelectedIndex == 0)
|
|
{
|
|
cboShiftSaturday.Focus();
|
|
MessageBox.Show("Select Saturday Shift.", "Save Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
return false;
|
|
}
|
|
|
|
if (cboShiftSunday.SelectedIndex == 0)
|
|
{
|
|
cboShiftSunday.Focus();
|
|
MessageBox.Show("Select Sunday Shift.", "Save Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
return false;
|
|
}
|
|
|
|
if (cboShiftMonday.SelectedIndex == 0)
|
|
{
|
|
cboShiftMonday.Focus();
|
|
MessageBox.Show("Select Monday Shift.", "Save Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
return false;
|
|
}
|
|
|
|
if (cboShiftTuesday.SelectedIndex == 0)
|
|
{
|
|
cboShiftTuesday.Focus();
|
|
MessageBox.Show("Select Tuesday Shift.", "Save Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
return false;
|
|
}
|
|
|
|
if (cboShiftWednesday.SelectedIndex == 0)
|
|
{
|
|
cboShiftWednesday.Focus();
|
|
MessageBox.Show("Select Wednesday Shift.", "Save Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
return false;
|
|
}
|
|
|
|
if (cboShiftThursday.SelectedIndex == 0)
|
|
{
|
|
cboShiftThursday.Focus();
|
|
MessageBox.Show("Select Thursday Shift.", "Save Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
return false;
|
|
}
|
|
|
|
if (cboShiftFriday.SelectedIndex == 0)
|
|
{
|
|
cboShiftFriday.Focus();
|
|
MessageBox.Show("Select Friday Shift.", "Save Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
private void RefreshObject()
|
|
{
|
|
_EmployeeWorkPlanSetupsForSave = new ObjectsTemplate<EmployeeWorkPlanSetup>();
|
|
|
|
foreach (EmployeeWorkPlanSetup empWPSetup in _EmployeeWorkPlanSetups)
|
|
{
|
|
RefreshEmployeeWorkplanDataFromCombo(empWPSetup);
|
|
|
|
_EmployeeWorkPlanSetupsForSave.Add(empWPSetup);
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Events
|
|
|
|
private void lsvFixedWP_ColumnClick(object sender, ColumnClickEventArgs e)
|
|
{
|
|
this.Cursor = Cursors.WaitCursor;
|
|
|
|
SortOrder order = SortOrder.Ascending;
|
|
if (order == lsvFixedWP.Sorting)
|
|
order = SortOrder.Descending;
|
|
else
|
|
order = SortOrder.Ascending;
|
|
|
|
lsvFixedWP.ListViewItemSorter = new Global.ItemSorter(e.Column, order);
|
|
lsvFixedWP.Sorting = order;
|
|
|
|
this.Cursor = Cursors.Default;
|
|
}
|
|
|
|
private void cboGroup_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
if (cboGroup.SelectedIndex > -1)
|
|
{
|
|
_EmployeeWorkPlanSetups = EmployeeWorkPlanSetup.GetByWPGroupID(_WorkPlanGroups[cboGroup.SelectedIndex].ID);
|
|
|
|
WorkPlanGroup wpGroup = new WorkPlanGroup();
|
|
wpGroup = WorkPlanGroup.Get(_WorkPlanGroups[cboGroup.SelectedIndex].ID);
|
|
|
|
//lblFromTime.Text = wpGroup.FromTime.ToString("HH:mm:ss tt");
|
|
//lblTotime.Text = wpGroup.ToTime.ToString("HH:mm:ss tt");
|
|
|
|
RefreshList();
|
|
|
|
cboWHolidayOne.SelectedValue = cboWHolidayTwo.SelectedValue = -1;
|
|
cboShiftSaturday.SelectedIndex = cboShiftSunday.SelectedIndex = cboShiftMonday.SelectedIndex =
|
|
cboShiftTuesday.SelectedIndex = cboShiftWednesday.SelectedIndex = cboShiftThursday.SelectedIndex =
|
|
cboShiftFriday.SelectedIndex = 0;
|
|
|
|
if (_EmployeeWorkPlanSetups.Count > 0)
|
|
{
|
|
if (_EmployeeWorkPlanSetups[0].WeekEndOn.HasValue)
|
|
{
|
|
cboWHolidayOne.SelectedValue = (int)_EmployeeWorkPlanSetups[0].WeekEndOn.Value;
|
|
}
|
|
|
|
if (_EmployeeWorkPlanSetups[0].WeekEndOn2.HasValue)
|
|
{
|
|
cboWHolidayTwo.SelectedValue = (int)_EmployeeWorkPlanSetups[0].WeekEndOn2.Value;
|
|
}
|
|
|
|
if (_EmployeeWorkPlanSetups[0].SaturdayShift != null)
|
|
{
|
|
cboShiftSaturday.SelectedItem = _EmployeeWorkPlanSetups[0].SaturdayShift;
|
|
}
|
|
|
|
if (_EmployeeWorkPlanSetups[0].SundayShift != null)
|
|
{
|
|
cboShiftSunday.SelectedItem = _EmployeeWorkPlanSetups[0].SundayShift;
|
|
}
|
|
|
|
if (_EmployeeWorkPlanSetups[0].MondayShift != null)
|
|
{
|
|
cboShiftMonday.SelectedItem = _EmployeeWorkPlanSetups[0].MondayShift;
|
|
}
|
|
|
|
if (_EmployeeWorkPlanSetups[0].TuesdayShift != null)
|
|
{
|
|
cboShiftTuesday.SelectedItem = _EmployeeWorkPlanSetups[0].TuesdayShift;
|
|
}
|
|
|
|
if (_EmployeeWorkPlanSetups[0].WednesdayShift != null)
|
|
{
|
|
cboShiftWednesday.SelectedItem = _EmployeeWorkPlanSetups[0].WednesdayShift;
|
|
}
|
|
|
|
if (_EmployeeWorkPlanSetups[0].ThursdayShift != null)
|
|
{
|
|
cboShiftThursday.SelectedItem = _EmployeeWorkPlanSetups[0].ThursdayShift;
|
|
}
|
|
|
|
if (_EmployeeWorkPlanSetups[0].FridayShift != null)
|
|
{
|
|
cboShiftFriday.SelectedItem = _EmployeeWorkPlanSetups[0].FridayShift;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private void cboWHolidayOne_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
// EnableShiftCombo();
|
|
|
|
if (Convert.ToInt32(cboWHolidayOne.SelectedValue) != -1)
|
|
{
|
|
cboWHolidayTwo.Enabled = true;
|
|
//DisableShiftCombo((DayOfWeek)cboWHolidayOne.SelectedValue);
|
|
}
|
|
else
|
|
{
|
|
cboWHolidayTwo.Enabled = false;
|
|
cboWHolidayTwo.SelectedValue = -1;
|
|
}
|
|
}
|
|
|
|
//private void cboWHolidayTwo_SelectedIndexChanged(object sender, EventArgs e)
|
|
//{
|
|
// EnableShiftCombo();
|
|
|
|
// if (Convert.ToInt32(cboWHolidayOne.SelectedValue) != -1)
|
|
// {
|
|
// DisableShiftCombo((DayOfWeek)cboWHolidayOne.SelectedValue);
|
|
// }
|
|
|
|
// if (Convert.ToInt32(cboWHolidayTwo.SelectedValue) != -1)
|
|
// {
|
|
// DisableShiftCombo((DayOfWeek)cboWHolidayTwo.SelectedValue);
|
|
// }
|
|
//}
|
|
|
|
private void btnSearch_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
this.Cursor = Cursors.WaitCursor;
|
|
_FSearchEmp = new fSearchEmployee();
|
|
_FSearchEmp.MultipleSelection = true;
|
|
_FSearchEmp.ShowDialog();
|
|
bool added = false;
|
|
|
|
if (_EmployeeWorkPlanSetups == null || _EmployeeWorkPlanSetups.Count == 0)
|
|
{
|
|
_EmployeeWorkPlanSetups = new ObjectsTemplate<EmployeeWorkPlanSetup>();
|
|
|
|
if (_FSearchEmp.SelectedEmployees != null && _FSearchEmp.SelectedEmployees.Count > 0)
|
|
{
|
|
foreach (SearchEmployee emp in _FSearchEmp.SelectedEmployees)
|
|
{
|
|
EmployeeWorkPlanSetup oEmpWPlanSetup = new EmployeeWorkPlanSetup();
|
|
oEmpWPlanSetup.EmployeeID = emp.EmployeeID;
|
|
oEmpWPlanSetup.StartDate = emp.Employee.JoiningDate;
|
|
RefreshEmployeeWorkplanDataFromCombo(oEmpWPlanSetup);
|
|
_EmployeeWorkPlanSetups.Add(oEmpWPlanSetup);
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
foreach (SearchEmployee emp in _FSearchEmp.SelectedEmployees)
|
|
{
|
|
added = false;
|
|
foreach (EmployeeWorkPlanSetup oEmpWSetup in _EmployeeWorkPlanSetups)
|
|
{
|
|
if (emp.EmployeeID == oEmpWSetup.EmployeeID)
|
|
{
|
|
//RefreshEmployeeWorkplanDataFromCombo(oEmpWSetup);
|
|
added = true;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (!added)
|
|
{
|
|
EmployeeWorkPlanSetup oEmpWPlanSetup = new EmployeeWorkPlanSetup();
|
|
oEmpWPlanSetup.EmployeeID = emp.EmployeeID;
|
|
oEmpWPlanSetup.StartDate = emp.Employee.JoiningDate;
|
|
oEmpWPlanSetup.SaturdayShiftID = _EmployeeWorkPlanSetups[0].SaturdayShiftID;
|
|
oEmpWPlanSetup.SundayShiftID = _EmployeeWorkPlanSetups[0].SundayShiftID;
|
|
oEmpWPlanSetup.MondayShiftID = _EmployeeWorkPlanSetups[0].MondayShiftID;
|
|
oEmpWPlanSetup.TuesdayShiftID = _EmployeeWorkPlanSetups[0].TuesdayShiftID;
|
|
oEmpWPlanSetup.WednesdayShiftID = _EmployeeWorkPlanSetups[0].WednesdayShiftID;
|
|
oEmpWPlanSetup.ThursdayShiftID = _EmployeeWorkPlanSetups[0].ThursdayShiftID;
|
|
oEmpWPlanSetup.FridayShiftID = _EmployeeWorkPlanSetups[0].FridayShiftID;
|
|
|
|
//RefreshEmployeeWorkplanDataFromCombo(oEmpWPlanSetup);
|
|
_EmployeeWorkPlanSetups.Add(oEmpWPlanSetup);
|
|
}
|
|
}
|
|
}
|
|
|
|
RefreshList();
|
|
this.Cursor = Cursors.Default;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show("Cannot Search Due To\n" + ex.Message, "Cannot Search", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
}
|
|
}
|
|
|
|
private void btnSave_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (!Validate())
|
|
{
|
|
return;
|
|
}
|
|
|
|
if (MessageBox.Show(String.Format("Do you want to save the information for group {0} \n For all employees ?", cboGroup.Text), "Save Information", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
|
{
|
|
return;
|
|
}
|
|
|
|
try
|
|
{
|
|
RefreshObject();
|
|
(new EmployeeWorkPlanSetup()).Save(_EmployeeWorkPlanSetupsForSave);
|
|
MessageBox.Show("Data saved successfully.", "Save Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
cboGroup_SelectedIndexChanged(null, null);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show(ex.Message, "Save Information", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
}
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
if (ex.InnerException == null)
|
|
MessageBox.Show(ex.Message, "Failed to save", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
else
|
|
MessageBox.Show(ex.InnerException.Message, "Failed to save", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
}
|
|
}
|
|
|
|
private void btnRemove_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (lsvFixedWP.SelectedItems == null || lsvFixedWP.SelectedItems.Count == 0)
|
|
{
|
|
return;
|
|
}
|
|
_EmployeeWorkPlanSetups.Remove((EmployeeWorkPlanSetup)lsvFixedWP.SelectedItems[0].Tag);
|
|
RefreshList();
|
|
MessageBox.Show("Item Removed Successfully", "Remove Information", MessageBoxButtons.OK,
|
|
MessageBoxIcon.Information);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
if (ex.InnerException == null)
|
|
MessageBox.Show(ex.Message, "Failed to remove", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
else
|
|
MessageBox.Show(ex.InnerException.Message, "Failed to remove", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
}
|
|
}
|
|
|
|
//private void cboGeneral_SelectedIndexChanged(object sender, EventArgs e)
|
|
//{
|
|
// if (_EmployeeWorkPlanSetups == null) return;
|
|
|
|
// foreach (EmployeeWorkPlanSetup oEmpWSetup in _EmployeeWorkPlanSetups)
|
|
// {
|
|
// RefreshEmployeeWorkplanDataFromCombo(oEmpWSetup);
|
|
// }
|
|
// RefreshList();
|
|
//}
|
|
|
|
#endregion
|
|
|
|
internal void ShowDlg(HREmployee employee)
|
|
{
|
|
_employee = new Employee();
|
|
_employee = employee;
|
|
//txtEmpName.Visible = true;
|
|
//txtEmpNo.Visible = true;
|
|
btnAdd.Visible = true;
|
|
//txtEmpNo.Text = _employee.EmployeeNo;
|
|
//txtEmpName.Text = _employee.Name;
|
|
btnSearch.Visible = false;
|
|
this.ShowDialog();
|
|
}
|
|
|
|
private void btnAdd_Click(object sender, EventArgs e)
|
|
{
|
|
bool added = false;
|
|
|
|
if (_employee != null)
|
|
{
|
|
if (_EmployeeWorkPlanSetups == null || _EmployeeWorkPlanSetups.Count == 0)
|
|
{
|
|
_EmployeeWorkPlanSetups = new ObjectsTemplate<EmployeeWorkPlanSetup>();
|
|
|
|
EmployeeWorkPlanSetup oEmpWPlanSetup = new EmployeeWorkPlanSetup();
|
|
oEmpWPlanSetup.EmployeeID = _employee.ID;
|
|
oEmpWPlanSetup.StartDate = _employee.JoiningDate;
|
|
RefreshEmployeeWorkplanDataFromCombo(oEmpWPlanSetup);
|
|
_EmployeeWorkPlanSetups.Add(oEmpWPlanSetup);
|
|
}
|
|
else
|
|
{
|
|
added = false;
|
|
foreach (EmployeeWorkPlanSetup oEmpWSetup in _EmployeeWorkPlanSetups)
|
|
{
|
|
if (_employee.ID == oEmpWSetup.EmployeeID)
|
|
{
|
|
added = true;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (!added)
|
|
{
|
|
EmployeeWorkPlanSetup oEmpWPlanSetup = new EmployeeWorkPlanSetup();
|
|
oEmpWPlanSetup.EmployeeID = _employee.ID;
|
|
oEmpWPlanSetup.StartDate = _employee.JoiningDate;
|
|
oEmpWPlanSetup.SaturdayShiftID = _EmployeeWorkPlanSetups[0].SaturdayShiftID;
|
|
oEmpWPlanSetup.SundayShiftID = _EmployeeWorkPlanSetups[0].SundayShiftID;
|
|
oEmpWPlanSetup.MondayShiftID = _EmployeeWorkPlanSetups[0].MondayShiftID;
|
|
oEmpWPlanSetup.TuesdayShiftID = _EmployeeWorkPlanSetups[0].TuesdayShiftID;
|
|
oEmpWPlanSetup.WednesdayShiftID = _EmployeeWorkPlanSetups[0].WednesdayShiftID;
|
|
oEmpWPlanSetup.ThursdayShiftID = _EmployeeWorkPlanSetups[0].ThursdayShiftID;
|
|
oEmpWPlanSetup.FridayShiftID = _EmployeeWorkPlanSetups[0].FridayShiftID;
|
|
|
|
_EmployeeWorkPlanSetups.Add(oEmpWPlanSetup);
|
|
}
|
|
}
|
|
|
|
RefreshList();
|
|
this.Cursor = Cursors.Default;
|
|
}
|
|
}
|
|
}
|
|
}
|