Dotnet : Vehicle Management System Project With Source Code


Previous Project with Source Code :

  1. Stock Management System Project With Source Code
  2. Library Management System Project With Source Code
  3. School Management System Project With Source Code
payment vehicle management system project

  • Vehicle Management System Project mostly deals with Vehicle Information System, Customer Info and Car services.
  • This Project was not developed in 3 tier architecture, but this project give some idea how to develop in C#.NET for Beginner's/Fresher's.
  • The Modules of Vehicle Management System : Vehicle, Customer, Servicing, Status of Servicing, Payment.
  • The Database for Vehicle Management System : Vehicle Table, Customer Table, Service Table, Payment Table.


Customer Details ( Add | Edit | Delete )

In this above form is used to register new customer details and we can modify existing customer details and also Delete unnecessary customer.

Vehicle Management system Project with source code

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data;
using System.Data.SqlClient;

namespace Vehicle_Management_System.Cust
{
    public partial class Customer : Form
    {
        string query;
        SqlConnection con = new SqlConnection("Server=.; Database = VHS; Trusted_Connection = Yes;");
        SqlCommand cmd;
        SqlDataAdapter da;
        string n = null;
        
        public Customer()
        {            
            InitializeComponent();
            txt_del_cust_id.Visible = false;
        }

        private void get_Veh_Model()
        {
            query = "Select * from Vehicle";
            da = new SqlDataAdapter(query, con);
            DataSet ds_v_name = new System.Data.DataSet();
            int c_count = da.Fill(ds_v_name);
            if (c_count > 0)
            {
                cb_prefer_car_model.DataSource = ds_v_name.Tables[0];
                cb_prefer_car_model.ValueMember = "v_name";
                string carmodel = cb_prefer_car_model.SelectedValue.ToString();
                if (carmodel == ds_v_name.Tables[0].Rows[0]["v_name"].ToString())
                {
                    groupBox2.Visible = true;
                    txt_vehicle_name.Text = ds_v_name.Tables[0].Rows[0]["v_manu_name"].ToString();
                    txt_vehicle_model.Text = ds_v_name.Tables[0].Rows[0]["v_model"].ToString();
                    txt_vehicle_manu_year.Text = ds_v_name.Tables[0].Rows[0]["v_manu_year"].ToString();
                    txt_vehicle_cost.Text = ds_v_name.Tables[0].Rows[0]["v_price"].ToString();                    
                }
            }
        }
        private void get_single_veh_model(string value)
        {
            query = "Select * from Vehicle where v_name='" + value + "'";
            da = new SqlDataAdapter(query, con);
            DataSet ds_v_name = new System.Data.DataSet();
            int c_count = da.Fill(ds_v_name);
            if (c_count > 0)
            {
                cb_prefer_car_model.DataSource = ds_v_name.Tables[0];
                cb_prefer_car_model.ValueMember = "v_name";
                string carmodel = cb_prefer_car_model.SelectedValue.ToString();
                if (carmodel == ds_v_name.Tables[0].Rows[0]["v_name"].ToString())
                {
                    groupBox2.Visible = true;
                    txt_vehicle_name.Text = ds_v_name.Tables[0].Rows[0]["v_manu_name"].ToString();
                    txt_vehicle_model.Text = ds_v_name.Tables[0].Rows[0]["v_model"].ToString();
                    txt_vehicle_manu_year.Text = ds_v_name.Tables[0].Rows[0]["v_manu_year"].ToString();
                    txt_vehicle_cost.Text = ds_v_name.Tables[0].Rows[0]["v_price"].ToString();
                }
            }
            get_Veh_Model();
        }

        private void Customer_Load(object sender, EventArgs e)
        {
            btn_customer_getdetails.Visible = false;
            btn_customer_delete.Visible = false;
            btn_customer_update.Visible = false;
            btn_customer_adddetails.Visible = true;
            groupBox2.Visible = false;
            get_Veh_Model();
        }

        private void btn_editcustomer_Click(object sender, EventArgs e)
        {
            groupBox1.Text = "Edit Customer";
            lbl_error.Text = "";

            btn_addcustomer.BackColor = Color.Black;
            btn_editcustomer.BackColor = Color.Purple;
            btn_deletecustomer.BackColor = Color.Black;

            btn_customer_delete.Visible = false;
            btn_customer_update.Visible = false;
            btn_customer_cancel.Visible = false;
            btn_customer_adddetails.Visible = false;
            btn_customer_getdetails.Visible = true;

            SilverTextbox();
            ClearTextbox();
            txt_del_cust_id.Visible = false;
            
        }

        private void btn_deletecustomer_Click(object sender, EventArgs e)
        {
            groupBox1.Text = "Delete Customer";
            lbl_error.Text = "( Please Enter Customer ID : )" ;

            btn_addcustomer.BackColor = Color.Black;
            btn_editcustomer.BackColor = Color.Black;
            btn_deletecustomer.BackColor = Color.Purple;

            btn_customer_delete.Visible = true;
            btn_customer_update.Visible = false;
            btn_customer_cancel.Visible = true;
            btn_customer_adddetails.Visible = false;
            btn_customer_getdetails.Visible = false;

            SilverTextbox();
            ClearTextbox();
            txt_del_cust_id.Visible = true;
        }

        private void btn_addcustomer_Click(object sender, EventArgs e)
        {
            groupBox1.Text = "Add Customer";
            lbl_error.Text = "";
            WhiteTextbox();
            btn_addcustomer.BackColor = Color.Purple;
            btn_editcustomer.BackColor = Color.Black;
            btn_deletecustomer.BackColor = Color.Black;

            btn_customer_delete.Visible = false;
            btn_customer_update.Visible = false;
            btn_customer_cancel.Visible = true;
            btn_customer_adddetails.Visible = true;
            btn_customer_getdetails.Visible = false;
            ClearTextbox();
            txt_del_cust_id.Visible = false;
        }

        private void btn_customer_getdetails_Click(object sender, EventArgs e)
        {
            btn_customer_delete.Visible = false;
            btn_customer_update.Visible = true;
            btn_customer_cancel.Visible = true;
            btn_customer_adddetails.Visible = false;
            btn_customer_getdetails.Visible = false;
            WhiteTextbox();

            get_cust_details(txt_customerid.Text);
        }
        private void get_cust_details(string cid)
        {           
                query = " select * from Customer where c_id='" + cid + "'";
                DataSet ds_get_cust = new System.Data.DataSet();
                da = new SqlDataAdapter(query, con);
                int n_get_cust = da.Fill(ds_get_cust);
                if (n_get_cust > 0)
                {
                    if (cid == ds_get_cust.Tables[0].Rows[0]["c_id"].ToString().Trim())
                    {
                        string _gender;
                        txt_customername.Text = ds_get_cust.Tables[0].Rows[0]["c_name"].ToString();
                        _gender = ds_get_cust.Tables[0].Rows[0]["c_gender"].ToString().Trim();
                        if (_gender == "Male")
                        {
                            rb_Male.Checked = true;
                            rb_Female.Checked = false;
                        }
                        else
                        {
                            rb_Male.Checked = false;
                            rb_Female.Checked = true;
                        }
                        cb_date.Text = ds_get_cust.Tables[0].Rows[0]["c_date"].ToString();
                        cb_month.Text = ds_get_cust.Tables[0].Rows[0]["c_month"].ToString();
                        cb_year.Text = ds_get_cust.Tables[0].Rows[0]["c_year"].ToString();
                        txt_customer_address.Text = ds_get_cust.Tables[0].Rows[0]["c_address"].ToString();
                        txt_customer_phone.Text = ds_get_cust.Tables[0].Rows[0]["c_phone"].ToString();
                        string _carmodel = ds_get_cust.Tables[0].Rows[0]["c_prefer_car_model"].ToString();
                        get_single_veh_model(_carmodel);
                    }
                    else
                    {
                        ClearTextbox();
                    }
                }
                else
                {
                    ClearTextbox();
                }
            
        }

        private void SilverTextbox()
        {
            txt_customername.Enabled = false;
            txt_customer_phone.Enabled = false;
            txt_customer_address.Enabled = false;
            rb_Female.Enabled = false;
            rb_Male.Enabled = false;
            cb_date.Enabled = false;
            cb_month.Enabled = false;
            cb_year.Enabled = false;
            cb_prefer_car_model.Enabled = false;

        }
        private void WhiteTextbox()
        {
            txt_customername.Enabled = true;
            txt_customer_phone.Enabled = true;
            txt_customer_address.Enabled = true;

            rb_Female.Enabled = true;
            rb_Male.Enabled = true;

            cb_date.Enabled = true;
            cb_month.Enabled = true;
            cb_year.Enabled = true;
            cb_prefer_car_model.Enabled = true;

        }
        private void ClearTextbox()
        {
            txt_customername.Text = "";
            txt_customer_phone.Text = "";
            txt_customer_address.Text = "";

            rb_Female.Checked = false;
            rb_Male.Checked = true;

            cb_date.Text = "Date";
            cb_month.Text = "Month";
            cb_year.Text = "Year";
        }

        private void cb_prefer_car_model_SelectedIndexChanged(object sender, EventArgs e)
        {
            string c1;
            c1 = cb_prefer_car_model.SelectedValue.ToString();

            query = "Select * from Vehicle where v_name='" + cb_prefer_car_model.SelectedValue.ToString() + "'";
            da = new SqlDataAdapter(query, con);
            DataSet ds_v_name = new System.Data.DataSet();
            int c_count = da.Fill(ds_v_name);
            if (c_count > 0)
            {
                //cb_prefer_car_model.DataSource = ds_v_name.Tables[0];
                //cb_prefer_car_model.ValueMember = "v_name";
                string carmodel = cb_prefer_car_model.SelectedValue.ToString();
                if (carmodel == ds_v_name.Tables[0].Rows[0]["v_name"].ToString())
                {
                    groupBox2.Visible = true;
                    txt_vehicle_name.Text = ds_v_name.Tables[0].Rows[0]["v_manu_name"].ToString();
                    txt_vehicle_model.Text = ds_v_name.Tables[0].Rows[0]["v_model"].ToString();
                    txt_vehicle_manu_year.Text = ds_v_name.Tables[0].Rows[0]["v_manu_year"].ToString();
                    txt_vehicle_cost.Text = ds_v_name.Tables[0].Rows[0]["v_price"].ToString();
                    //get_Veh_Model();
                }
            }
        }
        /*
        private void cb_prefer_car_model_SelectedValueChanged(object sender, EventArgs e)
        {
            
        }
        **/
        private void btn_customer_delete_Click(object sender, EventArgs e)
        {
            query = "Delete Customer where c_id='" + txt_customerid.Text + "'";
            cmd = new SqlCommand(query, con);
            con.Open();
            int n_del = cmd.ExecuteNonQuery();
            if (n_del > 0)
            {
                MessageBox.Show("Delete Successfully...");
                con.Close();
            }
        }

        private void btn_customer_adddetails_Click(object sender, EventArgs e)
        {            
            string gender;
            if(rb_Female.Checked==true)
            {
                gender=rb_Female.Text;
            }
            else{
                gender=rb_Male.Text;
            }
            query = "Insert into Customer(c_id, c_name, c_gender, c_date, c_month, c_year, c_address, c_phone, c_prefer_car_model) values('" + txt_customerid.Text + "', '" + txt_customername.Text + "', '" + gender + "', '" + cb_date.Text + "','" + cb_month.Text + "', '" + cb_year.Text + "', '" + txt_customer_address.Text + "', '" + txt_customer_phone.Text + "', '" + cb_prefer_car_model.Text + "')";
            cmd = new SqlCommand(query, con);
            con.Open();
            int cust_count = cmd.ExecuteNonQuery();
            if (cust_count > 0)
            {
                MessageBox.Show("Insert Successfully...");
                con.Close();
            }
        }

        private void btn_customer_update_Click(object sender, EventArgs e)
        {
            string gender;
            if(rb_Female.Checked==true)
            {
                gender=rb_Female.Text;
            }
            else{
                gender=rb_Male.Text;
            }
            query = "Update Customer set c_name='" + txt_customername.Text + "', c_gender='" + gender + "', c_date='" + cb_date.Text + "', c_month='" + cb_month.Text + "', c_year='" + cb_year.Text + "', c_address='" + txt_customer_address.Text + "', c_phone='" + txt_customer_phone.Text + "', c_prefer_car_model='" + cb_prefer_car_model.Text + "' where c_id='" + txt_customerid.Text + "'";
            cmd = new SqlCommand(query, con);
            con.Open();
            int n_update = cmd.ExecuteNonQuery();
            if (n_update > 0)
            {
                MessageBox.Show("Updated Successfully...");
                con.Close();
            }
        }

        private void btn_customer_cancel_Click(object sender, EventArgs e)
        {
            ClearTextbox();
        }

        private void txt_del_cust_id_TextChanged(object sender, EventArgs e)
        {
            get_cust_details(txt_del_cust_id.Text);
        }
    }
}

Vehicle Details ( Add | Edit | Delete )


vehicle management system project

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data;
using System.Data.SqlClient;

namespace Vehicle_Management_System
{
    public partial class Vehicle : Form
    {
        string query;
        SqlConnection con = new SqlConnection("Server=.; Database = VHS; Trusted_Connection = Yes;");
        SqlCommand cmd;
        SqlDataAdapter da;

        public Vehicle()
        {
            InitializeComponent();
        }

        private void Vehicle_Load(object sender, EventArgs e)
        {
            btn_vehicle_update.Visible = false;
            btn_vehicle_delete.Visible = false;
            btn_vehicle_getdetails.Visible = false;
            lbl_error.Text = "";
            txt_vid_delete.Visible = false;
        }

        private void btn_editvehicle_Click(object sender, EventArgs e)
        {
            groupBox1.Text = "Edit Vehicle";
            lbl_error.Text = "";
            btn_addvehicle.ForeColor = Color.Silver;
            btn_addvehicle.BackColor = Color.Black;
            btn_editvehicle.ForeColor = Color.White;
            btn_editvehicle.BackColor = Color.Blue;
            btn_deletevehicle.ForeColor = Color.Silver;
            btn_deletevehicle.BackColor = Color.Black;

            TextBoxClear();

            btn_vehicle_submit.Visible = false;
            btn_vehicle_cancel.Visible = false;
            btn_vehicle_update.Visible = false;
            btn_vehicle_delete.Visible = false;
            txt_vid_delete.Visible = false;

            btn_vehicle_getdetails.Visible = true;


            SilverTextbox();

            //btn_vehicle_submit.Visible = false;
            //btn_vehicle_update.Visible = true;
        }

        private void SilverTextbox()
        {
            txt_veh_manu_name.Enabled = false;
            txt_vehiclename.Enabled = false;
            cb_vehiclemodel.Enabled = false;
            txt_vehicle_chassisno.Enabled = false;
            txt_vehicle_engineno.Enabled = false;
            txt_vehicle_manu_year.Enabled = false;
            txt_vehicle_price.Enabled = false;
            txt_vehicle_stock.Enabled = false;
        }
        private void WhiteTextbox()
        {
            txt_veh_manu_name.Enabled = true;
            txt_vehiclename.Enabled = true;
            cb_vehiclemodel.Enabled = true;
            txt_vehicle_chassisno.Enabled = true;
            txt_vehicle_engineno.Enabled = true;
            txt_vehicle_manu_year.Enabled = true;
            txt_vehicle_price.Enabled = true;
            txt_vehicle_stock.Enabled = true;
            txt_vid_delete.Visible = false;

        }
        private void TextBoxClear()
        {
            txt_vehicleid.Text = "";
            txt_veh_manu_name.Text = "";
            txt_vehiclename.Text = "";
            cb_vehiclemodel.Text = "";
            txt_vehicle_chassisno.Text = "";
            txt_vehicle_engineno.Text = "";
            txt_vehicle_manu_year.Text = "";
            txt_vehicle_price.Text = "";
            txt_vehicle_stock.Text = "";            
            //txt_vid_delete.Text = "";
        }

        private void btn_vehicle_getdetails_Click(object sender, EventArgs e)
        {
            WhiteTextbox();
            lbl_error.Text = "";
            btn_vehicle_getdetails.Visible = false;

            btn_vehicle_update.Visible = true;
            btn_vehicle_cancel.Visible = true;
            btn_vehicle_delete.Visible = false;
            txt_vid_delete.Visible = false;

            query = "Select * from Vehicle where v_id='" + txt_vehicleid.Text + "'";
            da = new SqlDataAdapter(query, con);
            DataSet ds_get = new System.Data.DataSet();
            int _getcount = da.Fill(ds_get);
            if (_getcount > 0)
            {
                txt_veh_manu_name.Text=ds_get.Tables[0].Rows[0]["v_manu_name"].ToString();
                txt_vehiclename.Text = ds_get.Tables[0].Rows[0]["v_name"].ToString();
                cb_vehiclemodel.Text = ds_get.Tables[0].Rows[0]["v_model"].ToString();
                txt_vehicle_chassisno.Text = ds_get.Tables[0].Rows[0]["v_chasis_no"].ToString();
                txt_vehicle_engineno.Text = ds_get.Tables[0].Rows[0]["v_engine_no"].ToString();
                txt_vehicle_manu_year.Text = ds_get.Tables[0].Rows[0]["v_manu_year"].ToString();
                txt_vehicle_price.Text = ds_get.Tables[0].Rows[0]["v_price"].ToString();
                txt_vehicle_stock.Text = ds_get.Tables[0].Rows[0]["v_stock"].ToString();
            }
        }

        private void btn_addvehicle_Click(object sender, EventArgs e)
        {
            groupBox1.Text = "Add Vehicle";
            TextBoxClear();
            lbl_error.Text = "";
            WhiteTextbox();
            btn_addvehicle.ForeColor = Color.White;
            btn_addvehicle.BackColor = Color.Blue;
            btn_editvehicle.ForeColor = Color.Silver;
            btn_editvehicle.BackColor = Color.Black;
            btn_deletevehicle.ForeColor = Color.Silver;
            btn_deletevehicle.BackColor = Color.Black;

            btn_vehicle_getdetails.Visible = false;

            btn_vehicle_submit.Visible = true;
            btn_vehicle_update.Visible = false;
            btn_vehicle_delete.Visible = false;
            btn_vehicle_cancel.Visible = true;
            txt_vid_delete.Visible = false;
        }

        private void btn_deletevehicle_Click(object sender, EventArgs e)
        {
            groupBox1.Text = "Delete Vehicle";
            lbl_error.Text = "(Please Enter Vehicle ID :)";
            TextBoxClear();
            SilverTextbox();
            txt_vid_delete.Visible = true;

            btn_deletevehicle.ForeColor = Color.White;
            btn_deletevehicle.BackColor = Color.Blue;
            btn_addvehicle.ForeColor = Color.Silver;
            btn_addvehicle.BackColor = Color.Black;
            btn_editvehicle.ForeColor = Color.Silver;
            btn_editvehicle.BackColor = Color.Black;

            btn_vehicle_getdetails.Visible = false;
            btn_vehicle_submit.Visible = false;
            btn_vehicle_update.Visible = false;
            btn_vehicle_delete.Visible = true;
            btn_vehicle_cancel.Visible = true;
            
            
        }
        private void Get_Deleting_Details()
        {
            txt_vid_delete.Visible = false;
        }

        private void btn_vehicle_submit_Click(object sender, EventArgs e)
        {
            query = "Insert into Vehicle(v_id, v_manu_name, v_name, v_model, v_chasis_no, v_engine_no, v_manu_year, v_price, v_stock) values('" + txt_vehicleid.Text + "', '" + txt_veh_manu_name.Text + "' , '" + txt_vehiclename.Text + "', '" + cb_vehiclemodel.Text + "', '" + txt_vehicle_chassisno.Text + "', '" + txt_vehicle_engineno.Text + "', '" + txt_vehicle_manu_year.Text + "', '" + txt_vehicle_price.Text + "','" + txt_vehicle_stock.Text + "')";
            cmd = new SqlCommand(query, con);
            con.Open();
            int n = cmd.ExecuteNonQuery();
            if (n > 0)
            {
                MessageBox.Show("Vehicle Record Inserted Successfully...");
                con.Close();
            }
            else
            {
                MessageBox.Show("Error Occurs in Vehicle Record Inserting...");
            }
            
        }

        private void btn_vehicle_update_Click(object sender, EventArgs e)
        {
            query = "Update Vehicle set v_manu_name='" + txt_veh_manu_name.Text + "',v_name='" + txt_vehiclename.Text + "', v_model='" + cb_vehiclemodel.Text + "', v_chasis_no='" + txt_vehicle_chassisno.Text + "', v_engine_no='" + txt_vehicle_engineno.Text + "', v_manu_year='" + txt_vehicle_manu_year.Text + "', v_price='" + txt_vehicle_price.Text + "', v_stock='" + txt_vehicle_stock.Text + "' where v_id='" + txt_vehicleid.Text + "'";
            cmd = new SqlCommand(query, con);
            con.Open();
            int upd_count = cmd.ExecuteNonQuery();
            if (upd_count > 0)
            {
                MessageBox.Show("Updated Successfully....");
                con.Close();
            }
        }

        private void btn_vehicle_delete_Click(object sender, EventArgs e)
        {
            query = "Delete from Vehicle where v_id='" + txt_vid_delete.Text + "'";
            cmd = new SqlCommand(query, con);
            con.Open();
            int del_count = cmd.ExecuteNonQuery();
            if (del_count > 0)
            {
                MessageBox.Show("Deleted Successfully...");
            }
        }

        private void btn_vehicle_cancel_Click(object sender, EventArgs e)
        {
            TextBoxClear();
            txt_vehicleid.Text = "";
            txt_vid_delete.Text = "";
        }

        private void txt_vid_delete_TextChanged(object sender, EventArgs e)
        {
            query = "Select * from Vehicle where v_id='"+ txt_vid_delete.Text + "'";
            da = new SqlDataAdapter(query, con);
            DataSet ds_delete = new System.Data.DataSet();
            int _getcount = da.Fill(ds_delete);
            if (_getcount > 0)
            {
                string ID = txt_vid_delete.Text;
                if (ID == ds_delete.Tables[0].Rows[0]["v_id"].ToString().Trim())
                {
                    txt_veh_manu_name.Text = ds_delete.Tables[0].Rows[0]["v_manu_name"].ToString();
                    txt_vehiclename.Text = ds_delete.Tables[0].Rows[0]["v_name"].ToString();
                    cb_vehiclemodel.Text = ds_delete.Tables[0].Rows[0]["v_model"].ToString();
                    txt_vehicle_chassisno.Text = ds_delete.Tables[0].Rows[0]["v_chasis_no"].ToString();
                    txt_vehicle_engineno.Text = ds_delete.Tables[0].Rows[0]["v_engine_no"].ToString();
                    txt_vehicle_manu_year.Text = ds_delete.Tables[0].Rows[0]["v_manu_year"].ToString();
                    txt_vehicle_price.Text = ds_delete.Tables[0].Rows[0]["v_price"].ToString();
                    txt_vehicle_stock.Text = ds_delete.Tables[0].Rows[0]["v_stock"].ToString();
                }
                else
                {
                    TextBoxClear();
                }
            }
            else
            {
                TextBoxClear();
            }
        }
       
    }
}

Service Details ( Add | Edit | Delete )


Vehicle Management system Project

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data;
using System.Data.SqlClient;

namespace Vehicle_Management_System
{
    public partial class Service : Form
    {
        string query;
        SqlConnection con = new SqlConnection("Server=.; Database = VHS; Trusted_Connection = Yes;");
        SqlCommand cmd;
        SqlDataAdapter da;

        public Service()
        {
            InitializeComponent();
            btn_Submit.Visible = true;
            btn_update.Visible = false;
            btn_delete.Visible = false;

            btn_service_getdetails.Visible = false;
        }

        private void btn_addservice_Click(object sender, EventArgs e)
        {
            groupBox1.Text = "Add Service";

            btn_addservice.BackColor = Color.DarkCyan;
            btn_editservice.BackColor = Color.Black;
            btn_deleteservice.BackColor = Color.Black;

            btn_Submit.Visible = true;
            btn_update.Visible = false;
            btn_delete.Visible = false;
            btn_Cancel.Visible = true;
            btn_service_getdetails.Visible = false;
            txt_del_sid.Visible = false;
            WhiteTextbox();
        }

        private void btn_editservice_Click(object sender, EventArgs e)
        {
            SilverTextbox();
            groupBox1.Text = "Edit Service";
                        
            btn_addservice.BackColor = Color.Black;
            btn_editservice.BackColor = Color.DarkCyan;
            btn_deleteservice.BackColor = Color.Black;

            btn_Submit.Visible = false;
            btn_update.Visible = false;
            btn_delete.Visible = false;
            btn_Cancel.Visible = false;
            btn_service_getdetails.Visible = true;
            txt_del_sid.Visible = false;
            lbl_error.Text = "";
            
        }
        private void SilverTextbox()
        {
            txt_cust_name.Enabled = false;
            txt_cust_phone.Enabled = false;
            txt_vehicleno.Enabled = false;
            txt_vehiclename.Enabled = false;
            txt_vehicle_meterreading.Enabled = false;
            txt_vehicle_problems.Enabled = false;
            txt_cost.Enabled = false;
        }
        private void WhiteTextbox()
        {
            txt_cust_name.Enabled = true;
            txt_cust_phone.Enabled = true;
            txt_vehicleno.Enabled = true;
            txt_vehiclename.Enabled = true;
            txt_vehicle_meterreading.Enabled = true;
            txt_vehicle_problems.Enabled = true;
            txt_cost.Enabled = true;
        }
        private void Empty()
        {
            txt_cust_name.Text = "";
            txt_cust_phone.Text = "";
            txt_vehicleno.Text = "";
            txt_vehiclename.Text = "";
            txt_vehicle_meterreading.Text = "";
            txt_vehicle_problems.Text = "";
            txt_cost.Text = "";
        }

        private void btn_service_getdetails_Click(object sender, EventArgs e)
        {            
            WhiteTextbox();
            btn_Submit.Visible = false;
            btn_update.Visible = true;
            btn_delete.Visible = false;
            btn_Cancel.Visible = true;
            btn_service_getdetails.Visible = false;

            get_service_details(txt_serviceid.Text);

        }

        private void get_service_details(string cid)
        {
            query = " select * from Service where s_id='" + cid + "'";
            DataSet ds_get_cust = new System.Data.DataSet();
            da = new SqlDataAdapter(query, con);
            int n_get_cust = da.Fill(ds_get_cust);
            if (n_get_cust > 0)
            {
                if (cid == ds_get_cust.Tables[0].Rows[0]["s_id"].ToString().Trim())
                {
                    txt_cust_name.Text = ds_get_cust.Tables[0].Rows[0]["s_c_name"].ToString();
                    txt_cust_phone.Text =  ds_get_cust.Tables[0].Rows[0]["s_c_phone"].ToString();
                    txt_vehicleno.Text = ds_get_cust.Tables[0].Rows[0]["s_v_no"].ToString();
                    txt_vehiclename.Text=ds_get_cust.Tables[0].Rows[0]["s_v_name"].ToString();
                    txt_vehicle_meterreading.Text= ds_get_cust.Tables[0].Rows[0]["s_v_meter_reading"].ToString();
                    txt_vehicle_problems.Text= ds_get_cust.Tables[0].Rows[0]["s_v_problem"].ToString();
                    txt_cost.Text = ds_get_cust.Tables[0].Rows[0]["s_v_cost"].ToString();
                }
                else
                {
                    Empty();
                }
            }
            else
            {
                Empty();
            }

        }
        private void btn_deleteservice_Click(object sender, EventArgs e)
        {
            groupBox1.Text = "Delete Service";
            SilverTextbox();
            Empty();
            btn_addservice.BackColor = Color.Black;
            btn_editservice.BackColor = Color.Black;
            btn_deleteservice.BackColor = Color.DarkCyan;

            btn_Submit.Visible = false;
            btn_update.Visible = false;
            btn_delete.Visible = true;
            btn_Cancel.Visible = true;
            btn_service_getdetails.Visible = false;
            txt_del_sid.Visible = true;
            lbl_error.Text = "Please Enter Service ID";

        }

        private void btn_Submit_Click(object sender, EventArgs e)
        {
            query = "Insert into Service(s_id, s_c_name, s_c_phone, s_v_no, s_v_name, s_v_meter_reading, s_v_problem, s_v_cost) values('" + txt_serviceid.Text + "','" + txt_cust_name.Text + "', '" + txt_cust_phone.Text + "', '" + txt_vehicleno.Text + "','" + txt_vehiclename.Text + "', '" + txt_vehicle_meterreading.Text + "', '" + txt_vehicle_problems.Text + "' , '" + txt_cost.Text + "')";
            cmd = new SqlCommand(query, con);
            con.Open();
            int si_count = cmd.ExecuteNonQuery();
            if (si_count > 0)
            {
                MessageBox.Show("Insert Successfully...");
                con.Close();
            }

        }

        private void btn_update_Click(object sender, EventArgs e)
        {
            query = "Update Service set s_c_name='" + txt_cust_name.Text + "', s_c_phone='" + txt_cust_phone.Text + "', s_v_no= '" + txt_vehicleno.Text + "', s_v_name='" + txt_vehiclename.Text + "', s_v_meter_reading =  '" + txt_vehicle_meterreading.Text + "', s_v_problem='" + txt_vehicle_problems.Text + "' , s_v_cost='" + txt_cost.Text + "' where s_id='" + txt_serviceid.Text + "'";
            cmd = new SqlCommand(query, con);
            con.Open();
            int su_count = cmd.ExecuteNonQuery();
            if (su_count > 0)
            {
                MessageBox.Show("Updated Successfully...");
                con.Close();
            }

        }

        private void btn_delete_Click(object sender, EventArgs e)
        {
            query = "Delete Service where s_id='" + txt_serviceid.Text + "'";
            cmd = new SqlCommand(query, con);
            con.Open();
            int n_del = cmd.ExecuteNonQuery();
            if (n_del > 0)
            {
                MessageBox.Show("Delete Successfully...");
                con.Close();
            }
        }

        private void btn_Cancel_Click(object sender, EventArgs e)
        {
            Empty();
        }

        private void txt_del_sid_TextChanged(object sender, EventArgs e)
        {
            get_service_details(txt_del_sid.Text);
        }
    }
}

Check Your Vehicle Services Status


vehicle management system project in vehicle status

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data;
using System.Data.SqlClient;

namespace Vehicle_Management_System
{
    public partial class Enquiry : Form
    {
        string query;
        SqlConnection con = new SqlConnection("Server=.; Database = VHS; Trusted_Connection = Yes;");
        SqlDataAdapter da;


        public Enquiry()
        {
            InitializeComponent();
        }

        private void btn_check_Click(object sender, EventArgs e)
        {
            query = "Select s_id as 'Service ID', s_c_name as 'Customer Name',s_v_no as 'Vehicle No.', s_v_name as 'Vehicle Name', s_v_problem as 'Vehicle Problems', s_c_phone as 'Customer Phone', s_v_cost as 'Payment' from Service where s_id='" + txt_serviceid.Text + "' AND s_v_no='" + txt_vehicleNo.Text + "'";            
            da = new SqlDataAdapter(query, con);
            DataSet ds = new System.Data.DataSet();
            int n = da.Fill(ds, "st");
            if (n > 0)
            {
                dataGridView1.DataSource = ds;
                dataGridView1.DataMember = "st";

                DataGridViewComboBoxColumn cbcell = new DataGridViewComboBoxColumn();
                cbcell.HeaderText = "Status";
                cbcell.Width = 150;
                cbcell.Items.Add("Pending");
                cbcell.Items.Add("Closed");
                cbcell.Items.Add("In Progress");
                dataGridView1.Columns.Add(cbcell);
                con.Close();
            }
        }
    }
}

Payment


payment vehicle management system project

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data;
using System.Data.SqlClient;

namespace Vehicle_Management_System
{
    public partial class Payment : Form
    {
        string query;
        SqlConnection con = new SqlConnection("Server=.; Database = VHS; Trusted_Connection = Yes;");
        SqlDataAdapter da;


        public Payment()
        {
            InitializeComponent();
            SilverTextbox();
            groupBox1.Visible = false;
        }
        private void SilverTextbox()
        {
            txt_customer_Name.Enabled = false;
            txt_customer_phone.Enabled = false;
            txt_vehicle_problems.Enabled = false;
            txt_cost.Enabled = false;
            txt_amount.Enabled = false;
            txt_bankname.Enabled = false;
            txt_check_dd.Enabled = false;
            cb_payment_mode.Enabled = false;
        }

        private void Empty()
        {
            txt_customer_Name.Text = "";
            txt_customer_phone.Text = "";
            txt_vehicle_problems.Text = "";
            txt_cost.Text = "";
            txt_amount.Text = "";
            txt_bankname.Text = "";
            txt_check_dd.Text = "";
            cb_payment_mode.Enabled = false;
            groupBox1.Visible = false;
            cb_payment_mode.Text = "Select";
        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cb_payment_mode.Text.Trim() == "Select")
            {                
                groupBox1.Visible = false;
            }
            else if (cb_payment_mode.Text == "Cash")
            {
                groupBox1.Visible = true;
                groupBox1.Text = "Payment Mode : Cash";
                groupBox1.Height = 85;
                lbl_bankname.Visible = false;
                txt_bankname.Visible = false;
                lbl_checkdd.Visible = false;
                txt_check_dd.Visible = false;
                lbl_amount.Location = new Point(120, 42);
                txt_amount.Location = new Point(200, 39);
                txt_amount.Visible = true;//54, 103
                txt_amount.Enabled = true;
            }
            else if (cb_payment_mode.Text == "Check")
            {
                groupBox1.Visible = true;
                groupBox1.Text = "Payment Mode : Check";
                groupBox1.Height = 143; ;
                lbl_bankname.Visible = true;
                txt_bankname.Visible = true;
                txt_bankname.Enabled = true;
                lbl_checkdd.Visible = true;
                lbl_checkdd.Text = "Check No :";
                lbl_checkdd.Location = new Point(42, 61);
                txt_check_dd.Visible = true;
                txt_check_dd.Enabled = true;
                lbl_amount.Location = new Point(54, 103);
                txt_amount.Location = new Point(174, 100);
                lbl_amount.Visible = true;
                txt_amount.Visible = true;
            }
            else if (cb_payment_mode.Text == "D.D")
            {
                groupBox1.Visible = true;
                groupBox1.Text = "Payment Mode : D.D";
                groupBox1.Height = 143;
                lbl_bankname.Visible = true;
                txt_bankname.Visible = true;
                lbl_checkdd.Visible = true;
                lbl_checkdd.Text = "D.D No :"; 
                lbl_checkdd.Location = new Point(52, 61);
                txt_check_dd.Visible = true;
                lbl_amount.Location = new Point(54, 103);
                txt_amount.Location = new Point(174, 100);
                lbl_amount.Visible = true;
                txt_amount.Visible = true;
            }
        }

        private void txt_vehicleNo_TextChanged(object sender, EventArgs e)
        {
            query = "Select * from Service where s_v_no='" + txt_vehicleNo.Text+"'";
            da = new SqlDataAdapter(query, con);
            DataSet ds = new System.Data.DataSet();
            int n = da.Fill(ds, "st");
            if (n > 0)
            {
                if (txt_vehicleNo.Text == ds.Tables[0].Rows[0]["s_v_no"].ToString())
                {
                    txt_customer_Name.Text = ds.Tables[0].Rows[0]["s_c_name"].ToString();
                    txt_customer_phone.Text = ds.Tables[0].Rows[0]["s_c_phone"].ToString();
                    txt_vehicle_problems.Text = ds.Tables[0].Rows[0]["s_v_problem"].ToString();
                    txt_cost.Text = ds.Tables[0].Rows[0]["s_v_cost"].ToString();
                    cb_payment_mode.Enabled = true;
                }
                else
                {
                    Empty();
                    SilverTextbox();
                }

            }
            else
            {
                Empty();
            }
        }

        private void btn_Cancel_Click(object sender, EventArgs e)
        {
            Empty();
            txt_vehicleNo.Text = "";
        }

        private void btn_pay_Click(object sender, EventArgs e)
        {
            query = "Insert Payment(v_no, payment_mode, amount, check_dd, bank_name) values('" + txt_vehicleNo.Text + "', '" + cb_payment_mode.Text + "', '" + txt_amount.Text + "', '" + txt_check_dd.Text + "', '" + txt_bankname.Text + "')";
            SqlCommand cmd = new SqlCommand(query, con);
            con.Open();
            int n = cmd.ExecuteNonQuery();
            if (n > 0)
            {
                MessageBox.Show("Payment Done ...");
                con.Close();
                Empty();
                txt_vehicleNo.Text = "";
            }
        }
      
    }
}

Download Project with Source Code and Database


1 Komentar untuk "Dotnet : Vehicle Management System Project With Source Code"

Thanks for your informative article and the blog. Your article is very useful for .net professionals and freshers looking for interview. Best DOT NET Training | Dot Net course Chennai

Back To Top