예제 #1
0
 private void initVariables()
 {
     try
     {
         fillStatusCombo(cmbStatus);
         RegionDB.fillRegionComboNew(cmbRegion);
     }
     catch (Exception)
     {
     }
 }
예제 #2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                region   reg   = new region();
                RegionDB regDB = new RegionDB();

                reg.regionID = txtID.Text;
                reg.name     = txtName.Text;
                reg.status   = ComboFIll.getStatusCode(cmbStatus.SelectedItem.ToString());
                System.Windows.Forms.Button btn = sender as System.Windows.Forms.Button;
                string btnText = btn.Text;
                if (regDB.validateRegion(reg))
                {
                    if (btnText.Equals("Update"))
                    {
                        if (regDB.updateRegion(reg))
                        {
                            MessageBox.Show("Region updated");
                            closeAllPanels();
                            ListRegion();
                        }
                        else
                        {
                            MessageBox.Show("Failed to update Region");
                        }
                    }
                    else if (btnText.Equals("Save"))
                    {
                        if (regDB.insertRegion(reg))
                        {
                            MessageBox.Show("Region Added");
                            closeAllPanels();
                            ListRegion();
                        }
                        else
                        {
                            MessageBox.Show("Failed to Insert Region");
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Region Data Validation failed");
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Failed Adding / Editing Region");
            }
        }
예제 #3
0
        static void Main()
        {
            #region Testing Aldo
            try
            {
                var client = new RestClient(API + "summary")
                {
                    Timeout = -1
                };
                var           request  = new RestRequest(Method.GET);
                IRestResponse response = client.Execute(request);
                var           json     = SimpleJson.DeserializeObject(response.Content);
                JObject       obj      = JObject.Parse(json.ToString());
                JsonArray     array    = (JsonArray)SimpleJson.DeserializeObject(obj["Countries"].ToString());

                CoronaWatchContext context = new CoronaWatchContext();

                foreach (JsonObject jsonObject in array)
                {
                    string ISOCode = jsonObject["CountryCode"].ToString();
                    Console.WriteLine(ISOCode);
                    if (context.RegionDBs.Where(r => r.ISOCode == ISOCode).FirstOrDefault() == null)
                    {
                        RegionDB regionDB = new RegionDB
                        {
                            ISOCode = jsonObject["CountryCode"].ToString(),
                            Name    = jsonObject["Country"].ToString(),
                            Slug    = jsonObject["Slug"].ToString()
                        };
                        context.RegionDBs.Add(regionDB);
                        context.SaveChanges();
                    }
                    Console.WriteLine("ABC");
                }
            }
            catch (Exception e)
            {
                if (e.Message == "Invalid JSON string")
                {
                    Console.WriteLine(e.Message + "\nPlease Check Your Connection Error");
                }
                else
                {
                    Console.WriteLine(e.Message + "Error");
                }
            }
            #endregion

            Console.ReadLine();
        }
예제 #4
0
        public static void InitializeDatabase()
        {
            try
            {
                var client = new RestClient(API + "summary")
                {
                    Timeout = -1
                };
                var           request  = new RestRequest(Method.GET);
                IRestResponse response = client.Execute(request);
                var           json     = SimpleJson.DeserializeObject(response.Content);
                JObject       obj      = JObject.Parse(json.ToString());
                JsonArray     array    = (JsonArray)SimpleJson.DeserializeObject(obj["Countries"].ToString());

                CoronaWatchContext context = new CoronaWatchContext();

                foreach (JsonObject jsonObject in array)
                {
                    string ISOCode = jsonObject["CountryCode"].ToString();
                    if (context.RegionDBs.Where(r => r.ISOCode == ISOCode).FirstOrDefault() == null)
                    {
                        RegionDB regionDB = new RegionDB
                        {
                            ISOCode = jsonObject["CountryCode"].ToString(),
                            Name    = jsonObject["Country"].ToString(),
                            Slug    = jsonObject["Slug"].ToString()
                        };
                        context.RegionDBs.Add(regionDB);
                        context.SaveChanges();
                    }
                }
            }
            catch (Exception e)
            {
                if (e.Message == "Invalid JSON string")
                {
                    MessageBox.Show(e.Message + "\nPlease Check Your Connection", "Error", MessageBoxButton.OK);
                }
                else
                {
                    MessageBox.Show(e.Message, "Error");
                }
            }
        }
예제 #5
0
 private void initVariables()
 {
     closeAllPanels();
     RegionDB.fillRegionComboNew(cmbFilterRegion);
     cmbFilterRegion.Items.Add("All");
     cmbFilterRegion.SelectedItem = "All";
     cmbfilterOffice.Visible      = true;
     cmbFilterRegion.Visible      = true;
     lblOffice.Visible            = true;
     lblRegion.Visible            = true;
     btnView.Visible = true;
     if (cmbfilterOffice.SelectedItem.ToString() == "All")
     {
         officeid = "All";
     }
     else
     {
         officeid = ((Structures.ComboBoxItem)cmbfilterOffice.SelectedItem).HiddenValue;
     }
 }
예제 #6
0
 private void ListRegion()
 {
     try
     {
         grdList.Rows.Clear();
         RegionDB      dbrecord = new RegionDB();
         List <region> Regions  = dbrecord.getRegions();
         foreach (region reg in Regions)
         {
             grdList.Rows.Add(reg.regionID, reg.name,
                              ComboFIll.getStatusString(reg.status));
         }
     }
     catch (Exception)
     {
         MessageBox.Show("Error in Region listing");
     }
     enableBottomButtons();
     pnlRegionList.Visible = true;
 }
예제 #7
0
        /// <summary>
        /// Metoda dodająca lub edytująca obiekt regionu
        /// </summary>
        /// <param name="serviceitem">RegionDB item</param>
        /// <returns>RegionDB</returns>
        public RegionDB PostSave(RegionDB serviceitem)
        {
            serviceitem.DictionaryKey = serviceitem.DictionaryKey.Replace(" ", "_");

            if (serviceitem.Id > 0)
            {
                DatabaseContext.Database.Update(serviceitem);
            }
            else
            {
                DatabaseContext.Database.Save(serviceitem);
            }

            if (!Services.LocalizationService.DictionaryItemExists(serviceitem.DictionaryKey))
            {
                var dictionaryItem = Services.LocalizationService.CreateDictionaryItemWithIdentity(serviceitem.DictionaryKey, Guid.Parse("A7B9CD7F-FE1A-436F-8408-77AA589DA5A1"));
                Services.LocalizationService.Save(dictionaryItem);
            }

            return(serviceitem);
        }
예제 #8
0
        //获取城市列表
        public DataTable cityListQuery(int provinceId)
        {
            RegionDB regionDb = new RegionDB();

            return(regionDb.cityListQuery(provinceId).Tables[0]);
        }
예제 #9
0
        //获取省份列表
        public DataTable provinceListQuery()
        {
            RegionDB regionDb = new RegionDB();

            return(regionDb.provinceListQuery().Tables[0]);
        }