Example #1
0
        private async void next_Clicked(object sender, EventArgs e)
        {
            await BeBusy(true);

            WorkOrdersParameters wop = new WorkOrdersParameters();

            lwop = new List <WorkOrdersParameters>();
            foreach (var item in items)
            {
                if (item.value == null || item.value <= 0)
                {
                    //myGrid.FindByName<Entry>(item.id_control).TextColor = Color.Red;
                    await DisplayAlert("", "الرجاءادخال قيمة صحيحة للجميع", "ok");

                    return;
                }
            }

            foreach (var item in lp)
            {
                if (item.parameterUnitType_FKID == 4)
                {
                    lwop.Add(new WorkOrdersParameters
                    {
                        workOrder_FKID = newWO.ID,
                        parameter_FKID = item.ID,
                        lastUpdate     = DateTime.Now,
                        weightAmount   = int.Parse(item.ParameterWight.ToString()),
                        isDone         = false,
                        DoneAmount     = 0,
                        DoneLength     = 0,
                        Amount         = 100,
                    });
                }
                else
                {
                    lwop.Add(new WorkOrdersParameters
                    {
                        workOrder_FKID = newWO.ID,
                        parameter_FKID = item.ID,
                        lastUpdate     = DateTime.Now,
                        weightAmount   = int.Parse(item.ParameterWight.ToString()),
                        isDone         = false,
                        DoneAmount     = 0,
                        DoneLength     = 0
                    });
                }
            }

            foreach (var wopItem in lwop)
            {
                wopItem.workOrder_FKID = woNO;
                foreach (var item in items)
                {
                    if (wopItem.parameter_FKID == item.pid)
                    {
                        foreach (var pItem in lp)
                        {
                            if (wopItem.parameter_FKID == pItem.ID)
                            {
                                if (pItem.parameterUnitType_FKID == 1)
                                {
                                    wopItem.Lenght = int.Parse(item.value.ToString());
                                }
                                else if (pItem.parameterUnitType_FKID == 2)
                                {
                                    wopItem.Amount = int.Parse(item.value.ToString());
                                }
                            }
                        }
                    }
                }
            }



            try
            {
                bool isOk = await rcs.PostWorkOrderParametersAsync(lwop);

                if (isOk)
                {
                    await BeBusy(false);
                    await DisplayAlert("تمت الاضافة", "تمت لاضافة بنجاح", "موافق");

                    for (var counter = 1; counter < backCount; counter++)
                    {
                        Navigation.RemovePage(Navigation.NavigationStack[Navigation.NavigationStack.Count - 2]);
                    }
                    await Navigation.PopAsync();
                }
                else
                {
                    await BeBusy(false);
                    await DisplayAlert("خطأ", "توجد مشكلة", "موافق");
                }
            }
            catch (Exception err)
            {
                await BeBusy(false);
                await DisplayAlert("Error", err.InnerException.ToString(), "Ok");
            }
        }