public List<Discrepancy> GetAllDiscrepancy(Constants.VISIBILITY_STATUS visibilityStatus)
        {
            try
            {
                int status = Converter.objToInt(visibilityStatus);
                discrepancyListObj = inventory.Discrepancies.Where(x=> x.Status == status).ToList<Discrepancy>();
            }
            catch (Exception e)
            {
                discrepancyListObj = null;
            }

            return discrepancyListObj;
        }
        public static Constants.DB_STATUS Assign(IEmployeeBroker employeeBroker, int employeeId, Constants.EMPLOYEE_ROLE role)
        {
            Constants.DB_STATUS status = Constants.DB_STATUS.UNKNOWN;

            Employee employee = new Employee();
            employee.Id = employeeId;
            employee = employeeBroker.GetEmployee(employee);

            Role assignRole = new Role();
            assignRole.Id = Converter.objToInt(role);
            assignRole = employeeBroker.GetRole(assignRole);
            employee.Role = assignRole;

            status = employeeBroker.Update(employee);

            return status;
        }
        public static string GetDepartmentStatusText(Constants.DEPARTMENT_STATUS departmentStatus)
        {
            string departmentStatusText = null;

            switch (departmentStatus)
            {
                case Constants.DEPARTMENT_STATUS.BLACKLIST:
                    departmentStatusText = "Blacklist";
                    break;
                case Constants.DEPARTMENT_STATUS.HIDDEN:
                    departmentStatusText = "Hidden";
                    break;
                case Constants.DEPARTMENT_STATUS.SHOW:
                    departmentStatusText = "Show";
                    break;
                case Constants.DEPARTMENT_STATUS.UNBLACKLIST:
                    departmentStatusText = "Unblacklist";
                    break;
            }

            return departmentStatusText;
        }
 public static string GetCollectionStatusText(Constants.COLLECTION_STATUS collectionStatus)
 {
     string status = null;
     switch (collectionStatus)
     {
         case Constants.COLLECTION_STATUS.NEED_TO_RETRIEVE:
             status = "Need to Retrieve";
             break;
         case Constants.COLLECTION_STATUS.NEED_TO_COLLECT:
             status = "Need to Collect";
             break;
         case Constants.COLLECTION_STATUS.COLLECTED:
             status = "Collected";
             break;
         case Constants.COLLECTION_STATUS.UNCOLLECTED:
             status = "Uncollected";
             break;
         case Constants.COLLECTION_STATUS.INCOMPLETE:
             status = "Incomplete";
             break;
     }
     return status;
 }
        /// <summary>
        /// Retreive All of the requisition information according to status
        /// </summary>
        /// <param name="requisitionStatus"></param>
        /// <returns></returns>
        public List<Requisition> GetAllRequisition(Constants.REQUISITION_STATUS requisitionStatus)
        {
            try
            {

                int status = Converter.objToInt(requisitionStatus);
                requisitionList = inventory.Requisitions.Where(reqObj => reqObj.Status == status).ToList<Requisition>();
            }
            catch (Exception e)
            {
                requisitionList = null;
            }
            return requisitionList;
        }
        /// <summary>
        /// Retreive All of the requisition information according to status
        /// </summary>
        /// <param name="requisitionStatus"></param>
        /// <returns></returns>
        public List<Requisition> GetAllRequisition(Constants.REQUISITION_STATUS requisitionStatus, Department department)
        {
            try
            {

                int status = Converter.objToInt(requisitionStatus);
                requisitionList = inventory.Requisitions.Where(reqObj => reqObj.Status == status && reqObj.Department.Id.Contains(department.Id)).OrderByDescending(reqObj => reqObj.CreatedDate).ToList<Requisition>();
            }
            catch (Exception e)
            {
                requisitionList = null;
            }
            return requisitionList;
        }
 /// <summary>
 /// Get the list of CollectionMissed by department Id and status
 /// </summary>
 /// <param name="department"></param>
 /// <param name="status"></param>
 /// <returns>
 /// List of CollectionMissed
 /// </returns>
 public List<CollectionMissed> GetAllCollectionMissed(Department department, Constants.VISIBILITY_STATUS status)
 {
     try
     {
         //get the collectionMissed List by checking department Id of collecion Missed Table and check the Visibility Status
         collectionMissedList = inventory.CollectionMisseds.Where(c => c.Department.Id == department.Id || status.Equals("SHOW")).ToList();
     }
     catch (Exception e)
     {
         collectionMissedList = null;
     }
         return collectionMissedList;
 }
        /// <summary>
        /// Get all of the Notification data by employeeId and NOTIFICATION_STATUS
        /// </summary>
        /// <param name="employee"></param>
        /// <param name="notificationStatus"></param>
        /// <returns>
        /// Return lists of Notifications
        /// </returns>
        public List<Notification> GetAllNotification(Employee employee, Constants.NOTIFICATION_STATUS notificationStatus)
        {
            try
            {
                //get the collectionMissed List by checking department Id of collecion Missed Table and check the Visibility Status
                notificationList = inventory.Notifications.Where(n => n.Employee.Id == employee.Id || notificationStatus.Equals("SHOW")).ToList();

            }
            catch (Exception e)
            {
                notificationList = null;
            }
                return notificationList;
        }
        /// <summary>
        ///     Change List to DataTable
        ///     Created By:Zin Mar Thwin
        ///     Created Date:28-01-2012
        ///     Modified By:
        ///     Modified Date:
        ///     Modification Reason:
        ///     Modified By:
        ///     Modified Date:
        ///     Modification Reason:
        /// </summary>
        /// <param name="itemDescription"></param>
        /// <returns>The return value of this method is resultItem.</returns>
        private void ListToDataTable(List<Department> deptList, Constants.VISIBILITY_STATUS collectionMissedStatus)
        {
            foreach (Department dep in deptList)
            {
                dr = dt.NewRow();
                dr[columnName[0]] = dep.Name;
                List<CollectionMissed> missedTime = collectionMissedBroker.GetAllCollectionMissed(dep);
                List<CollectionMissed> newList = new List<CollectionMissed>();
                foreach (CollectionMissed temp in missedTime)
                {
                    if (temp.Status != Converter.objToInt(Constants.VISIBILITY_STATUS.HIDDEN))
                    {
                        newList.Add(temp);
                    }
                }
                int count = newList.Count;
                //if (missedTime != null)
                //{
                //    foreach (CollectionMissed times in missedTime)
                //    {
                //        count++;
                //    }
                //}
                string black = null;
                Constants.DEPARTMENT_STATUS departmentStatus = Converter.objToDepartmentStatus(dep.Status);

                if (departmentStatus == Constants.DEPARTMENT_STATUS.SHOW || departmentStatus == Constants.DEPARTMENT_STATUS.UNBLACKLIST)
                {
                    black = Converter.GetDepartmentStatusText(Constants.DEPARTMENT_STATUS.BLACKLIST);
                }
                else if (Converter.objToDepartmentStatus(dep.Status) == Constants.DEPARTMENT_STATUS.BLACKLIST)
                {
                    black = Converter.GetDepartmentStatusText(Constants.DEPARTMENT_STATUS.UNBLACKLIST);
                }
                dr[columnName[1]] = count;
                dr[columnName[2]] = Converter.GetDepartmentStatusText(Converter.objToDepartmentStatus(dep.Status));

                dr[columnName[3]] = black;
                dr[columnName[4]] = dep.Id;
                dt.Rows.Add(dr);
            }
             //   return dt;
        }
        public static Employee ValidateUser(Constants.EMPLOYEE_ROLE allowedRole)
        {
            Employee employee = ValidateUser();

            //if (!CheckPermission(allowedRole, GetRolePermission(Converter.objToEmployeeRole(employee.Role.Id))))
            if (!CheckPermission(Converter.objToEmployeeRole(employee.Role.Id), GetRolePermission(allowedRole)) && !(Converter.objToEmployeeRole(employee.Role.Id) == Constants.EMPLOYEE_ROLE.ADMIN))
            {
                commonController.LogOutControl logOutControl = new commonController.LogOutControl();
            }
            return employee;
        }
        /// <summary>
        ///     Refresh requisition list after withdraw one requisition
        ///     Created By:JinChengCheng
        ///     Created Date:26-01-2012
        ///     Modified By:
        ///     Modified Date:
        ///     Modification Reason:
        ///     Modified By:
        ///     Modified Date:
        ///     Modification Reason:
        /// </summary>
        /// <param name="requisitionId"></param>
        /// <returns>The return type of this method is datatable.</returns>
        public Constants.ACTION_STATUS Setstatus(string requisitionId, Constants.REQUISITION_STATUS Reqstatus, string remarks, DataTable dt)
        {
            Constants.ACTION_STATUS status = Constants.ACTION_STATUS.UNKNOWN;
            requisition = RequisitionList.Find(delegate(Requisition req) { return req.Id.Contains(requisitionId); });
            if (Reqstatus != Constants.REQUISITION_STATUS.REJECTED)
            {
                foreach (RequisitionDetail temp in requisition.RequisitionDetails)
                {
                    DataRow[] dr = dt.Select(" ItemCode = '" + temp.Item.Id + "'");
                    if (dr != null && dr.Length > 0)
                    {
                        temp.Qty = Convert.ToInt16(dr[0][1].ToString());
                        temp.DeliveredQty = Convert.ToInt16(dr[0][2].ToString());
                    }
                }
            }

            requisition.Remarks = remarks;
            requisition.Status = (int)(Reqstatus);
            requisitionBroker.Update(requisition);

            if(Reqstatus == Constants.REQUISITION_STATUS.COMPLETE)
            {
                RequisitionCollection RC = null;

                //Get all submitted requisitions
                RequisitionCollectionDetail rcDetails = requisitionCollectionBroker.GetAllRequisitionCollectionDetail(requisitionId);

                if(rcDetails != null)
                {
                    RC = requisitionCollectionBroker.GetAllRequisitionCollectionByRequisitionCollectionID(rcDetails.RequisitionCollection.Id.ToString());
                }

                foreach(RequisitionCollectionDetail rcd in RC.RequisitionCollectionDetails)
                {
                    if(rcd.Requisition.Status == (int)Constants.REQUISITION_STATUS.COMPLETE)
                        RC.Status = (int)Constants.COLLECTION_STATUS.COLLECTED;
                    else
                        RC.Status = (int)Constants.COLLECTION_STATUS.NEED_TO_COLLECT;
                }

                requisitionCollectionBroker.Update(RC);
            }
            return status;
        }
 public static string GetUnitOfMeasureText(Constants.UNIT_OF_MEASURE unitOfMeasure)
 {
     string unit = null;
     switch (unitOfMeasure)
     {
         case Constants.UNIT_OF_MEASURE.BOX:
             unit = "Box";
             break;
         case Constants.UNIT_OF_MEASURE.DOZEN:
             unit = "Dozen";
             break;
         case Constants.UNIT_OF_MEASURE.EACH:
             unit = "Each";
             break;
         case Constants.UNIT_OF_MEASURE.SET:
             unit = "Set";
             break;
         case Constants.UNIT_OF_MEASURE.PACKET:
             unit = "Packet";
             break;
     }
     return unit;
 }
 public static string GetRequisitionStatusText(Constants.REQUISITION_STATUS requisitionStatus)
 {
     string status = null;
     switch (requisitionStatus)
     {
         case Constants.REQUISITION_STATUS.PENDING:
             status = "Pending";
             break;
         case Constants.REQUISITION_STATUS.APPROVED:
             status = "Approved";
             break;
         case Constants.REQUISITION_STATUS.REJECTED:
             status = "Rejected";
             break;
         case Constants.REQUISITION_STATUS.SUBMITTED:
             status = "Submitted";
             break;
         case Constants.REQUISITION_STATUS.WITHDRAW:
             status = "Withdraw";
             break;
         case Constants.REQUISITION_STATUS.COMPLETE:
             status = "Complete";
             break;
     }
     return status;
 }
 public static string GetItemCategoryText(Constants.ITEM_CATEGORY itemCategory)
 {
     string category = null;
     switch (itemCategory)
     {
         case Constants.ITEM_CATEGORY.CLIP:
             category = "Clip";
             break;
         case Constants.ITEM_CATEGORY.DISK:
             category = "Disk";
             break;
         case Constants.ITEM_CATEGORY.ENVELOPE:
             category = "Envelope";
             break;
         case Constants.ITEM_CATEGORY.ERASER:
             category = "Eraser";
             break;
         case Constants.ITEM_CATEGORY.EXERCISE:
             category = "Exercise";
             break;
         case Constants.ITEM_CATEGORY.FILE:
             category = "File";
             break;
         case Constants.ITEM_CATEGORY.PAD:
             category = "Pad";
             break;
         case Constants.ITEM_CATEGORY.PAPER:
             category = "Paper";
             break;
         case Constants.ITEM_CATEGORY.PEN:
             category = "Pen";
             break;
         case Constants.ITEM_CATEGORY.PUNCHER:
             category = "Puncher";
             break;
         case Constants.ITEM_CATEGORY.RULER:
             category = "Ruler";
             break;
         case Constants.ITEM_CATEGORY.SCISSORS:
             category = "Scissors";
             break;
         case Constants.ITEM_CATEGORY.SHARPENER:
             category = "Sharpener";
             break;
         case Constants.ITEM_CATEGORY.SHORTHAND:
             category = "Shorthand";
             break;
         case Constants.ITEM_CATEGORY.STAPLER:
             category = "Stapler";
             break;
         case Constants.ITEM_CATEGORY.TACKS:
             category = "Tacks";
             break;
         case Constants.ITEM_CATEGORY.TAPE:
             category = "Tape";
             break;
         case Constants.ITEM_CATEGORY.TPARENCY:
             category = "Trapency";
             break;
         case Constants.ITEM_CATEGORY.TRAY:
             category = "Tray";
             break;
     }
     return category;
 }
 public static string GetDesignationText(Constants.DESIGNATION designation)
 {
     string designationText = null;
     switch (designation)
     {
         case Constants.DESIGNATION.PROFESSOR:
             designationText = "Professor";
             break;
         case Constants.DESIGNATION.SENIOR_PROFESSOR:
             designationText = "Senior Professor";
             break;
         case Constants.DESIGNATION.ACCOUNTANT:
             designationText = "Accountant";
             break;
         case Constants.DESIGNATION.SENIOR_ACCOUNTANT:
             designationText = "Senior Accountant";
             break;
     }
     return designationText;
 }
 public List<Department> GetAllDepartment(Constants.DEPARTMENT_STATUS departmentStatus)
 {
     int status = Converter.objToInt(departmentStatus);
     return inventory.Departments.Where(iObj => iObj.Status == status).ToList<Department>();
 }
        public static List<Constants.EMPLOYEE_ROLE> GetRolePermission(Constants.EMPLOYEE_ROLE employeeType)
        {
            List<Constants.EMPLOYEE_ROLE> permission = new List<Constants.EMPLOYEE_ROLE>();

            // Department
            if (employeeType == SystemStoreInventorySystemUtil.Constants.EMPLOYEE_ROLE.EMPLOYEE)
            {
                permission.Add(SystemStoreInventorySystemUtil.Constants.EMPLOYEE_ROLE.EMPLOYEE);
                employeeType = Constants.EMPLOYEE_ROLE.DEPARTMENT_REPRESENTATIVE;
            }

            if (employeeType == SystemStoreInventorySystemUtil.Constants.EMPLOYEE_ROLE.DEPARTMENT_REPRESENTATIVE || employeeType == SystemStoreInventorySystemUtil.Constants.EMPLOYEE_ROLE.TEMPORARY_DEPARTMENT_REPRESENTATIVE)
            {
                permission.Add(SystemStoreInventorySystemUtil.Constants.EMPLOYEE_ROLE.DEPARTMENT_REPRESENTATIVE);
                permission.Add(SystemStoreInventorySystemUtil.Constants.EMPLOYEE_ROLE.TEMPORARY_DEPARTMENT_REPRESENTATIVE);
                employeeType = SystemStoreInventorySystemUtil.Constants.EMPLOYEE_ROLE.DEPARTMENT_HEAD;
            }

            if (employeeType == SystemStoreInventorySystemUtil.Constants.EMPLOYEE_ROLE.DEPARTMENT_HEAD || employeeType == SystemStoreInventorySystemUtil.Constants.EMPLOYEE_ROLE.TEMPORARY_DEPARTMENT_HEAD)
            {
                permission.Add(SystemStoreInventorySystemUtil.Constants.EMPLOYEE_ROLE.DEPARTMENT_HEAD);
                permission.Add(SystemStoreInventorySystemUtil.Constants.EMPLOYEE_ROLE.TEMPORARY_DEPARTMENT_HEAD);
            }

            // end of Department

            // Store
            if (employeeType == SystemStoreInventorySystemUtil.Constants.EMPLOYEE_ROLE.STORE_CLERK)
            {
                permission.Add(SystemStoreInventorySystemUtil.Constants.EMPLOYEE_ROLE.STORE_CLERK);
                employeeType = Constants.EMPLOYEE_ROLE.STORE_SUPERVISOR;
            }

            if (employeeType == SystemStoreInventorySystemUtil.Constants.EMPLOYEE_ROLE.STORE_SUPERVISOR)
            {
                permission.Add(SystemStoreInventorySystemUtil.Constants.EMPLOYEE_ROLE.STORE_SUPERVISOR);
                employeeType = SystemStoreInventorySystemUtil.Constants.EMPLOYEE_ROLE.STORE_MANAGER;
            }

            if (employeeType == SystemStoreInventorySystemUtil.Constants.EMPLOYEE_ROLE.STORE_MANAGER || employeeType == Constants.EMPLOYEE_ROLE.ADMIN)
            {
                permission.Add(SystemStoreInventorySystemUtil.Constants.EMPLOYEE_ROLE.STORE_MANAGER);
            }
            // end of Store

            return permission;
        }
        public Constants.ACTION_STATUS SetCollectionStatus(Constants.COLLECTION_STATUS collectionStatus, List<string> collectionIdList)
        {
            foreach (string collectionId in collectionIdList)
            {
                RequisitionCollection requisitionCollection = new RequisitionCollection();
                requisitionCollection.Id = Converter.objToInt(collectionId);
                requisitionCollection = requisitionCollectionBroker.GetRequisitionCollection(requisitionCollection);
                requisitionCollection.Status = Converter.objToInt(collectionStatus);
                requisitionCollectionBroker.Update(requisitionCollection);
                if (collectionStatus == Constants.COLLECTION_STATUS.UNCOLLECTED)
                {
                    CollectionMissed collectionMissed = new CollectionMissed();
                    collectionMissed.Id = collectionMissedBroker.GetCollectionMissedId();
                    collectionMissed.Department = requisitionCollection.Department;
                    collectionMissed.CreatedBy = Util.GetEmployee(employeeBroker);
                    collectionMissed.CreatedDate = DateTime.Now;
                    collectionMissed.Status = Converter.objToInt(Constants.VISIBILITY_STATUS.SHOW);
                    collectionMissedBroker.Insert(collectionMissed);
                }
            }

            return SystemStoreInventorySystemUtil.Constants.ACTION_STATUS.UNKNOWN;
        }
 public static bool CheckPermission(Constants.EMPLOYEE_ROLE employeeType, List<Constants.EMPLOYEE_ROLE> permission)
 {
     return permission.Contains(employeeType);
 }
        private Constants.ACTION_STATUS SelectActionRequisition(Dictionary<string, string> remarks, Constants.REQUISITION_STATUS requisitionStatus)
        {
            Constants.ACTION_STATUS status = Constants.ACTION_STATUS.UNKNOWN;
            // employeeBroker = new EmployeeBroker(inventory);
            if (remarks.Count > 0)
            {
                status = Constants.ACTION_STATUS.SUCCESS;
                Requisition requisition;

                Employee employee = new Employee();
                employee.Id = currentEmployee.Id;
                employee = employeeBroker.GetEmployee(employee);

                foreach (string key in remarks.Keys)
                {

                    requisition = pendingRequisitionList.ElementAt(Converter.objToInt(key));
                    requisition.Status = Converter.objToInt(requisitionStatus);
                    requisition.Remarks = remarks[key];
                    requisition.ApprovedBy = employee;
                    requisition.ApprovedDate = DateTime.Now;

                    pendingRequisitionList[Converter.objToInt(key)] = requisition;

                    //pendingRequisitionList.Remove(requisition);

                    if (requisitionBroker.Update(requisition) == Constants.DB_STATUS.FAILED)
                    {
                        status = Constants.ACTION_STATUS.FAIL;
                        break;
                    }
                }
            }
            else
            {
                status = Constants.ACTION_STATUS.FAIL;
            }

            return status;
        }