private void CreateWorkOrder() { AlertDialog.Builder alert = new AlertDialog.Builder(this); dataLayer DA = new dataLayer(); string address = editTxt2.Text; DataTable dataTable = DA.GetCustomerDataByAddress(address); if (dataTable.Rows.Count > 0) { alert.SetTitle("ALERT"); alert.SetMessage("This customer already has a bin assigned to them\n\nWould you like to deliver this cart to them anyway?"); alert.SetPositiveButton("YES", (senderAlert, args) => { Toast.MakeText(this, "Delivering to existing customer...", ToastLength.Short).Show(); DataAccess(); }); alert.SetNegativeButton("NO", (senderAlert, args) => { Toast.MakeText(this, "Delivery cancelled", ToastLength.Short).Show(); }); Dialog dialog = alert.Create(); dialog.Show(); } }
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(); } }