private void EmployeeMaster_ById(int Id)
 {
     try
     {
         Business.HR.EmployeeMaster objEmployeeMaster = new Business.HR.EmployeeMaster();
         Entity.HR.EmployeeMaster   employeeMaster    = new Entity.HR.EmployeeMaster();
         employeeMaster.EmployeeMasterId = Id;
         DataTable dtEmployeeMaster = objEmployeeMaster.EmployeeMaster_ById(employeeMaster);
         EmployeeMasterId      = Convert.ToInt32(dtEmployeeMaster.Rows[0]["EmployeeMasterId"].ToString());
         lblName.Text          = dtEmployeeMaster.Rows[0]["EmployeeName"].ToString();
         lblDateOfBirth.Text   = (dtEmployeeMaster.Rows[0]["DOB"] == DBNull.Value) ? string.Empty : Convert.ToDateTime(dtEmployeeMaster.Rows[0]["DOB"].ToString()).ToString("dd MMM yyyy");
         lblMobile.Text        = dtEmployeeMaster.Rows[0]["PersonalMobileNo"].ToString();
         lblPersonalEmail.Text = dtEmployeeMaster.Rows[0]["PersonalEmailId"].ToString();
         lblOfficialEmail.Text = dtEmployeeMaster.Rows[0]["OfficeEmailId"].ToString();
         lblAddress.Text       = string.Concat(dtEmployeeMaster.Rows[0]["pAddress"].ToString(), ", ", dtEmployeeMaster.Rows[0]["PermanentCity"].ToString(), ", ", dtEmployeeMaster.Rows[0]["pPIN"].ToString());
         lblDesignation.Text   = dtEmployeeMaster.Rows[0]["DesignationName"].ToString();
         lblDateOfJoining.Text = (dtEmployeeMaster.Rows[0]["DOJ"] == DBNull.Value) ? string.Empty : Convert.ToDateTime(dtEmployeeMaster.Rows[0]["DOJ"].ToString()).ToString("dd MMM yyyy");
         lblReporting.Text     = dtEmployeeMaster.Rows[0]["ReportingPersion"].ToString();
         Image1.ImageUrl       = "EmployeeImage\\" + dtEmployeeMaster.Rows[0]["Image"].ToString();
     }
     catch (Exception ex)
     {
         ex.WriteException();
         MessageBox.IsSuccess = false;
         MessageBox.Text      = ex.Message;
         MessageBox.Show      = true;
     }
 }
        private AuthorizationModel IsAuthorized(int employeeId, string utilityCode)
        {
            AuthorizationModel model = new AuthorizationModel();

            Business.HR.EmployeeMaster objEmployeeMaster = new Business.HR.EmployeeMaster();
            Entity.HR.EmployeeMaster   employeeMaster    = new Entity.HR.EmployeeMaster();
            DataTable dtEmployee = objEmployeeMaster.EmployeeMaster_ById(new Entity.HR.EmployeeMaster()
            {
                EmployeeMasterId = employeeId
            });

            if (dtEmployee.AsEnumerable().Any())
            {
                employeeMaster = objEmployeeMaster.AuthenticateUser(dtEmployee.Rows[0]["EmployeeCode"].ToString());
            }

            if (employeeMaster != null)
            {
                string[] roles = employeeMaster.Roles.Split(',');
                model.ReturnValue = roles.Contains(utilityCode);
            }
            else
            {
                model.ReturnValue = false;
            }
            return(model);
        }
        private List <Models.StockSnapModel> GetStockSnaps(int employeeId, string itemName)
        {
            List <Models.StockSnapModel> model = new List <StockSnapModel>();

            Business.Inventory.Stock objStock = new Business.Inventory.Stock();
            string name = (string.IsNullOrEmpty(itemName.Trim())) ? string.Empty : itemName.Trim();

            Business.HR.EmployeeMaster objEmployeeMaster = new Business.HR.EmployeeMaster();
            Entity.HR.EmployeeMaster   employeeMaster    = new Entity.HR.EmployeeMaster();
            DataTable dtEmployee = objEmployeeMaster.EmployeeMaster_ById(new Entity.HR.EmployeeMaster()
            {
                EmployeeMasterId = employeeId
            });

            if (dtEmployee.AsEnumerable().Any())
            {
                employeeMaster = objEmployeeMaster.AuthenticateUser(dtEmployee.Rows[0]["EmployeeCode"].ToString());
            }

            if (employeeMaster != null)
            {
                string[] roles = employeeMaster.Roles.Split(',');
                if (roles.Contains(Entity.HR.Utility.STOCK_LOOKUP))
                {
                    DataTable response = objStock.GetStockSnap(itemName);
                    if (response != null &&
                        response.AsEnumerable().Any())
                    {
                        foreach (DataRow dr in response.Rows)
                        {
                            model.Add(new Models.StockSnapModel
                            {
                                AssetLocationId = dr["AssetLocationId"].ToString(),
                                ItemId          = dr["ItemId"].ToString(),
                                ItemType        = dr["ItemType"].ToString(),
                                Location        = string.Format("Location: {0}", dr["Location"].ToString()),
                                Quantity        = string.Format("Quantity: {0}", dr["Quantity"].ToString()),
                                ItemName        = (Convert.ToInt32(dr["ItemType"].ToString()) == (int)ItemType.Product)
                                ? string.Format("Product Name: {0}", dr["ProductName"].ToString())
                                : string.Format("Spare Name: {0}", dr["SpareName"].ToString()),
                            });
                        }
                    }
                }
                else
                {
                }
            }

            return(model);
        }
        private AccountModel EmployeeMaster_ById(AccountModel model)
        {
            try
            {
                Business.HR.EmployeeMaster objEmployeeMaster = new Business.HR.EmployeeMaster();
                Entity.HR.EmployeeMaster   employeeMaster    = new Entity.HR.EmployeeMaster();
                employeeMaster.EmployeeMasterId = model.UserId;
                DataTable dtEmployeeMaster = objEmployeeMaster.EmployeeMaster_ById(employeeMaster);

                model.EmployeeName = dtEmployeeMaster.Rows[0]["EmployeeName"].ToString();
                model.ImageProfile = string.Format("http://crm.aegissolutions.in/HR/EmployeeImage/{0}", dtEmployeeMaster.Rows[0]["Image"].ToString());
                model.Designation  = dtEmployeeMaster.Rows[0]["DesignationName"].ToString();
                model.ReportsTo    = dtEmployeeMaster.Rows[0]["ReportingPersion"].ToString();
                model.LoyaltyPoint = IndividualLoyalityPoint_ByEmployeeId(model.UserId).ToString();
                model.LastLogin    = GetLastLogin(model.UserId);
            }
            catch (Exception ex)
            {
                new Logger().LogException(ex, "EmployeeMaster_ById");
            }
            return(model);
        }
        private List <Models.TonerModel> GetToner(int employeeId)
        {
            List <Models.TonerModel> model = new List <Models.TonerModel>();

            Business.Service.TonerRequest objTonnerRequest = new Business.Service.TonerRequest();

            Business.HR.EmployeeMaster objEmployeeMaster = new Business.HR.EmployeeMaster();
            Entity.HR.EmployeeMaster   employeeMaster    = new Entity.HR.EmployeeMaster();
            DataTable dtEmployee = objEmployeeMaster.EmployeeMaster_ById(new Entity.HR.EmployeeMaster()
            {
                EmployeeMasterId = employeeId
            });

            if (dtEmployee.AsEnumerable().Any())
            {
                employeeMaster = objEmployeeMaster.AuthenticateUser(dtEmployee.Rows[0]["EmployeeCode"].ToString());
            }

            int assignEngineer = 0;

            if (employeeMaster != null)
            {
                string[] roles = employeeMaster.Roles.Split(',');
                if (roles.Contains(Entity.HR.Utility.CUSTOMER_LIST_SHOW_ALL))
                {
                    assignEngineer = 0;
                }
                else
                {
                    assignEngineer = employeeId;
                }
            }

            string callStatusIds = string.Empty;

            callStatusIds = string.Concat(((int)CallStatusType.TonerOpenForApproval).ToString(),
                                          ",",
                                          ((int)CallStatusType.TonerRequestInQueue).ToString(),
                                          ",",
                                          ((int)CallStatusType.TonerResponseGiven).ToString());

            DataTable response = objTonnerRequest.Service_Toner_GetByCallStatusIds(callStatusIds, assignEngineer);

            if (response != null &&
                response.AsEnumerable().Any())
            {
                foreach (DataRow dr in response.Rows)
                {
                    model.Add(new Models.TonerModel
                    {
                        CallStatus    = string.Format("Call Status: {0}", dr["CallStatus"].ToString()),
                        ContactPerson = string.Format("Contact Person: {0}", dr["ContactPerson"].ToString()),
                        CustomerName  = string.Format("Customer Name: {0}", dr["CustomerName"].ToString()),
                        TonerDateTime = string.Format("Toner Date & Time: {0}", Convert.ToDateTime(dr["RequestDate"].ToString()).ToString("dd MMM yyyy")),
                        TonerNo       = string.Format("Toner No: {0}", dr["TonnerRequestId"].ToString()),
                        ProductName   = string.Format("Product Name: {0}", dr["ProductName"].ToString())
                    });
                }
            }

            return(model);
        }
        private List <Models.DocketModel> GetDocket(int employeeId)
        {
            List <Models.DocketModel> model = new List <Models.DocketModel>();

            Business.Service.Docket objDocket = new Business.Service.Docket();
            Entity.Service.Docket   docket    = new Entity.Service.Docket();

            Business.HR.EmployeeMaster objEmployeeMaster = new Business.HR.EmployeeMaster();
            Entity.HR.EmployeeMaster   employeeMaster    = new Entity.HR.EmployeeMaster();
            DataTable dtEmployee = objEmployeeMaster.EmployeeMaster_ById(new Entity.HR.EmployeeMaster()
            {
                EmployeeMasterId = employeeId
            });

            if (dtEmployee.AsEnumerable().Any())
            {
                employeeMaster = objEmployeeMaster.AuthenticateUser(dtEmployee.Rows[0]["EmployeeCode"].ToString());
            }

            int assignEngineer = 0;

            if (employeeMaster != null)
            {
                string[] roles = employeeMaster.Roles.Split(',');
                if (roles.Contains(Entity.HR.Utility.CUSTOMER_LIST_SHOW_ALL))
                {
                    assignEngineer = 0;
                }
                else
                {
                    assignEngineer = employeeId;
                }
            }

            string callStatusIds = string.Empty;

            callStatusIds         = string.Concat(((int)CallStatusType.DocketClose).ToString(), ",", ((int)CallStatusType.DocketFunctional).ToString());//DOCKET CLOSE && FUNCTIONAL
            docket.CallStatusIds  = callStatusIds;
            docket.AssignEngineer = assignEngineer;

            DataTable response = objDocket.Service_Docket_GetAllByCallStatusIds(docket);

            if (response != null &&
                response.AsEnumerable().Any())
            {
                foreach (DataRow dr in response.Rows)
                {
                    model.Add(new Models.DocketModel
                    {
                        AssignedEngineerName = string.Format("Assigned Engineer: {0}", dr["AssignedEngineerName"].ToString()),
                        CallStatus           = string.Format("Call Status: {0}", dr["CallStatus"].ToString()),
                        ContactPerson        = string.Format("Contact Person: {0}", dr["ContactPerson"].ToString()),
                        CustomerName         = string.Format("Customer Name: {0}", dr["CustomerName"].ToString()),
                        DocketDateTime       = string.Format("Docket Date & Time: {0}", Convert.ToDateTime(dr["DocketDate"].ToString()).ToString("dd MMM yyyy")),
                        DocketNo             = string.Format("Docket No: {0}", dr["DocketId"].ToString()),
                        IsCallAttended       = string.Format("Call Attended: {0}", (dr["IsCallAttended"].ToString().Equals("1")) ? "True" : "False"),
                        ProductName          = string.Format("Product Name: {0}", dr["ProductName"].ToString())
                    });
                }
            }

            return(model);
        }