Beispiel #1
0
        internal void ShowList(RotiList list)
        {
            string sql = "SELECT [rotiID],[InvoiceID],[itemCode],[itemQty],[itemPrice],[discount],[subTotal] FROM [OTF_Invoice].[dbo].[invoiceDetail]";

            DataSet dataSet = DataProvider.GetDataSet(sql);

            //Creaete variable for dataSet table
            DataTable customerTabel = dataSet.Tables[0];

            rotiItem nextDetail = null;

            foreach (DataRow parentRow in customerTabel.Rows)
            {
                nextDetail = new rotiItem();

                nextDetail.ID        = Convert.ToInt32(parentRow["rotiID"]);
                nextDetail.Invoiceid = Convert.ToInt32(parentRow["InvoiceID"]);
                nextDetail.ItemCode  = parentRow["ItemCode"].ToString();
                nextDetail.Qty       = Convert.ToInt32(parentRow["itemQty"]);
                nextDetail.Price     = Convert.ToDecimal(parentRow["itemPrice"]);
                nextDetail.Discount  = Convert.ToDouble(parentRow["discount"]);
                //nextDetail.SubTotal = Convert.ToDecimal(parentRow["subTotal"]);

                list.Add(nextDetail);
            }

            dataSet.Dispose();
        }
Beispiel #2
0
        private void bindingItems_AddingNew(object sender, AddingNewEventArgs e)
        {
            //Create a new book
            InvoiceItem    parent     = (InvoiceItem)bindingInvoice.Current;
            CommandAddItem createItem = new CommandAddItem(parent.InvoiceID);
            rotiItem       newItem    = (rotiItem)m_AppController.ExecuteCommand(createItem);

            //Add it to the booklist
            e.NewObject = newItem;
        }
Beispiel #3
0
        private void bindingItem_ListChanged(object sender, ListChangedEventArgs e)
        {
            /* This event will be called several times during form initialization.
             * We don't want to do anything with it until the runtime author
             * list has been passed in. */

            // Exit if no parent
            InvoiceItem parent = (InvoiceItem)bindingInvoice.Current;

            if (parent == null)
            {
                return;
            }

            // Get the item affected
            int      index       = e.NewIndex;
            rotiItem changedItem = null;

            if ((index > -1) && (index < parent.Items.Count))
            {
                changedItem = parent.Items[index];
            }

            // Get the type of change that occured
            ListChangedType changeType = e.ListChangedType;

            /* We only need to respond to two types of changes here; updates
             * and moves. Adds are handled by bindingSourceAuthors_AddingNew(),
             * and deletes are handled by menuItemBooksDelete_Click(). */

            // Dispatch a change handler
            switch (changeType)
            {
            case ListChangedType.ItemChanged:
                if (changedItem.ItemCode != null)
                {
                    CommandUpdateItem updateItem = new CommandUpdateItem(changedItem);
                    m_AppController.ExecuteCommand(updateItem);
                }
                else
                {
                    CommandDeleteItem deleteItem = new CommandDeleteItem(changedItem);
                    m_AppController.ExecuteCommand(deleteItem);
                }

                break;

            case ListChangedType.ItemMoved:
                // Not supported in this app
                break;
            }

            m_Invoices.ResetBindings();
        }
Beispiel #4
0
        internal void CreateDatabaseRecord(rotiItem newRoti, int parentID)
        {
            //Built "insert" query
            String sql = string.Format("INSERT INTO invoiceDetail "
                                       + "(itemCode,invoiceID, itemQty, itemPrice) "
                                       + " OUTPUT INSERTED.rotiID  "
                                       + "VALUES ('0',{0},0,0)", parentID);
            //Execute Query
            int newRecordID = DataProvider.ExecuteScalar(sql);

            //Set record ID of new Object
            newRoti.ID = newRecordID;
        }
Beispiel #5
0
        public override object Execute()
        {
            /* Note that we will only create the book here and return it to the Projects
             * work panel. That's because the Books BindingSource object adds the
             * book to it's project. The BindingSource object  expects its e.NewObject
             * event arg to be set to the new object. Since the BookList is a bound
             * object, we will let the BindingSource object manage the addition. */

            // Create book
            //Creates a new Item Invoice
            rotiItem item = new rotiItem(m_ParentIDs);

            return(item);
        }
Beispiel #6
0
        internal void UpdateDatabaseRecord(rotiItem changedRoti)
        {
            StringBuilder sqlQuery = new StringBuilder("Update invoiceDetail SET ");

            sqlQuery.Append(String.Format("itemCode = '{0}', ", changedRoti.ItemCode));
            sqlQuery.Append(String.Format("itemQty = '{0}', ", changedRoti.Qty));
            sqlQuery.Append(String.Format("itemPrice = '{0}' , ", changedRoti.Price));
            sqlQuery.Append(String.Format("discount = '{0}' ,", changedRoti.Discount));
            sqlQuery.Append(String.Format("subTotal = '{0}' ", changedRoti.SubTotal));
            sqlQuery.Append(String.Format("WHERE rotiID = '{0}'", changedRoti.ID));

            //Execute Query
            DataProvider.ExecuteNonQuery(sqlQuery.ToString());
        }
        private void simpanBtn_Click(object sender, EventArgs e)
        {
            if (invoiceItemBindingSource.Current == null)
            {
                return;
            }
            InvoiceItem currentInvoice = (InvoiceItem)invoiceItemBindingSource.Current;

            switch (FrmStatus)
            {
            case FormStatus.OnEditMode:
                FrmStatus = FormStatus.Ready;

                CommandUpdateInvoice updateInvoice = new CommandUpdateInvoice(currentInvoice);
                m_AppController.ExecuteCommand(updateInvoice);

                foreach (DataGridViewRow row in dgItem.Rows)
                {
                    rotiItem item = row.DataBoundItem as rotiItem;
                    if (item != null)
                    {
                        CommandUpdateItem updateItem = new CommandUpdateItem(item);
                        m_AppController.ExecuteCommand(updateItem);
                    }
                }

                break;

            case FormStatus.Ready:
                FrmStatus = FormStatus.OnEditMode;
                break;

            case FormStatus.NewRecord:
                CommandInsertByDetailInvoice newInvoice = new CommandInsertByDetailInvoice(currentInvoice);
                m_AppController.ExecuteCommand(newInvoice);
                break;
            }
        }
Beispiel #8
0
        private void deleteBookToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //Get Item Roti
            InvoiceItem parent = (InvoiceItem)bindingInvoice.Current;

            //Confirm Delete
            string       message = String.Format("Delete Items ? ");
            DialogResult result  = MessageBox.Show(message, "Confirm Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

            //Delete Item
            if (result == DialogResult.Yes)
            {
                foreach (DataGridViewRow row in dgItem.SelectedRows)
                {
                    rotiItem item = row.DataBoundItem as rotiItem;
                    if (item != null)
                    {
                        CommandDeleteItem deleteItem = new CommandDeleteItem(parent, item);
                        m_AppController.ExecuteCommand(deleteItem);
                    }
                }
            }
        }
Beispiel #9
0
 public CommandUpdateItem(rotiItem rotiToUpdate)
 {
     m_rotiToUpdate = rotiToUpdate;
 }
Beispiel #10
0
        public void LoadInvoiceList(InvoiceList invoiceList)
        {
            //Build query to get Invoice's and their roti
            StringBuilder sqlQuery = new StringBuilder();

            sqlQuery.Append(String.Format("Select invoiceID, noInvoice, dueDate, invoiced.outletCode, OUTLET.OUTLNAME, subTotal, ppn, total, issuedDate, isPPN, nomorPO, Periode, Pengguna, id_payment, isPayed FROM invoiced INNER JOIN OUTLET ON invoiced.outletCode = OUTLET.OUTLCODE ;"));
            sqlQuery.Append(string.Format("Select rotiID, invoiceID, itemCode, itemQty, itemPrice, discount, subTotal FROM invoiceDetail"));

            //Get a data set from the query
            DataSet dataSet = DataProvider.GetDataSet(sqlQuery.ToString());

            //Create Variables for data set tables
            DataTable invoiceTable = dataSet.Tables[0];
            DataTable detailTable  = dataSet.Tables[1];

            //Create a data relation from invoice (parent table) to detail Invoice
            DataColumn   parentColumn    = invoiceTable.Columns["invoiceID"];
            DataColumn   childColumn     = detailTable.Columns["invoiceID"];
            DataRelation invoiceToDetail = new DataRelation("invoiceToDetail", parentColumn, childColumn, false);

            dataSet.Relations.Add(invoiceToDetail);

            //Load InvoiceList from the data set
            InvoiceItem nextInvoice = null;
            rotiItem    nextRoti    = null;

            foreach (DataRow parentRow in invoiceTable.Rows)
            {
                //Create a new invoice
                bool createDatabaseRecord = false;
                nextInvoice = new InvoiceItem(createDatabaseRecord);

                //Fill in invoice properties
                nextInvoice.InvoiceID  = Convert.ToInt32(parentRow["invoiceID"]);
                nextInvoice.Nomor      = parentRow["noInvoice"].ToString();
                nextInvoice.DueDate    = Convert.ToDateTime(parentRow["dueDate"]);
                nextInvoice.OutletCode = parentRow["outletCode"].ToString();

                //nextInvoice.SubTotal = Convert.ToDecimal(parentRow["subTotal"]);
                nextInvoice.PPN = Convert.ToInt32(parentRow["ppn"]);
                //nextInvoice.Total = Convert.ToDecimal(parentRow["total"]);
                nextInvoice.IssuedData = Convert.ToDateTime(parentRow["issuedDate"]);
                nextInvoice.IsPPN      = Convert.ToBoolean(parentRow["isPPN"]);
                nextInvoice.NomorPO    = parentRow["nomorPO"].ToString();
                nextInvoice.User       = parentRow["pengguna"].ToString();

                //Get Invoice Item
                DataRow[] childRows = parentRow.GetChildRows(invoiceToDetail);

                //Create invoiceItem object foe each of the invoice
                foreach (DataRow childRow in childRows)
                {
                    //Create a new item
                    nextRoti = new rotiItem();

                    //Fill in roti's properties
                    nextRoti.ID        = Convert.ToInt32(childRow["rotiID"]);
                    nextRoti.Invoiceid = Convert.ToInt32(childRow["invoiceID"]);
                    nextRoti.ItemCode  = childRow["itemCode"].ToString();
                    nextRoti.Qty       = Convert.ToInt32(childRow["itemQty"]);
                    nextRoti.Price     = Convert.ToDecimal(childRow["itemPrice"]);
                    nextRoti.Discount  = Convert.ToDouble(childRow["discount"]);
                    //nextRoti.SubTotal = Convert.ToDecimal(childRow["Subtotal"]);

                    //Add roti to invoice
                    if (nextRoti.ItemCode != "0")
                    {
                        nextInvoice.Items.Add(nextRoti);
                    }
                    else
                    {
                        nextRoti.DeleteDatabaseRecord();
                    }
                }

                //Add the invoice to the invoice List
                invoiceList.Add(nextInvoice);
            }

            //Dispose of the dataset
            dataSet.Dispose();
        }
 public CommandDeleteItem(InvoiceItem parent, rotiItem rotiToDelete)
 {
     m_parent       = parent;
     m_rotiToDelete = rotiToDelete;
 }
 public CommandDeleteItem(rotiItem rotiToDelete)
 {
     m_rotiToDelete = rotiToDelete;
 }