示例#1
0
        private void SellToCustomerEntry_Completed(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(SellToCustomerEntry.Text))
            {
                DataManager manager  = new DataManager();
                Customer    customer = new Customer();
                customer = manager.GetSQLite_CustomerbyCustNo(SellToCustomerEntry.Text);
                if (customer != null)
                {
                    SellToCustomerEntry.Text = customer.CustomerNo;
                    SellToNameLabel.Text     = customer.Name;
                    App.gCustPriceGroup      = customer.CustomerPriceGroup;

                    manager = new DataManager();
                    Customer objCust = new Customer();
                    objCust = manager.GetSQLite_CustomerbyCustNo(customer.billtoCustNo);
                    if (objCust != null)
                    {
                        BillToCustNo = objCust.CustomerNo;
                        BilltoName   = objCust.Name;
                    }
                    else
                    {
                        BillToCustNo = customer.CustomerNo;
                        BilltoName   = customer.Name;
                    }
                }
                else
                {
                    UserDialogs.Instance.ShowError("Wrong customer no or customer does not existed!", 3000);

                    SellToCustomerEntry.Text = string.Empty;
                    SellToNameLabel.Text     = string.Empty;
                    BillToCustNo             = string.Empty;
                    BilltoName          = string.Empty;
                    App.gCustPriceGroup = string.Empty;
                    SellToCustomerEntry.Focus();
                }
            }
        }
示例#2
0
        private async void SaveButton_Clicked(object sender, EventArgs e)
        {
            if (_isEnableSaveBtn)
            {
                _isEnableSaveBtn = false;
                if (CurStatus == "Open")
                {
                    if (!string.IsNullOrEmpty(SellToCustomerEntry.Text))
                    {
                        DataManager manager = new DataManager();
                        string      retval  = await manager.SaveSQLite_SalesHeader(new SalesHeader
                        {
                            ID             = EntryNo,
                            DocumentNo     = InvoiceNoLabel.Text,
                            DocumentDate   = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss tt"),//DocumentDatePicker.Date.ToString("yyyy-MM-dd"),
                            SellToCustomer = SellToCustomerEntry.Text,
                            SellToName     = SellToNameLabel.Text,
                            BillToCustomer = BillToCustNo,
                            BillToName     = BilltoName,
                            Status         = "Open",
                            TotalAmount    = SubTotal,
                            GSTAmount      = GSTAmount,
                            NetAmount      = NetTotal,
                            DocumentType   = App.gDocType,
                            Note           = string.Empty,
                            IsVoid         = "false",
                            IsSync         = "false",
                            SyncDateTime   = string.Empty,
                            ExternalDocNo  = ExternalDocNoEntry.Text
                        });

                        if (retval == "Success")
                        {
                            // Edit Sales line if Customer Changed
                            if (!string.IsNullOrEmpty(originCust))
                            {
                                if (originCust != SellToCustomerEntry.Text)
                                {
                                    ObservableCollection <SalesLine> prevLines = new ObservableCollection <SalesLine>();
                                    manager   = new DataManager();
                                    prevLines = manager.GetSalesLinesbyDocNo(InvoiceNoLabel.Text);
                                    if (prevLines != null)
                                    {
                                        if (prevLines.Count > 0)
                                        {
                                            foreach (SalesLine s in prevLines)
                                            {
                                                SalesLine line = new SalesLine()
                                                {
                                                    ID                    = s.ID,
                                                    DocumentNo            = s.DocumentNo,
                                                    ItemNo                = s.ItemNo,
                                                    Description           = s.Description,
                                                    UnitofMeasurementCode = s.UnitofMeasurementCode,
                                                    Quantity              = s.Quantity,
                                                    BadQuantity           = s.BadQuantity,
                                                    FOCQty                = s.FOCQty,
                                                    UnitPrice             = GetDefaultPrice(s.ItemNo),
                                                    GoodReasonCode        = s.GoodReasonCode,
                                                    BadReasonCode         = s.BadReasonCode,
                                                    ItemType              = s.ItemType,
                                                    // BagNo=ScanBagEntry.Text
                                                    //IsSync = "false",
                                                    //SyncDateTime = string.Empty
                                                };
                                                retval = manager.SaveSQLite_SalesLine(line);
                                            }
                                            if (retval == "Success")
                                            {
                                                ObservableCollection <SalesLine> lines = new ObservableCollection <SalesLine>();
                                                lines = manager.GetSalesLinesbyDocNo(InvoiceNoLabel.Text);
                                                decimal new_amt = lines.Sum(x => x.LineAmount);
                                                retval = manager.UpdateSalesHeaderTotalAmount(new_amt, InvoiceNoLabel.Text, lines);
                                            }
                                        } // end check line count
                                    }     // line!=null
                                }
                            }
                            if (EntryNo == 0) //DD #284
                            {
                                if (App.gDocType == "SO")
                                {
                                    manager.IncreaseNoSeries(App.gSOPrefix, InvoiceNoLabel.Text, "SO");
                                }
                                else
                                {
                                    manager.IncreaseNoSeries(App.gCRPrefix, InvoiceNoLabel.Text, "CR");
                                }
                            }

                            UserDialogs.Instance.ShowSuccess(retval, 3000);
                            Navigation.PopAsync();
                        }
                        else
                        {
                            UserDialogs.Instance.ShowError(retval, 3000);
                            _isEnableSaveBtn = true;
                        }
                    }
                    else
                    {
                        UserDialogs.Instance.ShowError("Required Sell to Customer!", 3000);
                        SellToCustomerEntry.Focus();
                        _isEnableSaveBtn = true;
                    }
                }
                else
                {
                    UserDialogs.Instance.ShowError("Not allow to save released Sales Order!", 3000);
                    _isEnableSaveBtn = true;
                }
            }
        }