Beispiel #1
0
        private DataSet LeaveReport(int EmployeeId)
        {
            DataSet ds = new DataSet();

            ds.DataSetName = "DataSourceForReport";

            DataTable dt = new DataTable("EmployeeLeave");

            dt.TableName = "EmployeeLeave";

            dt.Columns.Add(new DataColumn("EmployeeId", typeof(string)));
            dt.Columns.Add(new DataColumn("EmployeeFullNName", typeof(string)));
            dt.Columns.Add(new DataColumn("LeaveFromDate", typeof(DateTime)));
            dt.Columns.Add(new DataColumn("LeaveToDate", typeof(DateTime)));
            dt.Columns.Add(new DataColumn("LeaveType", typeof(string)));
            dt.Columns.Add(new DataColumn("BalanceLeaves", typeof(decimal)));
            dt.Columns.Add(new DataColumn("LeavesInDays", typeof(decimal)));
            dt.Columns.Add(new DataColumn("Reason", typeof(string)));
            dt.Columns.Add(new DataColumn("TransactionType", typeof(string)));



            EmployeeBAL balObject = new EmployeeBAL();
            IQueryable <Entities.EmployeeLeaveTransaction> entites = balObject.GetAllEmployeeLeaves(SessionHelper.SchoolId).Where(c => c.EmployeeId == EmployeeId);

            if (entites != null && entites.Count() > 0)
            {
                foreach (Entities.EmployeeLeaveTransaction entity in entites)
                {
                    //Entities.EmployeeLeaveTransaction entity = entites.FirstOrDefault();
                    DataRow dr = dt.NewRow();
                    dr["EmployeeId"]        = entity.EmployeeId;
                    dr["EmployeeFullNName"] = entity.EmployeeFullName;
                    dr["LeaveFromDate"]     = entity.LeaveFromDate;
                    dr["LeaveToDate"]       = entity.LeaveToDate;

                    string strLeaveType = "";
                    if (entity.LeaveType == 1)
                    {
                        strLeaveType = "Annual Leave";
                    }
                    else if (entity.LeaveType == 2)
                    {
                        strLeaveType = "Sick Leave";
                    }
                    dr["LeaveType"] = strLeaveType;

                    dr["LeavesInDays"]  = entity.LeavesInDays;
                    dr["BalanceLeaves"] = entity.BalanceLeaves;
                    dr["Reason"]        = entity.Remark;



                    if (entity.TransactionType == 1)
                    {
                        dr["TransactionType"] = "Cr";
                    }
                    else
                    {
                        dr["TransactionType"] = "Dr";
                    }



                    reportName = entity.EmployeeId + "_" + entity.EmployeeFullName.Trim();
                    dt.Rows.Add(dr);
                }
            }
            ds.Tables.Add(getSchoolDetails());
            ds.Tables.Add(dt);
            return(ds);
        }