Esempio n. 1
0
        public DataTable GetMCBalance(int nEmployeeID)
        {
            int nYearID = GetNYearID(nEmployeeID);

            return(SqlHelperUtils.ExecuteDataTableSP("pr_GetAllMCBalanceInfo",
                                                     new SqlParameter("@inEmployeeID", nEmployeeID), new SqlParameter("@inYearID", nYearID)));
        }
Esempio n. 2
0
 public DataTable ListAppointment(string strBranchCode, DateTime startDate, DateTime endDate)
 {
     return(SqlHelperUtils.ExecuteDataTableSP("pr_tblAppointment_SelectAllWnBranchCode",
                                              new SqlParameter("@strBranchCode", strBranchCode),
                                              new SqlParameter("@ddtStartDate", SqlDbType.DateTime, 8, ParameterDirection.Input, true, 23, 3, "", DataRowVersion.Proposed, startDate),
                                              new SqlParameter("@ddtEndDate", SqlDbType.DateTime, 8, ParameterDirection.Input, true, 23, 3, "", DataRowVersion.Proposed, endDate)));
 }
Esempio n. 3
0
        public double GetActual_AnnualBalance(int nEmployeeID, int nYearID, DateTime startDate)
        {
            DataTable leaveTable = SqlHelperUtils.ExecuteDataTableSP("pr_SelectAnnualLeaveBalance",
                                                                     new SqlParameter("@inEmployeeID", nEmployeeID),
                                                                     new SqlParameter("@inYearID", nYearID));

            DateTime employeeStartDate = DateTime.Today;

            TimeSpan dayDifferent = startDate - (employeeStartDate.AddYears(nYearID - 1));
            double   leaveEarned  = Convert.ToDouble(leaveTable.Rows[0]["inLeaveMaxQty"]) / 365.00 * dayDifferent.Days;

            leaveEarned = Math.Round(leaveEarned, 0);

            double leaveUsed = 0;

            if (leaveTable.Rows.Count > 1)
            {
                for (int i = 1; i <= leaveTable.Rows.Count - 1; i++)
                {
                    leaveUsed = leaveUsed + (Convert.ToDouble(leaveTable.Rows[i]["NoOfDays"]) * -1);
                }
            }

            double nLeaveBalance = leaveEarned - leaveUsed +
                                   Convert.ToDouble(leaveTable.Rows[0]["NoOfDays"]);

            return(nLeaveBalance);
        }
Esempio n. 4
0
 public DataTable ListOvertime(int nEmployeeID, DateTime startDate, DateTime endDate)
 {
     return(SqlHelperUtils.ExecuteDataTableSP("pr_tblOvertime_SelectAllWnEmployeeIDDateTime",
                                              new SqlParameter("@inEmployeeID", nEmployeeID),
                                              new SqlParameter("@ddtStartDate", SqlDbType.DateTime, 8, ParameterDirection.Input, true, 23, 3, "", DataRowVersion.Proposed, startDate),
                                              new SqlParameter("@ddtEndDate", SqlDbType.DateTime, 8, ParameterDirection.Input, true, 23, 3, "", DataRowVersion.Proposed, endDate)));
 }
Esempio n. 5
0
 public DataTable ListContacts(string strBranchCode, int nstatus, string txtSearchString)
 {
     return(SqlHelperUtils.ExecuteDataTableSP("sp_tblContactsNew_SelectAllWnBranchCodeLogic",
                                              new SqlParameter("@strBranchCode", strBranchCode),
                                              new SqlParameter("@nstatus", nstatus),
                                              new SqlParameter("@strSearchString", txtSearchString), SqlHelperUtils.paramErrorCode));
 }
Esempio n. 6
0
        public DataTable ListOneDetail(int nLeaveID)
        {
            SqlParameter paramLeaveID = new SqlParameter("@inLeaveID", SqlDbType.Int);

            paramLeaveID.Value = nLeaveID;

            return(SqlHelperUtils.ExecuteDataTableSP("pr_tblLeave_SelectBynLeaveID", paramLeaveID));
        }
Esempio n. 7
0
        public DataTable ListLeave(int nEmployeeID, Month aMonth, int year)
        {
            SqlParameter paramEmployeeID = new SqlParameter("@inEmployeeID", SqlDbType.Int);

            paramEmployeeID.Value = nEmployeeID;
            SqlParameter paramCurrentMonth = new SqlParameter("@ddtCurrentDate", SqlDbType.DateTime);

            paramCurrentMonth.Value = new DateTime(year, ((int)aMonth + 1), 1);

            return(SqlHelperUtils.ExecuteDataTableSP("pr_tblLeave_SelectCurrentMonthBynEmployeeID", paramEmployeeID,
                                                     paramCurrentMonth));
        }
        private void RetrieveRecordFromDB()
        {
            if (!isFinishBindInit)
            {
                return;
            }
            SqlParameter[] commandParameters = new SqlParameter[7];
            commandParameters[0] = new SqlParameter("@STARTDATE1", SqlDbType.DateTime, 8, ParameterDirection.Input, true, 23, 3, "", DataRowVersion.Proposed, dateEdit1.EditValue);
            commandParameters[1] = new SqlParameter("@ENDDATE1", SqlDbType.DateTime, 8, ParameterDirection.Input, true, 23, 3, "", DataRowVersion.Proposed, dateEdit2.EditValue);

            int i = 2;

            if (timeEdit1.EditValue.ToString() != "")
            {
                commandParameters[i] = new SqlParameter("@CLASSTIME1", SqlDbType.DateTime, 8, ParameterDirection.Input, true, 23, 3, "", DataRowVersion.Proposed, timeEdit1.EditValue);
                i += 1;
            }

            if (lkedtBranch.EditValue.ToString() != "")
            {
                commandParameters[i] = new SqlParameter("@BRANCHCODE1", lkedtBranch.EditValue);
                i += 1;
            }

            if (lkedtClassType.EditValue.ToString() != "")
            {
                commandParameters[i] = new SqlParameter("@CLASSTYPE1", lkedtClassType.EditValue);
                i += 1;
            }

            if (lkedtClassCode.EditValue.ToString() != "")
            {
                commandParameters[i] = new SqlParameter("@CLASSCODE1", lkedtClassCode.EditValue);
                i += 1;
            }

            if (lkedtInstructor.EditValue.ToString() != "")
            {
                commandParameters[i] = new SqlParameter("@INSTRUCTORID1", lkedtInstructor.EditValue);
                i += 1;
            }

            if (cmbDayOfWeek.Text != "")
            {
                commandParameters[i] = new SqlParameter("@DOW1", cmbDayOfWeek.Text);
                i += 1;
            }

            _dtClassSchedule = SqlHelperUtils.ExecuteDataTableSP("up_get_ClassAnalysis_Variable", commandParameters);
        }
Esempio n. 9
0
        public DataTable ListMiscLeave(int nEmployeeID, string strLeaveCode)
        {
            int nYearID = GetNYearID(nEmployeeID);

            SqlParameter paramEmployeeID = new SqlParameter("@inEmployeeID", SqlDbType.Int);

            paramEmployeeID.Value = nEmployeeID;
            SqlParameter paramYearID = new SqlParameter("@inYearID", SqlDbType.Int);

            paramYearID.Value = nYearID;
            SqlParameter paramLeaveCode = new SqlParameter("@sstrLeaveCode", SqlDbType.VarChar);

            paramLeaveCode.Value = strLeaveCode;

            return(SqlHelperUtils.ExecuteDataTableSP("pr_tblLeave_SelectMiscLeave", paramEmployeeID, paramYearID, paramLeaveCode));
        }
Esempio n. 10
0
        public DataTable GetAnnualLeaveBalance(int nEmployeeID, int nYearID)
        {
            DataTable employeeTable = SqlHelperUtils.ExecuteDataTableSP("pr_tblEmployee_SelectOne",
                                                                        new SqlParameter("@inEmployeeID", nEmployeeID));

            DateTime employeeStartDate;

            if (employeeTable.Rows[0]["dtEmployeeStartDate"] != DBNull.Value)
            {
                employeeStartDate = Convert.ToDateTime(employeeTable.Rows[0]["dtEmployeeStartDate"]);
            }
            else
            {
                employeeStartDate = new DateTime(DateTime.Today.Year, 1, 1);
            }

            DateTime startDate = employeeStartDate.AddYears(nYearID).AddDays(-1);

            DataTable leaveTable = SqlHelperUtils.ExecuteDataTableSP("pr_SelectAnnualLeaveBalance",
                                                                     new SqlParameter("@inEmployeeID", nEmployeeID),
                                                                     new SqlParameter("@inYearID", nYearID));

            if (!ACMS.Convert.ToBoolean(employeeTable.Rows[0]["fProbation"]))
            {
                TimeSpan dayDifferent = startDate - (employeeStartDate.AddYears(nYearID - 1));
                double   leaveEarned  = Convert.ToDouble(leaveTable.Rows[0]["inLeaveMaxQty"]) / 365.00 * dayDifferent.Days;
                leaveEarned = Math.Round(leaveEarned, 0);

                DataRow rNew = leaveTable.NewRow();
                rNew.BeginEdit();
                rNew["dtDate"]      = DateTime.Today;
                rNew["Transaction"] = "Leave earned";
                rNew["NoOfDays"]    = leaveEarned;
                rNew.EndEdit();
                leaveTable.Rows.Add(rNew);
            }
            else
            {
                leaveTable.Rows[0].Delete();
            }

            return(leaveTable);
        }
Esempio n. 11
0
        public DataTable GetSalesCommission(int nEmployeeID, string strBranchCode, CategoryType myCategory, Month month, int year)
        {
            DateTime startDate, endDate;

            Ultis.DatesRange(out startDate, out endDate, month, year);
            SqlParameter paramStartDate = new SqlParameter("@ddtStartDate", SqlDbType.DateTime);

            paramStartDate.Value = startDate;
            SqlParameter paramEndDate = new SqlParameter("@ddtEndDate", SqlDbType.DateTime);

            paramEndDate.Value = endDate;
            SqlParameter paramEmployeeID = new SqlParameter("@inEmployeeID", SqlDbType.Int);

            paramEmployeeID.Value = nEmployeeID;
            SqlParameter paramCategoryID = new SqlParameter("@inCategoryID", SqlDbType.Int);

            paramCategoryID.Value = (int)myCategory;
            return(SqlHelperUtils.ExecuteDataTableSP("pr_tblReceipt_SelectSalesCommission", paramCategoryID, paramStartDate,
                                                     paramEndDate, paramEmployeeID, new SqlParameter("@sstrBranchCode", strBranchCode)));
        }
Esempio n. 12
0
        public int GetNYearID(int nEmployeeID)
        {
            DateTime  startDate     = DateTime.Now;
            DataTable employeeTable = SqlHelperUtils.ExecuteDataTableSP("pr_tblEmployee_SelectOne",
                                                                        new SqlParameter("@inEmployeeID", nEmployeeID));

            DateTime employeeStartDate;

            if (employeeTable.Rows[0]["dtEmployeeStartDate"] != DBNull.Value)
            {
                employeeStartDate = Convert.ToDateTime(employeeTable.Rows[0]["dtEmployeeStartDate"]);
            }
            else
            {
                employeeStartDate = new DateTime(DateTime.Today.Year, 1, 1);
            }

            int nYearID = Ultis.NYearID(employeeStartDate, startDate);

            return(nYearID);
        }
Esempio n. 13
0
        public DataTable ListLeaveByYearIDStatus(int nEmployeeID, int nYearID, ListLeaveStatus aStatus)
        {
            SqlParameter paramEmployeeID = new SqlParameter("@inEmployeeID", SqlDbType.Int);

            paramEmployeeID.Value = nEmployeeID;
            SqlParameter paramYearID = new SqlParameter("@inYearID", SqlDbType.Int);

            paramYearID.Value = nYearID;
            SqlParameter paramLeaveStatus = new SqlParameter("@inStatusID", SqlDbType.Int);

            paramLeaveStatus.Value = (int)aStatus;
            if (aStatus != ListLeaveStatus.All)
            {
                return(SqlHelperUtils.ExecuteDataTableSP("pr_tblLeave_SelectLeaveBynEmployeeIDnYearIDnStatusID", paramEmployeeID,
                                                         paramYearID, paramLeaveStatus));
            }
            else
            {
                return(SqlHelperUtils.ExecuteDataTableSP("pr_tblLeave_SelectAllLeaveBynEmployeeIDnYearID", paramEmployeeID,
                                                         paramYearID));
            }
        }
Esempio n. 14
0
        public void UpdateTimeOff(int nLeaveID, int nEmployeeID, string strRemarks, DataRow rEmployeeInfo, DateTime startDate,
                                  DateTime endDate)
        {
            TimeSpan span = endDate - startDate;

            if (span.TotalHours > 4.0)
            {
                throw new Exception("Can't apply TimeOff larger then 4 hours.");
            }

            DataTable timeOffTable = SqlHelperUtils.ExecuteDataTableSP("pr_GetUpdateTimeOffBalanceInfo",
                                                                       new SqlParameter("@inEmployeeID", nEmployeeID),
                                                                       new SqlParameter("@inLeaveID", nLeaveID));

            int nTimeOffBalance = ACMS.Convert.ToInt32(timeOffTable.Rows[0]["nTimeOffBalance"]);

            DateTime employeeStartDate;

            if (rEmployeeInfo["dtEmployeeStartDate"] != DBNull.Value)
            {
                employeeStartDate = Convert.ToDateTime(rEmployeeInfo["dtEmployeeStartDate"]);
            }
            else
            {
                employeeStartDate = new DateTime(DateTime.Today.Year, 1, 1);
            }

            int nYearID = Ultis.NYearID(employeeStartDate, startDate);

            if (nTimeOffBalance >= span.Hours)
            {
                EditLeave(nLeaveID, nEmployeeID, nYearID, strRemarks, 0, 0, span.Hours, 0, false, startDate, endDate);
            }
            else
            {
                throw new Exception("Not enough time off balance.");
            }
        }
Esempio n. 15
0
        public DataTable ViewMemo(int nEmployeeID, ViewMemoType aType)
        {
            DataTable    dtblMessage;
            SqlParameter param1 = new SqlParameter("@nEmployeeID", nEmployeeID);

            if (aType == ViewMemoType.All)
            {
                dtblMessage = SqlHelperUtils.ExecuteDataTableSP("pr_tblMemo_SelectAllBynEmployeeID", param1);
            }
            else if (aType == ViewMemoType.BranchBulletin)
            {
                dtblMessage = SqlHelperUtils.ExecuteDataTableSP("pr_tblMemo_SelectBranchBulletinBynEmployeeID", param1);
            }
            else if (aType == ViewMemoType.PersonalMail)
            {
                dtblMessage = SqlHelperUtils.ExecuteDataTableSP("pr_tblMemo_SelectPersonalMailBynEmployeeID", param1);
            }
            else
            {
                dtblMessage = SqlHelperUtils.ExecuteDataTableSP("pr_tblMemo_SelectSentMailBynEmployeeID", param1);
            }
            return(dtblMessage);
        }
Esempio n. 16
0
        public void ApplyTimeOff(int nEmployeeID, string strRemarks, DataRow rEmployeeInfo, DateTime startDate, DateTime endDate)
        {
            /*
             * Edited by Albert. To get exact TimeOff Value.
             */
            TimeSpan span     = endDate - startDate;
            double   tTimeOff = span.TotalMinutes / 60;

            if (tTimeOff > 4.0)
            {
                throw new Exception("Can't apply TimeOff exceeding 4 hours.");
            }

            DataTable timeOffTable = SqlHelperUtils.ExecuteDataTableSP("pr_GetTimeOffBalanceInfo",
                                                                       new SqlParameter("@inEmployeeID", nEmployeeID));

            double nTimeOffBalance;

            if (timeOffTable.Rows.Count == 0)
            {
                nTimeOffBalance = 0;
            }
            else
            {
                nTimeOffBalance = ACMS.Convert.ToDouble(timeOffTable.Rows[0]["nTimeOffBalance"]);
            }

            DateTime employeeStartDate;

            if (rEmployeeInfo["dtEmployeeStartDate"] != DBNull.Value)
            {
                employeeStartDate = Convert.ToDateTime(rEmployeeInfo["dtEmployeeStartDate"]);
            }
            else
            {
                employeeStartDate = new DateTime(DateTime.Today.Year, 1, 1);
            }

            int nYearID = Ultis.NYearID(employeeStartDate, startDate);

            if (nTimeOffBalance >= tTimeOff)
            {
                NewLeave(nEmployeeID, "OFF", nYearID, strRemarks, true, 0, 0, tTimeOff, 0, false, startDate, endDate);
            }
            else
            {
                DialogResult result1 = MessageBox.Show(
                    "Insufficent time accumulated, take " + (tTimeOff - nTimeOffBalance) + " Hrs as Unpaid Time-Off?",
                    "Confirm Time Off",
                    MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                if (result1 == DialogResult.Yes)
                {
                    NewLeave(nEmployeeID, "OFF", nYearID, strRemarks, true, 0, 0, nTimeOffBalance, (tTimeOff - nTimeOffBalance), false, startDate, endDate);
                }
                else if (result1 == DialogResult.No)
                {
                    return;
                }
//				throw new Exception("Not enough time off balance.");
            }
        }
Esempio n. 17
0
 public DataTable ViewReceipientGroupEntries(int nMemoGroupID)
 {
     return(SqlHelperUtils.ExecuteDataTableSP("pr_tblMemoGroupEntries_SelectAllWnMemoGroupID",
                                              new SqlParameter("@inMemoGroupID", nMemoGroupID)));
 }
Esempio n. 18
0
 public DataTable ViewReceipientGroup(int nEmployeeID)
 {
     return(SqlHelperUtils.ExecuteDataTableSP("pr_tblMemoGroup_SelectAllWnEmployeeID",
                                              new SqlParameter("@inEmployeeID", nEmployeeID)));
 }
Esempio n. 19
0
 public DataTable GetTimeOffBalance(int nEmployeeID)
 {
     return(SqlHelperUtils.ExecuteDataTableSP("pr_SelectTimeOffBalance",
                                              new SqlParameter("@inEmployeeID", nEmployeeID)));
 }
Esempio n. 20
0
 public static DataRow EmployeeInfo(int nEmployeeID)
 {
     return(SqlHelperUtils.ExecuteDataTableSP("pr_tblEmployee_SelectOne",
                                              new SqlParameter("@inEmployeeID", nEmployeeID)).Rows[0]);
 }
Esempio n. 21
0
        public void ApplyAnnualLeave(int nEmployeeID, string strLeaveCode, string strRemarks, bool isFullDay, DateTime startDate,
                                     DateTime endDate)
        {
            DataTable employeeTable = SqlHelperUtils.ExecuteDataTableSP("pr_tblEmployee_SelectOne",
                                                                        new SqlParameter("@inEmployeeID", nEmployeeID));

            DateTime employeeStartDate;

            if (employeeTable.Rows[0]["dtEmployeeStartDate"] != DBNull.Value)
            {
                employeeStartDate = Convert.ToDateTime(employeeTable.Rows[0]["dtEmployeeStartDate"]);
            }
            else
            {
                employeeStartDate = new DateTime(DateTime.Today.Year, 1, 1);
            }

            int nYearID       = Ultis.NYearID(employeeStartDate, startDate);
            int CurrentYearID = Ultis.NYearID(employeeStartDate, DateTime.Now);

            double nLeaveQty;

            if (isFullDay)
            {
                nLeaveQty = 1.0;
            }
            else
            {
                nLeaveQty = 0.5;
            }

            if (!ACMS.Convert.ToBoolean(employeeTable.Rows[0]["fProbation"]))
            {
                DataTable leaveTable = SqlHelperUtils.ExecuteDataTableSP("pr_SelectAnnualLeaveBalance",
                                                                         new SqlParameter("@inEmployeeID", nEmployeeID),
                                                                         new SqlParameter("@inYearID", nYearID));

                TimeSpan dayDifferent = startDate - (employeeStartDate.AddYears(nYearID - 1));
                double   leaveEarned  = Convert.ToDouble(leaveTable.Rows[0]["inLeaveMaxQty"]) / 365.00 * dayDifferent.Days;
                leaveEarned = Math.Round(leaveEarned, 0);
//				double nLeaveBalance = leaveEarned - Convert.ToDouble(leaveTable.Rows[0]["inSumLeaveQty"]) +
//					Convert.ToDouble(leaveTable.Rows[0]["NoOfDays"]);


                double leaveUsed = 0;

                if (leaveTable.Rows.Count > 1)
                {
                    for (int i = 1; i <= leaveTable.Rows.Count - 1; i++)
                    {
                        leaveUsed = leaveUsed + (Convert.ToDouble(leaveTable.Rows[i]["NoOfDays"]) * -1);
                    }
                }

                double nLeaveBalance = leaveEarned - leaveUsed +
                                       Convert.ToDouble(leaveTable.Rows[0]["NoOfDays"]);

                if (nLeaveBalance >= nLeaveQty && nYearID == CurrentYearID)
                {
                    NewLeave(nEmployeeID, strLeaveCode, nYearID, strRemarks, false, nLeaveQty, 0, 0, 0, isFullDay, startDate,
                             endDate);
                }
                else if (nLeaveBalance >= 0 || nYearID > CurrentYearID)//unpaid leave
                {
                    DialogResult result1 = MessageBox.Show(
                        "Take as Unpaid Leave?",
                        "Confirm Leave",
                        MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                    if (result1 == DialogResult.Yes)
                    {
                        if (nYearID > CurrentYearID)
                        {
                            NewLeave(nEmployeeID, strLeaveCode, nYearID, strRemarks, false, nLeaveBalance, 1, 0, 0,
                                     isFullDay, startDate, endDate);
                        }
                        else
                        {
                            NewLeave(nEmployeeID, strLeaveCode, nYearID, strRemarks, false, nLeaveBalance, nLeaveQty - nLeaveBalance, 0, 0,
                                     isFullDay, startDate, endDate);
                        }
                    }
                    else if (result1 == DialogResult.No)
                    {
                        return;
                    }
                }
                else
                {
                    NewLeave(nEmployeeID, strLeaveCode, nYearID, strRemarks, false, 0, nLeaveQty, 0, 0, isFullDay, startDate,
                             endDate);
                }
            }
            else
            {
                NewLeave(nEmployeeID, strLeaveCode, nYearID, strRemarks, false, 0, nLeaveQty, 0, 0, isFullDay, startDate, endDate);
            }
        }
Esempio n. 22
0
        public void ListCV(int nEmployeeID, object nSubmitter, object nAssignTo, CVStatusID aCVStatusID, bool isManager)
        {
            SqlParameter paramEmp = new SqlParameter("@inEmployeeID", nEmployeeID);
            SqlParameter paramSum = new SqlParameter("@inSubmiterID", nSubmitter);
            SqlParameter paramAss = new SqlParameter("@inAssignToID", nAssignTo);

            if (aCVStatusID != CVStatusID.All)
            {
                SqlParameter paramCVStatus = new SqlParameter("@inStatusID", (int)aCVStatusID);
                if (nSubmitter == DBNull.Value && nAssignTo == DBNull.Value)
                {
                    listCVTable = SqlHelperUtils.ExecuteDataTableSP("pr_tblCase_SelectCVBynEmployeeIDnStatusID", paramEmp,
                                                                    paramCVStatus);
                }
                else if (nSubmitter == DBNull.Value && nAssignTo != DBNull.Value)
                {
                    listCVTable = SqlHelperUtils.ExecuteDataTableSP("pr_tblCase_SelectCVBynAssignTonStatusID", paramAss,
                                                                    paramCVStatus);
                }
                else if (nSubmitter != DBNull.Value && nAssignTo == DBNull.Value)
                {
                    if (!isManager)
                    {
                        listCVTable = SqlHelperUtils.ExecuteDataTableSP("pr_tblCase_SelectCVBynSubmiternStatusID", paramSum,
                                                                        paramCVStatus);
                    }
                    else
                    {
                        listCVTable = SqlHelperUtils.ExecuteDataTableSP("pr_tblCase_SelectCVBynSubmiternStatusIDManager", paramSum,
                                                                        paramCVStatus);
                    }
                }
                else
                {
                    if (!isManager)
                    {
                        listCVTable = SqlHelperUtils.ExecuteDataTableSP("pr_tblCase_SelectCVBynSubmiternAssignTonStatusID",
                                                                        paramSum, paramAss, paramCVStatus);
                    }
                    else
                    {
                        listCVTable = SqlHelperUtils.ExecuteDataTableSP("pr_tblCase_SelectCVBynSubmiternAssignTonStatusIDManager",
                                                                        paramSum, paramAss, paramCVStatus);
                    }
                }
            }
            else
            {
                if (nSubmitter == DBNull.Value && nAssignTo == DBNull.Value)
                {
                    listCVTable = SqlHelperUtils.ExecuteDataTableSP("pr_tblCase_SelectAllCVBynEmployeeID", paramEmp);
                }
                else if (nSubmitter == DBNull.Value && nAssignTo != DBNull.Value)
                {
                    listCVTable = SqlHelperUtils.ExecuteDataTableSP("pr_tblCase_SelectAllCVByAssignTo", paramAss);
                }
                else if (nSubmitter != DBNull.Value && nAssignTo == DBNull.Value)
                {
                    if (!isManager)
                    {
                        listCVTable = SqlHelperUtils.ExecuteDataTableSP("pr_tblCase_SelectAllCVBySubmiter", paramSum);
                    }
                    else
                    {
                        listCVTable = SqlHelperUtils.ExecuteDataTableSP("pr_tblCase_SelectAllCVBySubmiterManager", paramSum);
                    }
                }
                else
                {
                    if (!isManager)
                    {
                        listCVTable = SqlHelperUtils.ExecuteDataTableSP("pr_tblCase_SelectAllCVBySubmiterAssignTo", paramSum,
                                                                        paramAss);
                    }
                    else
                    {
                        listCVTable = SqlHelperUtils.ExecuteDataTableSP("pr_tblCase_SelectAllCVBySubmiterAssignToManager", paramSum,
                                                                        paramAss);
                    }
                }
            }
        }
Esempio n. 23
0
        public void UpdateAnnualLeave(int nLeaveID, int nEmployeeID, string strLeaveCode, string strRemarks, bool isFullDay,
                                      DateTime startDate, DateTime endDate)
        {
            DataTable employeeTable = SqlHelperUtils.ExecuteDataTableSP("pr_tblEmployee_SelectOne",
                                                                        new SqlParameter("@inEmployeeID", nEmployeeID));

            DateTime employeeStartDate;

            if (employeeTable.Rows[0]["dtEmployeeStartDate"] != DBNull.Value)
            {
                employeeStartDate = Convert.ToDateTime(employeeTable.Rows[0]["dtEmployeeStartDate"]);
            }
            else
            {
                employeeStartDate = new DateTime(DateTime.Today.Year, 1, 1);
            }

            int nYearID = Ultis.NYearID(employeeStartDate, startDate);

            double nLeaveQty;

            if (isFullDay)
            {
                nLeaveQty = 1.0;
            }
            else
            {
                nLeaveQty = 0.5;
            }

            if (!ACMS.Convert.ToBoolean(employeeTable.Rows[0]["fProbation"]))
            {
                DataTable leaveTable = SqlHelperUtils.ExecuteDataTableSP("pr_GetUpdateAnnualLeaveBalanceInfo",
                                                                         new SqlParameter("@inEmployeeID", nEmployeeID),
                                                                         new SqlParameter("@inLeaveID", nLeaveID),
                                                                         new SqlParameter("@inYearID", nYearID));

                TimeSpan dayDifferent = startDate - (employeeStartDate.AddYears(nYearID - 1));
                double   leaveEarned  = Convert.ToDouble(leaveTable.Rows[0]["inLeaveMaxQty"]) / 365.00 * dayDifferent.Days;
                leaveEarned = Math.Round(leaveEarned, 0);

                double nLeaveBalance = leaveEarned - Convert.ToDouble(leaveTable.Rows[0]["inSumLeaveQty"]) +
                                       Convert.ToDouble(leaveTable.Rows[0]["inSumBFLeaveQty"]);

                if (nLeaveBalance >= nLeaveQty)
                {
                    EditLeave(nLeaveID, nEmployeeID, nYearID, strRemarks, nLeaveQty, 0, 0, 0, isFullDay, startDate, endDate);
                }
                else if (nLeaveBalance >= 0)
                {
                    EditLeave(nLeaveID, nEmployeeID, nYearID, strRemarks, nLeaveBalance, nLeaveQty - nLeaveBalance, 0, 0,
                              isFullDay, startDate, endDate);
                }
                else
                {
                    EditLeave(nLeaveID, nEmployeeID, nYearID, strRemarks, 0, nLeaveQty, 0, 0, isFullDay, startDate, endDate);
                }
            }
            else
            {
                EditLeave(nLeaveID, nEmployeeID, nYearID, strRemarks, 0, nLeaveQty, 0, 0, isFullDay, startDate, endDate);
            }
        }