Exemple #1
0
        private async void Submit_Click(object sender, RoutedEventArgs e)
        {
            // Send without Layout
            if (cAddT.Text.Length > 0 && cNoT.Text.Length > 0 && cMailT.Text.Length > 0 && cNameT.Text.Length > 0 && DateT.Text.Length > 0 && TimeT.Text.Length > 0 && rSOrderT.Text.Length > 0 && MyList.Items.Count > 0)
            {
                try
                {
                    SOrder temp = new SOrder();
                    temp.ClientAddress       = cAddT.Text;
                    temp.ClientContactNumber = cNoT.Text;
                    temp.ClientMailID        = cMailT.Text;
                    temp.ClientName          = cNameT.Text;
                    temp.Date         = DateT.Text;
                    temp.Time         = TimeT.Text;
                    temp.SalesOrderID = rSOrderT.Text;
                    temp.status       = "Verified";
                    String          loc    = "Sales/SalesOrder/" + temp.SalesOrderID + "/";
                    IFirebaseConfig config = new FirebaseConfig
                    {
                        AuthSecret = "Fld3TLREfZ47bmggol008nKkHzDAMphTdhlqi09d",
                        BasePath   = "https://weldonetechnocrats.firebaseio.com/"
                    };
                    IFirebaseClient client = new FireSharp.FirebaseClient(config);
                    var             settr  = await client.SetAsync(loc, temp);

                    //Send Layout Now
                    loc = "Sales/SalesOrder/" + temp.SalesOrderID + "/Layout/";
                    int len = loc.Length;
                    client = new FireSharp.FirebaseClient(config);
                    int i = 1;
                    foreach (Layout temp1 in MyList.Items)
                    {
                        loc = loc + i + "/";
                        var settr1 = await client.SetAsync(loc, temp1);

                        loc = loc.Remove(len);
                        i++;
                    }
                    loc = loc + "count/";
                    var sett = await client.SetAsync(loc, i - 1);

                    loc  = loc.Remove(len);
                    loc  = "Sales/SalesOrder/count";
                    sett = await client.SetAsync(loc, temp.getCount());

                    // Get Verified Count
                    IFirebaseClient  client1  = new FireSharp.FirebaseClient(config);
                    FirebaseResponse response = await client.GetAsync("Sales/SalesOrder/Spinner/Pending/count/");

                    int pCount;
                    int vCount;
                    FirebaseResponse response1 = await client.GetAsync("Sales/SalesOrder/Spinner/Verified/count");

                    try
                    {
                        vCount = response1.ResultAs <int>();
                    }
                    catch
                    {
                        vCount = 0;
                    }
                    try
                    {
                        pCount = response.ResultAs <int>();
                    }
                    catch (Exception)
                    {
                        pCount = 0;
                    }
                    int flag1 = 0;
                    for (i = 1; i <= vCount; i++)
                    {
                        response = await client.GetAsync("Sales/SalesOrder/Spinner/Verified/" + i + "/");

                        string SOID = response.ResultAs <string>();
                        if (SOID == rSOrderT.Text)
                        {
                            flag1 = 1;
                            break;
                        }
                    }
                    if (flag1 != 1)
                    {
                        vCount = vCount + 1;
                        loc    = "Sales/SalesOrder/Spinner/Pending/count/";
                        sett   = await client.SetAsync(loc, pCount - 1);
                    }

                    loc  = "Sales/SalesOrder/Spinner/Verified/" + vCount + "/";
                    sett = await client.SetAsync(loc, rSOrderT.Text);

                    loc  = "Sales/SalesOrder/Spinner/Verified/count/";
                    sett = await client.SetAsync(loc, vCount);

                    loc = "Sales/SalesOrder/count";
                    // Pending Count Deletion
                    //response = await client.GetAsync("Sales/SalesOrder/Spinner/Pending/count/");
                    //pCount = response.ResultAs<int>();
                    response = await client.DeleteAsync("Sales/SalesOrder/Spinner/Pending/" + pCount);

                    //loc = "Sales/SalesOrder/Spinner/Pending/count/";
                    //sett = await client.SetAsync(loc, pCount - 1);
                    MessageDialog md = new MessageDialog("Sales Order Successfully Reviewed!");
                    await md.ShowAsync();
                }
                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();
            }
        }
Exemple #2
0
        private async void Button_Click_1(object sender, RoutedEventArgs e)
        {
            if ((cNameT.Text.Length > 0) && (cMailT.Text.Length > 0) && (cMailT.Text.Length > 0) && (cNoT.Text.Length > 0) && (cAddT.Text.Length > 0) && (DateT.Text.Length > 0) && (TimeT.Text.Length > 0) && (MyList.Items.Count > 0) == true)
            {
                try
                {
                    SOrder temp = new SOrder();
                    temp.ClientAddress       = cAddT.Text;
                    temp.ClientContactNumber = cNoT.Text;
                    temp.ClientMailID        = cMailT.Text;
                    temp.ClientName          = cNameT.Text;
                    temp.Date         = DateT.Text;
                    temp.Time         = TimeT.Text;
                    temp.SalesOrderID = orderT.Text;
                    temp.status       = "Pending";
                    String loc = "Sales/SalesOrder/" + temp.SalesOrderID + "/";
                    client = new FireSharp.FirebaseClient(config);
                    var settr = await client.SetAsync(loc, temp);

                    loc = "Sales/SalesOrder/" + temp.SalesOrderID + "/Layout/";
                    int len = loc.Length;
                    client = new FireSharp.FirebaseClient(config);
                    int i = 1;
                    foreach (Product1 tempP in MyList.Items)
                    {
                        Product temp1 = new Product();
                        temp1.pName     = tempP.pName;
                        temp1.pQuantity = tempP.pQuantity;
                        loc             = loc + i + "/";
                        var settr1 = await client.SetAsync(loc, temp1);

                        loc = loc.Remove(len);
                        i++;
                    }
                    loc = loc + "count/";
                    var sett = await client.SetAsync(loc, i - 1);

                    loc  = loc.Remove(len);
                    loc  = "Sales/SalesOrder/count";
                    sett = await client.SetAsync(loc, temp.getCount());

                    // Get Pending Count
                    IFirebaseClient  client1  = new FireSharp.FirebaseClient(config);
                    FirebaseResponse response = await client.GetAsync("Sales/SalesOrder/Spinner/Pending/count/");

                    int pCount, flag1 = 0;
                    try
                    {
                        pCount = response.ResultAs <int>();
                    }
                    catch (Exception)
                    {
                        pCount = 0;
                    }
                    for (i = 1; i <= pCount; i++)
                    {
                        response = await client.GetAsync("Sales/SalesOrder/Spinner/Pending/" + i + "/");

                        string SOID = response.ResultAs <string>();
                        if (SOID == orderT.Text)
                        {
                            flag1 = 1;
                            break;
                        }
                    }
                    if (flag1 != 1)
                    {
                        pCount = pCount + 1;
                    }
                    loc  = "Sales/SalesOrder/Spinner/Pending/" + pCount + "/";
                    sett = await client.SetAsync(loc, temp.SalesOrderID);

                    loc  = "Sales/SalesOrder/Spinner/Pending/count/";
                    sett = await client.SetAsync(loc, pCount);

                    loc = "Sales/SalesOrder/count";
                    MessageDialog md = new MessageDialog("SalesOrder Successfully Updated!");
                    await md.ShowAsync();
                }
                catch (FireSharp.Exceptions.FirebaseException)
                {
                    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();
            }
        }