Posts

data grid view

 Form1.cs using System; using System.Data; using System.Windows.Forms; namespace StudentRecordsApp { public partial class Form1 : Form { DataTable dt = new DataTable(); public Form1() { InitializeComponent(); InitializeDataTable(); } private void InitializeDataTable() { dt.Columns.Add("Student ID"); dt.Columns.Add("Name"); dt.Columns.Add("Age"); dt.Columns.Add("Course"); dataGridView1.DataSource = dt; } private void btnAdd_Click(object sender, EventArgs e) { if (txtStudentID.Text == "" || txtName.Text == "" || txtAge.Text == "" || txtCourse.Text == "") { MessageBox.Show("Please fill in all fields.", "Missing Information", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } dt.Rows.Add(txtStudentID.Text, txtName.Text, txtAge.Text, txtCourse.Text); txtStudentID.Clear(); txtName.Clear(); txtAge.Clear(); txtCourse.Clear(); } } } Program.cs using System; using System.Collections.Generic;...

ADO.NET

    ADO.net  form1.cs using System; using System.Data; using System.Data.SqlClient; using System.Windows.Forms; namespace StudentsServiceDBApp {     public partial class Form1 : Form     {         string connectionString = @"Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\USERS\ABISHEK\DOCUMENTS\VISUAL STUDIO 2012\PROJECTS\STUDENTSSERVICEDBAPP\STUDENTSSERVICEDBAPP\STUDENTS.MDF;Integrated Security=True";         public Form1()         {             InitializeComponent();             AppDomain.CurrentDomain.SetData("DataDirectory", @"C:\USERS\ABISHEK\DOCUMENTS\VISUAL STUDIO 2012\PROJECTS\STUDENTSSERVICEDBAPP\STUDENTSSERVICEDBAPP");         }         private void Form1_Load(object sender, EventArgs e)         {             LoadData();     ...

Login Form

  Login.system.cs using System;  using System.Windows.Forms;    namespace UserLoginApp  {      public partial class LoginSystem : Form      {          private string validUsername = "admin";          private string validPassword = "1234";            public LoginSystem()          {              InitializeComponent();          }          private void btnLogin_Click(object sender, EventArgs e)          {              // Get user inputs              string username = txtUsername.Text;              string password = txtPassword.Text;              if (username == validUsername && pa...

Sales Bill Preparation using Interface

 using System; using System.Collections.Generic; interface IBill { void GenerateBill(); } class SalesBill : IBill { private List<string> itemNames = new List<string>(); private List<int> quantities = new List<int>(); private List<double> prices = new List<double>(); private double totalAmount = 0; public void AddItem(string itemName, int quantity, double price) { itemNames.Add(itemName); quantities.Add(quantity); prices.Add(price); totalAmount += quantity * price; } public void GenerateBill() { Console.WriteLine("\n========== SALES BILL =========="); Console.WriteLine("{0,-20} {1,-10} {2,-10} {3,-10}", "Item Name", "Quantity", "Price", "Total"); Console.WriteLine("---------------------------------------------"); for (int i = 0; i < itemNames.Count; i++) { double totalItemPrice = quantities[i] * prices[i]; Console.WriteLine("{0,-20} {1,-10} {2,-10} {3,-10}", itemNames[i...

Student Information using Inheritance

 using System; using System.Collections.Generic; class Person { public string Name { get; set; } public int Age { get; set; } public void DisplayPersonInfo() { Console.WriteLine("\n------------------------------"); Console.WriteLine("Name: " + Name); Console.WriteLine("Age: " + Age); } } class Student : Person { public int StudentID { get; set; } public string Course { get; set; } public void DisplayStudentInfo() { DisplayPersonInfo(); Console.WriteLine("Student ID: " + StudentID); Console.WriteLine("Course: " + Course); Console.WriteLine("------------------------------"); } } class Program { static void Main() { List<Student> students = new List<Student>(); string choice; do { Student student = new Student(); Console.Write("\nEnter Student Name: "); student.Name = Console.ReadLine(); Console.Write("Enter Student Age: "); student.Age = Convert.ToInt32(Console.ReadLine()); Console.Write("Ent...

Online Registration form

 Site1.Master  <%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site1.master.cs"  Inherits="OnlineRegistration.Site1" %>    <!DOCTYPE html>    <html>  <head>      <title>Online Registration Form</title>      <link rel="stylesheet" type="text/css" href="Styles.css" />  </head>  <body>      <form id="Form1" runat="server">          <div class="header">              <h1>Online Registration Form</h1>              <nav>                  <a href="Default.aspx">Home</a> |                  <a href="Register.aspx">Register</a>              </nav>    ...

Online Mobile Application

  Site1.Master  <%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site1.master.cs"  Inherits="OnlineMobilePhoneShop.Site1" %>    <!DOCTYPE html>    <html>  <head>      <title>Online Mobile Phone Shop</title>      <link rel="stylesheet" type="text/css" href="Styles.css" />  </head>  <body>      <form id="Form1" runat="server">          <div class="header">              <h1>Online Mobile Phone Shop</h1>              <nav>                  <a href="Default.aspx">Home</a> |                  <a href="Product.aspx">Products</a> |                  <a href=...