Hi
I want Sample Code to create Purchase order form ( using c#
Thanks
Hi
I want Sample Code to create Purchase order form ( using c#
Thanks
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Mayooran NavamanyRank #438 · 5.7K reputationPosted Jan 29, 2024, 9:32 AM EST
Below is a simple example of how you can create a purchase order form with multiple items using C# in a Windows Forms Application. This example assumes you have a basic understanding of C# and Visual Studio.
Open Visual Studio and create a new Windows Forms Application.
Add the necessary controls to your form. For this example, you can use labels, textboxes, buttons, and a DataGridView to display the items.
Here's a sample code for the form:
using System; using System.Collections.Generic; using System.Windows.Forms; namespace PurchaseOrderForm { public partial class PurchaseOrderForm : Form { // Define a class to represent an item in the purchase order public class PurchaseOrderItem { public string ItemName { get; set; } public int Quantity { get; set; } public decimal Price { get; set; } public decimal Total { get { return Quantity * Price; } } } private List items = new List(); public PurchaseOrderForm() { InitializeComponent(); } private void AddItemButton_Click(object sender, EventArgs e) { // Get input from user and add a new item to the list string itemName = ItemNameTextBox.Text; int quantity = int.Parse(QuantityTextBox.Text); decimal price = decimal.Parse(PriceTextBox.Text); PurchaseOrderItem newItem = new PurchaseOrderItem { ItemName = itemName, Quantity = quantity, Price = price }; items.Add(newItem); // Update the DataGridView with the items UpdateDataGridView(); // Clear input fields ItemNameTextBox.Clear(); QuantityTextBox.Clear(); PriceTextBox.Clear(); } private void UpdateDataGridView() { // Clear previous data and add items to the DataGridView dataGridView1.Rows.Clear(); foreach (var item in items) { dataGridView1.Rows.Add(item.ItemName, item.Quantity, item.Price, item.Total); } } private void SubmitButton_Click(object sender, EventArgs e) { // Perform actions when the user submits the purchase order // You can save the order, send it to a server, etc. // For this example, just display a message MessageBox.Show("Purchase Order Submitted!"); } } }In the designer, double-click on the "Add Item" button to generate the
AddItemButton_Clickevent handler.Similarly, double-click on the "Submit" button to generate the
SubmitButton_Clickevent handler.This is a basic example, and you might need to add error handling and validation based on your specific requirements.