Example #1
0
		void Btnvalide_Click (object sender, EventArgs e)
		{
			DBRepository dbr = new DBRepository ();
			dialog = new AlertDialog.Builder(this);
			AlertDialog alert = dialog.Create();

			//afficher le cr si CR
			//cheque
			//afficher le champ mémo
			var viewAD = this.LayoutInflater.Inflate (Resource.Layout.valideDialBox, null);
			var check1 = viewAD.FindViewById<RadioButton> (Resource.Id.radioButton1);
			var check2 = viewAD.FindViewById<RadioButton> (Resource.Id.radioButton2);
			var checkP = viewAD.FindViewById<CheckBox> (Resource.Id.checkBox1);
			var txtCR = viewAD.FindViewById<TextView> (Resource.Id.textcr);
			EditText mémo = viewAD.FindViewById<EditText>(Resource.Id.edittext);

			if (data.CR == "" || data.CR == "0") {
				check1.Visibility = ViewStates.Gone;
				check2.Visibility = ViewStates.Gone;
				txtCR.Visibility = ViewStates.Gone;
				dialog.SetMessage ("Voulez-vous valider cette position ?");
			} else {
				check1.Visibility = ViewStates.Visible;
				check2.Visibility = ViewStates.Visible;
				txtCR.Visibility = ViewStates.Visible;
				txtCR.Text = data.CR;
				dialog.SetMessage ("Avez vous perçu le CR,?\n Si oui, valider cette livraison ?");
			}
			if (type =="RAM") {
				checkP.Visibility = ViewStates.Gone;
			}

			//afficher la checkbox si partic
			dialog.SetView(viewAD);
			dialog.SetCancelable (true);
			dialog.SetPositiveButton("Oui", delegate {
				
				//case btn check
				string typecr;
				if (check2.Checked) {
					typecr="CHEQUE";
					string JSONCHEQUE ="{\"codesuiviliv\":\""+typecr+"\",\"memosuiviliv\":\"cheque\",\"libellesuiviliv\":\"\",\"commandesuiviliv\":\""+data.numCommande+"\",\"groupagesuiviliv\":\""+data.groupage+"\",\"datesuiviliv\":\""+DateTime.Now.ToString("dd/MM/yyyy HH:mm")+"\",\"posgps\":\""+Data.GPS+"\"}";
					dbr.insertDataStatutpositions(typecr,"1",typecr,data.numCommande,mémo.Text,DateTime.Now.ToString("dd/MM/yyyy HH:mm"),JSONCHEQUE);
				}
				if (check1.Checked) {
					typecr="ESPECE";
					string JSONESPECE ="{\"codesuiviliv\":\""+typecr+"\",\"memosuiviliv\":\"espece\",\"libellesuiviliv\":\"\",\"commandesuiviliv\":\""+data.numCommande+"\",\"groupagesuiviliv\":\""+data.groupage+"\",\"datesuiviliv\":\""+DateTime.Now.ToString("dd/MM/yyyy HH:mm")+"\",\"posgps\":\""+Data.GPS+"\"}";
					dbr.insertDataStatutpositions(typecr,"1",typecr,data.numCommande,mémo.Text,DateTime.Now.ToString("dd/MM/yyyy HH:mm"),JSONESPECE);
				}
				if (checkP.Checked) {
					typecr="PARTIC";
					string JSONPARTIC ="{\"codesuiviliv\":\""+typecr+"\",\"memosuiviliv\":\"espece\",\"libellesuiviliv\":\"\",\"commandesuiviliv\":\""+data.numCommande+"\",\"groupagesuiviliv\":\""+data.groupage+"\",\"datesuiviliv\":\""+DateTime.Now.ToString("dd/MM/yyyy HH:mm")+"\",\"posgps\":\""+Data.GPS+"\"}";
					dbr.insertDataStatutpositions(typecr,"1",typecr,data.numCommande,mémo.Text,DateTime.Now.ToString("dd/MM/yyyy HH:mm"),JSONPARTIC);
				}

				//mise du statut de la position à 1
				dbr.updatePosition(i,"1","Validée",mémo.Text,tyValide,null);
				//creation du JSON
				string JSON ="{\"codesuiviliv\":\""+tyValide+"\",\"memosuiviliv\":\""+mémo.Text+"\",\"libellesuiviliv\":\"\",\"commandesuiviliv\":\""+data.numCommande+"\",\"groupagesuiviliv\":\""+data.groupage+"\",\"datesuiviliv\":\""+DateTime.Now.ToString("dd/MM/yyyy HH:mm")+"\",\"posgps\":\""+Data.GPS+"\"}";
				//création de la notification webservice // statut de position
				dbr.insertDataStatutpositions(tyValide,"1","Validée",data.numCommande,mémo.Text,DateTime.Now.ToString("dd/MM/yyyy HH:mm"),JSON);

				Intent intent = new Intent (this, typeof(ListeLivraisonsActivity));
				intent.PutExtra("TYPE",type);
				this.StartActivity (intent);

			});
			dialog.SetNegativeButton("Non", delegate {
				AndHUD.Shared.ShowError(this, "Annulée!", AndroidHUD.MaskType.Clear, TimeSpan.FromSeconds(1));
			});
			dialog.Show ();
		}
Example #2
0
		void Buttonvalider_Click ()
		{
			if (txtspinner == "Choisir une anomalie") {
				
			} else {
				txtRem = EdittxtRem.Text;
				switch (txtspinner) {
				case "Livre avec manquant":
					codeanomalie = "LIVRMQ";
					break;
				case "Livre avec reserves pour avaries":
					codeanomalie = "LIVRCA";
					break;
				case "Livre mais recepisse non rendu":
					codeanomalie = "LIVDOC";
					break;
				case "Livre avec manquants + avaries":
					codeanomalie = "LIVRMA";
					break;
				case "Refuse pour avaries":
					codeanomalie = "RENAVA";
					break;
				case "Avise (avis de passage)":
					codeanomalie = "RENAVI";
					break;
				case "Rendu non livre : complement adresse":
					codeanomalie = "RENCAD";
					break;
				case "Refus divers ou sans motifs":
					codeanomalie = "RENDIV";
					break;
				case "Refuse manque BL":
					codeanomalie = "RENDOC";
					break;
				case "Refuse manquant partiel":
					codeanomalie = "RENMQP";
					break;
				case "Refuse non commande":
					codeanomalie = "RENDIV";
					break;
				case "Refuse cause port du":
					codeanomalie = "RENSPD";
					break;
				case "Refuse cause contre remboursement":
					codeanomalie = "RENDRB";
					break;
				case "Refuse livraison trop tardive":
					codeanomalie = "RENTAR";
					break;
				case "Rendu non justifie":
					codeanomalie = "RENNJU";
					break;
				case "Fermeture hebdomadaire":
					codeanomalie = "RENFHB";
					break;
				case "Non charge":
					codeanomalie = "RENNCG";
					break;
				case "Inventaire":
					codeanomalie = "RENINV";
					break;
				case "Ramasse pas faite":
					codeanomalie = "RAMPFT";
					break;
				case "Positions non chargees":
					codeanomalie = "RENNCG";
					break;
				case "Avis de passage":
					codeanomalie = "RENAVI";
					break;
				case "Ramasse diverse":
					codeanomalie = "RAMDIV";
					break;
				case "Restaure en non traite":
					codeanomalie = "RESTNT";
					break;

				default:
					break;
				}

				DBRepository dbr = new DBRepository ();
				//mise du statut de la position à 1
				if (txtspinner == "Restaure en non traite") {
					dbr.updatePosition (i, "0", txtspinner, txtRem, codeanomalie, null);

				} else {
					dbr.updatePosition (i, "2", txtspinner, txtRem, codeanomalie, null);
				}


				//creation du JSON
				string JSON = "{\"codesuiviliv\":\"" + codeanomalie + "\",\"memosuiviliv\":\"" + txtRem + "\",\"libellesuiviliv\":\"" + txtspinner + "\",\"commandesuiviliv\":\"" + data.numCommande + "\",\"groupagesuiviliv\":\"" + data.groupage + "\",\"datesuiviliv\":\"" + DateTime.Now.ToString ("dd/MM/yyyy HH:mm") + "\",\"posgps\":\"" + Data.GPS + "\"}";
				//création de la notification webservice // statut de position
				dbr.insertDataStatutpositions (codeanomalie, "2", txtspinner, data.numCommande, txtRem, DateTime.Now.ToString ("dd/MM/yyyy HH:mm"), JSON);


				string compImg = String.Empty;
		

				Task.Factory.StartNew (
					() => {
						try {
							var imgpath = dbr.GetPositionsData (i);
							Android.Graphics.Bitmap bmp = Android.Graphics.BitmapFactory.DecodeFile (imgpath.imgpath);
							Bitmap rbmp = Bitmap.CreateScaledBitmap (bmp, bmp.Width / 5, bmp.Height / 5, true);
							compImg = imgpath.imgpath.Replace (".jpg", "-1_1.jpg");
							using (var fs = new FileStream (compImg, FileMode.OpenOrCreate)) {
								rbmp.Compress (Android.Graphics.Bitmap.CompressFormat.Jpeg, 100, fs);
							}
							//ftp://77.158.93.75 ftp://10.1.2.75
							Data.Instance.UploadFile ("ftp://77.158.93.75", compImg, "DMS", "Linuxr00tn", "");

						} catch (Exception ex) {
							Console.WriteLine ("\n" + ex);
						}
					}					
				);

				Intent intent = new Intent (this, typeof(ListeLivraisonsActivity));
				intent.PutExtra ("TYPE", type);
				this.StartActivity (intent);
				this.OverridePendingTransition (Android.Resource.Animation.SlideInLeft, Android.Resource.Animation.SlideOutRight);
			}
		}