Ejemplo n.º 1
0
        private async void Button_Click_2(object sender, RoutedEventArgs e)
        {
            if (fname.Text.Length > 0 && fcontact.Text.Length > 0 && fmail.Text.Length > 0 && faddress.Text.Length > 0)
            {
                try
                {
                    client2 = new FireSharp.FirebaseClient(config);
                    var data = new mClient
                    {
                        Name      = fname.Text,
                        ContactNo = fcontact.Text,
                        MailId    = fmail.Text,
                        Address   = faddress.Text
                    };
                    FirebaseResponse firebaseResponse = await client2.GetAsync("Master/Spinner/Employee/count/");

                    int count;
                    try
                    {
                        count = firebaseResponse.ResultAs <int>();
                    }
                    catch (Exception)
                    {
                        count = 0;
                    }
                    count++;

                    String ab;
                    if (count < 10)
                    {
                        ab = "Wd0" + count.ToString();
                        SetResponse set = await client2.SetAsync("Master/Spinner/Employee/" + count + "/", ab);

                        SetResponse set1 = await client2.SetAsync("Master/Spinner/Employee/count/", count);

                        SetResponse response = await client2.SetAsync("Master/Employee/" + ab + "/", data);
                    }
                    else if (count > 10 && count < 100)
                    {
                        ab = "Wd" + count.ToString();
                        SetResponse set = await client2.SetAsync("Master/Spinner/Employee/" + count + "/", ab);

                        SetResponse set1 = await client2.SetAsync("Master/Spinner/Employee/count/", count);

                        SetResponse response = await client2.SetAsync("Master/Employee/" + ab + "/", data);
                    }
                }
                catch (Exception)
                {
                    MessageDialog error = new MessageDialog("Failed to connect to database!");
                    this.Frame.Navigate(typeof(BlankPage6));
                }
            }
            else
            {
                MessageDialog md = new MessageDialog("Check the inputs!");
                await md.ShowAsync();
            }
        }
Ejemplo n.º 2
0
        private async void Page_Loader(object sender, RoutedEventArgs e)
        {
            try
            {
                client2 = new FireSharp.FirebaseClient(config);
                FirebaseResponse response = await client2.GetAsync("Master/Spinner/Client/count/");

                int c;
                try
                {
                    c = response.ResultAs <int>();
                }
                catch (Exception)
                {
                    c = 0;
                }
                for (int i = 1; i <= c; i++)
                {
                    FirebaseResponse response1 = await client2.GetAsync("Master/Spinner/Client/" + i + "/");

                    String           a         = response1.ResultAs <String>();
                    FirebaseResponse response2 = await client2.GetAsync("Master/Client/" + a + "/");

                    mClient       t  = response2.ResultAs <mClient>();
                    ClientDetails cd = new ClientDetails();
                    cd.cname    = t.Name;
                    cd.cphone   = t.ContactNo;
                    cd.cmail    = t.MailId;
                    cd.caddress = t.Address;
                    cd.sno      = i.ToString();
                    MyList.Items.Add(cd);
                    if (MyList.Items.Count == c)
                    {
                        progress1.Visibility = Visibility.Collapsed;
                        cln.Visibility       = Visibility.Visible;
                    }
                }
            }
            catch (Exception)
            {
                MessageDialog error = new MessageDialog("Failed to connect to database!");
                this.Frame.Navigate(typeof(BlankPage6));
            }
        }