/// <summary>
        /// Addition of existing trader info : Added By Apoorva Sharma 7/05/2018
        /// </summary>
        public void ModifyGrid()
        {
            try
            {
                Reset();
                bool NullCheckValue = NullCheck();
                if (NullCheckValue)
                {
                    TraderEntitlementModel oTEModel = new TraderEntitlementModel();

                    int index = TraderEntitlementCollection.IndexOf(TraderEntitlementCollection.Where(x => x.TraderId == VTraderId).FirstOrDefault());
                    if (TraderEntitlementCollection.Any(x => x.TraderId == VTraderId))
                    {
                        TraderEntitlementCollection.RemoveAt(index);
                    }
                    else
                    {
                        //    MessageBox.Show("Trader not found in Database", "!Warning!", MessageBoxButton.OK, MessageBoxImage.Error);
                    }

                    oTEModel.Branch           = VBranch.ToString();
                    oTEModel.TraderId         = VTraderId.ToString();
                    oTEModel.TraderIdSort     = Convert.ToInt32(oTEModel.TraderId);
                    oTEModel.TraderGroup      = VGroup.ToString();
                    oTEModel.ClientView       = ClientViewOnTrader.ToString();
                    oTEModel.ClientViewAT     = ViewClientOnLevel.ToString();
                    oTEModel.AuctionBlock     = AuctionBlock;
                    oTEModel.FourLBlock       = I4LBlock;
                    oTEModel.SixLBlock        = I6LBlock;
                    oTEModel.InstTradingBlock = InstitutionalTradingBlock;
                    oTEModel.ODDlotBlock      = OddLotBlock;
                    oTEModel.OrderRights      = OrderPlacementOutClientMaster.ToString();
                    oTEModel.BlockDealBlock   = BlockDealBlock;
                    oTEModel.NotApplicable    = NotApplicable;
                    oTEModel.Revert           = Revert;

                    TraderEntitlementCollection.Add(oTEModel);
                    TraderEntitlementCollection    = new ObservableCollection <TraderEntitlementModel>(TraderEntitlementCollection.OrderBy(i => i.TraderIdSort));
                    NewTraderEntitlementCollection = TraderEntitlementCollection;
                    RecordCount = TraderEntitlementCollection.Count();

                    oDataAccessLayer.OpenConnection((int)DataAccessLayer.ConnectionDB.TraderEntitlement);
                    str = @"UPDATE TRADER_ENTITLEMENT SET Branch = '" + VBranch + "', " +
                          "TraderGroup = '" + VGroup + "', " +
                          "TraderId = '" + VTraderId + "', " +
                          "ClientViewOnTraderTerminal = '" + ClientViewOnTrader + "' ," +
                          "OrderPlacementOutClientMaster = '" + OrderPlacementOutClientMaster + "', " +
                          "ViewClientOnLevel = '" + ViewClientOnLevel + "' ," +
                          "I4LBlock = '" + I4LBlock + "' ," +
                          "I6LBlock = '" + I6LBlock + "' ," +
                          "Filler = '" + "NA" + "' ," +
                          "AuctionBlock = '" + AuctionBlock + "' ," +
                          "BlockDealBlock = '" + BlockDealBlock + "' ," +
                          "OddLotBlock = '" + OddLotBlock + "' ," +
                          "InstitutionalTradingBlock = '" + InstitutionalTradingBlock + "' ," +
                          "NotApplicable = '" + NotApplicable + "' ," +
                          "RevertFromTrader = '" + Revert + "'" +
                          "WHERE TraderId = '" + VTraderId + "'";
                    int result = oDataAccessLayer.ExecuteNonQuery((int)ConnectionDB.TraderEntitlement, str, System.Data.CommandType.Text, null);
                    Replytxt = "Trader Modified";
                }
            }
            catch (Exception ex)
            {
                ExceptionUtility.LogError(ex);
            }
            finally
            {
                oDataAccessLayer.CloseConnection((int)DataAccessLayer.ConnectionDB.TraderEntitlement);
            }
        }
        /// <summary>
        /// Addition of new trader info :Added By Apoorva Sharma 7/05/2018
        /// </summary>
        private void ModelCreation()
        {
            try
            {
                Reset();
                bool NullCheckValue = NullCheck();
                if (NullCheckValue)
                {
                    TraderEntitlementModel oTEModel = new TraderEntitlementModel();
                    oTEModel.Branch           = VBranch?.ToString();
                    oTEModel.TraderId         = VTraderId?.ToString();
                    oTEModel.TraderIdSort     = Convert.ToInt32(oTEModel.TraderId);
                    oTEModel.TraderGroup      = VGroup?.ToString();
                    oTEModel.ClientView       = ClientViewOnTrader?.ToString();
                    oTEModel.ClientViewAT     = ViewClientOnLevel?.ToString();
                    oTEModel.AuctionBlock     = AuctionBlock;
                    oTEModel.FourLBlock       = I4LBlock;
                    oTEModel.SixLBlock        = I6LBlock;
                    oTEModel.InstTradingBlock = InstitutionalTradingBlock;
                    oTEModel.ODDlotBlock      = OddLotBlock;
                    oTEModel.OrderRights      = OrderPlacementOutClientMaster.ToString();;
                    oTEModel.BlockDealBlock   = BlockDealBlock;
                    oTEModel.NotApplicable    = NotApplicable;
                    oTEModel.Revert           = Revert;
                    //check short traderid duplication case
                    if (SelectedTraderADDUpdate == "Add")
                    {
                        if (TraderEntitlementCollection.Count > 0)
                        {
                            if (TraderEntitlementCollection.Any(x => x.TraderId == VTraderId))
                            {
                                Replytxt = "The TraderId Already exist";
                                return;
                            }
                            else
                            {
                                ModifyFlag = false;
                                TraderEntitlementCollection.Add(oTEModel);

                                oDataAccessLayer.OpenConnection((int)DataAccessLayer.ConnectionDB.TraderEntitlement);

                                str = @"INSERT INTO TRADER_ENTITLEMENT(Branch, TraderGroup,
                                   TraderId,
                                   ClientViewOnTraderTerminal,
                                   OrderPlacementOutClientMaster,
                                   ViewClientOnLevel,
                                   I4LBlock,
                                   I6LBlock,
                                   Filler,
                                   AuctionBlock,
                                   BlockDealBlock,
                                   OddLotBlock,
                                   InstitutionalTradingBlock,
                                   NotApplicable,
                                   RevertFromTrader) VALUES( " + "'" + oTEModel.Branch + "'," + "'" + oTEModel.TraderGroup + "'," + "'" + oTEModel.TraderId + "'," + "'" + oTEModel.ClientView + "'," + "'" + oTEModel.OrderRights + "'," + "'" + oTEModel.ClientViewAT + "'," + "'" + oTEModel.FourLBlock + "'," + "'" + oTEModel.SixLBlock + "'," + "'" + "NA" + "'," + "'" + oTEModel.AuctionBlock + "'," + "'" + oTEModel.BlockDealBlock + "'," + "'" + oTEModel.ODDlotBlock + "'," + "'" + oTEModel.InstTradingBlock + "'," + "'" + oTEModel.NotApplicable + "'," + "'" + oTEModel.Revert + "'); ";

                                int result = oDataAccessLayer.ExecuteNonQuery((int)ConnectionDB.TraderEntitlement, str, System.Data.CommandType.Text, null);
                                Replytxt = "Trader added successfully";
                            }
                        }
                    }
                    else if (SelectedTraderADDUpdate == "Modify")
                    {
                        ModifyGrid();
                    }
                    //else if(TraderEntitlementCollection.Count==0)
                    // TraderEntitlementCollection.Add(oTEModel);
                    TraderEntitlementCollection    = new ObservableCollection <TraderEntitlementModel>(TraderEntitlementCollection.OrderBy(i => i.TraderIdSort));
                    NewTraderEntitlementCollection = TraderEntitlementCollection;
                    RecordCount = TraderEntitlementCollection.Count;
                    //MasterSharedMemory.oDataAccessLayer.OpenConnection((int)DataAccessLayer.ConnectionDB.Masters);
                    //int result = MasterSharedMemory.oDataAccessLayer.ExecuteNonQuery((int)ConnectionDB.Mastersstr, System.Data.CommandType.Text, null);
                    //TODO:  insert and update in db
                }
            }

            catch (Exception ex)
            {
                ExceptionUtility.LogError(ex);
            }
            finally
            {
                oDataAccessLayer.CloseConnection((int)DataAccessLayer.ConnectionDB.TraderEntitlement);
            }
        }