Example #1
0
        public static DateTime GetTodayDate()
        {
            string url = Settings.InstanceURL;

            url = url + "/api/GetTodayDate";

            var logon = new
            {
            };

            try {
                string results = ConnectWebAPI.Request(url, logon);

                //too tired today , sorry about this stupid code :(
                results = results.Remove(0, 1);
                results = results.Remove(results.Length - 1, 1);

                LoginController.Log("Get Today Date :" + results);

                return(DateTime.Parse(results));
            } catch (Exception ex) {
                Console.WriteLine(ex.StackTrace);

                return(DateTime.Today);
            }
        }
Example #2
0
        private void onSuccessfulLogin(LoginObject obj)
        {
            Settings.UserId       = obj.UserId;
            Settings.Username     = obj.UserName;
            Settings.Fullname     = obj.Fullname;
            Settings.CKStaff      = obj.CKStaff;
            Settings.RestaurantId = obj.RestaurantId;

            if (cb_rememberMe.Checked)
            {
                Settings.RememberMe = true;
                Settings.Password   = password.Text;
            }
            else
            {
                Settings.RememberMe = false;
                Settings.Password   = "";
            }

            LoginController.Log(Constant.Login + "_" + this.Version);

            RunOnUiThread(() => progress.Dismiss());

            StartActivity(typeof(HomeActivity));

            this.OverridePendingTransition(Resource.Animation.slide_in_top, Resource.Animation.slide_out_bottom);

            this.Finish();
        }
Example #3
0
        //Handle when user click LIST button
        public void btFinalClick(object sender, EventArgs e)
        {
            //Save the last value
            //			try {
            //
            //				var stockNumber = Double.Parse (edit_Stock.Text);
            //
            //				if (Settings.CKStaff || this.EditType == "amend") {
            //					this.orderListAdapter.SetOrderAtPosition (selectedIndex, stockNumber);
            //				}
            //				else
            //				{
            //					this.orderListAdapter.SetStockAtPosition (selectedIndex, stockNumber);
            //					this.orderListAdapter.SetOrderAtPosition (selectedIndex, this.orderListAdapter.GetItemAtPosition (selectedIndex).ShouldNumber - stockNumber);
            //				}
            //
            //
            //			} catch (Exception ew) {
            //
            //				Console.WriteLine (ew.StackTrace);
            //
            //				Toast.MakeText (this, "Input not valid", ToastLength.Short).Show ();
            //				return;
            //			}

            LoginController.Log(Constant.ButtonListClick);


            //Go back to homepage
            Intent Intent = new Intent(this, typeof(HomeActivity));

            var orderList = this.orderListAdapter.GetOrderList();

            List <OrderList1> Items = new List <OrderList1> ();

            foreach (var order in orderList)
            {
                var isSkip = 0;

                if (order.IsSkip)
                {
                    isSkip = 1;
                }

                OrderList1 item = new OrderList1(order.StockId, order.StockName, order.ShouldNumber, order.StockNumber, order.OrderNumber, order.Unit, isSkip);
                Items.Add(item);
            }

            Intent.PutParcelableArrayListExtra("key", Items.ToArray());

            Intent.SetFlags(ActivityFlags.ClearTask | ActivityFlags.NewTask);

            StartActivity(Intent);

            this.OverridePendingTransition(Resource.Animation.slide_in_top, Resource.Animation.slide_out_bottom);

            this.Finish();
        }
Example #4
0
        public void btOrderClick(object sender, EventArgs e)
        {
            LoginController.Log(Constant.ButtonOrderClick);

            Intent Intent = new Intent(this, typeof(OrderActivity));

            var CurrentDate = Utility.GetTodayDate();

            List <OrderList> orderList = new List <OrderList>();

            //get current data
            if (CurrentDate == this.StartDate)
            {
                LoginController.Log("CurrentDate == this.StartDate: " + this.StartDate.ToShortDateString());

                orderList = this.orderListAdapter.GetOrderList();
            }
            //get the newest data
            else
            {
                LoginController.Log("CurrentDate != this.StartDate: " + CurrentDate.ToShortDateString());

                orderList = OrderController.GetOrderList(CurrentDate);
            }

            List <OrderList1> Items = new List <OrderList1>();

            foreach (var order in orderList)
            {
                var isSkip = 0;

                if (order.IsSkip)
                {
                    isSkip = 1;
                }

                OrderList1 item = new OrderList1(order.StockId, order.StockName, order.ShouldNumber, order.StockNumber, order.OrderNumber, order.Unit, isSkip);
                Items.Add(item);
            }

            Intent.PutExtra("type", "order");

            Intent.PutParcelableArrayListExtra("key", Items.ToArray());

            StartActivity(Intent);

            this.OverridePendingTransition(Resource.Animation.slide_in_top, Resource.Animation.slide_out_bottom);
        }
Example #5
0
 public override void OnBackPressed()
 {
     new AlertDialog.Builder(this)
     .SetPositiveButton("Yes", (sender1, args) =>
     {
         LoginController.Log(Constant.ButtonBackExitClick);
         this.Finish();
         Android.OS.Process.KillProcess(Android.OS.Process.MyPid());
     })
     .SetNegativeButton("No", (sender2, args) =>
     {
     })
     .SetMessage("Do you want to exit the application?")
     .SetTitle("Confirm")
     .Show();
 }
Example #6
0
        public static List <OrderList> GetOrderList(DateTime orderDate)
        {
            string url = Settings.InstanceURL;

            url = url + "/Api/GetOrderList";


            var objsearch = (new
            {
                OrderDate = orderDate,
                RestaurantId = Settings.RestaurantId
            });

            string results = ConnectWebAPI.Request(url, objsearch);

            if (results != null)
            {
                LoginController.Log(Constant.GetOrderDate + ":" + orderDate.ToShortDateString());


                ApiResultList <IEnumerable <OrderList> > objResult = Newtonsoft.Json.JsonConvert.DeserializeObject <ApiResultList <IEnumerable <OrderList> > > (results);

                List <OrderList> returnObject = new List <OrderList> ();

                if (objResult.Items != null)
                {
                    foreach (object Item in objResult.Items)
                    {
                        OrderList temp = Newtonsoft.Json.JsonConvert.DeserializeObject <OrderList> (Item.ToString());
                        returnObject.Add(temp);
                    }
                }
                else
                {
                    return(null);
                }

                return(returnObject);
            }
            else
            {
                return(null);
            }
        }
Example #7
0
        public void btAmendClick(object sender, EventArgs e)
        {
            new AlertDialog.Builder(this)
            .SetPositiveButton("Yes", async(sender1, args) =>
            {
                LoginController.Log(Constant.ButtonAmendClick);

                Intent Intent = new Intent(this, typeof(OrderActivity));

                var orderList = this.orderListAdapter.GetOrderList();

                List <OrderList1> Items = new List <OrderList1> ();

                foreach (var order in orderList)
                {
                    var isSkip = 0;

                    if (order.IsSkip)
                    {
                        isSkip = 1;
                    }

                    OrderList1 item = new OrderList1(order.StockId, order.StockName, order.ShouldNumber, order.StockNumber, order.OrderNumber, order.Unit, isSkip);
                    Items.Add(item);
                }

                Intent.PutParcelableArrayListExtra("key", Items.ToArray());

                Intent.PutExtra("type", "amend");

                StartActivity(Intent);

                this.OverridePendingTransition(Resource.Animation.slide_in_top, Resource.Animation.slide_out_bottom);
            })
            .SetNegativeButton("No", (sender3, args) =>
            {
                // User pressed no
            })
            .SetTitle("This button will allow you to enter or change the order number, Continue ?")
            .Show();
        }
Example #8
0
        public void btSendClick(object sender, EventArgs e)
        {
            OptionSendSelected = 0;

            string[] color_options = new string[] { "Send All", "Send to Daiwa", "Send to Centre Kitchen" };


            new AlertDialog.Builder(this)
            .SetPositiveButton("Send", async(sender1, args) =>
            {
                progress = new ProgressDialog(this, Resource.Style.StyledDialog);
                progress.Indeterminate = true;
                progress.SetMessage("Please wait...");
                progress.SetCancelable(true);
                progress.Show();

                ApiResultSave result = await OrderController.SendOrderList(orderListAdapter.GetOrderList(), this.mNotes.Text, OptionSendSelected);

                if (result != null)
                {
                    if (result.Success)
                    {
                        progress.Dismiss();

                        var builder    = new AlertDialog.Builder(this);
                        string message = "";

                        if (OptionSendSelected == 0)
                        {
                            message = "Order sent all successfully.";
                            LoginController.Log(Constant.ButtonSendAllClick + "_" + Version);
                        }
                        else if (OptionSendSelected == 1)
                        {
                            message = "Order sent to Daiwa successfully.";
                            LoginController.Log(Constant.ButtonSendDWClick + "_" + Version);
                        }
                        else if (OptionSendSelected == 2)
                        {
                            message = "Order sent to Centre Kitchen successfully.";
                            LoginController.Log(Constant.ButtonSendCKClick + "_" + Version);
                        }

                        builder.SetMessage(message);
                        builder.SetPositiveButton("Ok", (s, ee) => { });
                        builder.Create().Show();
                    }
                    else
                    {
                        progress.Dismiss();

                        new AlertDialog.Builder(this).SetMessage(result.ErrorMessage)
                        .SetTitle("Done")
                        .Show();
                    }
                }
                else
                {
                    progress.Dismiss();

                    new AlertDialog.Builder(this).SetMessage("Network or Server problem. Try again")
                    .SetTitle("Done")
                    .Show();
                }
            })

            .SetSingleChoiceItems(color_options, 0, ListClicked)

            .SetNegativeButton("Cancel", (sender3, args) =>
            {
                // User pressed no
            })
            .SetTitle("Please carefully select which option you want to send order ?")
            .Show();
        }