private async Task Save()
        {
            if (!App.isBusy)
            {
                // ObservableCollection<FranchiseSellDetails_Class> fscd = new ObservableCollection<FranchiseSellDetails_Class>();
                App.isBusy = true;
                FranchiseSell_Class Franchise_Sell_Class = new FranchiseSell_Class();
                Franchise_Sell_Class.Customer_Id = Franchise_Sell_Class_Data.Customer_Id;

                var Wait = UserDialogs.Instance.Loading("Wait..", null, null, true, MaskType.Black);
                Wait.Show();

                if (Franchise_Sell_Class.Customer_Id > 0)
                {
                    Franchise_Sell_Class.Customer_Class_Data = Franchise_Sell_Class_Data.Customer_Class_Data;
                    foreach (var item in ArticleMasterClassList)
                    {
                        foreach (var Subitem in item.FranchiseStokeMaster_Class_List)
                        {
                            if (Subitem.Insert_New_Qty > 0)
                            {
                                FranchiseSellDetails_Class fsl = new FranchiseSellDetails_Class();
                                Franchise_Sell_Class.Total_Amount = Franchise_Sell_Class.Total_Amount + (Subitem.Insert_New_Qty * item.MRP);
                                fsl.SubCategory_Id = Subitem.SubCategoryMaster_Class_Data.SubCategory_Id;
                                fsl.Article_Id     = item.Article_Id;
                                fsl.MRP            = item.MRP;
                                fsl.Quantity       = Subitem.Insert_New_Qty;
                                StockMaster_Class smc = new StockMaster_Class();
                                smc.Stock_Id = Subitem.Stock_Id;
                                fsl.FranchiseStokeMaster_Class_Data = smc;
                                ArticleMaster_Class amc = new ArticleMaster_Class();
                                amc.Article_No               = item.Article_No;
                                amc.Article_PrimaryImage     = item.Article_PrimaryImage;
                                amc.Article_SecondaryImage   = item.Article_SecondaryImage;
                                fsl.ArticleMaster_Class_Data = amc;
                                CategoryMaster_Class cmc = new CategoryMaster_Class();
                                cmc.Category_Name = item.CategoryMaster_Class_Data.Category_Name + " - " + Subitem.SubCategoryMaster_Class_Data.SubCategory_Name;
                                fsl._CategoryMaster_Class_Data = cmc;
                                //fsl._SubCategoryMaster_Class_Data.SubCategory_Name = Subitem.SubCategory_Name;
                                fsl.Total_Amount = (fsl.MRP * fsl.Quantity).ToString();
                                // fscd.Add(fsl);
                                Franchise_Sell_Class.FranchiseSellDetails_Class_List.Add(fsl);
                            }
                        }
                    }
                    //   Franchise_Sell_Class_Data.FranchiseSellDetails_Class_List.Add(fscd);
                    Wait.Hide();
                    App.isBusy = false;
                    if (Franchise_Sell_Class.Total_Amount > 0)
                    {
                        await navigation.PushAsync(new SellDetailPage(Franchise_Sell_Class), true);
                    }
                    else
                    {
                        await App.Current.MainPage.DisplayAlert("Oops!", "Please Fill Qty Then Submit..", "Ok");
                    }
                }
                else
                {
                    if (Customer_Class.Customer_Name != null && Customer_Class.Customer_Name != "")
                    {
                        JObject result = await _IAllDataServices.CustomerRegistration(Customer_Class);

                        if (result != null && result["Type"].ToString() == "1" || result["Type"].ToString() == "0")
                        {
                            JObject result2 = await _IAllDataServices.GetCustomerByMobileNo(Customer_Class);

                            type1 = result2["Type"].ToString();
                            if (type1 == "1")
                            {
                                Franchise_Sell_Class.Customer_Id = (int)result2["Result"]["Customer_Id"];

                                foreach (var item in ArticleMasterClassList)
                                {
                                    foreach (var Subitem in item.FranchiseStokeMaster_Class_List)
                                    {
                                        if (Subitem.Insert_New_Qty > 0)
                                        {
                                            FranchiseSellDetails_Class fsl = new FranchiseSellDetails_Class();
                                            Franchise_Sell_Class.Total_Amount = Franchise_Sell_Class.Total_Amount + (Subitem.Insert_New_Qty * item.MRP);
                                            fsl.SubCategory_Id = Subitem.SubCategoryMaster_Class_Data.SubCategory_Id;
                                            fsl.Article_Id     = item.Article_Id;
                                            fsl.MRP            = item.MRP;
                                            fsl.Quantity       = Subitem.Insert_New_Qty;
                                            StockMaster_Class smc = new StockMaster_Class();
                                            smc.Stock_Id = Subitem.Stock_Id;
                                            fsl.FranchiseStokeMaster_Class_Data = smc;
                                            ArticleMaster_Class amc = new ArticleMaster_Class();
                                            amc.Article_No               = item.Article_No;
                                            amc.Article_PrimaryImage     = item.Article_PrimaryImage;
                                            amc.Article_SecondaryImage   = item.Article_SecondaryImage;
                                            fsl.ArticleMaster_Class_Data = amc;
                                            CategoryMaster_Class cmc = new CategoryMaster_Class();
                                            cmc.Category_Name = item.CategoryMaster_Class_Data.Category_Name + " - " + Subitem.SubCategoryMaster_Class_Data.SubCategory_Name;
                                            fsl._CategoryMaster_Class_Data = cmc;
                                            //fsl._SubCategoryMaster_Class_Data.SubCategory_Name = Subitem.SubCategory_Name;
                                            fsl.Total_Amount = (fsl.MRP * fsl.Quantity).ToString();
                                            // fscd.Add(fsl);
                                            Franchise_Sell_Class.FranchiseSellDetails_Class_List.Add(fsl);
                                        }
                                    }
                                }



                                if (Franchise_Sell_Class.Total_Amount > 0)
                                {
                                    App.isBusy = false;
                                    await navigation.PushAsync(new SellDetailPage(Franchise_Sell_Class), true);
                                }
                                else
                                {
                                    App.isBusy = false;
                                    await App.Current.MainPage.DisplayAlert("Oops!", "Please Fill Qty Then Submit..", "Ok");
                                }
                            }
                            else
                            {
                                App.isBusy = false;
                                await App.Current.MainPage.DisplayAlert("Oops!", "Something is worng please try Again....", "Ok");
                            }
                        }
                        else
                        {
                            App.isBusy = false;
                            await App.Current.MainPage.DisplayAlert("Oops!", (string)result["ResponseMessage"], "Ok");
                        }
                    }
                    else
                    {
                        App.isBusy = false;
                        await App.Current.MainPage.DisplayAlert("Oops!", "Please fill customer name ", "Ok");
                    }
                    Wait.Hide();
                }

                Wait.Hide();
            }
        }
Exemple #2
0
        private async Task Submit()
        {
            try
            {
                if (HasErrors)
                {
                    // Error message
                    ScrollToControlProperty(GetFirstInvalidPropertyName);
                }
                else
                {
                    if (!string.IsNullOrEmpty(Customer_Class_GeSet.Contact_No) && !string.IsNullOrEmpty(Customer_Class_GeSet.Customer_Name))
                    {
                        var Wait = UserDialogs.Instance.Loading("Wait...", null, null, true, MaskType.Black);
                        Wait.Show();
                        JObject result = await _IAllDataServices.CustomerRegistration(Customer_Class_GeSet);



                        if (result != null)
                        {
                            string type = result["Type"].ToString();
                            if (type == "1")
                            {
                                await App.Current.MainPage.DisplayAlert("Success!", (string)result["ResponseMessage"], "Ok");

                                var ChackPriousPage = _INavigation.NavigationStack.Where(x => x.Title == "Customer Registration").FirstOrDefault();
                                if (ChackPriousPage != null)
                                {
                                    _INavigation.RemovePage(ChackPriousPage);
                                }
                                await _INavigation.PushAsync(new CustomerRegistrationPage());
                            }
                            else
                            {
                                await App.Current.MainPage.DisplayAlert("Error", (string)result["ResponseMessage"], "Ok");
                            }
                        }
                        else
                        {
                            await App.Current.MainPage.DisplayAlert("Oops!", "Please Refresh Page And try Again....", "Ok");
                        }

                        Wait.Dispose();
                    }
                    else
                    {
                        //if (string.IsNullOrEmpty(Customer_Class_GeSet.Address))
                        //{
                        //    _Address = "";
                        //}
                        //else
                        if (string.IsNullOrEmpty(Customer_Class_GeSet.Contact_No))
                        {
                            _Customer_Contect_No = "";
                        }
                        else if (string.IsNullOrEmpty(Customer_Class_GeSet.Customer_Name))
                        {
                            _Customer_Name = "";
                        }
                    }
                }
            }
            catch (Exception ee)
            {
                await App.Current.MainPage.DisplayAlert("Error", ee.Message, "Ok");
            }
        }