// public IEnumerable <PartTime> GetAll() { var lstparttime = new List <PartTime>(); using (var con = new MySqlConnection(connectionString)) { var cmd = new MySqlCommand("select * from parttime", con); con.Open(); using (var reader = cmd.ExecuteReader()) { while (reader.Read()) { PartTime parttime = new PartTime(); parttime.id = Convert.ToInt32(reader["id"]); parttime.firstname = reader["firstname"].ToString(); parttime.lastname = reader["lastname"].ToString(); parttime.email = reader["email"].ToString(); parttime.workfrom = reader["workfrom"].ToString(); lstparttime.Add(parttime); } } con.Close(); } return(lstparttime); }
public IHttpActionResult Update([FromBody] PartTime parttime) { repository.Update(parttime); return(Ok()); }
static void Main(string[] args) { var bill = new FullTime { FirstName = "Bill", LastName = "Gates", YearsEmployed = 5 }; bill.ShowFullName(); Debug.Assert(bill.ShowFullName() == "Bill Gates"); Debug.Assert(bill.YearsEmployed == 5); var steve = new PartTime { FirstName = "Steve", LastName = "Jobs", MonthsEmployed = 2 }; Debug.Assert(steve.ShowFullName() == "Steve Jobs"); Debug.Assert(steve.MonthsEmployed == 2); }
public static void Main() { ClassEmp[] employee = new ClassEmp[4]; employee[0] = new ClassEmp(); employee[1] = new PartTime(); employee[2] = new FullTime(); employee[3] = new TempTime(); //created an array of base class and to each element we assigned a different type of base class object // now create an array to loop through each base class object // since we have a base class reference variable referenceing to child classses, though we have the method in child overriding parent class //the base class method is called // the new keyword is used to hide the base class but our intension is to override the definition provided by base class, use override // for this mark the parent method virtual // this indicated the child class that it can override the parent class if it wishes to do so //though the ref variable is of type parent, the runtime checks the type of object, then it invokes the overriden method in the child class // this is called polymorphism // Polymorphism enables us to invoke the derived class methods using base class reference variables at run time // if the child class do not have any implementation overriding the parent class, then the parent class method is executed foreach (ClassEmp E in employee) { E.printfullname(); } }
public ActionResult DeleteConfirmed(int id) { PartTime partTime = db.Parttime.Find(id); db.Parttime.Remove(partTime); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "id,firstname,lastname,email,workfrom")] PartTime partTime) { if (ModelState.IsValid) { db.Entry(partTime).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(partTime)); }
public ActionResult Create([Bind(Include = "id,firstname,lastname,email,workfrom")] PartTime partTime) { if (ModelState.IsValid) { db.Parttime.Add(partTime); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(partTime)); }
public static void Main(string[] args) { Console.WriteLine("Hello World!"); // TODO: Implement Functionality Here FullTime ft = new FullTime(); PartTime pt = new PartTime(); ft.firstName = "babak"; ft.lastName = "slf"; ft.printFullName(); Console.Write("Press any key to continue . . . "); Console.ReadKey(true); }
static void Main(string[] args) { Console.WriteLine("ENTER ID"); int id = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("ENTER NAME"); string Name = Console.ReadLine(); Console.WriteLine("ENTER ADDRESS"); string Address = Console.ReadLine(); Console.WriteLine("ENTER PAN NO"); string panno = Console.ReadLine(); Console.WriteLine("Press 1 Calculate PartTime Salary"); Console.WriteLine("Press 2 Calculate FullTime Salary"); int ch = Convert.ToInt32(Console.ReadLine()); switch (ch) { case 1: PartTime p1 = new PartTime(); Console.WriteLine("Enter Number Of Hour"); p1.noofhours = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Enter Number Of Salary Per Hour"); p1.salaryperhour = Convert.ToInt32(Console.ReadLine()); int sal = p1.Salary(); p1.GetData(id, Name, Address, panno); p1.Display(); Console.WriteLine("YOUR PART TIIME SALARY IS :-" + sal); break; case 2: FullTime fl = new FullTime(); Console.WriteLine("ENTER BASIC SALARY"); fl.Basic = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("ENTER DA AMOUNT"); fl.DA = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("ENTER HRA AMOUNT"); fl.HRA = Convert.ToInt32(Console.ReadLine()); int fullsal = fl.Salary(); fl.GetData(id, Name, Address, panno); fl.Display(); Console.WriteLine("YOUR FULL TIIME SALARY IS :-" + fullsal); break; } Console.ReadLine(); }
// GET: PartTimes/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } PartTime partTime = db.Parttime.Find(id); if (partTime == null) { return(HttpNotFound()); } return(View(partTime)); }
static void Main() { Employee[] E = new Employee[4]; //Array of Employee E[0] = new Employee(); E[1] = new FullTime(); E[2] = new PartTime(); E[3] = new Temporary(); foreach (Employee e in E) { e.print(); } Console.Read(); }
static void Main(string[] args) { Employee emp = new Employee { FirstName = "John", LastName = "Doe" }; emp.PrintFullName(); PartTime pt = new PartTime { FirstName = "Jane", LastName = "Doe" }; float pay = pt.CalcPay(10, 8); pt.PrintFullName(); Console.WriteLine("Pay {0}", pay); Console.ReadKey(); }
public void Add(PartTime parttime) { using (MySqlConnection con = new MySqlConnection(connectionString)) { MySqlCommand command = con.CreateCommand(); con.Open(); command.CommandText = "INSERT INTO parttime VALUES (@id,@firstname,@lastname,@email, @workfrom)"; command.Parameters.AddWithValue("@id", parttime.id); command.Parameters.AddWithValue("@firstname", parttime.firstname); command.Parameters.AddWithValue("@lastname", parttime.lastname); command.Parameters.AddWithValue("@email", parttime.email); command.Parameters.AddWithValue("@workfrom", parttime.workfrom); command.ExecuteNonQuery(); con.Close(); } }
// public PartTime Get(string id) { PartTime parttime = new PartTime(); using (MySqlConnection con = new MySqlConnection(connectionString)) { string sqlQuery = "SELECT * FROM parttime WHERE id= " + id; var cmd = new MySqlCommand("SELECT * FROM parttime WHERE id=@id", con); cmd.Parameters.Add(new MySqlParameter("id", id)); con.Open(); MySqlDataReader rdr = cmd.ExecuteReader(); while (rdr.Read()) { parttime.id = Convert.ToInt32(rdr["id"]); parttime.firstname = rdr["firstname"].ToString(); parttime.lastname = rdr["lastname"].ToString(); parttime.email = rdr["email"].ToString(); parttime.workfrom = rdr["workfrom"].ToString(); } } return(parttime); }
public void Update(PartTime parttime) { using (MySqlConnection con = new MySqlConnection(connectionString)) { //MySqlCommand cmd = new MySqlCommand("UPDATE 'parttime' SET (firstname=@firstname , lastname=@lastname, email=@email ,workfrom=@workfrom) WHERE id=@id", con); //cmd.CommandType = CommandType.StoredProcedure; MySqlCommand cmd = con.CreateCommand(); var id = parttime.id; con.Open(); cmd.CommandText = "UPDATE parttime SET firstname=@firstname , lastname=@lastname, email=@email ,workfrom=@workfrom WHERE id=@id"; cmd.Parameters.AddWithValue("@firstname", parttime.firstname); cmd.Parameters.AddWithValue("@lastname", parttime.lastname); cmd.Parameters.AddWithValue("@email", parttime.email); cmd.Parameters.AddWithValue("@id", parttime.id); cmd.Parameters.AddWithValue("@workfrom", parttime.workfrom); cmd.ExecuteNonQuery(); con.Close(); } }
public IHttpActionResult Add([FromBody] PartTime parttime) { repository.Add(parttime); return(Ok()); }
static void Main(string[] args) { Console.WriteLine("PLEASE ENTER THE FOLLOWING DETAILS:"); Console.WriteLine("Enter the Name:"); string name = Console.ReadLine(); Console.WriteLine("Enter the Id:"); int id = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Enter the Address:"); string address = Console.ReadLine(); Console.WriteLine("Enter the PAN Number:"); string panno = Console.ReadLine(); Console.WriteLine("Press 1)PartTime Salary 2)FullTime Salary"); int choice = Convert.ToInt32(Console.ReadLine()); switch (choice) { case 1: Console.WriteLine("Enter the no of hours:"); int no = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Salary per hour:"); int sal = Convert.ToInt32(Console.ReadLine()); PartTime p = new PartTime(); p.noofhours = no; p.salperhour = sal; p.Get(id, name, address, panno); Console.WriteLine("PartTime Salary is: " + p.Salary()); p.Display(); break; case 2: Console.WriteLine("Enter the basic salary:"); int basic = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Enter the HRA:"); int hra = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Enter the TA:"); int ta = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Enter the DA:"); int da = Convert.ToInt32(Console.ReadLine()); FullTime f = new FullTime(); f.basic = basic; f.HRA = hra; f.TA = ta; f.DA = da; f.Get(id, name, address, panno); Console.WriteLine("FullTime Salary is: " + f.Salary()); f.Display(); break; default: Console.WriteLine("Invalid Choice!"); break; } Console.ReadKey(); }