//SuggestClient Api; protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); RequestWindowFeature(WindowFeatures.NoTitle); Window.AddFlags(WindowManagerFlags.KeepScreenOn); // Create your application here SetContentView(Resource.Layout.Pharmacy); FindViewById <Button>(Resource.Id.paCloseB).Click += (s, e) => { Finish(); }; FindViewById <Button>(Resource.Id.paSaveB).Click += (s, e) => { var transaction = MainDatabase.BeginTransaction(); Pharmacy item; if (Pharmacy == null) { item = MainDatabase.Create2 <Pharmacy>(); item.CreatedAt = DateTimeOffset.Now; /* Contracts */ if (!string.IsNullOrEmpty(ContractsNames.Text)) { var ll = ContractsNames.Parent as LinearLayout; var contractUUIDs = (string)ll.GetTag(Resource.String.ContractUUIDs); if (!string.IsNullOrEmpty(contractUUIDs)) { foreach (var contract in contractUUIDs.Split(';')) { var contractData = MainDatabase.Create <ContractData>(); contractData.Pharmacy = item.UUID; contractData.Contract = contract; } } } /* ./Contracts */ } else { item = Pharmacy; /* Contracts */ if (string.IsNullOrEmpty(ContractsNames.Text)) { var contractDatas = MainDatabase.GetPharmacyDatas <ContractData>(item.UUID); foreach (var contractData in contractDatas) { MainDatabase.DeleteEntity(transaction, contractData);; } contractDatas = null; } else { var ll = ContractsNames.Parent as LinearLayout; var contractUUIDs = (string)ll.GetTag(Resource.String.ContractUUIDs); if (!string.IsNullOrEmpty(contractUUIDs)) { var contracts = contractUUIDs.Split(';'); var contractDatas = MainDatabase.GetPharmacyDatas <ContractData>(item.UUID); foreach (var contractData in contractDatas) { MainDatabase.DeleteEntity(transaction, contractData); } contractDatas = null; foreach (var contract in contractUUIDs.Split(';')) { var contractData = MainDatabase.Create2 <ContractData>(); contractData.Pharmacy = item.UUID; contractData.Contract = contract; } } } /* ./Contracts */ } item.UpdatedAt = DateTimeOffset.Now; item.IsSynced = false; item.SetState((PharmacyState)State.SelectedItemPosition); item.Brand = FindViewById <EditText>(Resource.Id.paBrandET).Text; item.NumberName = FindViewById <EditText>(Resource.Id.paNumberNameET).Text; item.LegalName = FindViewById <EditText>(Resource.Id.paLegalNameET).Text; if (string.IsNullOrEmpty(NetName.Text)) { item.Net = string.Empty; } else { item.Net = NetUUID; } var address = FindViewById <AutoCompleteTextView>(Resource.Id.paAddressACTV); item.Address = address.Text; bool isChanged = (bool)address.GetTag(Resource.String.IsChanged); if (isChanged) { item.AddressFiasId = (string)address.GetTag(Resource.String.fias_id); item.AddressQCGeo = (string)address.GetTag(Resource.String.qc_geo); item.AddressGeoLat = (string)address.GetTag(Resource.String.geo_lat); item.AddressGeoLon = (string)address.GetTag(Resource.String.geo_lon); } if (string.IsNullOrEmpty(Subway.Text)) { item.Subway = string.Empty; } else { var subwayUUID = (string)Subway.GetTag(Resource.String.SubwayUUID); if (!string.IsNullOrEmpty(subwayUUID)) { item.Subway = subwayUUID; } } if (string.IsNullOrEmpty(Region.Text)) { item.Region = string.Empty; } else { var regionUUID = (string)Region.GetTag(Resource.String.RegionUUID); if (!string.IsNullOrEmpty(regionUUID)) { item.Region = regionUUID; } } item.Phone = FindViewById <EditText>(Resource.Id.paPhoneET).Text; if (string.IsNullOrEmpty(Place.Text)) { item.Place = string.Empty; } else { var placeUUID = (string)Place.GetTag(Resource.String.PlaceUUID); if (!string.IsNullOrEmpty(placeUUID)) { item.Place = placeUUID; } } if (Category.SelectedItemPosition > 0) { item.Category = Categories[Category.SelectedItemPosition].uuid; } else { item.Category = string.Empty; } //if (string.IsNullOrEmpty(Category.Text)) { // item.Category = string.Empty; //} else { // var categoryUUID = (string)Category.GetTag(Resource.String.CategoryUUID); // if (!string.IsNullOrEmpty(categoryUUID)) { // item.Category = categoryUUID; // } //} item.TurnOver = Helper.ToInt(FindViewById <EditText>(Resource.Id.paTurnOverET).Text); item.Comment = FindViewById <EditText>(Resource.Id.paCommentET).Text; if (!item.IsManaged) { MainDatabase.SaveEntity(transaction, item); } transaction.Commit(); //var sync = new SyncItem() { // Path = @"Pharmacy", // ObjectUUID = Pharmacy.UUID, // JSON = JsonConvert.SerializeObject(Pharmacy) //}; //MainDatabase.AddToQueue(sync); //StartService(new Intent("com.xamarin.SyncService")); GetSharedPreferences(MainActivity.C_MAIN_PREFS, FileCreationMode.Private) .Edit() .PutString(MainActivity.C_SAVED_PHARMACY_UUID, item.UUID) .Commit(); Finish(); }; //Api = new SuggestClient(Secret.DadataApiToken, Secret.DadataApiURL); #region State State = FindViewById <Spinner>(Resource.Id.paStateS); States = MainDatabase.GetStates(); var stateAdapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleSpinnerItem, States.ToArray()); stateAdapter.SetDropDownViewResource(Resource.Layout.SpinnerItem); State.Adapter = stateAdapter; #endregion #region Net Nets = MainDatabase.GetNets(); NetName = FindViewById <AutoCompleteTextView>(Resource.Id.paNetACTV); var netChoiceButton = FindViewById <Button>(Resource.Id.paNetB); netChoiceButton.Click += (object sender, EventArgs e) => { new AlertDialog.Builder(this) .SetTitle("Аптечная сеть") .SetCancelable(true) .SetItems(Nets.Select(item => item.name).ToArray(), (caller, arguments) => { SetNet(arguments.Which); //Toast.MakeText(this, @"Selected " + arguments.Which, ToastLength.Short).Show(); }) .Show(); }; #endregion ContractsNames = FindViewById <AutoCompleteTextView>(Resource.Id.paContractsACTV); ContractsChoice = FindViewById <Button>(Resource.Id.paContractsB); ContractsChoice.Click += ContractsChoice_Click; Address = FindViewById <AutoCompleteTextView>(Resource.Id.paAddressACTV); Address.SetTag(Resource.String.IsChanged, false); Subway = FindViewById <AutoCompleteTextView>(Resource.Id.paSubwayACTV); Region = FindViewById <AutoCompleteTextView>(Resource.Id.paRegionACTV); Place = FindViewById <AutoCompleteTextView>(Resource.Id.paPlaceACTV); //Category = FindViewById<AutoCompleteTextView>(Resource.Id.paCategoryACTV); #region Category Category = FindViewById <Spinner>(Resource.Id.paCategoryS); Categories = new List <Category>(); Categories.Add(new Category { name = @"Выберите категорию!", uuid = Guid.Empty.ToString() }); Categories.AddRange(MainDatabase.GetItems <Category>());; var categoryAdapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleSpinnerItem, Categories.Select(cat => cat.name).ToArray()); categoryAdapter.SetDropDownViewResource(Resource.Layout.SpinnerItem); Category.Adapter = categoryAdapter; #endregion var pharmacyUUID = Intent.GetStringExtra("UUID"); if (string.IsNullOrEmpty(pharmacyUUID)) { var shared = GetSharedPreferences(MainActivity.C_MAIN_PREFS, FileCreationMode.Private); var agentUUID = shared.GetString(SigninDialog.C_AGENT_UUID, string.Empty); try { var agent = MainDatabase.GetItem <Agent>(agentUUID); Address.Text = agent.city; } catch (Exception ex) { Console.WriteLine(ex.Message); } FindViewById <TextView>(Resource.Id.paInfoTV).Text = @"ДОБАВЛЕНИЕ НОВОЙ АПТЕКИ"; FindViewById <TableRow>(Resource.Id.paRowLastAttendance).Visibility = ViewStates.Gone; FindViewById <TableRow>(Resource.Id.paRowNextAttendanceDate).Visibility = ViewStates.Gone; InitViews(); return; } Pharmacy = MainDatabase.GetEntity <Pharmacy>(pharmacyUUID); FindViewById <TextView>(Resource.Id.paInfoTV).Text = "АПТЕКА : " + Pharmacy.GetName(); FindViewById <TextView>(Resource.Id.paUUIDTV).Text = Pharmacy.UUID; State.SetSelection((int)Pharmacy.GetState()); FindViewById <EditText>(Resource.Id.paBrandET).Text = Pharmacy.Brand; FindViewById <EditText>(Resource.Id.paNumberNameET).Text = Pharmacy.NumberName; FindViewById <EditText>(Resource.Id.paLegalNameET).Text = Pharmacy.LegalName; //NetName.Text = string.IsNullOrEmpty(Pharmacy.Net) ? // string.Empty : MainDatabase.GetNet(Pharmacy.Net).name; //NetUUID = Pharmacy.Net; if (!string.IsNullOrEmpty(Pharmacy.Net)) { SetNet(Nets.FindIndex(net => string.Compare(net.uuid, Pharmacy.Net) == 0)); } ContractDatas = MainDatabase.GetPharmacyDatas <ContractData>(Pharmacy.UUID); if (ContractDatas.Count > 0) { ContractsNames.Text = string.Join(", ", ContractDatas.Select(cd => MainDatabase.GetItem <Contract>(cd.Contract).name).ToArray()); var ll = ContractsNames.Parent as LinearLayout; ll.SetTag(Resource.String.ContractUUIDs, string.Join(@";", ContractDatas.Select(cd => cd.Contract).ToArray()) ); } Address.Text = Pharmacy.Address; Subway.Text = string.IsNullOrEmpty(Pharmacy.Subway) ? string.Empty : MainDatabase.GetItem <Subway>(Pharmacy.Subway).name; Region.Text = string.IsNullOrEmpty(Pharmacy.Region) ? string.Empty : MainDatabase.GetItem <Region>(Pharmacy.Region).name; FindViewById <EditText>(Resource.Id.paPhoneET).Text = Pharmacy.Phone; Place.Text = string.IsNullOrEmpty(Pharmacy.Place) ? string.Empty : MainDatabase.GetItem <Place>(Pharmacy.Place).name; //Category.Text = string.IsNullOrEmpty(Pharmacy.Category) ? // string.Empty : MainDatabase.GetItem<Category>(Pharmacy.Category).name; if (!string.IsNullOrEmpty(Pharmacy.Category)) { Category.SetSelection(Categories.FindIndex(cat => string.Compare(cat.uuid, Pharmacy.Category) == 0)); } FindViewById <EditText>(Resource.Id.paTurnOverET).Text = Pharmacy.TurnOver.HasValue ? Pharmacy.TurnOver.Value.ToString() : string.Empty; FindViewById <TextView>(Resource.Id.paLastAttendanceTV).Text = Pharmacy.LastAttendanceDate.HasValue ? Pharmacy.LastAttendanceDate.Value.ToString(@"dd.MM.yyyy") : @"<нет визита>"; FindViewById <TextView>(Resource.Id.paNextAttendanceDateTV).Text = Pharmacy.NextAttendanceDate.HasValue ? Pharmacy.NextAttendanceDate.Value.ToString(@"dd.MM.yyyy") : DateTimeOffset.Now.ToString(@"dd.MM.yyyy"); FindViewById <EditText>(Resource.Id.paCommentET).Text = Pharmacy.Comment; InitViews(); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); RequestWindowFeature(WindowFeatures.NoTitle); Window.AddFlags(WindowManagerFlags.KeepScreenOn); // Create your application here SetContentView(Resource.Layout.Contract); FindViewById <Button>(Resource.Id.caCloseB).Click += (s, e) => { Finish(); }; var pharmacyUUID = Intent.GetStringExtra(C_PHARMACY_UUID); if (string.IsNullOrEmpty(pharmacyUUID)) { return; } Pharmacy = MainDatabase.GetPharmacy(pharmacyUUID); FindViewById <TextView>(Resource.Id.caInfoTV).Text = "КОНТРАКТЫ АПТЕКИ: " + Pharmacy.GetName(); ContractTable = FindViewById <ListView>(Resource.Id.caContractTable); var header = LayoutInflater.Inflate(Resource.Layout.ContractTableHeader, ContractTable, false); ContractTable.AddHeaderView(header); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); RequestWindowFeature(WindowFeatures.NoTitle); Window.AddFlags(WindowManagerFlags.KeepScreenOn); // Create your application here SetContentView(Resource.Layout.Hospital); FindViewById <Button>(Resource.Id.haCloseB).Click += (s, e) => { Finish(); }; var pharmacyUUID = Intent.GetStringExtra(C_PHARMACY_UUID); if (string.IsNullOrEmpty(pharmacyUUID)) { return; } Pharmacy = MainDatabase.GetPharmacy(pharmacyUUID); FindViewById <TextView>(Resource.Id.haInfoTV).Text = string.Format("ЛПУ БЛИЗКИЕ К АПТЕКЕ : {0}", Pharmacy.GetName()); HospitalDatas = MainDatabase.GetPharmacyDatas <HospitalData>(Pharmacy.UUID); HospitalTable = FindViewById <ListView>(Resource.Id.haHospitalTable); var header = LayoutInflater.Inflate(Resource.Layout.HospitalTableHeader, HospitalTable, false); HospitalTable.AddHeaderView(header); HospitalTable.ItemClick += (object sender, AdapterView.ItemClickEventArgs e) => { HospitalData item; if (HospitalTable.HeaderViewsCount > 0) { if (e.Position < HospitalTable.HeaderViewsCount) { return; } item = HospitalDatas[e.Position - HospitalTable.HeaderViewsCount]; } else { item = HospitalDatas[e.Position]; } if (string.IsNullOrEmpty(item.Hospital)) { Toast.MakeText(this, @"Нельзя редактировать данные о ЛПУ, которые пришли с сервера!", ToastLength.Short).Show(); return; } var fragmentTransaction = FragmentManager.BeginTransaction(); var prev = FragmentManager.FindFragmentByTag(HospitalDialog.TAG); if (prev != null) { fragmentTransaction.Remove(prev); } fragmentTransaction.AddToBackStack(null); var hospitalDialog = new HospitalDialog(Pharmacy, item); hospitalDialog.Show(fragmentTransaction, HospitalDialog.TAG); hospitalDialog.AfterSaved += (caller, arguments) => { Console.WriteLine("Event {0} was called", "AfterSaved"); RecreateAdapter(); }; }; FindViewById <ImageView>(Resource.Id.haAddIV).Click += (s, ea) => { Console.WriteLine("Event {0} was called", "haAdd_Click"); var fragmentTransaction = FragmentManager.BeginTransaction(); var prev = FragmentManager.FindFragmentByTag(HospitalDialog.TAG); if (prev != null) { fragmentTransaction.Remove(prev); } fragmentTransaction.AddToBackStack(null); var hospitalDialog = new HospitalDialog(Pharmacy); hospitalDialog.Show(fragmentTransaction, HospitalDialog.TAG); hospitalDialog.AfterSaved += (object sender, EventArgs e) => { Console.WriteLine("Event {0} was called", "AfterSaved"); RecreateAdapter(); }; }; FindViewById <ImageView>(Resource.Id.haListIV).Click += (s, ea) => { Console.WriteLine("Event {0} was called", "haListIV_Click"); var fragmentTransaction = FragmentManager.BeginTransaction(); var prev = FragmentManager.FindFragmentByTag(ListedHospitalDialog.TAG); if (prev != null) { fragmentTransaction.Remove(prev); } fragmentTransaction.AddToBackStack(null); var hospitalDialog = new ListedHospitalDialog(Pharmacy); hospitalDialog.Show(fragmentTransaction, ListedHospitalDialog.TAG); hospitalDialog.AfterSaved += (object sender, EventArgs e) => { Console.WriteLine("Event {0} was called", "ListedHospitalDialog_AfterSaved"); RecreateAdapter(); }; }; }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); RequestWindowFeature(WindowFeatures.NoTitle); Window.AddFlags(WindowManagerFlags.KeepScreenOn); // Create your application here SetContentView(Resource.Layout.Employee); FindViewById <Button>(Resource.Id.eaCloseB).Click += (s, e) => { Finish(); }; var pharmacyUUID = Intent.GetStringExtra(C_PHARMACY_UUID); if (string.IsNullOrEmpty(pharmacyUUID)) { return; } Pharmacy = MainDatabase.GetPharmacy(pharmacyUUID); FindViewById <TextView>(Resource.Id.eaInfoTV).Text = "СОТРУДНИКИ АПТЕКИ : " + Pharmacy.GetName(); EmployeeTable = FindViewById <ListView>(Resource.Id.eaEmployeeTable); var header = LayoutInflater.Inflate(Resource.Layout.EmployeeTableHeader, EmployeeTable, false); EmployeeTable.AddHeaderView(header); EmployeeTable.ItemClick += (sender, e) => { Employee item; if (EmployeeTable.HeaderViewsCount > 0) { if (e.Position < EmployeeTable.HeaderViewsCount) { return; } item = Employees[e.Position - EmployeeTable.HeaderViewsCount]; } else { item = Employees[e.Position]; } var fragmentTransaction = FragmentManager.BeginTransaction(); var prev = FragmentManager.FindFragmentByTag(EmployeeDialog.TAG); if (prev != null) { fragmentTransaction.Remove(prev); } fragmentTransaction.AddToBackStack(null); var employeeDialog = new EmployeeDialog(Pharmacy, item); employeeDialog.Show(fragmentTransaction, EmployeeDialog.TAG); employeeDialog.AfterSaved += (caller, arguments) => { SDiag.Debug.WriteLine("Event {0} was called", "AfterSaved"); RecreateAdapter(); }; }; FindViewById <ImageView>(Resource.Id.eaAddIV).Click += (s, e) => { SDiag.Debug.WriteLine("Event {0} was called", "eaAdd_Click"); var fragmentTransaction = FragmentManager.BeginTransaction(); var prev = FragmentManager.FindFragmentByTag(EmployeeDialog.TAG); if (prev != null) { fragmentTransaction.Remove(prev); } fragmentTransaction.AddToBackStack(null); var employeeDialog = new EmployeeDialog(Pharmacy); employeeDialog.Show(fragmentTransaction, EmployeeDialog.TAG); employeeDialog.AfterSaved += (caller, arguments) => { SDiag.Debug.WriteLine("Event {0} was called", "AfterSaved"); RecreateAdapter(); }; }; }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); RequestWindowFeature(WindowFeatures.NoTitle); // Create your application here SetContentView(Resource.Layout.Finance); FindViewById <Button>(Resource.Id.faCloseB).Click += (sender, e) => { Finish(); }; var pharmacyUUID = Intent.GetStringExtra("UUID"); if (string.IsNullOrEmpty(pharmacyUUID)) { return; } Pharmacy = MainDatabase.GetPharmacy(pharmacyUUID); FindViewById <TextView>(Resource.Id.faInfoTV).Text = string.Format("ПРОДАЖИ: {0}", Pharmacy.GetName()); // var date1 = FindViewById<TextView>(Resource.Id.htiDate1); // date1.Text = DateTimeOffset.Now.Date.ToString("dd.MM.yy"); // // var date2 = FindViewById<TextView>(Resource.Id.htiDate2); // date2.Text = DateTimeOffset.Now.Date.AddDays(7).Date.ToString("dd.MM.yy"); // Content = FindViewById <LinearLayout>(Resource.Id.faContentLL); Table = FindViewById <LinearLayout>(Resource.Id.faTable); TableBySKU = FindViewById <LinearLayout>(Resource.Id.faTableBySKU); var add = FindViewById <ImageView>(Resource.Id.faAdd); var isCanAdd = Intent.GetBooleanExtra(C_IS_CAN_ADD, true); if (isCanAdd) { add.Click += (sender, e) => { //Toast.MakeText(this, "ADD BUTTON CLICKED", ToastLength.Short).Show(); Console.WriteLine("Event {0} was called", "faAdd_Click"); FragmentTransaction fragmentTransaction = FragmentManager.BeginTransaction(); var prev = FragmentManager.FindFragmentByTag(FinanceDialog.TAG); if (prev != null) { fragmentTransaction.Remove(prev); } fragmentTransaction.AddToBackStack(null); var financeDialog = new FinanceDialog(Pharmacy); financeDialog.Show(fragmentTransaction, FinanceDialog.TAG); financeDialog.AfterSaved += (caller, arguments) => { Console.WriteLine("Event {0} was called. FinanceDatas count {1}", "AfterSaved", arguments.FinanceDatas.Count); //Table.RemoveAllViews(); RefreshView(); //MainDatabase.SaveItems(arguments.FinanceDatas); //SetValues(arguments.FinanceDatas); }; }; } else { add.Visibility = ViewStates.Gone; } var switcher = FindViewById <ViewSwitcher>(Resource.Id.faSwitchViewTypeVS); var sw = FindViewById <ImageView>(Resource.Id.faSwitchIV); sw.Click += (sender, e) => { switcher.ShowNext(); }; }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); RequestWindowFeature(WindowFeatures.NoTitle); // Create your application here SetContentView(Resource.Layout.History); FindViewById <Button>(Resource.Id.haCloseB).Click += (sender, e) => { Finish(); }; var pharmacyUUID = Intent.GetStringExtra("UUID"); if (string.IsNullOrEmpty(pharmacyUUID)) { return; } Pharmacy = MainDatabase.GetPharmacy(pharmacyUUID); FindViewById <TextView>(Resource.Id.haInfoTV).Text = string.Format("ИСТОРИЯ ВИЗИТОВ: {0}", Pharmacy.GetName()); // var date1 = FindViewById<TextView>(Resource.Id.htiDate1); // date1.Text = DateTimeOffset.Now.Date.ToString("dd.MM.yy"); // // var date2 = FindViewById<TextView>(Resource.Id.htiDate2); // date2.Text = DateTimeOffset.Now.Date.AddDays(7).Date.ToString("dd.MM.yy"); Content = FindViewById <LinearLayout>(Resource.Id.haContentLL); Table = FindViewById <LinearLayout>(Resource.Id.haTable); TextViews = new Dictionary <string, TextView>(); }