private void AvailableLeave(string gridStatus, string strEmpID, string strLTypeID, Int32 intSelectedRowIndex) { DataTable dtLeaveProfile = new DataTable(); if (gridStatus == "A") { dtLeaveProfile = objLeaveMgr.SelectEmpLeaveProfile(strEmpID, strLTypeID); if (dtLeaveProfile.Rows.Count > 0) { if (string.IsNullOrEmpty(dtLeaveProfile.Rows[0]["LeaveEnjoyed"].ToString()) == false) { hfLEnjoyed.Value = Convert.ToString(Convert.ToDecimal(dtLeaveProfile.Rows[0]["LeaveEnjoyed"].ToString()) + Convert.ToDecimal(grLeaveList.DataKeys[intSelectedRowIndex].Values[7].ToString().Trim())); } else { hfLEnjoyed.Value = grLeaveList.DataKeys[intSelectedRowIndex].Values[7].ToString().Trim(); } } } else if (gridStatus == "D") { dtLeaveProfile = objLeaveMgr.SelectEmpLeaveProfile(strEmpID, strLTypeID); if (dtLeaveProfile.Rows.Count > 0) { if (string.IsNullOrEmpty(dtLeaveProfile.Rows[0]["LeaveEnjoyed"].ToString()) == false) { hfLEnjoyed.Value = Convert.ToString(Convert.ToDecimal(dtLeaveProfile.Rows[0]["LeaveEnjoyed"].ToString()) + Convert.ToDecimal(grLeaveList.DataKeys[intSelectedRowIndex].Values[7].ToString().Trim())); } else { hfLEnjoyed.Value = "0"; } } } }
private void AvailableLeave(string gridStatus, string strEmpID, string strLTypeID, string strDurationInDays) { DataTable dtLeaveProfile = new DataTable(); if (gridStatus == "A") { dtLeaveProfile = objLeaveMgr.SelectEmpLeaveProfile(strEmpID, strLTypeID); if (dtLeaveProfile.Rows.Count > 0) { if (string.IsNullOrEmpty(dtLeaveProfile.Rows[0]["LeaveEnjoyed"].ToString()) == false) { hfLEnjoyed.Value = Convert.ToString(Convert.ToDecimal(dtLeaveProfile.Rows[0]["LeaveEnjoyed"].ToString()) + Convert.ToDecimal(strDurationInDays.Trim())); } else { hfLEnjoyed.Value = strDurationInDays.Trim(); } } } else if (gridStatus == "D") { dtLeaveProfile = objLeaveMgr.SelectEmpLeaveProfile(strEmpID, strLTypeID); if (dtLeaveProfile.Rows.Count > 0) { if (string.IsNullOrEmpty(dtLeaveProfile.Rows[0]["LeaveEnjoyed"].ToString()) == false) { hfLEnjoyed.Value = Convert.ToString(Convert.ToDecimal(dtLeaveProfile.Rows[0]["LeaveEnjoyed"].ToString()) + Convert.ToDecimal(strDurationInDays.Trim())); } else { hfLEnjoyed.Value = "0"; } } } }
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[] 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); } }