
Hi
I want All Student marks CRUD operations with export excel functionality also in .net and all information should be display in the above grid format only Input fileds are - ID.NO.
NAME OF THE STUDENT
Sem. Final (50 M)
Quiz (10 M)
Mid. Sem (20 M)
Assignment including Record (10 M)
Final practical (10 M)
Total Internal + Practical (50 M) - This field is display based on below formula and should display automatic calculation values
|
(Total Internal + Practical (50 M)) = Quiz (10 M) + Mid. Sem (20 M) + Assignment including Record (10 M) + Final practical (10 M) |
Total Theory + Practical (100 M) - This field is display based on below formula and should display automatic calculation values
|
(Total Theory + Practical (100 M)) = Sem. Final (50 M) + (Total Internal + Practical (50 M)) |
Grade Point (10.00) - This field is display based on below formula and should display automatic calculation values
|
Grade Point (10.00) = (Total Theory + Practical (100 M) )* 10% |
Theory(%)
Practical(%)
Remarks -
Clicking on Remarks dropdown should display below options
PASS, FFT, FFP, AFT, AFP, Fail to get 5 GP
Should select any one option from the drop down
Sangeetha SPosted Feb 10, 2025, 11:59 AM
example with crud
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.IO;
using OfficeOpenXml; // Install EPPlus NuGet package
// Example Entity (replace with your actual entity)
public class Product
{
public int Id { get; set; }
public string Name { get; set; }
public decimal Price { get; set; }
public int Quantity { get; set; }
}
public class ProductManager products; // In-memory list for demonstration. Replace with database access.
{
private List
public ProductManager()();
{
products = new List
// Initialize with some sample data (replace with your data loading logic)
products.Add(new Product { Id = 1, Name = "Laptop", Price = 1200, Quantity = 10 });
products.Add(new Product { Id = 2, Name = "Mouse", Price = 25, Quantity = 50 });
}
// Create
public void AddProduct(Product product)
{
product.Id = products.Count + 1; // Simple ID generation for demo
products.Add(product);
}
// Read (All) GetAllProducts()
public List
{
return products;
}
// Read (Single)
public Product GetProductById(int id)
{
return products.FirstOrDefault(p => p.Id == id);
}
// Update
public void UpdateProduct(Product product)
{
var existingProduct = products.FirstOrDefault(p => p.Id == product.Id);
if (existingProduct != null)
{
existingProduct.Name = product.Name;
existingProduct.Price = product.Price;
existingProduct.Quantity = product.Quantity;
}
}
// Delete
public void DeleteProduct(int id)
{
var productToRemove = products.FirstOrDefault(p => p.Id == id);
if (productToRemove != null)
{
products.Remove(productToRemove);
}
}
// Export to Excel
public void ExportToExcel(string filePath)
{
using (var package = new ExcelPackage())
{
var worksheet = package.Workbook.Worksheets.Add("Products");
// Add header row
worksheet.Cells[1, 1].Value = "Id";
worksheet.Cells[1, 2].Value = "Name";
worksheet.Cells[1, 3].Value = "Price";
worksheet.Cells[1, 4].Value = "Quantity";
// Add data rows
for (int i = 0; i < products.Count; i++)
{
worksheet.Cells[i + 2, 1].Value = products[i].Id;
worksheet.Cells[i + 2, 2].Value = products[i].Name;
worksheet.Cells[i + 2, 3].Value = products[i].Price;
worksheet.Cells[i + 2, 4].Value = products[i].Quantity;
}
package.SaveAs(new FileInfo(filePath));
}
}
}
class Program
{
static void Main(string[] args)
{
var productManager = new ProductManager();
// Example usage:
// Create
productManager.AddProduct(new Product { Name = "Keyboard", Price = 75, Quantity = 20 });
// Read
var allProducts = productManager.GetAllProducts();
foreach (var product in allProducts)
{
Console.WriteLine($"Id: {product.Id}, Name: {product.Name}, Price: {product.Price}, Quantity: {product.Quantity}");
}
// Update
var productToUpdate = productManager.GetProductById(2);
if (productToUpdate != null)
{
productToUpdate.Price = 30;
productManager.UpdateProduct(productToUpdate);
}
// Delete
productManager.DeleteProduct(1);
// Export to Excel
productManager.ExportToExcel("products.xlsx"); // Save to products.xlsx
Console.WriteLine("Data exported to products.xlsx");
}
}