private void DetailButton_Clicked(object sender, EventArgs e)
        {
            if (_isDetail)
            {
                _isDetail = false;
                var item = (Button)sender;

                if (App.gDocType == "SO")
                {
                    App.gPageTitle = "Items List (Sales Order)";
                }
                else
                {
                    App.gPageTitle = "Items List (Credit Memo)";
                }
                SalesHeader head = new SalesHeader();
                head          = recItems.Where(x => x.DocumentNo == item.CommandParameter.ToString()).FirstOrDefault();
                App.gCustCode = head.SellToCustomer;
                DataManager manager  = new DataManager();
                Customer    customer = new Customer();
                customer = manager.GetSQLite_CustomerbyCustNo(head.SellToCustomer);
                if (customer != null)
                {
                    App.gCustPriceGroup = customer.CustomerPriceGroup;
                }
                else
                {
                    App.gCustPriceGroup = string.Empty;
                }
                Navigation.PushAsync(new SalesLinePage(item.CommandParameter.ToString(), "Open"));
            }
        }
        private void DtlButton_OnTouchesEnded(object sender, IEnumerable <NGraphics.Point> e)
        {
            var item = (ActionButton)sender;

            if (App.gDocType == "SO")
            {
                App.gPageTitle = "Items List (Sales Order)";
            }
            else
            {
                App.gPageTitle = "Items List (Credit Memo)";
            }
            SalesHeader head = new SalesHeader();

            head          = recItems.Where(x => x.DocumentNo == item.CommandParameter.ToString()).FirstOrDefault();
            App.gCustCode = head.SellToCustomer;
            Navigation.PushAsync(new SalesLinePage(item.CommandParameter.ToString(), "Open"));
        }
Exemple #3
0
 void DisplayData(SalesHeader record)
 {
     if (record != null)
     {
         EntryNo             = record.ID;
         InvoiceNoLabel.Text = record.DocumentNo;
         //DocumentDatePicker.Date =Convert.ToDateTime(record.DocumentDate);
         DocDateTimeLabel.Text    = record.DocumentDate;
         SellToCustomerEntry.Text = record.SellToCustomer;
         SellToNameLabel.Text     = record.SellToName;
         ExternalDocNoEntry.Text  = record.ExternalDocNo;
         BillToCustNo             = record.BillToCustomer;
         BilltoName = record.BillToName;
         SubTotal   = record.TotalAmount;
         GSTAmount  = record.GSTAmount;
         NetTotal   = record.NetAmount;
         CurStatus  = record.Status;
         originCust = record.SellToCustomer;
     }
     else
     {
         EntryNo = 0;
         DataManager manager = new DataManager();
         if (App.gDocType == "SO")
         {
             InvoiceNoLabel.Text = manager.GetLastNoSeries(App.gSOPrefix);
         }
         else
         {
             InvoiceNoLabel.Text = manager.GetLastNoSeries(App.gCRPrefix);
         }
         DocDateTimeLabel.Text   = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss tt");
         ExternalDocNoEntry.Text = string.Empty;
         // DocumentDatePicker.Date = DateTime.Today;
         SubTotal  = 0;
         GSTAmount = 0;
         NetTotal  = 0;
         // StatusPicker.SelectedItem = "Open";
         CurStatus  = "Open";
         originCust = string.Empty;
         // StatusPicker.IsEnabled = false;
         // //Status: Open (same as in NAV), Released (same as in NAV), Completed (when Transfer Order is posted and deleted)
     }
 }
        private void DeleteButton_OnTouchesEnded(object sender, IEnumerable <NGraphics.Point> e)
        {
            var  item      = (ActionButton)sender;
            bool isConfirm = false;

            Task.Run(async() =>
            {
                var answer = await UserDialogs.Instance.ConfirmAsync("Are you sure to delete?", "Delete", "Yes", "No");
                Device.BeginInvokeOnMainThread(() =>
                {
                    if (answer)
                    {
                        isConfirm = true;
                    }
                    else
                    {
                        isConfirm = false;
                    }
                });
            });
            if (isConfirm)
            {
                DataManager manager = new DataManager();

                SalesHeader hd = new SalesHeader();
                hd = manager.GetSalesHeaderbyID(int.Parse(item.CommandParameter.ToString()));
                ObservableCollection <SalesLine> recItems = new ObservableCollection <SalesLine>();
                recItems = manager.GetSalesLinesbyDocNo(hd.DocumentNo);
                if (recItems != null)
                {
                    if (recItems.Count > 0)
                    {
                        foreach (SalesLine s in recItems)
                        {
                            manager.DeleteScannedSoldDocbyBagNo(s.BagNo);
                        }
                        manager.DeleteSalesLinebyDocNo(hd.DocumentNo);
                    }
                }
                manager.DeleteSalesOrderbyID(int.Parse(item.CommandParameter.ToString()));
                LoadData(App.gSOStatus);
            }
        }
Exemple #5
0
        protected override void OnAppearing()
        {
            base.OnAppearing();
            _isEnableSaveBtn     = true;
            _isEnableCustomerBtn = true;
            data = new SalesHeader();
            if (!IsBack)
            {
                UserDialogs.Instance.ShowLoading("Loading", MaskType.Black); //IsLoading = true;
                try
                {
                    if (EntryNo != 0)
                    {
                        DataManager manager = new DataManager();
                        data = manager.GetSalesHeaderbyID(EntryNo);
                    }
                    else
                    {
                        data = null;
                    }

                    DisplayData(data);
                    UserDialogs.Instance.HideLoading();     //IsLoading = false;
                }
                catch (OperationCanceledException ex)
                {
                    UserDialogs.Instance.HideLoading(); //IsLoading = false;
                    //DependencyService.Get<IMessage>().LongAlert(ex.Message.ToString());
                    UserDialogs.Instance.ShowError(ex.Message.ToString(), 3000);
                }
                catch (Exception ex)
                {
                    UserDialogs.Instance.HideLoading(); //IsLoading = false;
                    //DependencyService.Get<IMessage>().LongAlert(ex.Message.ToString());
                    UserDialogs.Instance.ShowError(ex.Message.ToString(), 3000);
                }
            }
        }
Exemple #6
0
        private void Listview_ItemTapped(object sender, ItemTappedEventArgs e)
        {
            if (e.Item == null)
            {
                return;
            }
            ((ListView)sender).SelectedItem = null; // de-select the row
            var item = (SalesHeader)e.Item;

            if (App.gDocType == "SO")
            {
                App.gPageTitle = "Items List (Sales Order)";
            }
            else
            {
                App.gPageTitle = "Items List (Credit Memo)";
            }
            SalesHeader head = new SalesHeader();

            head          = recItems.Where(x => x.DocumentNo == item.DocumentNo).FirstOrDefault();
            App.gCustCode = head.SellToCustomer;
            Navigation.PushAsync(new ReleaseLinePage(item.DocumentNo));
        }
Exemple #7
0
        void ShowData()
        {
            _isEnableVoidBtn    = true;
            _isEnableCopyBtn    = true;
            _isEnableConfirmBtn = true;
            _isEnablePrintBtn   = true;
            DocNoLabel.Text     = DocumentNo;
            UserDialogs.Instance.ShowLoading("Loading", MaskType.Black); //IsLoading = true;
            Task.Run(async() =>
            {
                try
                {
                    //LoadPaymentMethods();

                    TotalAmount = recs.Sum(x => x.LineAmount);
                    GSTAmount   = CalculateGSTAmount();
                    NetAmount   = TotalAmount + GSTAmount;


                    // Get header info
                    head = new SalesHeader();
                    DataManager manager = new DataManager();
                    head = manager.GetSalesHeaderbyDocNo(DocumentNo);

                    customer = new Customer();
                    customer = await manager.GetCustomerbyCode(head.SellToCustomer);

                    Customer billcustomer = new Customer();
                    billcustomer          = await manager.GetCustomerbyCode(head.BillToCustomer);
                    Device.BeginInvokeOnMainThread(() =>
                    {
                        UserDialogs.Instance.HideLoading();
                        SubAmountNameLabel.Text = "SUB TOTAL :";
                        GSTAmountNameLabel.Text = "GST (" + App.gPercentGST + " % ) : ";
                        NetAmountNameLabel.Text = "TOTAL :";
                        TotalAmountLabel.Text   = string.Format("{0:0.00}", TotalAmount);
                        GSTAmountLabel.Text     = string.Format("{0:0.00}", GSTAmount);
                        NetAmountLabel.Text     = string.Format("{0:0.00}", NetAmount);

                        if (customer != null)
                        {
                            SellToNameLabel.Text  = head.SellToName;
                            SellToLine1Label.Text = customer.Address + "," + customer.Address2 + "," + customer.City + "  " + customer.Postcode;
                            SellToLine2Label.Text = customer.PhoneNo + "," + customer.MobileNo;
                            //Line4Label.Text = string.Empty;
                        }

                        if (billcustomer != null)
                        {
                            BillToNameLabel.Text = head.BillToName;
                            Line1Label.Text      = billcustomer.Address + "," + billcustomer.Address2 + "," + billcustomer.City + "  " + billcustomer.Postcode;
                            Line2Label.Text      = billcustomer.PhoneNo + "," + billcustomer.MobileNo;
                            //Line4Label.Text = string.Empty;
                        }
                        if (pagefrom == "Released")
                        {
                            ConfirmButton.IsVisible = false;
                            if (App.gDocType == "SO")
                            {
                                if (head.IsVoid == "true" || head.IsSync == "true")
                                {
                                    //VoidButton.IsVisible = false;
                                    VoidButton.Text      = "Copy";
                                    VoidButton.IsVisible = true;
                                    VoidButton.Clicked  += CopyButton_OnClicked;
                                }
                                else
                                {
                                    VoidButton.Text      = "Void";
                                    VoidButton.IsVisible = true;
                                    VoidButton.Clicked  += VoidButton_OnClicked;
                                }
                            }
                            else
                            {
                                VoidButton.IsVisible = false;
                            }

                            CustomerSignaturePad.IsVisible = false;
                            CommentEntry.IsEnabled         = false;
                            imgSignature.IsVisible         = true;
                            //PaymentMethodsPicker.IsEnabled = false;
                            //PaymentMethodsPicker.SelectedItem = head.PaymentMethod;
                            CommentEntry.Text   = head.Comment;
                            imgSignature.Source = Xamarin.Forms.ImageSource.FromStream(() => new MemoryStream(Convert.FromBase64String(head.StrSignature)));
                            _signature64str     = head.StrSignature;
                            // imgSignature.Source = head.StrSignature;
                            //CustomerSignaturePad.
                        }
                        else
                        {
                            VoidButton.IsVisible           = false;
                            CustomerSignaturePad.IsVisible = true;
                            imgSignature.IsVisible         = false;
                            _signature64str = string.Empty;
                        }
                    });
                }
                catch (OperationCanceledException ex)
                {
                    UserDialogs.Instance.HideLoading();

                    UserDialogs.Instance.Alert(ex.Message.ToString(), "Alert", "OK");
                }
                catch (Exception ex)
                {
                    UserDialogs.Instance.HideLoading();

                    UserDialogs.Instance.Alert(ex.Message.ToString(), "Alert", "OK");
                }
            });
        }
        private void DeleteButton_Clicked(object sender, EventArgs e)
        {
            if (_isDelete)
            {
                var item = (Button)sender;
                try
                {
                    _isDelete = false;
                    Device.BeginInvokeOnMainThread(() => UserDialogs.Instance.ShowLoading("Loading", MaskType.Black));
                    Task.Run(async() =>
                    {
                        var answer = await UserDialogs.Instance.ConfirmAsync("Are you sure to delete?", "Delete", "Yes", "No");
                        if (answer)
                        {
                            DataManager manager = new DataManager();

                            SalesHeader hd = new SalesHeader();
                            hd             = manager.GetSalesHeaderbyID(int.Parse(item.CommandParameter.ToString()));
                            ObservableCollection <SalesLine> recItems = new ObservableCollection <SalesLine>();
                            recItems = manager.GetSalesLinesbyDocNo(hd.DocumentNo);
                            if (recItems != null)
                            {
                                if (recItems.Count > 0)
                                {
                                    //if (App.gDocType == "SO")
                                    //{
                                    foreach (SalesLine s in recItems)
                                    {
                                        Item iobj = new Item();
                                        iobj      = manager.GetSQLite_ItembyItemNo(s.ItemNo);
                                        if (App.gDocType == "SO")
                                        {
                                            decimal soldQty = 0;
                                            if (s.ItemType == "EXC")
                                            {
                                                soldQty           = iobj.SoldQty - s.BadQuantity;
                                                decimal excBadQty = iobj.BadQty - s.BadQuantity;
                                                manager.UpdateSQLite_ExchangeInventory(s.ItemNo, excBadQty);
                                            }
                                            else
                                            {
                                                soldQty = iobj.SoldQty - s.Quantity;
                                            }

                                            manager.UpdateSQLite_SOInventory(s.ItemNo, soldQty);
                                        }
                                        else
                                        {
                                            decimal returnQty = iobj.ReturnQty - s.Quantity;
                                            decimal badQty    = iobj.BadQty - s.BadQuantity;
                                            manager.UpdateSQLite_ReturnInventory(s.ItemNo, returnQty, badQty);
                                        }
                                    }
                                    // }
                                    manager.DeleteSalesLinebyDocNo(hd.DocumentNo);
                                }
                            }
                            manager.DeleteSalesOrderbyID(int.Parse(item.CommandParameter.ToString()));
                        }
                        _isDelete = true;
                    }).ContinueWith(result => Device.BeginInvokeOnMainThread(() =>
                    {
                        UserDialogs.Instance.HideLoading();
                        LoadData(App.gSOStatus);
                    }));
                }
                catch (Exception ex)
                {
                    UserDialogs.Instance.HideLoading();
                    UserDialogs.Instance.ShowError(ex.Message.ToString(), 3000);
                }
            }
        }