public void selectDrawerItem(IMenuItem item)
        {
            Fragment fragment = null;
            string   title    = "";

            if (CurrentFocus != null)
            {
                imm.HideSoftInputFromWindow(CurrentFocus.WindowToken, 0);
            }



            /*if (item.ItemId == Resource.Id.nav_receiving)
             * {
             *  fragment = new ReceiveFragment();
             *
             *  title = Resources.GetString(Resource.String.action_receiving_main);
             *  receiving_main.SetVisible(true);
             *  receiving_record.SetVisible(true);
             *  receiving_board.SetVisible(true);
             *  receiving_multi.SetVisible(true);
             *  shipment_main.SetVisible(false);
             *  shipment_find.SetVisible(false);
             *  allocation_find.SetVisible(false);
             *  allocation_replenishment.SetVisible(false);
             *  allocation_send_msg.SetVisible(false);
             *  allocation_msg.SetVisible(false);
             *  allocation_area_confirm.SetVisible(false);
             *  allocation_direct.SetVisible(false);
             *  entering_warehouse_main.SetVisible(false);
             *  entering_warehouse_find.SetVisible(false);
             *  production_storage_main.SetVisible(false);
             *  production_storage_find.SetVisible(false);
             *  production_storage_scan.SetVisible(false);
             * }
             * else if(item.ItemId == Resource.Id.nav_shipment)
             * {
             *  fragment = new ShipmentFragment();
             *
             *  title = Resources.GetString(Resource.String.action_shipment_main);
             *  receiving_main.SetVisible(false);
             *  receiving_record.SetVisible(false);
             *  receiving_board.SetVisible(false);
             *  receiving_multi.SetVisible(false);
             *  shipment_main.SetVisible(true);
             *  shipment_find.SetVisible(true);
             *  allocation_find.SetVisible(false);
             *  allocation_replenishment.SetVisible(false);
             *  allocation_send_msg.SetVisible(false);
             *  allocation_msg.SetVisible(false);
             *  allocation_area_confirm.SetVisible(false);
             *  allocation_direct.SetVisible(false);
             *  entering_warehouse_main.SetVisible(false);
             *  entering_warehouse_find.SetVisible(false);
             *  production_storage_main.SetVisible(false);
             *  production_storage_find.SetVisible(false);
             *  production_storage_scan.SetVisible(false);
             * }
             * else*/
            if (item.ItemId == Resource.Id.nav_search)
            {
                fragment = new LookupInStockFragment();

                title = Resources.GetString(Resource.String.action_allocation_find);
                searchFilter.SetVisible(false);
                receiving_main.SetVisible(false);
                receiving_record.SetVisible(false);
                receiving_board.SetVisible(false);
                receiving_multi.SetVisible(false);
                shipment_main.SetVisible(false);
                shipment_find.SetVisible(false);
                allocation_find.SetVisible(false);
                allocation_replenishment.SetVisible(false);
                allocation_send_msg.SetVisible(false);
                allocation_msg.SetVisible(false);
                allocation_area_confirm.SetVisible(false);
                allocation_direct.SetVisible(false);
                entering_warehouse_main.SetVisible(false);
                entering_warehouse_find.SetVisible(false);
                production_storage_main.SetVisible(false);
                production_storage_find.SetVisible(false);
                production_storage_scan.SetVisible(false);
            }
            else if (item.ItemId == Resource.Id.nav_allocation_send_msg)
            {
                Log.Debug(TAG, "Send msg");
                fragment = new AllocationSendMsgToReserveWarehouseFragment();

                title = Resources.GetString(Resource.String.action_allocation_send_msg_to_reserve);
                searchFilter.SetVisible(false);
                receiving_main.SetVisible(false);
                receiving_record.SetVisible(false);
                receiving_board.SetVisible(false);
                receiving_multi.SetVisible(false);
                shipment_main.SetVisible(false);
                shipment_find.SetVisible(false);
                allocation_find.SetVisible(true);
                allocation_replenishment.SetVisible(true);
                allocation_send_msg.SetVisible(true);
                allocation_msg.SetVisible(true);
                allocation_area_confirm.SetVisible(true);
                allocation_direct.SetVisible(true);
                entering_warehouse_main.SetVisible(false);
                entering_warehouse_find.SetVisible(false);
                production_storage_main.SetVisible(false);
                production_storage_find.SetVisible(false);
                production_storage_scan.SetVisible(false);
            }
            else if (item.ItemId == Resource.Id.nav_allocation)
            {
                fragment = new AllocationMsgFragment();

                title = Resources.GetString(Resource.String.action_allocation_msg);
                searchFilter.SetVisible(false);
                receiving_main.SetVisible(false);
                receiving_record.SetVisible(false);
                receiving_board.SetVisible(false);
                receiving_multi.SetVisible(false);
                shipment_main.SetVisible(false);
                shipment_find.SetVisible(false);
                allocation_find.SetVisible(true);
                allocation_replenishment.SetVisible(true);
                allocation_send_msg.SetVisible(true);
                allocation_msg.SetVisible(true);
                allocation_area_confirm.SetVisible(true);
                allocation_direct.SetVisible(true);
                entering_warehouse_main.SetVisible(false);
                entering_warehouse_find.SetVisible(false);
                production_storage_main.SetVisible(false);
                production_storage_find.SetVisible(false);
                production_storage_scan.SetVisible(false);
            }
            else if (item.ItemId == Resource.Id.nav_entering_warehouse)
            {
                fragment = new EnteringWarehouseFragment();

                title = Resources.GetString(Resource.String.action_entering_warehouse_main);
                searchFilter.SetVisible(false);
                receiving_main.SetVisible(false);
                receiving_record.SetVisible(false);
                receiving_board.SetVisible(false);
                receiving_multi.SetVisible(false);
                shipment_main.SetVisible(false);
                shipment_find.SetVisible(false);
                allocation_find.SetVisible(false);
                allocation_replenishment.SetVisible(false);
                allocation_send_msg.SetVisible(false);
                allocation_msg.SetVisible(false);
                allocation_area_confirm.SetVisible(false);
                allocation_direct.SetVisible(false);
                entering_warehouse_main.SetVisible(true);
                entering_warehouse_find.SetVisible(true);
                production_storage_main.SetVisible(false);
                production_storage_find.SetVisible(false);
                production_storage_scan.SetVisible(false);
            }
            else if (item.ItemId == Resource.Id.nav_production_storage)
            {
                fragment = new ProductionStorageFragment();

                title = Resources.GetString(Resource.String.action_production_storage_main);
                receiving_main.SetVisible(false);
                receiving_record.SetVisible(false);
                receiving_board.SetVisible(false);
                receiving_multi.SetVisible(false);
                shipment_main.SetVisible(false);
                shipment_find.SetVisible(false);
                allocation_find.SetVisible(false);
                allocation_replenishment.SetVisible(false);
                allocation_send_msg.SetVisible(false);
                allocation_msg.SetVisible(false);
                allocation_area_confirm.SetVisible(false);
                allocation_direct.SetVisible(false);
                entering_warehouse_main.SetVisible(false);
                entering_warehouse_find.SetVisible(false);
                production_storage_main.SetVisible(true);
                production_storage_find.SetVisible(true);
                production_storage_scan.SetVisible(true);
            }/*
              * else if (item.ItemId == Resource.Id.nav_receiving_inspection)
              * {
              * fragment = new ReceivingInspectionFragment();
              *
              * title = Resources.GetString(Resource.String.action_receiving_inspection_main);
              * receiving_main.SetVisible(false);
              * receiving_record.SetVisible(false);
              * receiving_board.SetVisible(false);
              * receiving_multi.SetVisible(false);
              * shipment_main.SetVisible(false);
              * shipment_find.SetVisible(false);
              * allocation_find.SetVisible(false);
              * allocation_replenishment.SetVisible(false);
              * allocation_send_msg.SetVisible(false);
              * allocation_msg.SetVisible(false);
              * allocation_area_confirm.SetVisible(false);
              * allocation_direct.SetVisible(false);
              * entering_warehouse_main.SetVisible(false);
              * entering_warehouse_find.SetVisible(false);
              * production_storage_main.SetVisible(false);
              * production_storage_find.SetVisible(false);
              * production_storage_scan.SetVisible(false);
              * }*/
            else if (item.ItemId == Resource.Id.nav_setting)
            {
                fragment = new Settingfragment();

                title = Resources.GetString(Resource.String.action_settings);
                receiving_main.SetVisible(false);
                receiving_record.SetVisible(false);
                receiving_board.SetVisible(false);
                receiving_multi.SetVisible(false);
                shipment_main.SetVisible(false);
                shipment_find.SetVisible(false);
                allocation_find.SetVisible(false);
                allocation_replenishment.SetVisible(false);
                allocation_send_msg.SetVisible(false);
                allocation_msg.SetVisible(false);
                allocation_area_confirm.SetVisible(false);
                allocation_direct.SetVisible(false);
                entering_warehouse_main.SetVisible(false);
                entering_warehouse_find.SetVisible(false);
                production_storage_main.SetVisible(false);
                production_storage_find.SetVisible(false);
                production_storage_scan.SetVisible(false);
            }
            else if (item.ItemId == Resource.Id.nav_login)
            {
                fragment = new LoginFragment();

                title = Resources.GetString(Resource.String.nav_login);
                receiving_main.SetVisible(false);
                receiving_record.SetVisible(false);
                receiving_board.SetVisible(false);
                receiving_multi.SetVisible(false);
                shipment_main.SetVisible(false);
                shipment_find.SetVisible(false);
                allocation_find.SetVisible(false);
                allocation_replenishment.SetVisible(false);
                allocation_send_msg.SetVisible(false);
                allocation_msg.SetVisible(false);
                allocation_area_confirm.SetVisible(false);
                allocation_direct.SetVisible(false);
                entering_warehouse_main.SetVisible(false);
                entering_warehouse_find.SetVisible(false);
                production_storage_main.SetVisible(false);
                production_storage_find.SetVisible(false);
                production_storage_scan.SetVisible(false);
            }
            else if (item.ItemId == Resource.Id.nav_logout)
            {
                fragment = new LogoutFragment();

                title = Resources.GetString(Resource.String.nav_logout);
                receiving_main.SetVisible(false);
                receiving_record.SetVisible(false);
                receiving_board.SetVisible(false);
                receiving_multi.SetVisible(false);
                shipment_main.SetVisible(false);
                shipment_find.SetVisible(false);
                allocation_find.SetVisible(false);
                allocation_replenishment.SetVisible(false);
                allocation_send_msg.SetVisible(false);
                allocation_msg.SetVisible(false);
                allocation_area_confirm.SetVisible(false);
                allocation_direct.SetVisible(false);
                entering_warehouse_main.SetVisible(false);
                entering_warehouse_find.SetVisible(false);
                production_storage_main.SetVisible(false);
                production_storage_find.SetVisible(false);
                production_storage_scan.SetVisible(false);

                Intent intent = new Intent();
                intent.SetAction(Constants.ACTION_LOGOUT_ACTION);
                context.SendBroadcast(intent);
            }
            else
            {
                fragment = new LoginFragment();

                title = Resources.GetString(Resource.String.nav_login);
                receiving_main.SetVisible(false);
                receiving_record.SetVisible(false);
                receiving_board.SetVisible(false);
                receiving_multi.SetVisible(false);
                shipment_main.SetVisible(false);
                shipment_find.SetVisible(false);
                allocation_find.SetVisible(false);
                allocation_replenishment.SetVisible(false);
                allocation_send_msg.SetVisible(false);
                allocation_msg.SetVisible(false);
                allocation_area_confirm.SetVisible(false);
                allocation_direct.SetVisible(false);
                entering_warehouse_main.SetVisible(false);
                entering_warehouse_find.SetVisible(false);
                production_storage_main.SetVisible(false);
                production_storage_find.SetVisible(false);
                production_storage_scan.SetVisible(false);
            }

            FragmentTransaction fragmentTx = this.FragmentManager.BeginTransaction();

            //fragmentTx.Add(Resource.Id.flContent, fragment);
            fragmentTx.Replace(Resource.Id.flContent, fragment);

            fragmentTx.Commit();

            this.Title = title;

            DrawerLayout drawer = FindViewById <DrawerLayout>(Resource.Id.drawer_layout);

            drawer.CloseDrawer(GravityCompat.Start);
        }
            public override void OnReceive(Context context, Intent intent)
            {
                if (intent.Action == Constants.ACTION_SETTING_PDA_TYPE_ACTION)
                {
                    Log.Debug(TAG, "receive ACTION_SETTING_PDA_TYPE_ACTION");
                    string ret = intent.GetStringExtra("MODEL_TYPE");
                    pda_type = Convert.ToInt32(ret);

                    editor = prefs.Edit();
                    editor.PutInt("PDA_TYPE", pda_type);
                    editor.Apply();
                }
                else if (intent.Action == Constants.ACTION_SETTING_WEB_SOAP_PORT_ACTION)
                {
                    Log.Debug(TAG, "receive ACTION_SETTING_WEB_SOAP_PORT_ACTION");
                    web_soap_port = intent.GetStringExtra("WEB_SOAP_PORT");
                    Log.Debug(TAG, "web_soap_port = " + web_soap_port);

                    editor = prefs.Edit();
                    editor.PutString("WEB_SOAP_PORT", web_soap_port);
                    editor.Apply();
                }
                else if (intent.Action == Constants.SOAP_CONNECTION_FAIL)
                {
                    Log.Debug(TAG, "receive SOAP_CONNECTION_FAIL");
                    //if (loadDialog != null)
                    //{
                    //    loadDialog.Dismiss();
                    //    loadDialog = null;
                    //}
                }
                else if (intent.Action == Constants.ACTION_LOGIN_SUCCESS)
                {
                    string account  = intent.GetStringExtra("ACCOUNT");
                    string password = intent.GetStringExtra("PASSWORD");

                    Log.Debug(TAG, "account = " + account + ", password = "******" " + account;
                    }
                    else
                    {
                        Log.Debug("empID = ", "null");
                    }

                    myToolbar.Title = context.Resources.GetString(Resource.String.action_allocation_find);

                    isLogin = true;
                    //if (loadDialog != null)
                    //{
                    //    loadDialog.Dismiss();
                    //    loadDialog = null;
                    //}
                    //hide virtual keyboard
                    var currentFocus = ((Activity)context).CurrentFocus;
                    if (currentFocus != null)
                    {
                        imm.HideSoftInputFromWindow(currentFocus.WindowToken, HideSoftInputFlags.None);
                    }
                }

                /*else if (intent.Action == Constants.ACTION_LOGIN_FAIL)
                 * {
                 *  Log.Debug(TAG, "Password mismatched!");
                 *  //if (loadDialog != null)
                 *  //{
                 *  //    loadDialog.Dismiss();
                 *  //    loadDialog = null;
                 *  //}
                 * }
                 * else if (intent.Action == Constants.ACTION_LOGIN_ACTION)
                 * {
                 *  Log.Debug(TAG, "receive ACTION_LOGIN_ACTION");
                 *
                 *  loadDialog = new ProgressDialog(context);
                 *  loadDialog.SetProgressStyle(ProgressDialogStyle.Spinner);
                 *  loadDialog.SetTitle(context.Resources.GetString(Resource.String.progress_login));
                 *  //loadDialog.SetIndeterminate(false);
                 *  loadDialog.SetCancelable(false);
                 *  loadDialog.Show();
                 *
                 * }*/
                else if (intent.Action == Constants.ACTION_LOGOUT_ACTION)
                {
                    Log.Debug(TAG, "receive ACTION_LOGOUT_ACTION");
                    Android.App.AlertDialog.Builder alert = new Android.App.AlertDialog.Builder(context);
                    alert.SetTitle(Resource.String.logout_title);
                    alert.SetIcon(Resource.Drawable.ic_warning_black_48dp);
                    alert.SetMessage(Resource.String.logout_title_msg);
                    alert.SetPositiveButton(Resource.String.confirm, (senderAlert, args) => {
                        Log.Debug("MainActivity", "Logout!");
                        Fragment fragment = new LoginFragment();
                        FragmentTransaction fragmentTx = fragmentManager.BeginTransaction();
                        fragmentTx.Replace(Resource.Id.flContent, fragment);
                        fragmentTx.Commit();

                        receiving_main.SetVisible(false);
                        receiving_record.SetVisible(false);
                        receiving_board.SetVisible(false);
                        receiving_multi.SetVisible(false);

                        shipment_main.SetVisible(false);
                        shipment_find.SetVisible(false);

                        allocation_find.SetVisible(false);
                        allocation_replenishment.SetVisible(false);
                        allocation_send_msg.SetVisible(false);
                        allocation_msg.SetVisible(false);
                        allocation_area_confirm.SetVisible(false);
                        allocation_direct.SetVisible(false);

                        entering_warehouse_main.SetVisible(false);
                        entering_warehouse_find.SetVisible(false);

                        production_storage_main.SetVisible(false);
                        production_storage_find.SetVisible(false);
                        production_storage_scan.SetVisible(false);

                        menuItemLogin.SetVisible(true);
                        menuItemLogout.SetVisible(false);
                        //menuItemReceiveGoods.SetVisible(false);
                        //menuItemShipment.SetVisible(false);
                        menuItemSearch.SetVisible(false);
                        menuItemAllocationSendMsg.SetVisible(false);
                        menuItemAllocation.SetVisible(false);
                        menuItemEnteringWareHouse.SetVisible(false);
                        menuItemProductionStorage.SetVisible(false);
                        //menuItemReceivingInspection.SetVisible(false);
                        //menuItemProductionStorage.SetVisible(false);

                        isLogin    = false;
                        empID.Text = "";
                    });

                    alert.SetNegativeButton(Resource.String.cancel, (senderAlert, args) => {
                    });

                    Dialog dialog = alert.Create();
                    dialog.Show();
                }/*
                  * else if (intent.Action == Constants.ACTION_ENTERING_WAREHOUSE_INTO_STOCK_SHOW_DIALOG)
                  * {
                  * Log.Debug(TAG, "receive ACTION_ENTERING_WAREHOUSE_INTO_STOCK_SHOW_DIALOG");
                  *
                  * string msg = intent.GetStringExtra("MSG");
                  * string head = context.GetString(Resource.String.entering_warehouse_dialog_content);
                  *
                  * Android.App.AlertDialog.Builder alert = new Android.App.AlertDialog.Builder(context);
                  * alert.SetTitle(Resource.String.entering_warehouse_dialog_title);
                  * alert.SetIcon(Resource.Drawable.ic_warning_black_48dp);
                  * alert.SetMessage(head+"\n"+msg);
                  * alert.SetPositiveButton(Resource.String.dialog_confirm, (senderAlert, args) => {
                  *     Intent confirmIntent = new Intent(Constants.ACTION_ENTERING_WAREHOUSE_INTO_STOCK_CONFIRM);
                  *     context.SendBroadcast(confirmIntent);
                  * });
                  *
                  * alert.SetNegativeButton(Resource.String.dialog_cancel, (senderAlert, args) => {
                  *
                  * });
                  *
                  * Dialog dialog = alert.Create();
                  * dialog.Show();
                  *
                  *
                  * }*/
                else if (intent.Action == Constants.ACTION_SEARCH_MENU_SHOW_ACTION)
                {
                    Log.Debug(TAG, "receive ACTION_SEARCH_MENU_SHOW_ACTION");
                    searchFilter.SetVisible(true);
                }
                else if (intent.Action == Constants.ACTION_SEARCH_MENU_HIDE_ACTION)
                {
                    Log.Debug(TAG, "receive ACTION_SEARCH_MENU_HIDE_ACTION");
                    searchFilter.SetVisible(false);
                }
                else if (intent.Action == Constants.ACTION_RESET_TITLE_PART_IN_STOCK)
                {
                    Log.Debug(TAG, "receive ACTION_RESET_TITLE_PART_IN_STOCK");
                    myToolbar.Title = context.Resources.GetString(Resource.String.action_allocation_find);
                }
            }
        public override bool OnOptionsItemSelected(IMenuItem item)
        {
            Fragment fragment = null;
            string   title    = "";
            int      id       = item.ItemId;

            if (id == Resource.Id.action_settings)
            {
                title = Resources.GetString(Resource.String.action_settings);
                return(true);
            }
            //search
            else if (id == Resource.Id.action_shipping_find)
            {
                title    = Resources.GetString(Resource.String.action_shipment_find);
                fragment = new LookupInStockFragment();
            }
            else if (id == Resource.Id.action_allocation_find)
            {
                title    = Resources.GetString(Resource.String.action_allocation_find);
                fragment = new LookupInStockFragment();
            }
            else if (id == Resource.Id.action_entering_warehouse_find)
            {
                title    = Resources.GetString(Resource.String.action_entering_warehouse_find);
                fragment = new LookupInStockFragment();
            }
            else if (id == Resource.Id.action_production_storage_find)
            {
                title    = Resources.GetString(Resource.String.action_production_storage_find);
                fragment = new LookupInStockFragment();
            }
            //receive main fragment
            else if (id == Resource.Id.action_receiving_main)
            {
                title    = Resources.GetString(Resource.String.action_receiving_main);
                fragment = new ReceiveFragment();
            }
            //receive record fragment
            else if (id == Resource.Id.action_receiving_record)
            {
                title    = Resources.GetString(Resource.String.action_receiving_record);
                fragment = new ReceivingRecordFragment();
            }
            //receive board fragment
            else if (id == Resource.Id.action_receiving_board)
            {
                title    = Resources.GetString(Resource.String.action_receiving_board);
                fragment = new ReceivingBoardFragment();
            }
            //receive multi fragment
            else if (id == Resource.Id.action_receiving_multi)
            {
                title    = Resources.GetString(Resource.String.action_receiving_multi);
                fragment = new ReceivingMultiFragment();
            }
            //shipping main
            else if (id == Resource.Id.action_shipping_main)
            {
                title    = Resources.GetString(Resource.String.action_shipment_main);
                fragment = new ShipmentFragment();
            }
            //allocation replenishment
            else if (id == Resource.Id.action_allocation_replenishment)
            {
                title    = Resources.GetString(Resource.String.action_allocation_replenishment);
                fragment = new AllocationReplenishmentFragment();
            }
            //allocation send msg to reserve
            else if (id == Resource.Id.action_allocation_send_msg_to_reserve)
            {
                title    = Resources.GetString(Resource.String.action_allocation_send_msg_to_reserve);
                fragment = new AllocationSendMsgToReserveWarehouseFragment();
            }
            //allocation msg
            else if (id == Resource.Id.action_allocation_msg)
            {
                title    = Resources.GetString(Resource.String.action_allocation_msg);
                fragment = new AllocationMsgFragment();
            }
            //allocation area confirm
            else if (id == Resource.Id.action_allocation_area_confirm)
            {
                title    = Resources.GetString(Resource.String.action_allocation_area_confirm);
                fragment = new AllocationAreaConfirmFragment();
            }
            //allocation direct
            else if (id == Resource.Id.action_allocation_direct)
            {
                title    = Resources.GetString(Resource.String.action_allocation_direct);
                fragment = new AllocationDirectFragment();
            }
            //entering warehouse
            else if (id == Resource.Id.action_entering_warehouse_main)
            {
                title    = Resources.GetString(Resource.String.action_entering_warehouse_main);
                fragment = new EnteringWarehouseFragment();
            }
            //production storage
            else if (id == Resource.Id.action_production_storage_main)
            {
                title    = Resources.GetString(Resource.String.action_production_storage_main);
                fragment = new ProductionStorageFragment();
            }
            //production storage scan
            else if (id == Resource.Id.action_production_storage_scan)
            {
                title    = Resources.GetString(Resource.String.action_production_storage_scan);
                fragment = new ProductionFeedingScanFragment();
            }

            if (fragment != null)
            {
                FragmentTransaction fragmentTx = this.FragmentManager.BeginTransaction();
                //fragmentTx.Add(Resource.Id.flContent, fragment);
                fragmentTx.Replace(Resource.Id.flContent, fragment);

                fragmentTx.Commit();
                this.Title = title;
            }


            return(base.OnOptionsItemSelected(item));
        }