Documente Academic
Documente Profesional
Documente Cultură
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using vpAssignment2;
namespace VPAssignment3
{
public partial class AssignDriver : Form
{
public AssignDriver()
{
InitializeComponent();
}
public string VEHICLESEARCHBOX
{
get { return vSEARCHBOX.Text; }
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using vpAssignment2;
namespace VPAssignment3
{
public partial class AssignStudent : Form
{
public AssignStudent()
{
InitializeComponent();
}
}
public string Enrollment
{
get{ return enrl.Text; }
set{ enrl.Text += value; }
}
public string VSEARCHBOX
{
get { return vSEARCHBOX.Text; }
set { vSEARCHBOX.Text += value; }
}
public void capException()
{
MessageBox.Show("The Vehicle is full ", "Error");
}
public void vehexception()
{
MessageBox.Show("Vehicle not found ", "Error");
}
public void stuException()
{
MessageBox.Show("Student not found ", "Error");
}
private void AssignButton_Click(object sender, EventArgs e)
{
if (Enrollment == "" || VSEARCHBOX == "")
{
MessageBox.Show("Field left empty!", "Error");
}
Vehicle v = new Vehicle();
v.ASTV(this);
MessageBox.Show("Student assigned to this vehicle","SUCCESS");
Enrollment = "";
VSEARCHBOX = "";
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VPAssignment3;
namespace vpAssignment2
{
class Driver
{
string driverId;
string dName;
string cnic;
string dContact;
string dAddress;
List<Driver> dlist = new List<Driver>();
public Driver() { }
public Driver(string dId, string dNm, string cnc, string dCt, string dAdd)
{
this.driverId = dId;
this.dName = dNm;
this.dContact = dCt;
this.cnic = cnc;
this.dAddress = dAdd;
}
public string driverID
{
get { return driverId; }
set { driverId = value; }
}
public void NewDriver(DriverForm df)
{
this.driverId = "D-"+df.DID;
this.dName = df.DNAME;
this.cnic = df.DCNIC;
this.dContact = df.DCONTACT;
this.dAddress = df.DADDRESS;
Driver d = new Driver(driverId, dName, cnic, dContact, dAddress);
dlist.Add(d);
dToFile(dlist);
dlist.Clear();
}
private void dToFile(List<Driver> dobj)
{
FileStream f = new FileStream("drivers.txt", FileMode.Append,
FileAccess.Write);
StreamWriter s = new StreamWriter(f);
for (int i = 0; i < dobj.Count; i++)
{
Driver d = dobj[i] as Driver;
s.WriteLine(d.driverId);
s.WriteLine(d.dName);
s.WriteLine(d.cnic);
s.WriteLine(d.dContact);
s.WriteLine(d.dAddress);
s.Close();
}
f.Close();
}
public List<Driver> findDriver(DriverForm df)
{
List<Driver> list = new List<Driver>();
FileStream fr = new FileStream("drivers.txt", FileMode.Open,
FileAccess.Read);
StreamReader s = new StreamReader(fr);
string temp;
string f = df.DRIVERSEARCHBOX;
bool test = false;
while (!s.EndOfStream)
{
temp = s.ReadLine();
string di, dn, cn, ct, ad;
if (temp == f)
{
test = true;
di = f;
dn = s.ReadLine();
cn = s.ReadLine();
ct = s.ReadLine();
ad = s.ReadLine();
Driver driver = new Driver(di, dn, cn, ct, ad);
list.Add(driver);
}
}
if(test!=true)
{
df.DRIVERDETAILS = "DRIVER WITH ID ( " + f + " ) NOT FOUND !";
df.DRIVERDETAILS = "ID is case sensistive and mostly written in
UPPERCASE letters";
}
s.Close();
fr.Close();
return list;
}
}
if (test != true)
{
ad.driverException();
}
s.Close();
fr.Close();
return list;
}
public void printDObj(List<Driver> dl,DriverForm df)
{
foreach (Driver d in dl)
{
df.DRIVERDETAILS = "Driver's ID : "+d.driverId+"\n";
df.DRIVERDETAILS = "Driver's Name : " + d.dName + "\n";
df.DRIVERDETAILS = "Driver's CNIC : " + d.cnic + "\n";
df.DRIVERDETAILS = "Driver's Contact : " + d.dContact + "\n";
df.DRIVERDETAILS = "Driver's Address : " + d.dAddress + "\n";
}
dl.Clear();
}
public Driver readDObj(List<Driver> dl)
{
string a, b, c, d, e;
Driver dri = dl[0] as Driver;
for (int i=0;i<dl.Count;i++)
{
a =dri.driverId;
b =dri.dName;
c =dri.cnic;
d =dri.dContact;
e =dri.dAddress;
}
dl.Clear();
return dri;
}
public string getiD(List<Driver> dl)
{
string s = dl[0].driverId;
return s;
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using vpAssignment2;
namespace VPAssignment3
{
public partial class DriverForm : Form
{
public DriverForm()
{
InitializeComponent();
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using vpAssignment2;
namespace VPAssignment3
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
Focus();
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace VPAssignment3
{
static class Program
{using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using vpAssignment2;
namespace VPAssignment3
{
public partial class ReportForm : Form
{
public ReportForm()
{
InitializeComponent();
}
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VPAssignment3;
namespace vpAssignment2
{
class Student
{
string enrollment;
string sName;
string dept;
string sContact;
string sAddress;
List<Student> slist = new List<Student>();
public Student() { }
public Student(string en, string sNm, string dp,string sCt, string sAdd)
{
this.enrollment=en;
this.sName=sNm;
this.dept=dp;
this.sContact=sCt;
this.sAddress=sAdd;
}
}
private void sToFile(List<Student> sobj)
{
FileStream f = new FileStream("students.txt", FileMode.Append,
FileAccess.Write);
StreamWriter s = new StreamWriter(f);
for (int i = 0; i < sobj.Count; i++)
{
Student st= sobj[i] as Student;
s.WriteLine(st.enrollment);
s.WriteLine(st.sName);
s.WriteLine(st.dept);
s.WriteLine(st.sContact);
s.WriteLine(st.sAddress);
s.Close();
}
f.Close();
}
public List<Student> findStudent(StudentForm sf)
{
List<Student> list = new List<Student>();
FileStream fr = new FileStream("students.txt", FileMode.Open,
FileAccess.Read);
StreamReader s = new StreamReader(fr);
string temp;
string f = sf.STUDENTSEARCHBOX;
bool test = false;
while (!s.EndOfStream)
{
temp = s.ReadLine();
string di, dn, cn, ct, ad;
if (temp == f)
{
test = true;
di = f;
dn = s.ReadLine();
cn = s.ReadLine();
ct = s.ReadLine();
ad = s.ReadLine();
Student st = new Student(di, dn, cn, ct, ad);
list.Add(st);
}
}
if (test != true)
{
sf.STUDENTDETAILS= "STUDENT WITH ID ( " + f + " ) NOT FOUND !";
sf.STUDENTDETAILS = "Follow the format: e.g 01-134171-095";
}
s.Close();
fr.Close();
return list;
}
public List<Student> findStudent2(AssignStudent ast)
{
List<Student> list = new List<Student>();
FileStream fr = new FileStream("students.txt", FileMode.Open,
FileAccess.Read);
StreamReader s = new StreamReader(fr);
string temp;
string f = ast.Enrollment;
bool test = false;
while (!s.EndOfStream)
{
temp = s.ReadLine();
string di, dn, cn, ct, ad;
if (temp == f)
{
test = true;
di = f;
dn = s.ReadLine();
cn = s.ReadLine();
ct = s.ReadLine();
ad = s.ReadLine();
Student st = new Student(di, dn, cn, ct, ad);
list.Add(st);
}
}
if (test != true)
{
ast.stuException();
}
s.Close();
fr.Close();
return list;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using vpAssignment2;
namespace VPAssignment3
{
public partial class StudentForm : Form
{
public StudentForm()
{
InitializeComponent();
}
public string STUDENTSEARCHBOX
{
get { return studentSearchBox.Text; }
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VPAssignment3;
namespace vpAssignment2
{
class Vehicle
{
string vName;
string vNo;
string color;
string chasis;
int capacity;
string drivId;
string studId;
Driver driver;
Student student;
List<Driver> dlist = new List<Driver>();
List<Vehicle> vlist = new List<Vehicle>();
List<Student> slist = new List<Student>();
public Vehicle() { }
public Vehicle(string vn,string vnm,string cl,string ch,int cp)
{
this.vNo = vn;
this.vName = vnm;
this.color = cl;
this.chasis = ch;
this.capacity = cp;
}
public Vehicle(string vn, string vnm, string cl, string ch, int cp,string
did)
{
this.vNo = vn;
this.vName = vnm;
this.color = cl;
this.chasis = ch;
this.capacity = cp;
this.drivId = did;
}
public Vehicle(string vn, string vnm, string cl, string ch, int cp, string
did, string sid)
{
this.vNo = vn;
this.vName = vnm;
this.color = cl;
this.chasis = ch;
this.capacity = cp;
this.drivId = did;
this.studId = sid;
}
public void newVehicle(VehicleForm vf)
{
this.vNo = vf.VID;
this.vName = vf.VNAME;
this.color = vf.VCOLOR;
this.chasis = vf.VCHASIS;
this.capacity = int.Parse(vf.VCAPACITY);
Vehicle v = new Vehicle(vNo, vName, color, chasis, capacity);
vlist.Add(v);
vToFile(vlist);
vlist.Clear();
}
public void ADTV(AssignDriver ad)
{
vlist = findVehicle2(ad);
Driver d = new Driver();
dlist=d.findDriver2(ad);
string s = ad.DRIVERSEARCHBOX;
vTovd(vlist, s);
}
public void printrepobject(List<Vehicle> vl, ReportForm vf)
{
foreach (Vehicle v in vl)
{
vf.REPORTBOX = "Vehicle ID: " + v.vNo + "\n";
vf.REPORTBOX = "Vehicle Name: " + v.vName + "\n";
vf.REPORTBOX = "Vehicle Color: " + v.color + "\n";
vf.REPORTBOX = "Vehicle Chasis: " + v.chasis + "\n";
vf.REPORTBOX = "Vehicle Capacity: " + v.capacity + "\n\n";
vf.REPORTBOX = "Driver ID: " + v.drivId+ "\n";
vf.REPORTBOX = "STUDENTS : \n" +v.studId;
}
vl.Clear();
}
public List<Vehicle> findVehicleinVDreport(ReportForm ast)
{
string vi, vn, cl, ch, did, enrl;
int cp;
List<Vehicle> list = new List<Vehicle>();
string f = ast.VSEARCHBOX;
FileStream fr = new FileStream("VD.txt", FileMode.Open,
FileAccess.Read);
StreamReader s = new StreamReader(fr);
string temp;
sf.Close();
fs.Close();
return list;
}
static void lineChanger(string newText, string fileName, int line)
{
string[] arrLine = File.ReadAllLines(fileName);
arrLine[line - 1] = newText;
File.WriteAllLines(fileName, arrLine);
}
if (test != true)
{
ad.vehicleException();
}
s.Close();
fr.Close();
return list;
}
else
ad.vehicleException();
return null;
}
public bool findVehicleinVD(AssignDriver ad)
{
List<Vehicle> list = new List<Vehicle>();
string f = ad.VEHICLESEARCHBOX;
FileStream fr = new FileStream("VD.txt", FileMode.Open,
FileAccess.Read);
StreamReader s = new StreamReader(fr);
string temp;
while (!s.EndOfStream)
{
temp = s.ReadLine();
string vi, vn, cl, ch, did;
int cp;
if (temp == f)
{
vi = temp;
vn = s.ReadLine();
cl = s.ReadLine();
ch = s.ReadLine();
cp = Convert.ToInt32(s.ReadLine());
did = s.ReadLine();
s.Close();
fr.Close();
}
return false;
}
return true;
}
public List<Vehicle> findVehicle(VehicleForm vf)
{
List<Vehicle> list = new List<Vehicle>();
string f=vf.VEHICLESEARCHBOX;
FileStream fr = new FileStream("vehicles.txt", FileMode.Open,
FileAccess.Read);
StreamReader s = new StreamReader(fr);
string temp;
bool test = false;
while (!s.EndOfStream)
{
temp = s.ReadLine();
string vi, vn, cl, ch;
int cp;
if (temp == f)
{
test = true;
vi = temp;
vn = s.ReadLine();
cl = s.ReadLine();
ch = s.ReadLine();
cp = Convert.ToInt32(s.ReadLine());
Vehicle vehicle = new Vehicle(vi, vn, cl, ch, cp);
list.Add(vehicle);
}
}
if (test != true)
{
vf.VEHICLEDETAILS="VEHICLE WITH ID ( " + f + " ) NOT FOUND !\n";
vf.VEHICLEDETAILS = "ID is case sensistive and mostly written in
UPPERCASE letters";
}
s.Close();
fr.Close();
return list;
}
public int linecounter(string id)
{
List<Vehicle> list = new List<Vehicle>();
string f=id;
int counter=0;
FileStream fr = new FileStream("VD.txt", FileMode.Open,
FileAccess.Read);
StreamReader s = new StreamReader(fr);
string temp;
while (!s.EndOfStream)
{
temp = s.ReadLine();
counter++;
string vi, vn, cl, ch, did;
int cp;
if (temp == f)
{
vi = temp;
counter++;
vn = s.ReadLine();
counter++;
cl = s.ReadLine();
counter++;
ch = s.ReadLine();
counter++;
cp = Convert.ToInt32(s.ReadLine());
did = s.ReadLine();
}
}
s.Close();
fr.Close();
return counter;
vl.Clear();
return veh;
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using vpAssignment2;
namespace VPAssignment3
{
public partial class VehicleForm : Form
{
public VehicleForm()
{
InitializeComponent();
}
}
}
}
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}