protected void Page_Load(object sender, EventArgs e)
        {
            TransactionReport newTR = new TransactionReport();

            CrystalReportViewer1.ReportSource = newTR;
            newTR.SetDataSource(GenerateData(HeaderTransactionController.gettAllHeaderTransaction()));
        }
Esempio n. 2
0
        protected void CheckOutBtn_Click(object sender, EventArgs e)
        {
            int userId        = getUserId();
            int PaymentTypeId = getPaymentTypeId();

            int         headerTransactionId = HeaderTransactionController.doInsertHeaderTransaction(userId, PaymentTypeId);
            List <Cart> cartList            = CartController.getCartbyUserId(userId);

            for (int i = 0; i < cartList.Count; i++)
            {
                TransactionApprovementController.doInsertDetailTransaction(headerTransactionId, cartList.ElementAt(i).ProductID, cartList.ElementAt(i).Quantity);
            }

            //Remove Cart
            CartController.deleteAlLCartByUser(userId);

            Response.Redirect("./Home.aspx");
        }
        protected void LoadTransaction()
        {
            int userId = getUserId();
            List <HeaderTransaction> headerTransactionList = HeaderTransactionController.getHeaderTransactionById(userId);

            if (headerTransactionList.Count < 1)
            {
                SpaceUp.Visible   = true;
                LblEmpty.Text     = "You have not do any Payment yet";
                SpaceDown.Visible = true;
                HeaderTransactionHistoryTable.Visible = false;
            }
            else
            {
                for (int i = 0; i < headerTransactionList.Count; i++)
                {
                    TableRow newRow = new TableRow();
                    HeaderTransactionHistoryTable.Controls.Add(newRow);

                    TableCell numberCell = new TableCell();
                    numberCell.Controls.Add(new Label()
                    {
                        Text = (i + 1) + "."
                    });
                    newRow.Cells.Add(numberCell);

                    TableCell transactionIdCell = new TableCell();
                    transactionIdCell.Controls.Add(new Label()
                    {
                        Text = headerTransactionList.ElementAt(i).ID.ToString()
                    });
                    newRow.Cells.Add(transactionIdCell);

                    string    paymentTypeName = getPaymentTypeName(headerTransactionList.ElementAt(i).PaymentTypeID);
                    TableCell paymentTypeCell = new TableCell();
                    paymentTypeCell.Controls.Add(new Label()
                    {
                        Text = paymentTypeName
                    });
                    newRow.Cells.Add(paymentTypeCell);

                    TableCell transactionDateCell = new TableCell();
                    transactionDateCell.Controls.Add(new Label()
                    {
                        Text = headerTransactionList.ElementAt(i).Date.ToString("dd-MM-yyy")
                    });
                    newRow.Cells.Add(transactionDateCell);

                    TableCell DetailButtonCell = new TableCell();
                    Button    DetailButton     = new Button()
                    {
                        ID       = (i + 1) + "_D",
                        Text     = "Detail",
                        CssClass = "btn btn-secondary"
                    };
                    DetailButton.Click += DetailButton_Click;
                    DetailButtonCell.Controls.Add(DetailButton);
                    newRow.Cells.Add(DetailButtonCell);
                }

                SpaceTable.Visible = true;
            }
        }
        protected void LoadAllTransaction()
        {
            List <HeaderTransaction> headerTransactionList = HeaderTransactionController.gettAllHeaderTransaction();

            if (headerTransactionList.Count < 1)
            {
                SpaceUp.Visible   = true;
                LblEmpty.Text     = "There's No Payment Available";
                SpaceDown.Visible = true;
                HeaderTransactionHistoryTable.Visible = false;
            }
            else
            {
                for (int i = 0; i < headerTransactionList.Count; i++)
                {
                    TableRow newRow = new TableRow();
                    AllHeaderTransaction.Controls.Add(newRow);

                    TableCell numberCell = new TableCell();
                    numberCell.Controls.Add(new Label()
                    {
                        Text = (i + 1) + "."
                    });
                    newRow.Cells.Add(numberCell);

                    TableCell transactionIdCell = new TableCell();
                    transactionIdCell.Controls.Add(new Label()
                    {
                        Text = headerTransactionList.ElementAt(i).ID.ToString()
                    });
                    newRow.Cells.Add(transactionIdCell);

                    TableCell transactionNameCell = new TableCell();
                    transactionNameCell.Controls.Add(new Label()
                    {
                        Text = headerTransactionList.ElementAt(i).User.Name.ToString()
                    });
                    newRow.Cells.Add(transactionNameCell);

                    //Cari paymentName dari PaymentId nya
                    string    paymentTypeName = getPaymentTypeName(headerTransactionList.ElementAt(i).PaymentTypeID);
                    TableCell paymentTypeCell = new TableCell();
                    paymentTypeCell.Controls.Add(new Label()
                    {
                        Text = paymentTypeName
                    });
                    newRow.Cells.Add(paymentTypeCell);

                    TableCell transactionDateCell = new TableCell();
                    transactionDateCell.Controls.Add(new Label()
                    {
                        Text = headerTransactionList.ElementAt(i).Date.ToString("dd-MM-yyy")
                    });
                    newRow.Cells.Add(transactionDateCell);

                    TableCell DetailButtonCell = new TableCell();
                    Button    DetailButton     = new Button()
                    {
                        ID       = (i + 1) + "_D",
                        Text     = "Detail",
                        CssClass = "btn btn-secondary"
                    };
                    DetailButton.Click += DetailButton_Click;
                    DetailButtonCell.Controls.Add(DetailButton);
                    newRow.Cells.Add(DetailButtonCell);
                }
                SpaceTable.Visible = true;
            }
        }
        protected void LoadDetailTransaction()
        {
            int transactionId = Convert.ToInt32(Request.QueryString["ID"]);
            List <DetailTransaction> detailTransactionList = DetailTransactionController.getDetailTransactionById(transactionId);

            int userId           = getUserId();
            HeaderTransaction ht = HeaderTransactionController.getHeaderTransactionByTransactionId(transactionId);

            int subtotal   = 0;
            int grandtotal = 0;

            for (int i = 0; i < detailTransactionList.Count; i++)
            {
                TableRow newRow = new TableRow();
                HeaderTransactionHistoryTable.Controls.Add(newRow);

                TableCell numberCell = new TableCell();
                numberCell.Controls.Add(new Label()
                {
                    // Letak Masukkin Nomor
                    Text = (i + 1) + "."
                });
                newRow.Cells.Add(numberCell);

                //Cari nama Product dari product
                int     productId = detailTransactionList.ElementAt(i).ProductID;
                Product products  = ProductController.getProductById(productId);

                TableCell TransactionProductNameCell = new TableCell();
                TransactionProductNameCell.Controls.Add(new Label()
                {
                    Text = products.Name
                });
                newRow.Cells.Add(TransactionProductNameCell);


                //Quantity
                TableCell TransactionProductQuantityCell = new TableCell();
                TransactionProductQuantityCell.Controls.Add(new Label()
                {
                    Text = detailTransactionList.ElementAt(i).Quantity.ToString()
                });
                newRow.Cells.Add(TransactionProductQuantityCell);


                //Subtotal
                subtotal = (products.Price * detailTransactionList.ElementAt(i).Quantity);
                TableCell subTotalCell = new TableCell();
                subTotalCell.Controls.Add(new Label()
                {
                    Text = "Rp. " + subtotal.ToString()
                });
                newRow.Cells.Add(subTotalCell);


                //GrandTotal
                grandtotal = grandtotal + subtotal;
            }

            PaymentType pays = PaymentTypeController.getPaymentTypeById(ht.PaymentTypeID);

            LblGrandTotal.Text      = "Rp. " + grandtotal.ToString();
            LblPaymentType.Text     = pays.Type.ToString();
            LblTransactionDate.Text = ht.Date.ToString("dd-MM-yyyy");
        }