// Get General Manager AssignStore Information
        public ArrayList GetGenMngAssignStore(int userId)
        {
            ArrayList amList = new ArrayList();

            DataBaseUtility db = new DataBaseUtility();

            SqlConnection con = null;

            try
            {

              //  string query = " select su.*,u.UserId as AeaManagerName  from dbo.StoreUser su,dbo.Users u where su.UserId=u.Id and  su.UserId  in(select AreaManagerId from dbo.AssignAreaManagerInfo where GeneralManagerId=" + SQLUtility.getInteger(userId) + " ) ";

              //  string query = "select AreaManagerId from dbo.AssignAreaManagerInfo where GeneralManagerId=" + SQLUtility.getInteger(userId) + " ";

                string query = " select aami.AreaManagerId,u.UserId from dbo.AssignAreaManagerInfo aami,dbo.Users u  where aami.AreaManagerId=u.Id and  aami.GeneralManagerId=" + SQLUtility.getInteger(userId) + " ";
                con = db.OpenConnection();

                SqlCommand comm = db.getSQLCommand(query, con);

                SqlDataReader reader = comm.ExecuteReader();

                while (reader.Read())
                {

                    int uId = ValidationUtility.ToInteger(reader["AreaManagerId"].ToString());

                    string amName = reader["UserId"].ToString();

                    GeneralManagerBonusDTO dto = new GeneralManagerBonusDTO {UserId = uId, AmName = amName };
                    amList.Add(dto);
                }

                reader.Close();
                comm.Dispose();

            }
            catch (Exception ex)
            {

                log.Error(" Exception in  GetGenMngAssignStore Method ", ex);
            }
            finally
            {
                db.CloseConnection(con);
            }

            return amList;
        }
        //Get General Manager Bonus
        public JsonResult GetGeneralManagerBonus(string selectDate)
        {
            AreaManagerBonusModel areaManagerBonusModel = new AreaManagerBonusModel();

            ArrayList bonusList = new ArrayList();
            DateTime formatedDate;

            if (!ValidationUtility.IsNull(selectDate))
            {
                formatedDate = ValidationUtility.ToDate(selectDate);

            }
            else
            {
                formatedDate = DateTime.Now;
            }

            DateTime givenMontWeekStartDate = ValidationUtility.MonthWeekStartDate(formatedDate);

            DateTime montEndDate = ValidationUtility.MonthWeekEndDate(formatedDate);

            UserContext cont = (UserContext)Session["UserContext"];

            ArrayList assignStoreList = null;

            if (!ValidationUtility.IsNull(cont))
            {
                ArrayList areaManagerList = areaManagerBonusModel.GetGenMngAssignStore(cont.Id);

                ManagerBonusModel managerBonusModel = new ManagerBonusModel();

                foreach (GeneralManagerBonusDTO gmDTO in areaManagerList)
                {

                    //   assignStoreList = areaManagerBonusModel.GetAreaMngAssignStore(gmDTO.UserId);

                 //   assignStoreList = ValidationUtility.GetAreaMngAssignStore(gmDTO.UserId);

                    assignStoreList = ValidationUtility.GetAreaMngAssignActiveStore(gmDTO.UserId);

                    double totalAmBonus = 0;

                    foreach (StoreDTO storeDTO in assignStoreList)
                    {
                        double totalAmount = 0;

                        ArrayList storeList = ValidationUtility.GetActiveStoreList(true);

                        ArrayList goalStoreList = new ArrayList();

                        foreach (StoreDTO storDTO in storeList)
                        {
                            if (storDTO.Id == storeDTO.Id)
                            {
                                goalStoreList.Add(storDTO);
                                break;
                            }
                        }

                        ManagerBonusDTO managerBonusDTO = managerBonusModel.CalculateManagerBonus(formatedDate, goalStoreList);

                        ManagerBonusDTO returnManagerBonusDTO = managerBonusModel.GetActualBounus(managerBonusDTO.StoreId, managerBonusDTO.FirstDateOFMonth, managerBonusDTO.LastDateOFMonth);

                        if (ValidationUtility.IsNull(returnManagerBonusDTO))
                        {
                            // Add

                            managerBonusModel.AddBounus(managerBonusDTO, false);
                        }
                        else
                        {
                            // update
                            managerBonusModel.UpdateActualValue(managerBonusDTO);
                        }

                        ArrayList getbonusList = new ArrayList();

                        ManagerBonusDTO actualBonusDTO = managerBonusModel.GetActualBounus(storeDTO.Id, givenMontWeekStartDate, montEndDate.AddDays(6));
                        getbonusList.Add(actualBonusDTO);
                        ManagerBonusDTO zeroBasisDTO = managerBonusModel.GetZeroBasisList(storeDTO.Id, givenMontWeekStartDate, montEndDate.AddDays(6));
                        getbonusList.Add(zeroBasisDTO);

                        totalAmount = areaManagerBonusModel.GetTotalBonus(getbonusList);

                        totalAmBonus = totalAmBonus + totalAmount;

                    }
                    GeneralManagerBonusDTO gmBonusDTO = new GeneralManagerBonusDTO { AmName = gmDTO.AmName, Total = totalAmBonus };
                    bonusList.Add(gmBonusDTO);

                }

            }

            return Json(bonusList, JsonRequestBehavior.AllowGet);
        }