Exemplo n.º 1
0
        void financeIdComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            IList list = new List <TTransaction>();

            if (financeIdComboBox.SelectedIndex != 0)
            {
                NHibernate.Expression.ICriterion[] expArrays = new NHibernate.Expression.ICriterion[3];
                expArrays[0] = NHibernate.Expression.Expression.Eq(TTransaction.ColumnNames.TransactionDesc2, financeIdComboBox.SelectedValue.ToString());

                expArrays[1] = NHibernate.Expression.Expression.Eq(TTransaction.ColumnNames.TransactionStatus, ListOfTransaction.Sales.ToString());

                //sisa utang tidak nol
                expArrays[2] = NHibernate.Expression.Expression.Not(NHibernate.Expression.Expression.Eq(TTransaction.ColumnNames.TransactionPpn, decimal.Zero));

                NHibernate.Expression.Order[] orderArrays = new NHibernate.Expression.Order[1];
                orderArrays[0] = NHibernate.Expression.Order.Asc(TTransaction.ColumnNames.TransactionDate);

                list = DataMaster.GetList(typeof(TTransaction), expArrays, orderArrays);
                for (int i = 0; i < list.Count; i++)
                {
                    TTransaction t = list[i] as TTransaction;
                    t.TransactionByName = AppCode.GetCustomerName(t.TransactionBy, true);
                }
            }
            tTransactionBindingSource.DataSource = list;
        }
Exemplo n.º 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;
                    }
                }
            }
        }