public static bool createSale(string userToken, SaleObjectWS sale) { bool blnReturn = false; try { CR_ResultActionOfInt32 result; if (connectToWebServiceOperations()) { result = webServiceOperation.CreateSale(userToken, sale); if (result.Success) { blnReturn = true; } else { errorMessage = result.Errors[0].Message.ToString(); } } } catch (WebException) { switch (Configuration.currentLanguage) { case CR_TTLangue.French_Canada: { //MessageBox.Show(My.Resources.RessourceFR.errCannotReachWebservice); break; } default: { //MessageBox.Show(My.Resources.RessourceEN.errCannotReachWebservice); break; } } } catch (Exception) { switch (Configuration.currentLanguage) { case CR_TTLangue.French_Canada: { //MessageBox.Show(My.Resources.RessourceFR.errWebserviceGeneric); break; } default: { //MessageBox.Show(My.Resources.RessourceEN.errWebserviceGeneric); break; } } } return(blnReturn); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState, Resource.Layout.frmNewSale); translateScreen(); mustRefresh = false; spinnerClient = FindViewById <Spinner>(Resource.Id.spnClient); spinnerRecipient = FindViewById <Spinner>(Resource.Id.spnRecipient); spinnerOwner = FindViewById <Spinner>(Resource.Id.spnOwner); var po = FindViewById <EditText>(Resource.Id.tfPO); SaleObjectWS sale = new SaleObjectWS(); // Creation des listes List <string> listClient = new List <string>(); List <string> listRecipient = new List <string>(); List <string> listOwner = new List <string>(); var dictionaryClient = initSpinner(COMPANY_TYPE.CLIENT, spinnerClient, listClient); var dictionaryDestinataire = initSpinner(COMPANY_TYPE.DESTINATAIRE, spinnerRecipient, listRecipient); var dictionaryProprietaire = initSpinner(COMPANY_TYPE.ANY, spinnerOwner, listOwner); spinnerClient.ItemSelected += (parent, args) => { sale.CustomerNRI = dictionaryClient.FirstOrDefault(x => x.Value == listClient[args.Position]).Key; }; spinnerRecipient.ItemSelected += (parent, args) => { sale.RecipientNRI = dictionaryDestinataire.FirstOrDefault(x => x.Value == listRecipient[args.Position]).Key; }; spinnerOwner.ItemSelected += (parent, args) => { sale.OwnerNRI = dictionaryProprietaire.FirstOrDefault(x => x.Value == listOwner[args.Position]).Key; }; dateSelect = FindViewById <TextView>(Resource.Id.tvDate); dateSelect.Click += (sender, e) => { DatePickerFragment frag = DatePickerFragment.NewInstance(delegate(DateTime time) { date = new DateTime(); date = time; dateSelect.Text = time.ToLongDateString(); Console.Write(time.ToLongDateString()); }); Console.Write(dateSelect.Text); frag.Show(FragmentManager, DatePickerFragment.TAG); }; FindViewById <Button>(Resource.Id.btnConfirm).Click += async(sender, e) => { bool sucess = true; string msg = ""; switch (Configuration.currentLanguage) { case CR_TTLangue.French_Canada: { msg = "Veuillez renseigner les champs : "; break; } case CR_TTLangue.English: { msg = "Please fill in the fields: "; break; } } sale.CreatorNRI = Configuration.userInfos.NRI; sale.WarehouseNRI = Configuration.userInfos.warehouseNRI; if (date != null) { sale.DateCreated = DateTime.Today; sale.DateExpected = date; } else { msg += "date, "; sucess = false; } if (po != null) { sale.POCode = po.Text; } else { msg += "PO, "; sucess = false; } if (sucess == true) { IsBusy = true; await Task.Delay(50); if (OperationsWebService.createSale(Configuration.securityToken, sale)) { switch (Configuration.currentLanguage) { case CR_TTLangue.French_Canada: { Toast.MakeText(this, "Commande créée", ToastLength.Long).Show(); break; } case CR_TTLangue.English: { Toast.MakeText(this, "Order created", ToastLength.Long).Show(); break; } } } else { Toast.MakeText(this, OperationsWebService.errorMessage, ToastLength.Long).Show(); } IsBusy = false; mustRefresh = true; Finish(); } else { msg.Remove(msg.Length - 2, 2); Toast.MakeText(this, msg, ToastLength.Long).Show(); } IsBusy = false; }; }