コード例 #1
0
ファイル: FormPayment.cs プロジェクト: ryuki/YTech.Inventory
 private void UpdateTransaction()
 {
     if (tTransactionBindingSource.Current != null)
     {
         TTransaction t = (tTransactionBindingSource.Current as TTransaction);
         t.TransactionPpn = t.TransactionSisa - paymentAmmountNumericUpDown.Value;
         DataMaster.UpdatePersistence(t);
     }
 }
コード例 #2
0
        private void UpdatePrice(string ItemId)
        {
            NHibernate.Expression.ICriterion[] expArrays = new NHibernate.Expression.ICriterion[2];
            expArrays[0] = NHibernate.Expression.Expression.Between(TTransaction.ColumnNames.TransactionDate, transactionDateFromDateTimePicker.Value, transactionDateToDateTimePicker.Value.AddDays(1));
            expArrays[1] = NHibernate.Expression.Expression.Or(NHibernate.Expression.Expression.Eq(TTransaction.ColumnNames.TransactionStatus, ListOfTransaction.Sales.ToString()), NHibernate.Expression.Expression.Eq(TTransaction.ColumnNames.TransactionStatus, ListOfTransaction.Purchase.ToString()));

            IList              listTrans = DataMaster.GetList(typeof(TTransaction), expArrays, null);
            IList              listDet;
            IList              listStock;
            TTransaction       t;
            TTransactionDetail det;
            TStock             stok;
            decimal            total = decimal.Zero;

            for (int i = 0; i < listTrans.Count; i++)
            {
                t     = listTrans[i] as TTransaction;
                total = decimal.Zero;

                listDet = DataMaster.GetListEq(typeof(TTransactionDetail), TTransactionDetail.ColumnNames.TransactionId, t.TransactionId, TTransactionDetail.ColumnNames.ItemId, ItemId);

                for (int j = 0; j < listDet.Count; j++)
                {
                    det = listDet[j] as TTransactionDetail;

                    if (t.TransactionStatus == ListOfTransaction.Sales.ToString())
                    {
                        det.Price = itemPriceMaxNumericUpDown.Value;
                        DataMaster.UpdatePersistence(det);
                        total += det.Price;
                    }
                    else if (true)
                    {
                        det.Price = itemPricePurchaseNumericUpDown.Value;
                        DataMaster.UpdatePersistence(det);
                        total += det.Price;
                    }

                    listStock = DataMaster.GetListEq(typeof(TStock), TStock.ColumnNames.StockId, det.StockId, TStock.ColumnNames.ItemId, ItemId);

                    for (int k = 0; k < listStock.Count; k++)
                    {
                        stok = listStock[k] as TStock;
                        if (t.TransactionStatus == ListOfTransaction.Sales.ToString())
                        {
                            stok.StockPriceIn = itemPriceMaxNumericUpDown.Value;
                        }
                        else if (true)
                        {
                            stok.StockPriceOut = itemPricePurchaseNumericUpDown.Value;
                        }
                    }
                }

                if (listDet.Count > 0)
                {
                    t.TransactionSubTotal   = total;
                    t.TransactionGrandTotal = total;
                    if (t.TransactionPayment == ListOfPayment.Credit.ToString())
                    {
                        t.TransactionSisa = t.TransactionGrandTotal - t.TransactionPaid + t.TransactionPotongan;
                        t.TransactionPpn  = t.TransactionGrandTotal - t.TransactionPaid + t.TransactionPotongan;
                    }
                }
            }
        }