public List<AssignLeaveViewModel> BindGridData()
 {
     MasterEntries objMasterEntries = new MasterEntries();
     DBDataHelper.ConnectionString = ConfigurationManager.ConnectionStrings["CSBiometricAttendance"].ConnectionString;
     DataTable dt = new DataTable();
     List<SqlParameter> lstData = new List<SqlParameter>();
     lstData.Add(new SqlParameter("@employeeId", Convert.ToInt32(Session["employeeId"])));
     lstData.Add(new SqlParameter("@dateMonth", Calendar1.SelectedDate.Month));
     lstData.Add(new SqlParameter("@dateYear", Calendar1.SelectedDate.Year));
     lstData.Add(new SqlParameter("@IsDeleted", Convert.ToInt32(0)));
     DataSet ds;
     int i = 0;
     string query = "SELECT Id , LeaveTypeId , [Date] FROM tblLeave WHERE MONTH([Date]) = @dateMonth AND YEAR([Date]) = @dateYear And EmployeeId = @employeeId And IsDeleted = @IsDeleted";
     using (DBDataHelper objDDBDataHelper = new DBDataHelper())
     {
         ds = objDDBDataHelper.GetDataSet(query, SQLTextType.Query, lstData);
         List<AssignLeaveViewModel> lstLeaves = new List<AssignLeaveViewModel>();
         foreach (DataRow row in ds.Tables[0].Rows)
         {
             AssignLeaveViewModel objLeaves = new AssignLeaveViewModel();
             int Id = Convert.ToInt32(ds.Tables[0].Rows[i][0]);
             int leaveId = Convert.ToInt32(ds.Tables[0].Rows[i][1]);
             Leaves objLeaves1 = new Leaves();
             objMasterEntries.GetLeavesById(leaveId, out objLeaves1);
             objLeaves.leaveId = Id;
             objLeaves.Id = objLeaves1.Id;
             objLeaves.LeaveName = objLeaves1.LeaveName;
             objLeaves.EmployeeId = Convert.ToInt32(Session["employeeId"]);
             objLeaves.Date = (Convert.ToDateTime(ds.Tables[0].Rows[i][2])).Date;
             lstLeaves.Add(objLeaves);
             i++;
         }
         return lstLeaves;
     }
 }
    public List <AssignLeaveViewModel> GetDataForGridview()
    {
        MasterEntries objMasterEntries = new MasterEntries();

        DBDataHelper.ConnectionString = ConfigurationManager.ConnectionStrings["CSBiometricAttendance"].ConnectionString;
        DateTime sessionStartDate = new DateTime();
        DateTime sessionEndDate   = new DateTime();

        if (DateTime.Now.Month <= 7)
        {
            sessionStartDate = new DateTime(DateTime.Now.Year - 1, 8, 1);
            sessionEndDate   = new DateTime(DateTime.Now.Year, 7, 31);
        }
        else
        {
            sessionStartDate = new DateTime(DateTime.Now.Year, 8, 1);
            sessionEndDate   = new DateTime(DateTime.Now.Year + 1, 7, 31);
        }

        List <SqlParameter> lstData = new List <SqlParameter>();

        lstData.Add(new SqlParameter("@employeeId", Convert.ToInt32(Session["employeeId"])));
        lstData.Add(new SqlParameter("@sessionStartDate", sessionStartDate));
        lstData.Add(new SqlParameter("@sessionEndDate", sessionEndDate));
        lstData.Add(new SqlParameter("@IsDeleted", Convert.ToInt32(0)));

        DataSet ds;
        int     i     = 0;
        string  query = @"SELECT Id , LeaveTypeId , [Date] 
                         FROM tblLeave 
                         WHERE [Date]  >= @sessionStartDate
                         AND [Date] <= @sessionEndDate 
                         AND EmployeeId = @employeeId 
                         AND IsDeleted = @IsDeleted";

        using (DBDataHelper objDDBDataHelper = new DBDataHelper())
        {
            ds = objDDBDataHelper.GetDataSet(query, SQLTextType.Query, lstData);
            List <AssignLeaveViewModel> lstLeaves = new List <AssignLeaveViewModel>();
            foreach (DataRow row in ds.Tables[0].Rows)
            {
                AssignLeaveViewModel objLeaves = new AssignLeaveViewModel();
                int    Id         = Convert.ToInt32(ds.Tables[0].Rows[i][0]);
                int    leaveId    = Convert.ToInt32(ds.Tables[0].Rows[i][1]);
                Leaves objLeaves1 = new Leaves();
                objMasterEntries.GetLeavesById(leaveId, out objLeaves1);
                objLeaves.leaveId    = Id;
                objLeaves.Id         = objLeaves1.Id;
                objLeaves.LeaveName  = objLeaves1.LeaveName;
                objLeaves.EmployeeId = Convert.ToInt32(Session["employeeId"]);
                objLeaves.Date       = (Convert.ToDateTime(ds.Tables[0].Rows[i][2])).Date;
                lstLeaves.Add(objLeaves);
                i++;
            }
            return(lstLeaves);
        }
    }
    public List<AssignLeaveViewModel> GetDataForGridview()
    {
        MasterEntries objMasterEntries = new MasterEntries();
        DBDataHelper.ConnectionString = ConfigurationManager.ConnectionStrings["CSBiometricAttendance"].ConnectionString;
        DateTime sessionStartDate = new DateTime();
        DateTime sessionEndDate = new DateTime();
        if (DateTime.Now.Month <= 7)
        {
            sessionStartDate = new DateTime(DateTime.Now.Year - 1, 8, 1);
            sessionEndDate = new DateTime(DateTime.Now.Year, 7, 31);
        }
        else
        {
            sessionStartDate = new DateTime(DateTime.Now.Year, 8, 1);
            sessionEndDate = new DateTime(DateTime.Now.Year + 1, 7, 31);
        }

        List<SqlParameter> lstData = new List<SqlParameter>();
        lstData.Add(new SqlParameter("@employeeId", Convert.ToInt32(Session["employeeId"])));
        lstData.Add(new SqlParameter("@sessionStartDate", sessionStartDate));
        lstData.Add(new SqlParameter("@sessionEndDate", sessionEndDate));
        lstData.Add(new SqlParameter("@IsDeleted", Convert.ToInt32(0)));

        DataSet ds;
        int i = 0;
        string query = @"SELECT Id , LeaveTypeId , [Date] 
                         FROM tblLeave 
                         WHERE [Date]  >= @sessionStartDate
                         AND [Date] <= @sessionEndDate 
                         AND EmployeeId = @employeeId 
                         AND IsDeleted = @IsDeleted";

        using (DBDataHelper objDDBDataHelper = new DBDataHelper())
        {
            ds = objDDBDataHelper.GetDataSet(query, SQLTextType.Query, lstData);
            List<AssignLeaveViewModel> lstLeaves = new List<AssignLeaveViewModel>();
            foreach (DataRow row in ds.Tables[0].Rows)
            {
                AssignLeaveViewModel objLeaves = new AssignLeaveViewModel();
                int Id = Convert.ToInt32(ds.Tables[0].Rows[i][0]);
                int leaveId = Convert.ToInt32(ds.Tables[0].Rows[i][1]);
                Leaves objLeaves1 = new Leaves();
                objMasterEntries.GetLeavesById(leaveId, out objLeaves1);
                objLeaves.leaveId = Id;
                objLeaves.Id = objLeaves1.Id;
                objLeaves.LeaveName = objLeaves1.LeaveName;
                objLeaves.EmployeeId = Convert.ToInt32(Session["employeeId"]);
                objLeaves.Date = (Convert.ToDateTime(ds.Tables[0].Rows[i][2])).Date;
                lstLeaves.Add(objLeaves);
                i++;
            }
            return lstLeaves;
        }
    }