Beispiel #1
0
 protected void BandedView_CellValueChanged(object sender, CellValueChangedEventArgs e)
 {
     if (e.RowHandle >= 0)
     {
         GridView gridView = (GridView)MainView;
         HREmployeeTimeSheetsInfo objEmployeeTimeSheetsInfo = (HREmployeeTimeSheetsInfo)gridView.GetRow(e.RowHandle);
         //Update time sheet total quantity
         ((TimeSheetModule)Screen.Module).UpdateTimeSheetTotalQty(objEmployeeTimeSheetsInfo);
     }
 }
Beispiel #2
0
        public void SetEmployeeTimeSheetValue(HREmployeeTimeSheetsInfo objEmployeeTimeSheetsInfo)
        {
            HRTimeSheetsInfo timeSheet = (HRTimeSheetsInfo)MainObject;
            List <string>    employeeTimeSheetValueList = new List <string> {
                string.Empty, string.Empty, string.Empty, string.Empty, string.Empty,
                string.Empty, string.Empty, string.Empty, string.Empty, string.Empty,
                string.Empty, string.Empty, string.Empty, string.Empty, string.Empty,
                string.Empty, string.Empty, string.Empty, string.Empty, string.Empty,
                string.Empty, string.Empty, string.Empty, string.Empty, string.Empty,
                string.Empty, string.Empty, string.Empty, string.Empty, string.Empty,
                string.Empty
            };

            foreach (HRTimeSheetEntrysInfo timeSheetEntry in objEmployeeTimeSheetsInfo.HRTimeSheetEntrysList)
            {
                if (timeSheetEntry.HRTimeSheetEntryDate.Date >= timeSheet.HRTimeSheetFromDate.Date &&
                    timeSheetEntry.HRTimeSheetEntryDate.Date <= timeSheet.HRTimeSheetToDate.Date)
                {
                    int    index            = (int)(timeSheetEntry.HRTimeSheetEntryDate.Date - timeSheet.HRTimeSheetFromDate.Date).TotalDays + 1;
                    string timeSheetParamNo = string.Empty;
                    HRTimeSheetParamsInfo objTimeSheetParamsInfo = TimeSheetParams.Where(t => t.HRTimeSheetParamID == timeSheetEntry.FK_HRTimeSheetParamID).FirstOrDefault();
                    if (objTimeSheetParamsInfo != null)
                    {
                        timeSheetParamNo = objTimeSheetParamsInfo.HRTimeSheetParamNo;
                    }
                    if (!string.IsNullOrEmpty(timeSheetParamNo))
                    {
                        if (string.IsNullOrEmpty(employeeTimeSheetValueList[index - 1].Trim()))
                        {
                            employeeTimeSheetValueList[index - 1] = timeSheetParamNo;
                        }
                        else
                        {
                            employeeTimeSheetValueList[index - 1] += String.Format(", {0}", timeSheetParamNo);
                        }
                    }
                }
            }

            VinaDbUtil dbUtil  = new VinaDbUtil();
            int        numDays = ((TimeSheetModule)Module).NumOfDayInMonth();

            if (numDays > 31)
            {
                numDays = 31;
            }
            for (int i = 1; i <= numDays; i++)
            {
                String propertyName = String.Format("{0}{1}", "HREmployeeTimeSheetDate", i.ToString());
                dbUtil.SetPropertyValue(objEmployeeTimeSheetsInfo, propertyName, employeeTimeSheetValueList[i - 1]);
            }
        }
Beispiel #3
0
        protected void BandedView_CustomDrawCell(object sender, RowCellCustomDrawEventArgs e)
        {
            BandedGridView bandedView = (BandedGridView)MainView;

            if (!bandedView.IsValidRowHandle(e.RowHandle))
            {
                return;
            }
            int focusedRowHandle = e.RowHandle;

            if (focusedRowHandle >= 0)
            {
                HREmployeeTimeSheetsInfo objEmployeeTimeSheetsInfo = bandedView.GetRow(focusedRowHandle) as HREmployeeTimeSheetsInfo;
                if (objEmployeeTimeSheetsInfo != null)
                {
                    if (objEmployeeTimeSheetsInfo.HREmployeeTimeSheetOTDetailsList != null)
                    {
                        foreach (var item in objEmployeeTimeSheetsInfo.HREmployeeTimeSheetOTDetailsList)
                        {
                            if (e.Column.FieldName == item.HREmployeeTimeSheetOTDetailName)
                            {
                                e.DisplayText = item.HREmployeeTimeSheetOTDetailHours.ToString();
                                e.CellValue   = item.HREmployeeTimeSheetOTDetailHours;
                            }
                        }
                    }
                    if (objEmployeeTimeSheetsInfo.HRTimeSheetEntrysList != null)
                    {
                        objEmployeeTimeSheetsInfo.HRTimeSheetEntrysList.ForEach(o =>
                        {
                            if (e.Column.FieldName == "CONG" + o.FK_ADWorkingShiftID.ToString())
                            {
                                decimal total = (decimal)objEmployeeTimeSheetsInfo.HRTimeSheetEntrysList.
                                                Where(x => x.FK_ADWorkingShiftID == o.FK_ADWorkingShiftID &&
                                                      !x.IsCommonParam)
                                                .Sum(x => x.HRTimeSheetEntryWorkingQty);

                                e.DisplayText = total.ToString("n5");
                            }
                        });
                    }
                }
            }
        }
Beispiel #4
0
        public void SetDefaultValuesFromEmployee(HREmployeeAllowancesInfo objEmployeeAllowancesInfo, HREmployeesInfo objEmployeesInfo)
        {
            HRAllowancesInfo objAllowancesInfo = (HRAllowancesInfo)MainObject;

            objEmployeeAllowancesInfo.FK_HREmployeeID                = objEmployeesInfo.HREmployeeID;
            objEmployeeAllowancesInfo.FK_HRAllowanceID               = objAllowancesInfo.HRAllowanceID;
            objEmployeeAllowancesInfo.HREmployeeAllowanceValue       = objAllowancesInfo.HRAllowanceValue;
            objEmployeeAllowancesInfo.HREmployeeNo                   = objEmployeesInfo.HREmployeeNo;
            objEmployeeAllowancesInfo.HREmployeeCardNumber           = objEmployeesInfo.HREmployeeCardNumber;
            objEmployeeAllowancesInfo.HREmployeeAllowanceValueAmount = objAllowancesInfo.HRAllowanceConfigValue;
            objEmployeeAllowancesInfo.HREmployeeAllowanceDate        = DateTime.Now;

            // Set default config
            int timeSpan = GetTimeSpan(objEmployeesInfo.HREmployeeStartWorkingDate);
            HRAllowanceConfigsController  objAllowanceConfigsController = new HRAllowanceConfigsController();
            List <HRAllowanceConfigsInfo> listAllowanceConfigsInfo      = objAllowanceConfigsController.GetAllowanceConfigByFKEmployeePayrollFormula(objEmployeesInfo.FK_HREmployeePayrollFormulaID);

            if (listAllowanceConfigsInfo != null)
            {
                HREmployeeTimeSheetsController objEmployeeTimeSheetsController = new HREmployeeTimeSheetsController();
                HREmployeeTimeSheetsInfo       objEmployeeTimeSheetsInfo       = objEmployeeTimeSheetsController.GetEmployeeTimeSheetBySomeCriteria(objEmployeesInfo.HREmployeeID, objAllowancesInfo.HRAllowanceFromDate);
                HRTimesheetConfigsController   objTimesheetConfigsController   = new HRTimesheetConfigsController();
                int dateQty = objTimesheetConfigsController.GetDaysPerMonthByEmployeeFormullaID(objEmployeesInfo.FK_HREmployeePayrollFormulaID, objAllowancesInfo.HRAllowanceFromDate.Month, objAllowancesInfo.HRAllowanceFromDate.Year);

                foreach (HRAllowanceConfigsInfo item in listAllowanceConfigsInfo)
                {
                    if (item.HRAllowanceConfigName == AllowanceConfigName.Diligence.ToString() && objAllowancesInfo.HRAllowanceType == AllowanceType.Diligence.ToString())
                    {
                        objEmployeeAllowancesInfo.HREmployeeAllowanceAmount = item.HRAllowanceConfigAmount;
                        if (objEmployeeTimeSheetsInfo != null && objEmployeeTimeSheetsInfo.HREmployeeTimeSheetWorkingQty + objEmployeeTimeSheetsInfo.HREmployeeTimeSheetLeaveQty >= dateQty)
                        {
                            if (!item.HRAllowanceConfigIsTimeKeeping)
                            {
                                objEmployeeAllowancesInfo.HREmployeeAllowanceValueAmount = item.HRAllowanceConfigAmount;
                            }
                            else
                            {
                                objEmployeeAllowancesInfo.HREmployeeAllowanceValueAmount = item.HRAllowanceConfigAmount * objEmployeeTimeSheetsInfo.HREmployeeTimeSheetWorkingQty;
                            }
                        }
                    }
                    if (item.HRAllowanceConfigName == AllowanceConfigName.HeavyToxic.ToString() && objAllowancesInfo.HRAllowanceType == AllowanceType.HeavyToxic.ToString())
                    {
                        objEmployeeAllowancesInfo.HREmployeeAllowanceAmount = item.HRAllowanceConfigAmount;
                        if (item.HRAllowanceConfigIsTimeKeeping)
                        {
                            if (objEmployeeTimeSheetsInfo != null)
                            {
                                objEmployeeAllowancesInfo.HREmployeeAllowanceValueAmount = objEmployeeTimeSheetsInfo.HREmployeeTimeSheetWorkingQty * item.HRAllowanceConfigAmount;
                            }
                        }
                        else
                        {
                            objEmployeeAllowancesInfo.HREmployeeAllowanceValueAmount = item.HRAllowanceConfigAmount;
                        }
                    }
                    if (item.HRAllowanceConfigName == AllowanceConfigName.Perennial.ToString() && objAllowancesInfo.HRAllowanceType == AllowanceType.Perennial.ToString())
                    {
                        if (timeSpan >= item.HRAllowanceConfigFromDate && timeSpan < item.HRAllowanceConfigToDate)
                        {
                            objEmployeeAllowancesInfo.HREmployeeAllowanceAmount = item.HRAllowanceConfigAmount;
                            if (item.HRAllowanceConfigIsTimeKeeping)
                            {
                                if (objEmployeeTimeSheetsInfo != null)
                                {
                                    objEmployeeAllowancesInfo.HREmployeeAllowanceValueAmount = objEmployeeTimeSheetsInfo.HREmployeeTimeSheetWorkingQty * item.HRAllowanceConfigAmount;
                                }
                            }
                            else
                            {
                                objEmployeeAllowancesInfo.HREmployeeAllowanceValueAmount = item.HRAllowanceConfigAmount;
                            }
                        }
                    }
                    //TNDLoc [ADD][22/12/2015][Other allowance],START
                    if (item.HRAllowanceConfigName == AllowanceConfigName.Other.ToString() && objAllowancesInfo.HRAllowanceType == AllowanceType.Other.ToString())
                    {
                        objEmployeeAllowancesInfo.HREmployeeAllowanceAmount = item.HRAllowanceConfigAmount;
                        if (item.HRAllowanceConfigIsTimeKeeping)
                        {
                            if (objEmployeeTimeSheetsInfo != null)
                            {
                                objEmployeeAllowancesInfo.HREmployeeAllowanceValueAmount = objEmployeeTimeSheetsInfo.HREmployeeTimeSheetWorkingQty * item.HRAllowanceConfigAmount;
                            }
                        }
                        else
                        {
                            objEmployeeAllowancesInfo.HREmployeeAllowanceValueAmount = item.HRAllowanceConfigAmount;
                        }
                    }
                    //TNDLoc [ADD][22/12/2015][Other allowance],END
                }
            }

            float result;

            // Set Amount Bus
            if (objAllowancesInfo.HRAllowanceType == AllowanceType.Bus.ToString())
            {
                if (!objAllowancesInfo.HRAllowanceValue.Equals(String.Empty) && Single.TryParse(objAllowancesInfo.HRAllowanceValue, out result))
                {
                    objEmployeeAllowancesInfo.HREmployeeAllowanceValueAmount = Convert.ToDecimal(Convert.ToSingle(objAllowancesInfo.HRAllowanceValue));
                }
                else
                {
                    objEmployeeAllowancesInfo.HREmployeeAllowanceValueAmount = 0;
                }
            }

            if (objAllowancesInfo.HRAllowanceType.Contains("Amount"))
            {
                if (!objAllowancesInfo.HRAllowanceValue.Equals(String.Empty) && Single.TryParse(objAllowancesInfo.HRAllowanceValue, out result))
                {
                    objEmployeeAllowancesInfo.HREmployeeAllowanceValueAmount = Convert.ToDecimal(Convert.ToSingle(objAllowancesInfo.HRAllowanceValue));
                }
                else
                {
                    objEmployeeAllowancesInfo.HREmployeeAllowanceValueAmount = 0;
                }
            }
        }