private bool CheckHasReturn(ProductWithInvoice result)
        {
            if (result == null)
            {
                return(false);
            }

            bool hasReturn;

            using (var db = new Db(true))
            {
                hasReturn = db.InvoiceHasReturn(result.InvoiceHeader.AlisverisID);
            }
            if (hasReturn)
            {
                using (var frm = new FrmReturnInvoiceOptions())
                {
                    frm.lblMessage.Text = StringResource.ReturnInvoiceConfirm;
                    frm.CreateButton(StringResource.ContinueCollect, () => true);
                    frm.CreateButton(StringResource.MarkComplete, () => OnMarkComplete(result), DialogResult.Cancel);
                    frm.StartPosition = FormStartPosition.CenterScreen;
                    return(frm.ShowDialog() == DialogResult.Cancel);
                }
            }
            return(false);
        }
 private void SetInvoiceControls(ProductWithInvoice result)
 {
     txtCustomerCode.Text   = result.InvoiceHeader.MusteriKodu;
     txtInvoiceNumber.Text  = result.InvoiceHeader.FaturaNumarasi;
     txtCustomerName.Text   = result.InvoiceHeader.AdiSoyadi;
     deInvoiceDate.DateTime = result.InvoiceHeader.FaturaTarihi;
     SetInvoiceStateControls(result);
 }
 private void SetInvoiceStateControls(ProductWithInvoice result)
 {
     lblPrinted.ForeColor              = result.Printed() ? AppAppearance.GreenForeColor : AppAppearance.RedForeColor;
     lblCompleted.ForeColor            = result.Completed() ? AppAppearance.GreenForeColor : AppAppearance.RedForeColor;
     lblPrinted.Text                   = result.Printed() ? StringResource.Yes : StringResource.No;
     lblCompleted.Text                 = result.Completed() ? StringResource.Yes : StringResource.No;
     lblTotalQty.Text                  = result.InvoiceLines.Sum(p => p.Miktar).ToString();
     grdControlInvoiceLines.DataSource = result.InvoiceLines;
     grdViewInvoiceLines.BestFitColumns();
 }
        private void SaveCollectResult(InvoiceLine collectedLine, ProductWithInvoice result)
        {
            if (collectedLine == null)
            {
                return;
            }

            using (var db = new Db(true))
            {
                db.SaveCollectHeaderAndDetail(result.InvoiceHeader.AlisverisID, result.Completed(), collectedLine.IslemID, collectedLine.ToplananMiktar);
                db.Commit();
            }
        }
 private bool OnMarkComplete(ProductWithInvoice result)
 {
     if (AppContext.ShowQuestionMessage(StringResource.CompleteCollectConfirm, MessageBoxButtons.YesNo, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
     {
         var alisverisId = result.InvoiceHeader.AlisverisID;
         using (var db = new Db())
         {
             db.UpdateCollectCompletedAndPrinted(alisverisId, CollectCompleteType.Marked);
             foreach (var line in result.InvoiceLines)
             {
                 db.SaveCollectDetail(alisverisId, line.IslemID, line.Miktar);
             }
             db.Commit();
         }
         return(true);
     }
     return(false);
 }
        private void ReadResult(ProductWithInvoice result)
        {
            Check.NotNull(result, nameof(result));
            if (result.Product == null)
            {
                ResetControls();
                AppContext.ShowErrorMessage(StringResource.ProductNotFound);
                return;
            }

            SetProductControls(result.Product);

            if (!result.InvoiceLines.HasItem())
            {
                ResetInvoiceControls();
                return;
            }

            SetInvoiceControls(result);
        }
        private void LoadInvoice()
        {
            var collectContext = AppContext.CollectContext;

            if (string.IsNullOrWhiteSpace(btxtBarcode.Text.Trim()))
            {
                return;
            }

            using (new WaitFormScope())
            {
                try
                {
                    ProductWithInvoice result;
                    using (var db = new Db())
                    {
                        result = db.GetProductWithInvoice(btxtBarcode.Text.Trim(), new FilterParameters(collectContext.StoreCode, collectContext.StartDate, collectContext.EndDate));
                    }

                    var collectedLine = result.Collect();
                    SaveCollectResult(collectedLine, result);
                    ReadResult(result);
                    if (result.Valid())
                    {
                        CurrentProductWithInvoice = result;
                        collectContext.OperationContext.OperationCompleted();
                    }
                }
                catch (Exception ex)
                {
                    ResetControls();
                    AppContext.Logger.Error(ex);
                }
                finally
                {
                    SelectBarcodeControl();
                }
            }
        }
 private void ResetControls(bool beforeRead = false)
 {
     CurrentProductWithInvoice = null;
     ResetProductControls(beforeRead);
     ResetInvoiceControls(beforeRead);
 }