public void Initialize(Invoice invoiceToLoad)
        {
            LoadControls(invoiceToLoad);

            if (ActiveInvoice != null)
            {
                DB_InvoiceType invoiceType = (DB_InvoiceType)ActiveInvoice.InvoiceType_P_ID;
                switch (invoiceType)
                {
                case DB_InvoiceType.InPatientPrivate:
                case DB_InvoiceType.InPatientNotPrivate:
                    List <InvoiceDetail> List_mainServices = ActiveInvoice.List_InvoiceDetails.FindAll(item => item.IsInPatientParentService);

                    CommonViewsActions.ShowUserControl(ref _invoiceDetailsViewing, pnlMain);
                    if (_invoiceDetailsViewing != null)
                    {
                        _invoiceDetailsViewing.Initialize(List_mainServices, InvoiceDetailType.Accommodation);
                    }
                    lytInPatientExit.Visibility = LayoutVisibility.Always;
                    break;

                case DB_InvoiceType.OutPatientPrivate:
                case DB_InvoiceType.OutPatientNotPrivate:
                    CommonViewsActions.ShowUserControl(ref _outPatientInvoiceDetails, pnlMain);
                    if (_outPatientInvoiceDetails != null)
                    {
                        _outPatientInvoiceDetails.Initialize(ActiveInvoice);
                    }
                    lytInPatientExit.Visibility = LayoutVisibility.Never;
                    break;
                }
            }
        }
Beispiel #2
0
        public void Initialize(DB_InvoiceType invoiceType)
        {
            InvoiceTypeID = invoiceType;
            InventoryBusinessLogicEngine.ActiveInvoiceType = invoiceType;
            switch ((DB_InvoiceType)InvoiceTypeID)
            {
            case DB_InvoiceType.PurchasingInvoice:
            case DB_InvoiceType.ReturningPurchasingInvoice:
                CommonViewsActions.FillGridlookupEdit(lkeDedicatedPerson, Supplier_cu.ItemsList, "FullName", "Person_CU_ID");
                lytDedicatedPerson.Text = "المــــورد";
                break;

            case DB_InvoiceType.SellingInvoice:
            case DB_InvoiceType.ReturningSellingInvoice:
                CommonViewsActions.FillGridlookupEdit(lkeDedicatedPerson, Customer_cu.ItemsList, "FullName", "Person_CU_ID");
                lytDedicatedPerson.Text = "العميـــل";
                break;
            }

            if (CommonActions.CommonActions.GetMaxFinancialIntervalDate(2018) != null)
            {
                dtInvoiceCreation.Properties.MaxValue =
                    Convert.ToDateTime(CommonActions.CommonActions.GetMaxFinancialIntervalDate(2018)).StartOfDayDateTime();
            }
            if (CommonActions.CommonActions.GetMinFinancialIntervalDate(2018) != null)
            {
                dtInvoiceCreation.Properties.MinValue =
                    Convert.ToDateTime(CommonActions.CommonActions.GetMinFinancialIntervalDate(2018)).StartOfDayDateTime();
            }
        }
        public override bool AfterSave()
        {
            if ((FinanceInvoice)ActiveDBItem == null)
            {
                return(false);
            }

            if (FinanceInvoiceDetailsList != null && FinanceInvoiceDetailsList.Count > 0)
            {
                foreach (FinanceInvoiceDetail invoiceDetail in FinanceInvoiceDetailsList.OrderBy(item => item.UnitMeasurment_CU_ID))
                {
                    InventoryItemTransaction inventoryItemTransaction = DBCommon.CreateNewDBEntity <InventoryItemTransaction>();
                    inventoryItemTransaction.UnitMeasurment_CU_ID   = Convert.ToInt32(invoiceDetail.UnitMeasurment_CU_ID);
                    inventoryItemTransaction.InventoryItem_CU_ID    = Convert.ToInt32(invoiceDetail.InventoryItem_CU_ID);
                    inventoryItemTransaction.InventoryHousing_CU_ID = Convert.ToInt32(invoiceDetail.InventoryHousing_CU_ID);
                    inventoryItemTransaction.Quantity = Convert.ToDouble(invoiceDetail.Quantity);
                    inventoryItemTransaction.Date     = Convert.ToDateTime(invoiceDetail.Date);
                    inventoryItemTransaction.IsOnDuty = true;
                    if (UserID != null)
                    {
                        inventoryItemTransaction.InsertedBy = Convert.ToInt32(UserID);
                    }
                    DB_InvoiceType invoiceType = (DB_InvoiceType)Convert.ToInt32(((FinanceInvoice)ActiveDBItem).InvoiceType_P_ID);
                    switch (invoiceType)
                    {
                    case DB_InvoiceType.SellingInvoice:
                    case DB_InvoiceType.ReturningPurchasingInvoice:
                        inventoryItemTransaction.TransactionFactor = -1;
                        inventoryItemTransaction.InventoryItemTransactionType_P_ID =
                            Convert.ToInt32(DB_InventoryItemTransactionType.OutputTransaction);
                        break;

                    case DB_InvoiceType.PurchasingInvoice:
                    case DB_InvoiceType.ReturningSellingInvoice:
                        inventoryItemTransaction.TransactionFactor = 1;
                        inventoryItemTransaction.InventoryItemTransactionType_P_ID =
                            Convert.ToInt32(DB_InventoryItemTransactionType.InputTransaction);
                        break;
                    }
                    inventoryItemTransaction.SaveChanges();
                }
            }

            FinanceInvoiceDetailsList = null;

            return(true);
        }
Beispiel #4
0
        private void lkeUnitMeasurments_EditValueChanged(object sender, EventArgs e)
        {
            if (lkeInventoryItems.EditValue == null)
            {
                return;
            }

            DB_PriceType   priceType   = DB_PriceType.None;
            DB_InvoiceType invoiceType = (DB_InvoiceType)InvoiceTypeID;

            switch (invoiceType)
            {
            case DB_InvoiceType.SellingInvoice:
            case DB_InvoiceType.ReturningSellingInvoice:
                priceType = DB_PriceType.SellingPrice;
                break;

            case DB_InvoiceType.PurchasingInvoice:
            case DB_InvoiceType.ReturningPurchasingInvoice:
                priceType = DB_PriceType.PurchasingPrice;
                break;
            }

            Line_PricePerUnit = InventoryBusinessLogicEngine.GetInventoryItemSellingPrice(Line_InventoryItem_CU_ID,
                                                                                          Line_UnitMeasurment_CU_ID, InvoiceCreationDate, Person_CU_ID, priceType);

            Line_InventoryItemAvaliableQuantity =
                Math.Floor(InventoryBusinessLogicEngine.GetInventoryItemAvailableQuantity(Line_InventoryItem_CU_ID,
                                                                                          Line_UnitMeasurment_CU_ID, InventoryHousing_CU_ID));

            UnitMeasurment_cu inventoryTrackingUnitMeasurment =
                InventoryBusinessLogicEngine.GetInventoryTrackingUnitMeasurment(Line_InventoryItem_CU_ID);

            if (inventoryTrackingUnitMeasurment == null)
            {
                txtEncapsulatedQuantity.EditValue = 1;
            }
            else
            {
                txtEncapsulatedQuantity.EditValue = InventoryBusinessLogicEngine.GetEncapsulatedQuantity(Line_UnitMeasurment_CU_ID,
                                                                                                         inventoryTrackingUnitMeasurment.ID);
            }
        }
Beispiel #5
0
        private void lkeDedicatedPerson_EditValueChanged(object sender, EventArgs e)
        {
            DB_PriceType   priceType   = DB_PriceType.None;
            DB_InvoiceType invoiceType = (DB_InvoiceType)InvoiceTypeID;

            switch (invoiceType)
            {
            case DB_InvoiceType.SellingInvoice:
            case DB_InvoiceType.ReturningSellingInvoice:
                priceType = DB_PriceType.SellingPrice;
                break;

            case DB_InvoiceType.PurchasingInvoice:
            case DB_InvoiceType.ReturningPurchasingInvoice:
                priceType = DB_PriceType.PurchasingPrice;
                break;
            }
            Line_PricePerUnit = InventoryBusinessLogicEngine.GetInventoryItemSellingPrice(Line_InventoryItem_CU_ID,
                                                                                          Line_UnitMeasurment_CU_ID, InvoiceCreationDate, Person_CU_ID, priceType);
            if (InvoiceTypeID != null)
            {
                switch ((DB_InvoiceType)InvoiceTypeID)
                {
                case DB_InvoiceType.SellingInvoice:
                case DB_InvoiceType.ReturningSellingInvoice:
                    txtDedicatedPersonBalance.EditValue =
                        FinancialBusinessLogicLibrary.GetCustomerBalance(FinancialBusinessLogicLibrary.CustomerBalanceType.NetBalance,
                                                                         InvoiceTypeID, lkeDedicatedPerson.EditValue);
                    break;

                case DB_InvoiceType.PurchasingInvoice:
                case DB_InvoiceType.ReturningPurchasingInvoice:
                    txtDedicatedPersonBalance.EditValue = FinancialBusinessLogicLibrary.GetSupplierBalance(InvoiceTypeID,
                                                                                                           lkeDedicatedPerson.EditValue);
                    break;
                }
            }
        }
        public override bool Collect(AbstractDataCollector <TEntity> collector)
        {
            if (collector == null)
            {
                return(false);
            }

            ActiveCollector = collector;

            ID = ((IFinanceInvoiceCreation)ActiveCollector.ActiveViewer).ID;

            if (ActiveDBItem == null)
            {
                return(false);
            }

            ((FinanceInvoice)ActiveDBItem).DBCommonTransactionType = CommonTransactionType;
            if (InvoiceTypeID != null)
            {
                ((FinanceInvoice)ActiveDBItem).InvoiceType_P_ID = (int)InvoiceTypeID;
            }
            if (InvoicePaymentTypeID != null)
            {
                ((FinanceInvoice)ActiveDBItem).InvoicePaymentType_P_ID = (int)InvoicePaymentTypeID;
            }
            if (InvoiceCreationDate != null)
            {
                ((FinanceInvoice)ActiveDBItem).InvoiceCreationDate = Convert.ToDateTime(InvoiceCreationDate);
            }

            DB_InvoiceType invoiceType = (DB_InvoiceType)Convert.ToInt32(((FinanceInvoice)ActiveDBItem).InvoiceType_P_ID);

            switch (invoiceType)
            {
            case DB_InvoiceType.SellingInvoice:
            case DB_InvoiceType.ReturningSellingInvoice:
                if (Person_CU_ID != null)
                {
                    ((FinanceInvoice)ActiveDBItem).Customer_CU_ID = Convert.ToInt32(Person_CU_ID);
                }
                break;

            case DB_InvoiceType.PurchasingInvoice:
            case DB_InvoiceType.ReturningPurchasingInvoice:
                if (Person_CU_ID != null)
                {
                    ((FinanceInvoice)ActiveDBItem).Supplier_CU_ID = Convert.ToInt32(Person_CU_ID);
                }
                break;
            }

            ((FinanceInvoice)ActiveDBItem).IsPrinted = false;
            if (InvoiceSerialNumber != null)
            {
                ((FinanceInvoice)ActiveDBItem).InvoiceSerial = InvoiceSerialNumber.ToString();
            }
            ((FinanceInvoice)ActiveDBItem).PrintingDate     = null;
            ((FinanceInvoice)ActiveDBItem).IsPaymentsEnough = Convert.ToBoolean(IsPaymentEnough);
            if (InvoiceDescription != null)
            {
                ((FinanceInvoice)ActiveDBItem).Description = InvoiceDescription.ToString();
            }
            ((FinanceInvoice)ActiveDBItem).Description            = null;
            ((FinanceInvoice)ActiveDBItem).IsOnDuty               = true;
            ((FinanceInvoice)ActiveDBItem).IsFinanciallyReviewed  = false;
            ((FinanceInvoice)ActiveDBItem).IsFinanciallyCompleted = false;
            ((FinanceInvoice)ActiveDBItem).IsCancelled            = false;
            ((FinanceInvoice)ActiveDBItem).CancelledBy            = null;
            ((FinanceInvoice)ActiveDBItem).CancellationDate       = null;
            ((FinanceInvoice)ActiveDBItem).IsSuspended            = false;
            if (UserID != null)
            {
                ((FinanceInvoice)ActiveDBItem).InsertedBy = Convert.ToInt32(UserID);
            }

            double accummulativeRequiredAmount = 0;

            if (FinanceInvoiceDetailsList != null && FinanceInvoiceDetailsList.Count > 0)
            {
                foreach (FinanceInvoiceDetail invoiceDetail in FinanceInvoiceDetailsList)
                {
                    if (UserID != null)
                    {
                        invoiceDetail.InsertedBy = Convert.ToInt32(UserID);
                    }
                    ((FinanceInvoice)ActiveDBItem).FinanceInvoiceDetails.Add(invoiceDetail);
                    accummulativeRequiredAmount = accummulativeRequiredAmount +
                                                  Convert.ToDouble(invoiceDetail.PricePerUnit) * Convert.ToDouble(invoiceDetail.Quantity);
                }
            }
            else
            {
                return(false);
            }

            ((FinanceInvoice)ActiveDBItem).FinanceInvoiceShare = new FinanceInvoiceShare();
            ((FinanceInvoice)ActiveDBItem).FinanceInvoiceShare.TotalRequestedAmount = accummulativeRequiredAmount;
            if (UserID != null)
            {
                ((FinanceInvoice)ActiveDBItem).FinanceInvoiceShare.InsertedBy = Convert.ToInt32(UserID);
            }
            if (AmountPaid != null)
            {
                ((FinanceInvoice)ActiveDBItem).FinanceInvoiceShare.TotalPayment = Convert.ToDouble(AmountPaid);
            }

            if (Convert.ToBoolean(PaymentTypeID) && AmountPaid != null &&
                Convert.ToDouble(AmountPaid) >= 0)
            {
                FinanceInvoicePayment invoicePayment = DBCommon.CreateNewDBEntity <FinanceInvoicePayment>();
                invoicePayment.Amount = Convert.ToDouble(AmountPaid);
                if (InvoiceCreationDate != null)
                {
                    invoicePayment.Date = Convert.ToDateTime(InvoiceCreationDate);
                }
                invoicePayment.PaymentType_P_ID    = (int)DB_PaymentType.CashPayment;
                invoicePayment.PaymentSerial       = "123";
                invoicePayment.IsOnDuty            = true;
                invoicePayment.Description         = "sdfsdfsdf";
                invoicePayment.IsRemainingReturned = Convert.ToBoolean(IsRemainingReturned);
                if (UserID != null)
                {
                    invoicePayment.InsertedBy = Convert.ToInt32(UserID);
                }
                ((FinanceInvoice)ActiveDBItem).FinanceInvoicePayments.Add(invoicePayment);
            }

            return(true);
        }
Beispiel #7
0
        private void lkeInventoryItems_EditValueChanged(object sender, EventArgs e)
        {
            if (lkeInventoryItems.EditValue == null)
            {
                lkeUnitMeasurments.Properties.DataSource = null;
                return;
            }

            List <UnitMeasurment_cu> unitMeasurmentList =
                InventoryBusinessLogicEngine.GetInventoryItemRegisteredUnitMeasurments(Convert.ToInt32(lkeInventoryItems.EditValue));

            if (unitMeasurmentList == null || unitMeasurmentList.Count == 0)
            {
                XtraMessageBox.Show("لا يـوجـــد وحـدات قيــــاس مـربـوطــــة مـع هــذا المنتــــج", "تنبيـــــه",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, DefaultBoolean.Default);
            }

            CommonViewsActions.FillGridlookupEdit(lkeUnitMeasurments, unitMeasurmentList);

            DB_PriceType   priceType   = DB_PriceType.None;
            DB_InvoiceType invoiceType = (DB_InvoiceType)InvoiceTypeID;

            switch (invoiceType)
            {
            case DB_InvoiceType.SellingInvoice:
            case DB_InvoiceType.ReturningSellingInvoice:
                priceType = DB_PriceType.SellingPrice;
                break;

            case DB_InvoiceType.PurchasingInvoice:
            case DB_InvoiceType.ReturningPurchasingInvoice:
                priceType = DB_PriceType.PurchasingPrice;
                break;
            }

            Line_PricePerUnit = InventoryBusinessLogicEngine.GetInventoryItemSellingPrice(Line_InventoryItem_CU_ID,
                                                                                          Line_UnitMeasurment_CU_ID, InvoiceCreationDate, Person_CU_ID, priceType);
            Line_InventoryItemAvaliableQuantity =
                Math.Floor(InventoryBusinessLogicEngine.GetInventoryItemAvailableQuantity(Line_InventoryItem_CU_ID,
                                                                                          Line_UnitMeasurment_CU_ID, InventoryHousing_CU_ID));

            UnitMeasurment_cu inventoryTrackingUnitMeasurment =
                InventoryBusinessLogicEngine.GetInventoryTrackingUnitMeasurment(Line_InventoryItem_CU_ID);

            if (inventoryTrackingUnitMeasurment != null)
            {
                txtInventoryTrackingUnitMeasurment.Text = inventoryTrackingUnitMeasurment.Name_P;
            }
            else
            {
                txtInventoryTrackingUnitMeasurment.Text = "لـم يحــدد";
            }

            if (inventoryTrackingUnitMeasurment == null)
            {
                txtEncapsulatedQuantity.EditValue = 1;
            }
            else if (Line_UnitMeasurment_CU_ID != null)
            {
                txtEncapsulatedQuantity.EditValue = InventoryBusinessLogicEngine.GetEncapsulatedQuantity(Line_UnitMeasurment_CU_ID,
                                                                                                         inventoryTrackingUnitMeasurment.ID);
            }
            else
            {
                txtEncapsulatedQuantity.EditValue = 1;
            }
        }