public void BindSurgeonPopupover(List<SurgeonDetails> listOfSurgeons,UILabel lblField,int FrameY)
		{
			int uvwidth;
			ATlist.Clear();
			List<CodePickerModel> alist = SetSurgeonDataSource(listOfSurgeons, out  uvwidth);
			SurgeonDetails sd = listOfSurgeons.Find (u => u.ID == SurgeonID);
			CodePickerModel selecteditem = new CodePickerModel ();
			if (sd != null) {				
				selecteditem.ItemID = sd.ID;
				selecteditem.ItemText = sd.Name;
			}
			// SurgeonID
			uvwidth=500;
			qmcp = new qmCodePicker(this,uvwidth,alist);
			qmcp.Issearchactive = true;
			qmcp.TypeOfList = "Surgeons";
			qmcp.AllowsMultipleSelection = false;
			qmcp.SelectedItems.Add (selecteditem);
			float x = 100;
			float y = (float)lblField.Frame.Y+FrameY  ;

			qmcp.PresentFromPopover(lblField, x, y,uvwidth);
			//qmcp.mDataSource(alist);
			qmcp._ValueChanged += async delegate
			{
				if(qmcp.SelectedItems.Count > 0){
					ATlist = qmcp.SelectedItems;
					lblField.Text =  " " + ATlist[0].ItemText;
					SurgeonID=ATlist[0].ItemID;
					ProcedureSurgeonDetails procSurgeon = new ProcedureSurgeonDetails();
					procSurgeon.Name = lblField.Text;
					procSurgeon.SurgeonID = ATlist[0].ItemID;
					procSurgeon.ProcID = procedureDetails.ID;
					if(selectedSurgeon.Count >0)
						procSurgeon.ProcSurgeonID = selectedSurgeon[0].ProcSurgeonID;
					else
						procSurgeon.ProcSurgeonID = 0;
					AddUpdateProcedureSurgeon(procSurgeon);
					ATlist.Clear();


				}
			};
		}
Exemplo n.º 2
0
        public qmCodePickerSource(qmCodePicker homeController)
        {
            this.CodePickerController = homeController;

            indexedtableitems = new Dictionary<string,List<CodePickerModel>> ();
            foreach (var t in CodePickerController.DataSource) {
                if (indexedtableitems.ContainsKey (t.ItemText [0].ToString ().ToUpper())) {
                    indexedtableitems [t.ItemText [0].ToString ().ToUpper()].Add (t);
                } else {
                    indexedtableitems.Add (t.ItemText [0].ToString ().ToUpper(), new List<CodePickerModel> (){ t });
                }
            }
            keys = indexedtableitems.Keys.OrderBy (o=>o.ToString()).ToArray();
        }
		public void qmBindPopupover(List<iProPQRSPortableLib.Option> items,UILabel lblField,int FrameY,int AttribTypeID)
		{
			int uvwidth;
			ATlist.Clear ();
			List<CodePickerModel> alist = SetTypeDataSource(items, out  uvwidth);

			qmcp = new qmCodePicker(this,uvwidth,alist);

			AttribType selectedattribtitem = new AttribType();
			if (iProPQRSPortableLib.Consts.SelectedProcAttribtslist == null)
				selectedattribtitem = null;
			// need to set Selected Items
			else
				selectedattribtitem = iProPQRSPortableLib.Consts.SelectedProcAttribtslist.result.Where (u => u.ProcAttribTypeID == AttribTypeID).SingleOrDefault ();
			if (selectedattribtitem != null ) {
				CodePickerModel sitem;	
				if (selectedattribtitem != null ) {
					sitem = new CodePickerModel ();
					sitem = alist.Where (u => u.ItemID == selectedattribtitem.ProcAttribTypeID && u.ItemCode == selectedattribtitem.Value).SingleOrDefault ();
					if(sitem != null)
						ATlist.Add (sitem);
				}

			}
			if (ATlist.Count > 0)
				qmcp.SelectedItems = ATlist;


			float x = (float)lblField.Frame.X;
			float y = (float)lblField.Frame.Y+FrameY;

			qmcp.PresentFromPopover(lblField, x, y,uvwidth);
			//qmcp.mDataSource(alist);
			qmcp._ValueChanged += async delegate
			{
				List<AttribType>  procalist=new List<AttribType>();
				AttribType procitem; 
				int ProcID=0;
				if(procedureDetails != null && procedureDetails.ID != 0)
					ProcID = procedureDetails.ID;
				if(qmcp.SelectedItems.Count > 0){
					ATlist = qmcp.SelectedItems;
					string finalText = " ";

					if(selectedattribtitem != null)							
					{
						selectedattribtitem.Value="";
						procalist.Add(selectedattribtitem);
					}			

					foreach (var item in ATlist)
					{					
						procitem = new AttribType();
						procitem.ProcAttribTypeID = item.ItemID;
						procitem.ProcID = ProcID;
						procitem.Value = item.ItemCode;
						procitem.IsHighLighted = false;
						procalist.Add(procitem);
						procitem = null;
						finalText = finalText + ", " + item.ItemText;
					}
					lblField.Text = finalText.Trim().TrimStart(',');




					if(procalist != null && procalist.Count > 0 ){
						var procAttribtsobject  = await AppDelegate.Current.pqrsMgr.UpdateProcAttribs(procalist);
						if(procAttribtsobject != null && procAttribtsobject.status != null && procAttribtsobject.status.ToUpper() == "OK"){
							UpdateProcedureStatus ();
							Console.WriteLine("Procedure, Info. Successfully Saved.");	
							//						new UIAlertView("Procedure Info", "Successfully Saved."
							//							, null, "ok", null).Show();
						}else{
							Console.WriteLine("Procedure,  Info. Save failed.");	
							//						new UIAlertView("Error", procAttribtsobject.message
							//							, null, "ok", null).Show();
						}//
					}


					int lbldescwidth = 40;
					lblField.Lines = 1;
					int lbltextcount = lblField.Text.Length;
					if (lbltextcount < 58) {
						lbldescwidth = 40;
						lblField.Lines = 1;
					} else if (lbltextcount > 58 && lbltextcount < 114) {
						lbldescwidth = 55;
						lblField.Lines = 2;
					} else if (lbltextcount > 114) {
						lbldescwidth = 75;
						lblField.Lines = 3;
					}
					if(AttribTypeID != 602)
					 lblField.Frame = new CoreGraphics.CGRect (500, 8, 480, lbldescwidth);

				}
				else
				{
					       
					if(selectedattribtitem != null)							
					{
						selectedattribtitem.Value="";
					     procalist.Add(selectedattribtitem);
					}			



					if(procalist != null && procalist.Count > 0 ){
						var procAttribtsobject  = await AppDelegate.Current.pqrsMgr.UpdateProcAttribs(procalist);
						if(procAttribtsobject != null && procAttribtsobject.status != null && procAttribtsobject.status.ToUpper() == "OK"){
							lblField.Text = "";
							if(AttribTypeID != 602)
							 lblField.Frame = new CoreGraphics.CGRect (500, 8, 480, 40);
						}
					}
				}
				ATlist.Clear();
				iProPQRSPortableLib.Consts.SelectedProcAttribtslist  = await AppDelegate.Current.pqrsMgr.GetAllAttribTypesOfAProcedure(ProcID);
			};
		}