Example #1
0
        private void DataAccess()
        {
            AlertDialog.Builder alert     = new AlertDialog.Builder(this);
            DataTable           dtAddress = new DataTable();
            DataTable           dtRFID    = new DataTable();
            string workOrderNumber        = DA.GetLatestWorkOrderNumber(Resources.GetString(Resource.String.program_code));
            string rfid    = rfidValue.Text;
            string address = customerAddress.Text;
            string city    = customerCity.Text;
            string state   = customerState.Text;
            string zip     = customerZip.Text;
            string size    = cartSize.Text;
            string type    = cartType.Text;
            string notes   = null;

            if (rfid != null)
            {
                if (DA.InsertWorkOrderInfo(workOrderNumber, "REMOVAL", Resources.GetString(Resource.String.program_code), rfid, address,
                                           city, state, zip, size, type, notes, "C", Resources.GetString(Resource.String.truck_number), DateTime.Now, DateTime.Now))
                {
                    Toast.MakeText(this, "Work Order Created! Updated work order...", ToastLength.Long).Show();
                    dtRFID = DA.GetCustomerDataByRFID(rfid);

                    if (dtRFID.Rows.Count > 0)
                    {
                        DA.UpdateWorkOrderInfo(workOrderNumber, rfid);
                        Toast.MakeText(this, DA.UpdateCustomerInfo(rfid), ToastLength.Long).Show();

                        int rowsAffected = DA.RemoveCustomer(rfidValue.Text);

                        if (rowsAffected > 0)
                        {
                            Toast.MakeText(this, "Successfully removed cart info from customer!", ToastLength.Short).Show();

                            Dialog dialog = alert.Create();
                            dialog.Show();

                            rfidValue.Text       = "";
                            customerName.Text    = "";
                            customerAddress.Text = "";
                            customerCity.Text    = "";
                            customerState.Text   = "";
                            customerZip.Text     = "";
                            cartSerial.Text      = "";
                            cartType.Text        = "";
                            cartSize.Text        = "";
                        }
                        else
                        {
                            alert.SetTitle("ERROR");
                            alert.SetMessage("There was an error removing the cart from the customer database, please try again.");

                            alert.SetPositiveButton("OK", (senderAlert, args) =>
                            {
                                Toast.MakeText(this, "Please Try Again!", ToastLength.Short).Show();
                            });

                            Dialog dialog = alert.Create();
                            dialog.Show();
                        }
                    }
                    else
                    {
                        Toast.MakeText(this, "Customer does not exist!", ToastLength.Long).Show();
                    }
                }
                else
                {
                    Toast.MakeText(this, "An error occurred while creating the Work Order, Please try again!", ToastLength.Long).Show();
                }
            }
            else
            {
                alert = new AlertDialog.Builder(this);
                alert.SetTitle("ERROR");
                alert.SetMessage("Please make sure you enter in an RFID value before removing a cart!");

                alert.SetPositiveButton("OK", (senderAlert, args) => {
                    Toast.MakeText(this, "Enter RFID Value", ToastLength.Short).Show();
                });

                Dialog dialog = alert.Create();
                dialog.Show();
            }
        }
Example #2
0
        private void DataAccess()
        {
            dataLayer DA              = new dataLayer();
            DataTable dtAddress       = new DataTable();
            DataTable dtRFID          = new DataTable();
            string    workOrderNumber = DA.GetLatestWorkOrderNumber(Resources.GetString(Resource.String.program_code));
            string    rfid            = editTxt1.Text;
            string    address         = editTxt2.Text;
            string    city            = editTxt3.Text;
            string    state           = editTxt5.Text;
            string    zip             = editTxt4.Text;
            string    size            = sizeSpinner.SelectedItem.ToString();
            string    type            = typeSpinner.SelectedItem.ToString();
            string    notes           = editTxt7.Text;

            if (rfid != null)
            {
                if (DA.InsertWorkOrderInfo(workOrderNumber, "DELIVERY", Resources.GetString(Resource.String.program_code), rfid, address,
                                           city, state, zip, size, type, notes, "C", Resources.GetString(Resource.String.truck_number), DateTime.Now, DateTime.Now))
                {
                    dtRFID = DA.GetCustomerDataByRFID(rfid);

                    if (dtRFID.Rows.Count > 1)
                    {
                        DA.UpdateWorkOrderInfo(workOrderNumber, rfid);
                        Toast.MakeText(this, DA.UpdateCustomerInfo(rfid), ToastLength.Long).Show();
                    }
                    else
                    {
                        if (type == "Trash")
                        {
                            DA.InsertNewCustomer("Trash", address, city, state, zip, size, rfid, Resources.GetString(Resource.String.program_code), _currentLocation.Latitude, _currentLocation.Longitude, workOrderNumber);
                            Toast.MakeText(this, "Delivered!", ToastLength.Long).Show();
                            DA.UpdateWorkOrderInfo(workOrderNumber, rfid);
                            Toast.MakeText(this, "Delivered and Updated Work Order!", ToastLength.Long).Show();
                        }
                        else if (type == "Recycling")
                        {
                            DA.InsertNewCustomer("Recycling", address, city, state, zip, size, rfid, Resources.GetString(Resource.String.program_code), _currentLocation.Latitude, _currentLocation.Longitude, workOrderNumber);
                            Toast.MakeText(this, "Delivered!", ToastLength.Long).Show();
                            DA.UpdateWorkOrderInfo(workOrderNumber, rfid);
                            Toast.MakeText(this, "Delivered and Updated Work Order!", ToastLength.Long).Show();
                        }
                    }
                }
                else
                {
                    Toast.MakeText(this, "An error occurred while creating the Work Order, Please try again!", ToastLength.Long).Show();
                }
            }
            else
            {
                AlertDialog.Builder alert = new AlertDialog.Builder(this);
                alert.SetTitle("ERROR");
                alert.SetMessage("Please make sure you enter in an RFID value before delivering a cart!");

                alert.SetPositiveButton("OK", (senderAlert, args) => {
                    Toast.MakeText(this, "Enter RFID Value", ToastLength.Short).Show();
                });

                Dialog dialog = alert.Create();
                dialog.Show();
            }
        }