예제 #1
0
 protected override void OnRestoreInstanceState(Bundle savedState)
 {
     base.OnRestoreInstanceState(savedState);
     listItem         = savedState.GetParcelableArrayList("listItem").Cast <IParcelable>().ToList(); //as IList<IParcelable>;
     adapter          = new Sal1050Adapter(this, listItem);                                          // Using cursor is not feasible since we use Mono SQlite library.
     listView.Adapter = adapter;
     mTVLookUpCustomPriceTotal.Text = savedState.GetString("mTVLookUpCustomPriceTotal");
     tvSerial.Text = savedState.GetString("formNo");
     seq           = savedState.GetInt("seq");
 }
예제 #2
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            ((SharedEnviroment)ApplicationContext).Logging = Pref.getLogging(this);
            ((SharedEnviroment)ApplicationContext).TAG     = "NamaadMobile.Sal1050";
            SetActionBarTitle(((SharedEnviroment)ApplicationContext).ActionName);
            SetContentView(Resource.Layout.sal1050);
            btnCreate         = (Button)FindViewById(Resource.Id.btnCreate);
            btnSave           = (Button)FindViewById(Resource.Id.btnSave);
            btnBarCodeScanner = (Button)FindViewById(Resource.Id.btnBarCodeScanner);
            tvPosCustNo       = ((TextView)FindViewById(Resource.Id.tvPosCustNo));
            tvPosPriceType    = ((TextView)FindViewById(Resource.Id.tvPosPriceType));
            tvCurrentDate     = ((TextView)FindViewById(Resource.Id.tvCurrentDate));
            tvSerial          = ((TextView)FindViewById(Resource.Id.tvSerial));
            hv = (HorizontalScrollView)FindViewById(Resource.Id.horizontalScrollView1);
            try
            {
                using (dbHelper = new NmdMobileDBAdapter(this))
                {
                    dbHelper.OpenOrCreateDatabase(((SharedEnviroment)ApplicationContext).ActionArgument);
                    using (SqliteDataReader reader = dbHelper.ExecuteReader("Select CrmDprt, PosCustNo, PosPriceType, CurrentDate From WebSalCommon"))
                        while (reader.Read())
                        {
                            tvPosCustNo.Text    = reader["PosCustNo"].ToString();
                            tvPosPriceType.Text = reader["PosPriceType"].ToString();
                            //mTVCurrentDate_FactorForooshGah.Text = reader["CurrentDate"].ToString();
                            serialDprt = int.Parse(reader["CrmDprt"].ToString());
                        }
                    object obj = dbHelper.ExecuteScalar("SELECT Max(FormNo) As MaxFormNo FROM WebSalPerformaDtl");
                    if (obj != DBNull.Value)
                    {
                        tvSerial.Text = (int.Parse(obj.ToString()) + 1).ToString();
                    }
                }
            }
            catch (Exception e)
            {
                if (e.Message.Contains("SQLite error\r\nno such table:"))
                {
                    ExceptionHandler.toastMsg(this, GetString(Resource.String.error_reRefresh_Sal1050));
                }
                else
                {
                    ExceptionHandler.toastMsg(this, e.Message);
                }
                btnCreate.Enabled = false;
                btnSave.Enabled   = false;
                ExceptionHandler.logDActivity(e.ToString(), ((SharedEnviroment)ApplicationContext).Logging, ((SharedEnviroment)ApplicationContext).TAG);
            }
            tvCurrentDate.Text        = GetFormDate().ToString();
            mTVLookUpCustomPriceTotal = (TextView)FindViewById(Resource.Id.tVLookUpCustomPriceTotal);
            //mTVLookUpCustomQuantityTotal = (TextView)FindViewById(Resource.Id.tVLookUpCustomQuantityTotal);

            listView = (ListView)FindViewById(Resource.Id.lVFactorForooshGah);
            //var listItemCon = LastNonConfigurationInstance as IList<IParcelable>;
            //if (listItemCon != null)
            //{
            //	listItem = listItemCon;
            //}
            adapter                    = new Sal1050Adapter(this, listItem);// Using cursor is not feasible since we use Mono SQlite library.
            listView.Adapter           = adapter;
            listView.TextFilterEnabled = true;
            // Tell the list view to show one checked/activated item at a time.
            listView.ChoiceMode = ChoiceMode.Single;

            RegisterForContextMenu(listView);

            btnSave = (Button)FindViewById(Resource.Id.btnSave);
        }