Ejemplo n.º 1
0
        public void ShowList(itemMasterList list)
        {
            string sql = "SELECT [ITEMCODE],[ITEMNAME],[ITEMSORT],[ITEMPRICE],[ITEMSATUAN] FROM [standArtInvoicingDB].[dbo].[ITEM]";

            DataSet dataSet = DataProvider.GetDataSet(sql);

            //Create variable for dataset table
            DataTable itemTabel = dataSet.Tables[0];

            itemMaster nextItem = null;

            foreach (DataRow parentRow in itemTabel.Rows)
            {
                nextItem = new itemMaster();

                nextItem.Code   = parentRow["ITEMCODE"].ToString();
                nextItem.Name   = parentRow["ITEMNAME"].ToString();
                nextItem.Sort   = parentRow["ITEMSORT"].ToString();
                nextItem.Price  = Convert.ToDecimal(parentRow["ITEMPRICE"]);
                nextItem.Satuan = parentRow["ITEMSATUAN"].ToString();

                list.Add(nextItem);
            }
            dataSet.Dispose();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Add or update the Item record
        /// </summary>
        /// <param name="sql">
        /// The query string which will br run against, Make sure the parameter name is correct,
        /// Param = @code,@name, @sort, @price, @satuan
        /// </param>
        /// <param name="ItemMaster">The itemMaster object that will be passed</param>
        internal void AddorUpdateRecord(string sql, itemMaster ItemMaster)
        {
            try
            {
                //Create and open a connection
                SqlConnection connection = new SqlConnection(connectionString);
                connection.Open();

                //create and configure a command
                SqlCommand command = new SqlCommand(sql, connection);

                //Adding value through parameter
                command.CommandType = System.Data.CommandType.Text;
                command.Parameters.Clear();
                command.Parameters.AddWithValue("@code", ItemMaster.Code);
                command.Parameters.AddWithValue("@name", ItemMaster.Name);
                command.Parameters.AddWithValue("@sort", ItemMaster.Sort);
                command.Parameters.AddWithValue("@price", ItemMaster.Price);
                command.Parameters.AddWithValue("@satuan", ItemMaster.Satuan);

                //execute the command
                command.ExecuteNonQuery();

                //Close and dispose
                command.Dispose();
                connection.Close();
                connection.Dispose();
            }
            catch (SqlException ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }
Ejemplo n.º 3
0
        internal void CreateDatabaseRecord(itemMaster newItem)
        {
            string sql = "INSERT INTO ITEM " +
                         "(ITEMCODE, ITEMNAME, ITEMSORT, ITEMPRICE, ITEMSATUAN) "
                         + "OUTPUT INSERTED.ITEMCODE "
                         + "VALUES (@code, @name, @sort, @price, @satuan)";

            AddorUpdateRecord(sql, newItem);
        }
Ejemplo n.º 4
0
        private void deleteBtn_Click(object sender, EventArgs e)
        {
            if (m_ItemList == null)
            {
                return;
            }

            itemMaster m_item = (itemMaster)itemMasterBindingSource.Current;

            CommandDeleteItem deleteitem = new CommandDeleteItem(m_ItemList, m_item);
            itemMaster        itemDelete = (itemMaster)m_AppController.ExecuteCommand(deleteitem);
        }
Ejemplo n.º 5
0
        internal void UpdateDatabaseRecord(itemMaster changedItem)
        {
            //    if (string.IsNullOrEmpty(changedItem.Code))
            //    {
            //        MessageBox.Show("TRUE");
            //    }
            //    else
            //    {
            //        MessageBox.Show("FALSE");
            //    }
            string sql = "UPDATE ITEM SET " +
                         "itemName = @name, " +
                         "itemSort = @sort, " +
                         "itemPrice = @price, " +
                         "itemSatuan = @satuan " +
                         "WHERE itemCode = @code ";

            AddorUpdateRecord(sql, changedItem);
        }
Ejemplo n.º 6
0
        private void itemMasterBindingSource_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 authors
             * list has been passed in. */

            // Exit if no project list
            if (m_ItemList == null)
            {
                return;
            }

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

            if ((index > -1) && (index < m_ItemList.Count))
            {
                changedItem = m_ItemList[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 bindingSourceProjects_AddingNew(),
             * and deletes are handled by menuItemAuthorsDelete_Click(). */

            // Dispatch a change handler

            switch (changeType)
            {
            case ListChangedType.ItemChanged:
                CommandUpdateItem updateAuthor = new CommandUpdateItem(changedItem);
                m_AppController.ExecuteCommand(updateAuthor);
                break;

            case ListChangedType.ItemMoved:
                // Not supported in this app
                break;
            }
        }
Ejemplo n.º 7
0
        private void saveBtn_Click(object sender, EventArgs e)
        {
            if (m_ItemList == null)
            {
                return;
            }

            itemMaster m_item = (itemMaster)itemMasterBindingSource.Current;

            if (isNewRecord)
            {
                CommandCreateItem createItem = new CommandCreateItem(m_item);
                itemMaster        newItem    = (itemMaster)m_AppController.ExecuteCommand(createItem);
            }
            else if (!isNewRecord)
            {
                CommandUpdateItem updateItem = new CommandUpdateItem(m_item);
                itemMaster        changeItem = (itemMaster)m_AppController.ExecuteCommand(updateItem);
            }

            isNewRecord = false;
        }
Ejemplo n.º 8
0
 public CommandCreateItem(itemMaster newItem)
 {
     m_Item = newItem;
 }
Ejemplo n.º 9
0
 public CommandDeleteItem(itemMasterList list, itemMaster deleteItem)
 {
     m_List = list;
     m_Item = deleteItem;
 }
Ejemplo n.º 10
0
 public CommandUpdateItem(itemMaster changeItem)
 {
     m_Item = changeItem;
 }