예제 #1
0
    public SqlCommand InsertIntoEmpLevPro(clsEmpLeaveProfile clEmp, string strIsUpdate, string strIsDelete)
    {
        try
        {
            SqlCommand cmd = new SqlCommand("proc_Insert_EmpLeaveProfile");
            cmd.CommandType = CommandType.StoredProcedure;

            SqlParameter p_EmpId = cmd.Parameters.Add("EmpId", SqlDbType.Char);
            p_EmpId.Direction = ParameterDirection.Input;
            p_EmpId.Value     = clEmp.EmpId;

            SqlParameter p_LTypeID = cmd.Parameters.Add("LTypeID", SqlDbType.BigInt);
            p_LTypeID.Direction = ParameterDirection.Input;
            p_LTypeID.Value     = clEmp.LTypeID;

            SqlParameter p_LEntitled = cmd.Parameters.Add("LEntitled", SqlDbType.BigInt);
            p_LEntitled.Direction = ParameterDirection.Input;
            p_LEntitled.Value     = clEmp.LEntitled;

            SqlParameter p_InsertedBy = cmd.Parameters.Add("InsertedBy", SqlDbType.VarChar);
            p_InsertedBy.Direction = ParameterDirection.Input;
            p_InsertedBy.Value     = clEmp.InsertedBy;

            SqlParameter p_InsertedDate = cmd.Parameters.Add("InsertedDate", SqlDbType.DateTime);
            p_InsertedDate.Direction = ParameterDirection.Input;
            p_InsertedDate.Value     = clEmp.InsertedDate;

            SqlParameter p_IsUpdate = cmd.Parameters.Add("IsUpdate", SqlDbType.Char);
            p_IsUpdate.Direction = ParameterDirection.Input;
            p_IsUpdate.Value     = strIsUpdate;

            SqlParameter p_IsDelete = cmd.Parameters.Add("IsDelete", SqlDbType.Char);
            p_IsDelete.Direction = ParameterDirection.Input;
            p_IsDelete.Value     = strIsDelete;

            return(cmd);
        }
        catch (Exception ex)
        {
            throw (ex);
        }
    }
예제 #2
0
    //public void UpdateLeaveEntitlement(GridView grEmployee, string UserId, string strLPakId)
    //{
    //    try
    //    {
    //        int i = 0;
    //        DataTable dtLeavePeriod = new DataTable();
    //        DataTable dtLevProfile = new DataTable();
    //        DataTable dtLevPakMst = new DataTable();

    //        int LeaveAvail = 0;
    //        int LEntitled = 0;
    //        decimal tempValue = 0;
    //        string IsLeaveOnJoinDate = "";

    //        DateTime JoinYear;
    //        DateTime CurrYear = DateTime.Now;
    //        clsEmpLeaveProfile objEmpLevPro = new clsEmpLeaveProfile();

    //        if (dtLeavePeriod.Rows.Count == 0)
    //        {
    //            dtLeavePeriod = SelectLeavePeriod(strLPakId);
    //        }

    //        dtLevProfile = SelectEmpLeaveProfile(strLPakId);

    //        SqlCommand[] cmd = new SqlCommand[dtLevProfile.Rows.Count];

    //        if (dtLevProfile.Rows.Count > 0)
    //        {
    //            IsLeaveOnJoinDate = dtLevProfile.Rows[0]["IsLCalOnJoinDate"].ToString();
    //        }

    //        if (dtLevProfile.Rows.Count > 0)
    //        {
    //            foreach (DataRow LTRow in dtLevProfile.Rows)
    //            {
    //                DataRow[] foundRows;
    //                string strExpr = "";
    //                strExpr = "LTypeId='" + LTRow["LTypeId"].ToString().Trim() + "'";

    //                foundRows = dtLevProfile.Select(strExpr);
    //                if (foundRows.Length > 0)//data found in profile so update it with new entitled amount
    //                {
    //                    if (IsLeaveOnJoinDate == "Y")
    //                    {
    //                        LeaveAvail = 0;
    //                        if (LTRow["MaxLAmt"].ToString() != "0")
    //                        {
    //                            ////if ((LTRow["LAbbrName"].ToString().Trim() != "EL") && (LTRow["LAbbrName"].ToString().Trim() != "SL"))// All Leave Entitled Except Annual Leave
    //                            ////{
    //                            ////    LEntitled = Convert.ToInt32(LTRow["MaxLAmt"]);
    //                            ////}
    //                            ////else// "EL or SL"
    //                            ////{
    //                            foreach (DataRow dRow in dtLeavePeriod.Rows)
    //                            {
    //                                CurrYear = Convert.ToDateTime(dRow["LeaveStartPeriod"]);
    //                                }
    //                                CurrYear = CurrYear.AddYears(-1);

    //                                if (LTRow["JoiningDate"].ToString() == "")
    //                                {
    //                                    JoinYear = CurrYear;
    //                                }
    //                                else
    //                                {
    //                                    JoinYear = Convert.ToDateTime(LTRow["JoiningDate"].ToString());
    //                                }
    //                                //if (JoinYear > CurrYear.AddYears(1))
    //                                //{
    //                                //    ////LEntitled = 0;
    //                                //}
    //                                //else

    //                                if (JoinYear > CurrYear && (JoinYear < CurrYear.AddYears(1)))
    //                                {
    //                                    TimeSpan DateDiff = JoinYear - CurrYear;
    //                                    string strTotDay = ReturnTotalDay(DateDiff.ToString());
    //                                    tempValue = (Convert.ToDecimal(LTRow["MaxLAmt"]) / 365);
    //                                    tempValue = (tempValue * (365 - Convert.ToInt32(strTotDay)));
    //                                    LeaveAvail = Convert.ToInt32(tempValue);
    //                                    LEntitled = LeaveAvail;
    //                                }
    //                                else
    //                                    LEntitled = Convert.ToInt32(LTRow["MaxLAmt"]);
    //                            ////}
    //                        }
    //                        else
    //                            LEntitled = Convert.ToInt32(LTRow["MaxLAmt"]);
    //                    }
    //                    else
    //                    {
    //                        LEntitled = Convert.ToInt32(LTRow["MaxLAmt"]);
    //                    }
    //                    objEmpLevPro = new clsEmpLeaveProfile(LTRow["EmpId"].ToString(), LTRow["LTypeId"].ToString().Trim(), LEntitled.ToString(),
    //                        UserId, Common.SetDateTime(DateTime.Now.ToString()));

    //                    cmd[i] = InsertIntoEmpLevPro(objEmpLevPro, "Y", "N");
    //                    i++;
    //                }
    //            }
    //        }

    //        dtLevProfile.Rows.Clear();
    //        i++;
    //        objDC.MakeTransaction(cmd);
    //    }
    //    catch (Exception ex)
    //    {
    //        throw (ex);
    //    }

    //    //try
    //    //{
    //    //    int i = 0;
    //    //    DataTable dtLevProfile = new DataTable();
    //    //    int LEntitled = 0;
    //    //    clsEmpLeaveProfile objEmpLevPro = new clsEmpLeaveProfile();

    //    //    SqlCommand[] cmd = new SqlCommand[(grEmployee.Rows.Count*2) + 1];

    //    //    foreach (GridViewRow gRow in grEmployee.Rows)
    //    //    {
    //    //        CheckBox chBox = new CheckBox();
    //    //        chBox = (CheckBox)gRow.Cells[0].FindControl("chkBox");
    //    //        if (chBox.Checked == true)
    //    //        {
    //    //            dtLevProfile = SelectEmpLeaveProfile(strLPakId, gRow.Cells[2].Text.Trim());
    //    //            if (dtLevProfile.Rows.Count > 0)
    //    //            {
    //    //                //AL
    //    //                LEntitled = Convert.ToInt32(dtLevProfile.Rows[0]["MaxLAmt"]);

    //    //                objEmpLevPro = new clsEmpLeaveProfile(dtLevProfile.Rows[0]["EmpId"].ToString(), dtLevProfile.Rows[0]["LTypeId"].ToString().Trim(), LEntitled.ToString(),
    //    //                    UserId, Common.SetDateTime(DateTime.Now.ToString()));

    //    //                cmd[i] = InsertIntoEmpLevPro(objEmpLevPro, "Y", "N");
    //    //                i++;

    //    //                //SL
    //    //                LEntitled = Convert.ToInt32(dtLevProfile.Rows[0]["MaxLAmt"]);

    //    //                objEmpLevPro = new clsEmpLeaveProfile(dtLevProfile.Rows[0]["EmpId"].ToString(), dtLevProfile.Rows[1]["LTypeId"].ToString().Trim(), LEntitled.ToString(),
    //    //                    UserId, Common.SetDateTime(DateTime.Now.ToString()));

    //    //                cmd[i] = InsertIntoEmpLevPro(objEmpLevPro, "Y", "N");
    //    //                i++;
    //    //            }
    //    //        }
    //    //        dtLevProfile.Rows.Clear();
    //    //    }

    //    //    cmd[i] = UpdateLeavePeriod(strLPakId);
    //    //    i++;

    //    //    objDC.MakeTransaction(cmd);
    //    //}
    //    //catch (Exception ex)
    //    //{
    //    //    throw (ex);
    //    //}
    //}

    public void UpdateLeaveEntitlement(GridView grEmployee, string UserId, string strLPakId)
    {
        try
        {
            int       i             = 0;
            DataTable dtLeavePeriod = new DataTable();
            DataTable dtLevProfile  = new DataTable();
            DataTable dtLevPakMst   = new DataTable();

            int     LeaveAvail        = 0;
            int     LEntitled         = 0;
            decimal tempValue         = 0;
            string  IsLeaveOnJoinDate = "";

            DateTime           JoinYear;
            DateTime           CurrYear     = DateTime.Now;
            clsEmpLeaveProfile objEmpLevPro = new clsEmpLeaveProfile();

            if (dtLeavePeriod.Rows.Count == 0)
            {
                dtLeavePeriod = SelectLeavePeriod(strLPakId);
            }

            dtLevProfile = SelectEmpLeaveProfile(strLPakId);

            SqlCommand[] cmd = new SqlCommand[dtLevProfile.Rows.Count];

            if (dtLevProfile.Rows.Count > 0)
            {
                IsLeaveOnJoinDate = dtLevProfile.Rows[0]["IsLCalOnJoinDate"].ToString();
            }

            if (dtLevProfile.Rows.Count > 0)
            {
                foreach (DataRow LTRow in dtLevProfile.Rows)
                {
                    DataRow[] foundRows;
                    string    strExpr = "";
                    strExpr = "LTypeId='" + LTRow["LTypeId"].ToString().Trim() + "'";

                    foundRows = dtLevProfile.Select(strExpr);
                    if (foundRows.Length > 0)//data found in profile so update it with new entitled amount
                    {
                        if (IsLeaveOnJoinDate == "Y")
                        {
                            LeaveAvail = 0;
                            if (LTRow["MaxLAmt"].ToString() != "0")
                            {
                                //if (LTRow["LAbbrName"].ToString().Trim() != "AL")// All Leave Entitled Except Annual Leave
                                //{
                                //    LEntitled = Convert.ToInt32(LTRow["MaxLAmt"]);
                                //}
                                //else// "AL"
                                //{
                                foreach (DataRow dRow in dtLeavePeriod.Rows)
                                {
                                    CurrYear = Convert.ToDateTime(dRow["LeaveStartPeriod"]);
                                }
                                //CurrYear = CurrYear.AddYears(-1);

                                if (LTRow["JoiningDate"].ToString() == "")
                                {
                                    JoinYear = CurrYear;
                                }
                                else
                                {
                                    JoinYear = Convert.ToDateTime(LTRow["JoiningDate"].ToString());
                                }
                                if (JoinYear > CurrYear.AddYears(1))
                                {
                                    LEntitled = 0;
                                }
                                else if (JoinYear > CurrYear && (JoinYear < CurrYear.AddYears(1)))
                                {
                                    TimeSpan DateDiff  = JoinYear - CurrYear;
                                    string   strTotDay = ReturnTotalDay(DateDiff.ToString());
                                    tempValue  = (Convert.ToDecimal(LTRow["MaxLAmt"]) / 365);
                                    tempValue  = (tempValue * (365 - Convert.ToInt32(strTotDay)));
                                    LeaveAvail = Convert.ToInt32(tempValue);
                                    LEntitled  = LeaveAvail;
                                }
                                else
                                {
                                    LEntitled = Convert.ToInt32(LTRow["MaxLAmt"]);
                                }
                            }
                            //}
                            //else
                            //    LEntitled = Convert.ToInt32(LTRow["MaxLAmt"]);
                        }
                        else
                        {
                            LEntitled = Convert.ToInt32(LTRow["MaxLAmt"]);
                        }
                        objEmpLevPro = new clsEmpLeaveProfile(LTRow["EmpId"].ToString(), LTRow["LTypeId"].ToString().Trim(), LEntitled.ToString(),
                                                              UserId, Common.SetDateTime(DateTime.Now.ToString()));

                        cmd[i] = InsertIntoEmpLevPro(objEmpLevPro, "Y", "N");
                        i++;
                    }
                }
            }

            dtLevProfile.Rows.Clear();
            i++;
            objDC.MakeTransaction(cmd);
        }
        catch (Exception ex)
        {
            throw (ex);
        }
    }
    public SqlCommand[] UpdatedEmpLevProfile(string EmpId, string LPakId, string JoiningDate, string userId, string strEmpTypeId)
    {
        try
        {
            i = 0;
            decimal LeaveAvail        = 0;
            decimal LEntitled         = 0;
            decimal tempValue         = 0;
            string  IsLeaveOnJoinDate = "";

            DateTime           dtJoinDate;
            DateTime           dtLeaveStDate = DateTime.Now;
            clsEmpLeaveProfile objEmpLevPro  = new clsEmpLeaveProfile();
            SqlCommand[]       cmd           = new SqlCommand[15];

            if (dtLeavePakMst.Rows.Count == 0)
            {
                dtLeavePakMst = SelectLeavePakMst(LPakId);
            }

            DataTable dtLeavePeriod = SelectLeavePeriod(LPakId);

            if (dtLeavePeriod.Rows.Count > 0)
            {
                dtLeaveStDate = Convert.ToDateTime(dtLeavePeriod.Rows[0]["LeaveStartPeriod"]);
            }

            DataTable dtLevProfile = objLeaveAppMgr.SelectEmpLeaveProfile(EmpId, "0");

            DataTable dtLeaveType = objLeaveMgr.SelectLeavePakDet(Convert.ToInt32(LPakId));

            if (dtLeavePakMst.Rows.Count > 0)
            {
                IsLeaveOnJoinDate = dtLeavePakMst.Rows[0]["IsLCalOnJoinDate"].ToString();
            }

            if (dtLeaveType.Rows.Count > 0)
            {
                if (dtLevProfile.Rows.Count > 0)
                {
                    foreach (DataRow LTRow in dtLeaveType.Rows)
                    {
                        DataRow[] foundRows;
                        string    strExpr = "";
                        strExpr   = "LTypeId='" + LTRow["LTypeId"].ToString().Trim() + "'";
                        foundRows = dtLevProfile.Select(strExpr);
                        if (foundRows.Length > 0)
                        {
                            if (IsLeaveOnJoinDate == "Y")
                            {
                                LeaveAvail = 0;
                                if (LTRow["MaxLAmt"].ToString() != "0")
                                {
                                    dtLeaveStDate = Convert.ToDateTime(dtLeavePeriod.Rows[0]["LeaveStartPeriod"]);
                                    if (JoiningDate == "")
                                    {
                                        dtJoinDate = dtLeaveStDate;
                                    }
                                    else
                                    {
                                        dtJoinDate = Convert.ToDateTime(JoiningDate);
                                    }

                                    if (dtJoinDate > dtLeaveStDate)
                                    {
                                        TimeSpan DateDiff  = dtJoinDate - dtLeaveStDate;
                                        string   strTotDay = ReturnTotalDay(DateDiff.ToString());
                                        tempValue  = (Convert.ToDecimal(LTRow["MaxLAmt"]) / 366);
                                        tempValue  = (tempValue * (366 - Convert.ToInt32(strTotDay)));
                                        LeaveAvail = Convert.ToDecimal(tempValue);
                                        LeaveAvail = Math.Round(LeaveAvail, 2);

                                        char[]   strSpliter = { '.' };
                                        string[] arinfo     = new string[2];

                                        arinfo    = LeaveAvail.ToString().Split(strSpliter);
                                        LEntitled = Convert.ToDecimal(LTRow["LEntitled"]) + LeaveAvail;
                                    }
                                    else
                                    {
                                        LEntitled = Convert.ToDecimal(LTRow["LEntitled"]) + Convert.ToDecimal(LTRow["MaxLAmt"]);
                                    }
                                }
                                else
                                {
                                    LEntitled = Convert.ToDecimal(LTRow["LEntitled"]) + Convert.ToDecimal(LTRow["MaxLAmt"]);
                                }
                            }
                            else
                            {
                                LEntitled = Convert.ToDecimal(LTRow["LEntitled"]) + Convert.ToDecimal(LTRow["MaxLAmt"]);
                            }

                            objEmpLevPro = new clsEmpLeaveProfile(EmpId, LTRow["LTypeId"].ToString().Trim(), LEntitled.ToString(),
                                                                  userId, Common.SetDateTime(DateTime.Now.ToString()));

                            cmd[i] = InsertIntoEmpLevPro(objEmpLevPro, "Y", "N");
                            i++;
                        }
                    }
                }
            }
            dtLeaveType.Rows.Clear();
            dtLevProfile.Rows.Clear();
            return(cmd);
        }
        catch (Exception ex)
        {
            throw (ex);
        }
    }
    public SqlCommand[] UpdateConfirmLevProfile(string EmpId, string LPakId, string ConfirmDate, string JoiningDate, string userId)
    {
        try
        {
            i = 0;
            DataTable dtLeavePeriod = new DataTable();

            decimal LeaveAvail        = 0;
            decimal LEntitled         = 0;
            decimal tempValue         = 0;
            string  IsLeaveOnJoinDate = "";

            DateTime dtJoinDate;
            DateTime dtLeaveStDate = DateTime.Now;

            if (dtLeavePakMst.Rows.Count == 0)
            {
                dtLeavePakMst = SelectLeavePakMst(LPakId);
            }
            if (dtLeavePeriod.Rows.Count == 0)
            {
                dtLeavePeriod = SelectLeavePeriod(LPakId);
            }

            dtLevProfile = objLeaveMgr.SelectEmpLeaveProfile(EmpId, "0");

            DataTable dtLeaveType = new DataTable();
            if (dtLeaveType.Rows.Count == 0)
            {
                dtLeaveType = SelectLPakDetls(LPakId);
            }

            DateTime           ConfirmYear      = new DateTime();
            DateTime           CurrYear         = DateTime.Now;
            DateTime           dtLeaveEndPeriod = new DateTime();
            clsEmpLeaveProfile objEmpLevPro     = new clsEmpLeaveProfile();
            SqlCommand[]       cmd = new SqlCommand[11];

            if (dtLeavePakMst.Rows.Count > 0)
            {
                IsLeaveOnJoinDate = dtLeavePakMst.Rows[0]["IsLCalOnJoinDate"].ToString();
            }

            if (dtLeaveType.Rows.Count > 0)
            {
                if (dtLevProfile.Rows.Count > 0)
                {
                    foreach (DataRow LTRow in dtLeaveType.Rows)
                    {
                        //foreach (DataRow LevProRow in dtLevProfile.Rows)
                        //{
                        DataRow[] foundProfileRows = dtLevProfile.Select("LTypeId=" + LTRow["LTypeId"].ToString());
                        foreach (DataRow dRow in dtLeavePeriod.Rows)
                        {
                            dtLeaveEndPeriod = Convert.ToDateTime(dRow["LeaveEndPeriod"]);
                            ConfirmYear      = Convert.ToDateTime(ConfirmDate);
                        }

                        Int32 MaxLogConfirmMonth = 0;
                        Int32 MaxLogConfirmYear  = 0;
                        Int32 iRemainMonth       = 0;

                        DataTable dtRemainMonth = new DataTable();
                        dtRemainMonth = GET_LeaveEntitleMaxMonth(EmpId);
                        foreach (DataRow dataRow in dtRemainMonth.Rows)
                        {
                            MaxLogConfirmMonth = Convert.ToInt32(dataRow["MaxMonth"].ToString());
                            MaxLogConfirmYear  = Convert.ToInt32(dataRow["MaxYear"].ToString());
                        }

                        Int32 iConfirmMonth = ConfirmYear.Month;
                        Int32 iEndMonth     = dtLeaveEndPeriod.Month;

                        if (ConfirmYear.Year > MaxLogConfirmYear)
                        {
                            iRemainMonth = (iEndMonth - iConfirmMonth) + 1;
                        }
                        else
                        {
                            if (iConfirmMonth < MaxLogConfirmMonth)
                            {
                                iRemainMonth = (iEndMonth - MaxLogConfirmMonth) + 1;
                            }
                            else
                            {
                                iRemainMonth = (iEndMonth - iConfirmMonth) + 1;
                            }
                        }

                        dtLeaveStDate = Convert.ToDateTime(dtLeavePeriod.Rows[0]["LeaveStartPeriod"]);
                        if (JoiningDate == "")
                        {
                            dtJoinDate = dtLeaveStDate;
                        }
                        else
                        {
                            dtJoinDate = Convert.ToDateTime(JoiningDate);
                        }

                        if (dtJoinDate > dtLeaveStDate)
                        {
                            TimeSpan DateDiff  = dtJoinDate - dtLeaveStDate;
                            string   strTotDay = ReturnTotalDay(DateDiff.ToString());
                            tempValue  = (Convert.ToDecimal(LTRow["MaxLAmt"]) / 366);
                            tempValue  = (tempValue * (366 - Convert.ToInt32(strTotDay)));
                            LeaveAvail = Convert.ToDecimal(tempValue);
                            LeaveAvail = Math.Round(LeaveAvail, 2);

                            //char[] strSpliter = { '.' };
                            //string[] arinfo = new string[2];

                            //arinfo = LeaveAvail.ToString().Split(strSpliter);
                            LEntitled = LeaveAvail + Convert.ToDecimal(foundProfileRows[0]["LEntitled"]);
                        }
                        objEmpLevPro = new clsEmpLeaveProfile(EmpId, LTRow["LTypeId"].ToString().Trim(), LEntitled.ToString(),
                                                              userId, Common.SetDateTime(DateTime.Now.ToString()));

                        cmd[i] = InsertIntoEmpLevPro(objEmpLevPro, "Y", "N");
                        //}
                        i++;
                    }
                }
            }
            dtLeaveType.Rows.Clear();
            dtLevProfile.Rows.Clear();

            return(cmd);
        }
        catch (Exception ex)
        {
            throw (ex);
        }
    }
    public SqlCommand[] InsertIntoEmpLevProfile(string EmpId, string LPakId, string JoiningDate, string userId, string strEmpTypeId)
    {
        try
        {
            i = 0;

            decimal LEntitled         = 0;
            string  IsLeaveOnJoinDate = "";

            DateTime           dtLeaveStDate = DateTime.Now;
            clsEmpLeaveProfile objEmpLevPro  = new clsEmpLeaveProfile();
            SqlCommand[]       cmd           = new SqlCommand[15];

            if (dtLeavePakMst.Rows.Count == 0)
            {
                dtLeavePakMst = SelectLeavePakMst(LPakId);
            }

            DataTable dtLeavePeriod = SelectLeavePeriod(LPakId);

            if (dtLeavePeriod.Rows.Count > 0)
            {
                dtLeaveStDate = Convert.ToDateTime(dtLeavePeriod.Rows[0]["LeaveStartPeriod"]);
            }

            DataTable dtLevProfile = objLeaveAppMgr.SelectEmpLeaveProfile(EmpId, "0");

            DataTable dtLeaveType = objLeaveMgr.SelectLeavePakDet(Convert.ToInt32(LPakId));

            if (dtLeavePakMst.Rows.Count > 0)
            {
                IsLeaveOnJoinDate = dtLeavePakMst.Rows[0]["IsLCalOnJoinDate"].ToString();
            }

            if (dtLeaveType.Rows.Count > 0)
            {
                if (dtLevProfile.Rows.Count > 0)
                {
                    foreach (DataRow LTRow in dtLeaveType.Rows)
                    {
                        LEntitled    = 0;
                        objEmpLevPro = new clsEmpLeaveProfile(EmpId, LTRow["LTypeId"].ToString().Trim(), Math.Round(LEntitled, 2).ToString(),
                                                              userId, Common.SetDateTime(DateTime.Now.ToString()));

                        cmd[i] = InsertIntoEmpLevPro(objEmpLevPro, "Y", "N");
                        i++;
                    }
                }
                else
                {
                    foreach (DataRow LTRow in dtLeaveType.Rows)
                    {
                        if (IsLeaveOnJoinDate == "Y")
                        {
                            LEntitled = 0;
                        }

                        objEmpLevPro = new clsEmpLeaveProfile(EmpId, LTRow["LTypeId"].ToString().Trim(), Math.Round(LEntitled, 2).ToString(),
                                                              userId, Common.SetDateTime(DateTime.Now.ToString()));

                        cmd[i] = InsertIntoEmpLevPro(objEmpLevPro, "N", "N");
                        i++;
                    }
                }
            }

            dtLeaveType.Rows.Clear();
            dtLevProfile.Rows.Clear();
            return(cmd);
        }
        catch (Exception ex)
        {
            throw (ex);
        }
    }
예제 #6
0
    public SqlCommand[] UpdateConfirmLevProfile(string EmpId, string LPakId, string ConfirmDate, string userId)
    {
        try
        {
            i = 0;
            DataTable dtLeavePeriod    = new DataTable();
            DataTable dtEmpLeaveDelete = new DataTable();
            dtEmpLeaveDelete = DeleteEmpLeaveProfile(EmpId, LPakId);
            if (dtLeavePakMst.Rows.Count == 0)
            {
                dtLeavePakMst = SelectLeavePakMst(LPakId);
            }
            if (dtLeavePeriod.Rows.Count == 0)
            {
                dtLeavePeriod = SelectLeavePeriod(LPakId);
            }

            dtLevProfile = objLeaveMgr.SelectEmpLeaveProfile(EmpId, "");

            DataTable dtLeaveType = new DataTable();
            if (dtLeaveType.Rows.Count == 0)
            {
                dtLeaveType = SelectLPakDetls(LPakId);
            }
            decimal LEntitled = 0;

            string IsLeaveOnJoinDate = "";

            DateTime           ConfirmYear      = new DateTime();
            DateTime           CurrYear         = DateTime.Now;
            DateTime           dtLeaveEndPeriod = new DateTime();
            clsEmpLeaveProfile objEmpLevPro     = new clsEmpLeaveProfile();
            SqlCommand[]       cmd = new SqlCommand[11];

            if (dtLeavePakMst.Rows.Count > 0)
            {
                IsLeaveOnJoinDate = dtLeavePakMst.Rows[0]["IsLCalOnJoinDate"].ToString();
            }

            if (dtLeaveType.Rows.Count > 0)
            {
                if (dtLevProfile.Rows.Count > 0)
                {
                    foreach (DataRow LTRow in dtLeaveType.Rows)
                    {
                        DataRow[] foundRows;
                        string    strExpr = "";
                        strExpr   = "LTypeId=1";
                        foundRows = dtLevProfile.Select(strExpr);

                        if (foundRows.Length > 0)
                        {
                            if (IsLeaveOnJoinDate == "Y")
                            {
                                if (LTRow["LAbbrName"].ToString().Trim() == "AL")
                                {
                                    foreach (DataRow dRow in dtLeavePeriod.Rows)
                                    {
                                        dtLeaveEndPeriod = Convert.ToDateTime(dRow["LeaveEndPeriod"]);
                                        ConfirmYear      = Convert.ToDateTime(ConfirmDate);
                                    }

                                    Int32 MaxLogConfirmMonth = 0;
                                    Int32 MaxLogConfirmYear  = 0;
                                    Int32 iRemainMonth       = 0;

                                    DataTable dtRemainMonth = new DataTable();
                                    dtRemainMonth = GET_LeaveEntitleMaxMonth(EmpId);
                                    foreach (DataRow dataRow in dtRemainMonth.Rows)
                                    {
                                        MaxLogConfirmMonth = Convert.ToInt32(dataRow["MaxMonth"].ToString());
                                        MaxLogConfirmYear  = Convert.ToInt32(dataRow["MaxYear"].ToString());
                                    }

                                    Int32 iConfirmMonth = ConfirmYear.Month;
                                    Int32 iEndMonth     = dtLeaveEndPeriod.Month;

                                    //Need to debug
                                    if (ConfirmYear.Year > MaxLogConfirmYear)
                                    {
                                        iRemainMonth = (iEndMonth - iConfirmMonth) + 1;
                                    }
                                    else
                                    {
                                        if (iConfirmMonth < MaxLogConfirmMonth)
                                        {
                                            iRemainMonth = (iEndMonth - MaxLogConfirmMonth) + 1;
                                        }
                                        else
                                        {
                                            iRemainMonth = (iEndMonth - iConfirmMonth) + 1;
                                        }
                                    }

                                    LEntitled = Convert.ToDecimal(iRemainMonth * 1.833333333);

                                    //Int32 iRemainMonth = (iEndMonth - reConfirmMonth) + 1;
                                    //LEntitled = Convert.ToDecimal(iRemainMonth * 1.833333333);


                                    LEntitled = LEntitled + Convert.ToDecimal(foundRows[0]["LEntitled"]);

                                    objEmpLevPro = new clsEmpLeaveProfile(EmpId, LTRow["LTypeId"].ToString().Trim(), LEntitled.ToString(),
                                                                          userId, Common.SetDateTime(DateTime.Now.ToString()));

                                    cmd[i] = InsertIntoEmpLevPro(objEmpLevPro, "Y", "N");
                                }
                            }
                            i++;
                        }
                    }
                }
            }
            dtLeaveType.Rows.Clear();
            dtLevProfile.Rows.Clear();

            return(cmd);
        }
        catch (Exception ex)
        {
            throw (ex);
        }
    }
예제 #7
0
    public SqlCommand[] InsertIntoLevProfile(string EmpId, string LPakId, string JoiningDate, string userId, string strEmpTypeId)
    {
        try
        {
            i = 0;
            decimal LeaveAvail        = 0;
            decimal LEntitled         = 0;
            decimal tempValue         = 0;
            string  IsLeaveOnJoinDate = "";

            DateTime           dtJoinDate;
            DateTime           dtLeaveStDate = DateTime.Now;
            clsEmpLeaveProfile objEmpLevPro  = new clsEmpLeaveProfile();
            SqlCommand[]       cmd           = new SqlCommand[15];

            if (dtLeavePakMst.Rows.Count == 0)
            {
                dtLeavePakMst = SelectLeavePakMst(LPakId);
            }

            DataTable dtLeavePeriod = SelectLeavePeriod(LPakId);

            if (dtLeavePeriod.Rows.Count > 0)
            {
                dtLeaveStDate = Convert.ToDateTime(dtLeavePeriod.Rows[0]["LeaveStartPeriod"]);
            }

            DataTable dtLevProfile = objLeaveAppMgr.SelectEmpLeaveProfile(EmpId, "0");

            DataTable dtLeaveType = objLeaveMgr.SelectLeavePakDet(Convert.ToInt32(LPakId));

            if (dtLeavePakMst.Rows.Count > 0)
            {
                IsLeaveOnJoinDate = dtLeavePakMst.Rows[0]["IsLCalOnJoinDate"].ToString();
            }

            if (dtLeaveType.Rows.Count > 0)
            {
                if (dtLevProfile.Rows.Count > 0)
                {
                    foreach (DataRow LTRow in dtLeaveType.Rows)
                    {
                        DataRow[] foundRows;
                        string    strExpr = "";
                        strExpr   = "LTypeId='" + LTRow["LTypeId"].ToString().Trim() + "'";
                        foundRows = dtLevProfile.Select(strExpr);
                        if (foundRows.Length > 0)
                        {
                            if (IsLeaveOnJoinDate == "Y")
                            {
                                LeaveAvail = 0;
                                if (LTRow["LTypeId"].ToString().Trim() == "2")
                                {
                                    if (LTRow["MaxLAmt"].ToString() != "0")
                                    {
                                        dtLeaveStDate = Convert.ToDateTime(dtLeavePeriod.Rows[0]["LeaveStartPeriod"]);
                                        if (JoiningDate == "")
                                        {
                                            dtJoinDate = dtLeaveStDate;
                                        }
                                        else
                                        {
                                            dtJoinDate = Convert.ToDateTime(JoiningDate);
                                        }

                                        if (dtJoinDate > dtLeaveStDate)
                                        {
                                            TimeSpan DateDiff  = dtJoinDate - dtLeaveStDate;
                                            string   strTotDay = ReturnTotalDay(DateDiff.ToString());
                                            tempValue  = (Convert.ToDecimal(LTRow["MaxLAmt"]) / 366);
                                            tempValue  = (tempValue * (366 - Convert.ToInt32(strTotDay)));
                                            LeaveAvail = Convert.ToDecimal(tempValue);
                                            LeaveAvail = Math.Round(LeaveAvail, 2);
                                            //LEntitled = LeaveAvail;

                                            char[]   strSpliter = { '.' };
                                            string[] arinfo     = new string[2];

                                            arinfo = LeaveAvail.ToString().Split(strSpliter);

                                            if (strEmpTypeId == "1")
                                            {
                                                LEntitled = LeaveAvail;// Convert.ToDecimal(arinfo[0]) + Convert.ToDecimal(arinfo[1].ToString());
                                            }
                                            else
                                            {
                                                //double dclJoinMonth = dtJoinDate.Month;
                                                //double dclBal = (12 - dclJoinMonth) * 1.16;

                                                //if (dtJoinDate.Day == 1)
                                                //    arinfo[1] = "1.16";
                                                //else if (dtJoinDate.Day > 1 && dtJoinDate.Day <= 7)
                                                //    arinfo[1] = ".87";
                                                //else if (dtJoinDate.Day > 7 && dtJoinDate.Day <= 14)
                                                //    arinfo[1] = ".58";
                                                //else if (dtJoinDate.Day > 14 && dtJoinDate.Day <= 21)
                                                //    arinfo[1] = ".29";
                                                //else if (dtJoinDate.Day > 21 && dtJoinDate.Day <= 31)
                                                //    arinfo[1] = "0";

                                                //dclBal = dclBal + Convert.ToDouble(arinfo[1]);
                                                LEntitled = 0;// Convert.ToDecimal(dclBal);
                                            }
                                        }
                                        else
                                        {
                                            LEntitled = Convert.ToDecimal(LTRow["MaxLAmt"]);
                                        }
                                    }
                                    else
                                    {
                                        LEntitled = Convert.ToDecimal(LTRow["MaxLAmt"]);
                                    }
                                }
                                else
                                {
                                    LEntitled = Convert.ToDecimal(LTRow["MaxLAmt"]);
                                }
                            }
                            else
                            {
                                LEntitled = Convert.ToDecimal(LTRow["MaxLAmt"]);
                            }

                            objEmpLevPro = new clsEmpLeaveProfile(EmpId, LTRow["LTypeId"].ToString().Trim(), LEntitled.ToString(),
                                                                  userId, Common.SetDateTime(DateTime.Now.ToString()));

                            cmd[i] = InsertIntoEmpLevPro(objEmpLevPro, "Y", "N");
                            i++;
                        }
                        #region Comment
                        //Add new record in LeaveProfile when dtLeaveType.Rows.count=0
                        ////else
                        ////{
                        ////    if (IsLeaveOnJoinDate == "Y")
                        ////    {
                        ////        LeaveAvail = 0;
                        ////        if (LTRow["MaxLAmt"].ToString() != "0")
                        ////        {
                        ////            dtLeaveStDate = Convert.ToDateTime(dtLeavePeriod.Rows[0]["LeaveStartPeriod"]);
                        ////            if (JoiningDate == "")
                        ////                dtJoinDate = dtLeaveStDate;
                        ////            else
                        ////                dtJoinDate = Convert.ToDateTime(JoiningDate);

                        ////            if (dtJoinDate > dtLeaveStDate)
                        ////            {
                        ////                TimeSpan DateDiff = dtJoinDate - dtLeaveStDate;
                        ////                string strTotDay = ReturnTotalDay(DateDiff.ToString());
                        ////                tempValue = (Convert.ToDecimal(LTRow["MaxLAmt"]) / 366);
                        ////                tempValue = (tempValue * (366 - Convert.ToInt32(strTotDay)));
                        ////                LeaveAvail = Convert.ToDecimal(tempValue);
                        ////                LEntitled = LeaveAvail;
                        ////            }
                        ////            else
                        ////                LEntitled = Convert.ToDecimal(LTRow["MaxLAmt"]);
                        ////        }
                        ////        else
                        ////            LEntitled = Convert.ToDecimal(LTRow["MaxLAmt"]);
                        ////    }
                        ////    else
                        ////        LEntitled = Convert.ToDecimal(LTRow["MaxLAmt"]);

                        ////    objEmpLevPro = new clsEmpLeaveProfile(EmpId, LTRow["LTypeId"].ToString().Trim(), LEntitled.ToString(),
                        ////       userId, Common.SetDateTime(DateTime.Now.ToString()));

                        ////    cmd[i] = InsertIntoEmpLevPro(objEmpLevPro, "N", "N");
                        ////    i++;
                        ////}
                        #endregion
                    }
                }
                else//(dtLevProfile.Rows.Count = 0)
                {
                    foreach (DataRow LTRow in dtLeaveType.Rows)
                    {
                        if (IsLeaveOnJoinDate == "Y")
                        {
                            LeaveAvail = 0;
                            if (LTRow["LTypeId"].ToString().Trim() == "2")
                            {
                                if (LTRow["MaxLAmt"].ToString() != "0")
                                {
                                    dtLeaveStDate = Convert.ToDateTime(dtLeavePeriod.Rows[0]["LeaveStartPeriod"]);
                                    if (JoiningDate == "")
                                    {
                                        dtJoinDate = dtLeaveStDate;
                                    }
                                    else
                                    {
                                        dtJoinDate = Convert.ToDateTime(JoiningDate);
                                    }

                                    if (dtJoinDate > dtLeaveStDate)
                                    {
                                        TimeSpan DateDiff  = dtJoinDate - dtLeaveStDate;
                                        string   strTotDay = ReturnTotalDay(DateDiff.ToString());
                                        tempValue  = (Convert.ToDecimal(LTRow["MaxLAmt"]) / 366);
                                        tempValue  = (tempValue * (366 - Convert.ToInt32(strTotDay)));
                                        LeaveAvail = Convert.ToDecimal(tempValue);
                                        LeaveAvail = Math.Round(LeaveAvail, 2);
                                        //LEntitled = LeaveAvail;

                                        char[]   strSpliter = { '.' };
                                        string[] arinfo     = new string[2];

                                        arinfo = LeaveAvail.ToString().Split(strSpliter);

                                        if (strEmpTypeId == "1")
                                        {
                                            LEntitled = LeaveAvail;//Convert.ToDecimal(arinfo[0]) + Convert.ToDecimal(arinfo[1].ToString());
                                        }
                                        else
                                        {
                                            //double dclJoinMonth = dtJoinDate.Month;
                                            //double dclBal = (12 - dclJoinMonth) * 1.16;

                                            //if (dtJoinDate.Day == 1)
                                            //    arinfo[1] = "1.16";
                                            //else if (dtJoinDate.Day > 1 && dtJoinDate.Day <= 7)
                                            //    arinfo[1] = ".87";
                                            //else if (dtJoinDate.Day > 7 && dtJoinDate.Day <= 14)
                                            //    arinfo[1] = ".58";
                                            //else if (dtJoinDate.Day > 14 && dtJoinDate.Day <= 21)
                                            //    arinfo[1] = ".29";
                                            //else if (dtJoinDate.Day > 21 && dtJoinDate.Day <= 31)
                                            //    arinfo[1] = "0";

                                            //dclBal = dclBal + Convert.ToDouble(arinfo[1]);
                                            //LEntitled = Convert.ToDecimal(dclBal);
                                            LEntitled = 0;
                                        }
                                    }
                                    else
                                    {
                                        LEntitled = Convert.ToDecimal(LTRow["MaxLAmt"]);
                                    }
                                }
                                else
                                {
                                    LEntitled = Convert.ToDecimal(LTRow["MaxLAmt"]);
                                }
                            }
                            else
                            {
                                LEntitled = Convert.ToDecimal(LTRow["MaxLAmt"]);
                            }
                        }
                        else
                        {
                            LEntitled = Convert.ToDecimal(LTRow["MaxLAmt"]);
                        }

                        objEmpLevPro = new clsEmpLeaveProfile(EmpId, LTRow["LTypeId"].ToString().Trim(), Math.Round(LEntitled, 2).ToString(),
                                                              userId, Common.SetDateTime(DateTime.Now.ToString()));

                        cmd[i] = InsertIntoEmpLevPro(objEmpLevPro, "N", "N");
                        i++;
                    }
                }
            }
            dtLeaveType.Rows.Clear();
            dtLevProfile.Rows.Clear();
            return(cmd);
        }
        catch (Exception ex)
        {
            throw (ex);
        }
    }