public SoilTest(int num, SQLiteConnection s) : base(UITableViewStyle.Grouped, null) { sql = s; sql.CreateTable<SoilTestData> (); fieldID = num; notes = new SimpleMultilineEntryElement (null, null); notes.Editable = true; this.Title = "Soil Test"; this.Pushing = true; this.NavigationItem.SetRightBarButtonItem ( new UIBarButtonItem (UIBarButtonSystemItem.Save, (sender,args) => { // button was clicked var soilTestData = new SoilTestData { DbField = fieldID, DbNotes = notes.Value }; //insert to database sql.Insert (soilTestData); UIAlertView alert = new UIAlertView (); alert.Title = "Success"; alert.Message = "Your Data Has Been Saved"; alert.AddButton("OK"); alert.Clicked += delegate { this.NavigationController.PopViewControllerAnimated(true); } ; alert.Show(); }) , true); Root = new RootElement (null) { new Section ("Notes"){ notes, }, }; }
public Selection(String farmName,String fieldName,int fieldID) : base(UITableViewStyle.Grouped, null) { this.Pushing = true; LocalStorage.getLocalStorageManager ().createTable (); Root = new RootElement (farmName+" "+fieldName) {}; var section0 = new Section ("Field Info:") { }; var acreElem=new EntryElement("Acre: ","Enter field size here",DBConnection.getFieldAcre(fieldID).ToString()); acreElem.KeyboardType = UIKeyboardType.NumbersAndPunctuation; acreElem.ShouldReturn+=()=>{acreElem.ResignFirstResponder(true);return true;}; var noteElem=new SimpleMultilineEntryElement("Note",DBConnection.getFieldNote(fieldID)); noteElem.Editable=true; //noteElem.ShouldReturn+=()=>{noteElem.ResignFirstResponder(true);return true;}; var btnSave=new StringElement("Save",()=>{ try{ DBConnection.updateAcre(fieldID,Int32.Parse(acreElem.Value)); } catch(Exception e){ new UIAlertView ("Error", "Wrong input format for acre!", null, "Continue").Show (); return; } try{ DBConnection.updateNote(fieldID,noteElem.Value); } catch(Exception e){ new UIAlertView ("Error", "Wrong input format for note!", null, "Continue").Show (); return; } UIAlertView alert = new UIAlertView (); alert.Title = "Success"; alert.Message = "Your Data Has Been Saved"; alert.AddButton("OK"); alert.Show(); }); section0.Add(acreElem); section0.Add(noteElem); section0.Add(btnSave); Root.Add(section0); SQLiteConnection sql = DBConnection.initialDB(); var section = new Section ("choose the action you want to do") { }; var seed=new StringElement("Seed",()=>{ //add code here Wen this.NavigationController.PushViewController(new Seed(fieldID),true); }); var chemical=new StringElement("Chemical",()=>{ //add code here Wen this.NavigationController.PushViewController(new Chemical(fieldID),true); }); var harvest=new StringElement("Harvest",()=>{ //add code here khaled this.NavigationController.PushViewController(new Harvest(fieldID, sql),true); }); var cultivation=new StringElement("Cultivation",()=>{ //add code here khaled this.NavigationController.PushViewController(new Cultivation(fieldID, sql),true); }); var soilTest=new StringElement("Soil Test",()=>{ //add code here khaled this.NavigationController.PushViewController(new SoilTest(fieldID, sql),true); }); section.Add (seed); section.Add(chemical); section.Add(harvest); section.Add (cultivation); section.Add(soilTest); Root.Add(section); }
public Cultivation(int num, SQLiteConnection s) : base(UITableViewStyle.Grouped, null) { sql = s; sql.CreateTable<CultivationData> (); fieldID = num; date = new DateElement (null, DateTime.Today); implement = new EntryElement (null, "Which implement was used?", null); depth = new FloatElementEx (0); notes = new SimpleMultilineEntryElement (null, null); depth.UseCaptionForValueDisplay = true; depth.ShowCaption = true; depth.MinValue = 0; depth.MaxValue = 2; implement.ShouldReturn += delegate { implement.ResignFirstResponder (true); return true; }; notes.Editable = true; this.Title = "Cultivation"; this.Pushing = true; this.NavigationItem.SetRightBarButtonItem ( new UIBarButtonItem (UIBarButtonSystemItem.Save, (sender,args) => { // button was clicked var cultivationData = new CultivationData { DbField = fieldID, DbDate = date.DateValue, DbImplement = implement.Value, DbDepth = depth.Value, DbNotes = notes.Value }; //insert to database sql.Insert (cultivationData); UIAlertView alert = new UIAlertView (); alert.Title = "Success"; alert.Message = "Your Data Has Been Saved"; alert.AddButton("OK"); alert.Clicked += delegate { this.NavigationController.PopViewControllerAnimated(true); } ; alert.Show(); }) , true); Root = new RootElement (null) { new Section ("Date"){ date, }, new Section ("Implement Used"){ implement, }, new Section("Depth (in)"){ depth, }, new Section ("Notes"){ notes, }, }; }
public void initializeUserInterface() { // 0. Chemical Template chemicalTemplateDict = new Dictionary<string, ChemicalTemplate> (); chemicalTemplateDict = LocalStorage.getLocalStorageManager ().loadChemicalTemplate(); Section chemicalTemplateS = new Section ("Chemical Template"); chemicalTemplate = new RadioGroup (0); Section stSection = new Section (); foreach(var templateName in chemicalTemplateDict){ var t = new myRadioElement(templateName.Value.templateName); t.OnSelected += delegate(object sender, EventArgs e) { InvokeOnMainThread(()=>{ loadValueFromTemplate(t.Caption); }); }; stSection .Add(t); } RootElement stRoot = new RootElement ("Chemical Template", chemicalTemplate) { }; stRoot.Add(stSection); chemicalTemplateS.Add (stRoot); // 1. Chemical Date Section chemicalDateS = new Section ("Chemical Date"); chemicalDate = new DateElement ("", DateTime.Now); chemicalDateS.Add (this.chemicalDate); // 2. Implemented Used Section implementedUsedS = new Section ("Implemented Used"); tools = new EntryElement (" ","Tools",""); tools.ShouldReturn += delegate { tools.ResignFirstResponder(true); return true; }; tools.ReturnKeyType = UIReturnKeyType.Done; implementedUsedS.Add (tools); // 3. Seed Type Section chemicalTypeS = new Section ("Chemical Types"); chemicalTypes = new EntryElement (" ", "Chemical Types", ""); chemicalTypes.ShouldReturn += delegate { chemicalTypes.ResignFirstResponder(true); return true; }; chemicalTypes.ReturnKeyType = UIReturnKeyType.Done; chemicalTypeS.Add (chemicalTypes); // 4. chemical Rate Section chemicalRateS = new Section ("Chemical Rate (L/ac)"); chemicalRate = new EntryElement (" ", "Chemical Rates", ""); chemicalRate.ShouldReturn += delegate { chemicalRate.ResignFirstResponder(true); return true; }; chemicalRate.ReturnKeyType = UIReturnKeyType.Done; chemicalRateS.Add (chemicalRate); // 5. Note Section noteS = new Section ("Notes"); note = new SimpleMultilineEntryElement ("", " ") { Editable = true }; noteS.Add (note); Root.Add (chemicalTemplateS); Root.Add (chemicalDateS); Root.Add (implementedUsedS); Root.Add (chemicalTypeS); Root.Add (chemicalRateS); Root.Add (noteS); }
public void initializeUserInterface() { // 0. Seed Templates seedTemplateDict = new Dictionary<string, SeedTemplate> (); seedTemplateDict = LocalStorage.getLocalStorageManager ().loadSeedTemplate (); Section seedTemplateS = new Section ("Seed Template"); seedTemplate = new RadioGroup (0); Section stSection = new Section (); foreach(var templateName in seedTemplateDict){ var t = new myRadioElement(templateName.Value.templateName); t.OnSelected += delegate(object sender, EventArgs e) { InvokeOnMainThread(()=>{ loadValueFromTemplate(t.Caption); }); }; stSection .Add(t); } RootElement stRoot = new RootElement ("Seed Template", seedTemplate) { }; stRoot.Add(stSection); seedTemplateS.Add (stRoot); // 1. Seed Date Section seedDateS = new Section ("Seed Date"); this.seedDate = new DateElement ("", DateTime.Now); seedDateS.Add (this.seedDate); // 2. Seed Type Section seedTypeS = new Section ("Seed Types"); seedTypes = new EntryElement (" ", "Seed Types", ""); seedTypes.ShouldReturn += delegate { seedTypes.ResignFirstResponder(true); return true; }; seedTypes.ReturnKeyType = UIReturnKeyType.Done; seedTypeS.Add (seedTypes); // 3. Seeding Depth Section seedDepthS = new Section ("Seeding Depth (in)"); // seedDepth = new FloatElementEx (0, lockable: false) { // ShowCaption = true, // UseCaptionForValueDisplay = true, // MaxValue = 2, // }; seedDepth = new EntryElement(" ","Seed Depth", ""); seedDepth.ShouldReturn += delegate { seedDepth.ResignFirstResponder(true); return true; }; seedDepth.ReturnKeyType = UIReturnKeyType.Done; seedDepthS.Add(seedDepth); // 4. Implemented Used Section implementedUsedS = new Section ("Implemented Used"); tools = new EntryElement (" ","Tools",""); tools.ShouldReturn += delegate { tools.ResignFirstResponder(true); return true; }; tools.ReturnKeyType = UIReturnKeyType.Done; implementedUsedS.Add (tools); // 5. Variety Name Section varietyNameS = new Section ("Variety Name"); varietyName = new EntryElement (" ","Enter Variety Name",""); varietyName.ReturnKeyType = UIReturnKeyType.Done; varietyName.ShouldReturn += delegate { varietyName.ResignFirstResponder(true); return true; }; varietyNameS.Add (varietyName); // 6. Seed Rate Section seedRateS = new Section ("Seed Rate (lb/ac)"); seedRate = new FloatElementEx (0, lockable: false) { ShowCaption = true, UseCaptionForValueDisplay = true, MaxValue = 300, }; seedRateS.Add(seedRate); // 7. Seed Treatment Section seedTreatmentS = new Section ("Seed Treatment"); seedTreatment = new EntryElement (" ","Enter Seed Treatment",""); seedTreatment.ReturnKeyType = UIReturnKeyType.Done; seedTreatmentS.Add (seedTreatment); // 8. NH3 Section NH3S = new Section ("NH3 (lb/ac)"); NH3 = new FloatElementEx (0, lockable: false) { ShowCaption = true, UseCaptionForValueDisplay = true, MaxValue = 120, }; NH3S.Add (NH3); // 9. 11-52-20 Section _11S = new Section ("11-52-20 (lb/ac)"); _11 = new FloatElementEx (0, lockable: false) { ShowCaption = true, UseCaptionForValueDisplay = true, MaxValue = 100, }; _11S.Add(_11); // 10. Note Section noteS = new Section ("Notes"); note = new SimpleMultilineEntryElement ("", " ") { Editable = true }; noteS.Add (note); Root.Add (seedTemplateS); Root.Add (seedDateS); Root.Add (seedTypeS); Root.Add (implementedUsedS); Root.Add (seedDepthS); Root.Add (varietyNameS); Root.Add (seedRateS); Root.Add (seedTreatmentS); Root.Add (NH3S); Root.Add (_11S); Root.Add (noteS); }
public Harvest(int num, SQLiteConnection s) : base(UITableViewStyle.Grouped, null) { sql = s; //Create the db table for this viewcontroller. sql.CreateTable<HarvestData> (); //The field Id passed to this controller. Represents a unique field on a farm. fieldID = num; //The Elements with their variables date = new DateElement (null, DateTime.Today); implement = new EntryElement (null, "Which implement was used?", null); yield = new FloatElementEx (0); moisture = new FloatElementEx (0); bin = new EntryElement (null, "Enter Bin #", null); notes = new SimpleMultilineEntryElement (null, null); //Specify element details yield.UseCaptionForValueDisplay = true; yield.ShowCaption = true; yield.MinValue = 0; yield.MaxValue = 120; moisture.UseCaptionForValueDisplay = true; moisture.ShowCaption = true; moisture.MinValue = 0; moisture.MaxValue = 25; notes.Editable = true; implement.ShouldReturn += delegate { implement.ResignFirstResponder (true); return true; }; bin.ShouldReturn += delegate { bin.ResignFirstResponder (true); return true; }; this.Title = "Harvest"; this.Pushing = true; //Create the save button this.NavigationItem.SetRightBarButtonItem ( new UIBarButtonItem (UIBarButtonSystemItem.Save, (sender,args) => { //Create table row with data. var harvestData = new HarvestData { DbField = fieldID, DbDate = date.DateValue, DbImplement = implement.Value, DbYield = yield.Value, DbMoisture = moisture.Value, DbBin = bin.Value, DbNotes = notes.Value }; //insert to database sql.Insert (harvestData); UIAlertView alert = new UIAlertView (); alert.Title = "Success"; alert.Message = "Your Data Has Been Saved"; alert.AddButton("OK"); alert.Clicked += delegate { this.NavigationController.PopViewControllerAnimated(true); } ; alert.Show(); }) , true); //Create the GUI Root = new RootElement (null) { new Section ("Date"){ date, }, new Section("Implement Used") { implement, }, new Section("Yield (bushel / acre)"){ yield, }, new Section("Moisture (%)"){ moisture, }, new Section ("Bin"){ bin, }, new Section("Notes") { notes, }, }; }