Best Pratice In Inheritance - Three Classes Employee, Manager And Salesman. Manager And Salesman Classes Inherits Employee Class
Jul 27, 2010
I have three classes Employee, Manager and Salesman. Manager and Salesman classes inherits Employee class.
Employee :
Public MustInherit Class Employee
' Field data.
Protected empName As String
Protected empID As Integer
Protected currPay As Single
[CODE]...
Manager :
Public Class Manager
Inherits Employee
[CODE]...
Salesman :
Public Class Salesman
Inherits Employee
[CODE]...
Now I have created a object of salesman and manager using the following code:
Dim objSalesMan as Employee=new Salesman("xyz",1,2000,5000)
Dim objManager as Employee=new Manager("abx",2,5000,"production")
Is this a good programming pratice or should I use:
Dim objSalesMan as new Salesman("xyz",1,2000,5000)
Dim objManager as new Manager("abx",2,5000,"production")
View 6 Replies
ADVERTISEMENT
Sep 15, 2009
I have a VB project with a form where user adds/modifies the data, data are stored in SQL. On the form there are 2 tables that are linked by employee ID. When I test the process and insert a new employee record and add new comment for this new employee in DataGridView - when I save it I get an error that "Object reference is not set to an instance of an object". During more detailed debug it says that CurrentCell is set to Nothing - even that I do have values in all fields.I do set employee ID in the related table in the Grid to the value from the employee record - so all primary keys do have value and the comment is saved after all but I get an error and saved comment dissapears from the screen right after saving. When I pull the same new record again - everything is saved. What am I missing and how to avoid the error and dissapearing of the saved comment?
Also - I tried to save the new employee data in the first table first and then add comments - it didn't solve the problem. But if I add first part of information in the main table, save and close the form, then go back and add comment - it works fine. The problem is - it's not convenient for the user - they'd like to enter everything at once.
Private Sub TblCommentsBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TblCommentsBindingNavigatorSaveItem.Click
Me.Validate()[code]....
View 6 Replies
Sep 30, 2009
You need to design and create a program that accepts input of employee name, employee type, and the number of hours worked each week for two weeks.
You must be able to select an employee type. An employee of type Trainee makes $10 per hour. An employee of type Regular makes $15 per hour. An employee of type Manager makes $20 per hour.
The program should calculate the employee pay for the week. The employee should receive 1 times the regular pay for any hours worked over the prescribed 40 hours in a week. The program should output the following information:
-The employees name without trailing or leading spaces
-Regular hours worked
-Regular pay
-Overtime hours worked
-Overtime pay
-Total pay
The Problem that i am having right now is "Displaying " the overtime hours on my "FORM VIEW" i mean i did the math right its just when i type (lblOverHrs.Text = CDec(CDec(OvrHrsWrkWeek1.Text) + CDec(txtOvrHrsWrkWeek2.Text))
Its says the "OvrHrsWrkWeek1 and 2" are not Declared which are..im not really sure where i went wrong..
Heres my code
CODE:
View 4 Replies
Aug 8, 2011
Background:I have a base class and several inherited derived classes. The derived classes don't always need to have the same properties. If any properties are shared among the derived classes, those properties would live at the base class level ('Contents', for example).Similarly, GoodDocument below has 'GoodThings' but would not want/need to have 'BadThings'.I want to treat instances of both 'GoodDocument' and 'BadDocument' as type 'Document'
public mustinherit class Document
public property Contents as string
public sub new()...
[code]....
View 3 Replies
Oct 15, 2011
I am cleaning up some code and I have multiple classes that are 99% exactly the same. So my understanding is that my options are...
1. Create a class and all other classes inherit from it and modify it a bit
2. Create an abstract class and all classes inherit from it and modify a bit ** I took this route
3. Create an interface and all classes Implement that interface.
Here is my 'original' class below (the one that all of them look 99% identical). This class is used in an arraylist so I have a listing of all my images from a folder I have searched.
[Code]...
View 10 Replies
Jun 13, 2012
How can I structure my classes so that the user interfaces though a single class while the supporting classes are hidden from their view? I think its best understood in an example:
Public Class MyInterface
Public Economic as EconomicClass
Public Sub New()
MyBase.New()
[code].....
So you might ask why am I even separating them? It's strictly for others who will be working with this interface. I need to funnel them though a logical structure:
interface.Economic.MyMethod
interface.Currency.MyMethod
etc
This way everything is already handled for them in the background and they only need to run the method they need. I don't know if I can have it both ways in VB.NET.
View 23 Replies
Feb 15, 2011
I'm currently taking a newbie VB course (online) and in this program that I am writing, I am getting one error (red) that when double clicked in the Error List, takes me to the Application.Designer window and states that "Employee is a type in 'WindowsApplication1' and cannot be used as an expression." The only solution it gives me is to generate the Employee Class (in the designer). When I select that, it gives me 3 more errors (all yellow). The Employee class has been made, so I don't really know where else to go from here.[code]...
View 1 Replies
Feb 15, 2011
I'm currently taking a newbie VB course (online) and in this program that I am writing, I am getting one error (red) that when double clicked in the Error List, takes me to the Application.Designer window and states that "Employee is a type in 'WindowsApplication1' and cannot be used as an expression." The only solution it gives me is to generate the Employee Class (in the designer). When I select that, it gives me 3 more errors (all yellow).
Option Strict On
Public Class Employee
Private firstName As String ' employee first name
[code]....
View 3 Replies
Jan 16, 2012
inherit from two classes in VB.net?We are developing Custom User Controls that inherits from say System.Web.UI.WebControls.Label. We are planning on implementing a bunch of these controls but they will share mostly the same additional properties. We are hopeful about centralising these properties.I have looked into interfaces but it seems they only 'contract' properties you need to implement.
View 2 Replies
Feb 15, 2011
I'm currently taking a newbie VB course (online) and in this program that I am writing, I am getting one error (red) that when double clicked in the Error List, takes me to the Application.Designer window and states that "Employee is a type in 'WindowsApplication1' and cannot be used as an expression." The only solution it gives me is to generate the Employee Class (in the designer). When I select that, it gives me 3 more errors (all yellow). The Employee class has been made, so I don't really know where else to go from here. Could anyone point me in the right direction?
[Code]...
View 5 Replies
Apr 5, 2012
I have a function that will allow me to edit the manager property of a user here:
Public Shared Sub SetManagerProperty(ByVal de As DirectoryEntry, ByVal pName As String, ByVal pValue As String)
'First make sure the property value isnt "nothing"
[Code]....
But what if the manager is not in the Company OU? How can I edit this to search for him in the entire domain?
View 1 Replies
Jun 17, 2011
I am experimenting with a transition from my application built in VB6 to vb.net. I know, about time. At the same time, i am making changes and improving upon the original. One area that I am working on is within my employee class. very standard class, nothing fancy. One change I want to make though is allow for an employee to be assigned more than one work location. Employee has (is assigned) Stores. In reading about collections, it appears they are different in .net (as they should be), but I don't know what the sytax changes will be to implement my changes.
View 6 Replies
Jun 27, 2011
I am having trouble getting inheritance to work with the VB 2008 Express entity classes. I am a beginner with VB.Net and self-taught in VB6.0.I am able to pull data from an SQL Server data base into my application using the O/R designer. The data can be successfully queried using LINQ to SQL, either returning a single record, or multiple records or an entire table as a collection of the enty class type (so the problem is not with LINQ queries).
View 2 Replies
Feb 26, 2011
I've been wondering if there is anyway to extend a sub of a base class in a derived class or subclass. To date, the only thing I've been able to find is overrides and overloads functions, but to my understanding these functions just ignore your base class's sub and just allows you to run the new one with the same name.
What I want to be able to do is:
CODE:
I'm not sure whether this is possible, or if I'd simply either make a new sub in my derived class that first ran the base's class sub or whether I'd override the base class and then copy and paste the old code.
View 6 Replies
Oct 15, 2011
I seem to be having a problem with controls that I am creating as new classes (not UserControls) inheriting from an existing system control. Everything seems ok while I create the control code, through to the compile (which is successful and adds the control to the toolbox) and dragging the control from the toolbox to the GUI surface. However, when I then debug or compile the project, I get a message such
[Code]...
View 2 Replies
Jan 23, 2012
I have two classes, one nested in the other. [code]Neither "Name" or "ID" are unique between operations and records.I wish to construct a dictionary using LINQ = Dictionary(Of String, Of List(Of Integer), whereby the keys are uniqe examples of Names in my collection and the values are the collective set of distinct IDs that are associated with those names.
View 2 Replies
Oct 4, 2011
How can I make a task manager. I found this code but I do not know how to test it. I mean its just a class1.vb and then I add another form.
Here's the code:
Imports Microsoft.VisualBasic
Imports System
Imports System.Diagnostics
Imports System.ComponentModel
Namespace MyProcessSample
[Code] .....
View 1 Replies
Oct 24, 2009
Here is some example code of what I mean:
vb
Public Class Form1
Private Sub Button1_Click(ByVal sender as Object, e as systemEventArgs) Handles Button1.Click
[Code]....
View 5 Replies
Jul 10, 2009
I m trying to raise Click event of Textbox explictly but I m getting "Derived classes cannot raise base classes" error.[code]....
View 1 Replies
Dec 23, 2011
i want to calculate the Productivity for the employee when he saled it will add to his account by his ID so i want to calculated by ID from log in ?
View 6 Replies
Oct 20, 2010
I am developing an application for employee goals and management. The application has a login screen that when a employee successfuly logs in takes him to main screen that contains a table to enter Items, Accesories, Insurance,ect. and will also allow the employee to see data from previous days. Now my question is how do I make this table that is on the Main Screen present data that belongs to only to the employee that is log in? And also How do I let this employee enter the sales for the day, update
and record into this database? Do I have to make different databases for each employee?
View 2 Replies
Jun 20, 2009
I am trying to Mask Employee ID, so the user doesn't have to type the entire employee ID number CCETA01. I want them to type only two digit numbers. e.g. 01 to 99...
Here what I did but its not working:I draged from toolbox a Maskedtextbox on the Form and in the textbox progerties I put cce a. The entire number show up on my textbox pretty good but it does not allow me to change the two digit numeric number?
View 2 Replies
Jan 1, 2012
I have Class1 and class2 which is inside class1, VB.NET code:
Public Class class1
Public varisbleX As Integer = 1
Public Class class2
[code]....
View 1 Replies
Dec 8, 2011
Employee Data Application
Part 1: Recording employee data
For Gams, create an application that allows a user to enter the following employee
[code].....
View 2 Replies
Sep 22, 2007
want to know how to code in vb for developing a payroll software want 2 make software for a industry of min 200 employee's..
View 8 Replies
Jun 11, 2011
i wanted to show the name of an employee once he/she typed the correct id number and password.. and it will show the name into the name textbox... same as the the current time once the user clicked the time in button it will show into the time-in txtbox...same to the time-out how its logic goes..
View 3 Replies
Jul 8, 2009
I have a form with a datagridview that show a list of employees. Right next to the datagridview, I have a small set of textbox containing employee information (name, phone, etc) which is my "details section". I have a tableadapter that populate the datagridview, this is working well. Now, what I want is to when I select a row in the datagridview, the details of the employee shows up in the details section.
I tried to bind textboxes to the correct column. It works, but if I specify the datatable a query that will get this employee info, the data of the datagridview change to be the only row in it. I want the list to be showing all results and then the details secion giving only information on the selected employee. Do I need two dataset for this?
View 7 Replies
Sep 28, 2009
I have created a class using the code below. Why do I get an error saying Type 'Employee' is not defined..[code]
View 1 Replies
Jul 13, 2011
I have to make an interviews with programmers. Do you have any ideas how I can test their knowledge from the field of vb.net/C#?
View 2 Replies
Mar 24, 2012
I have a problem how DateTimePicker to calculate if how many days of an employees work and the DateTimePicker1 will get the Days from another Table time in and time out and will display it in a listview the Day Time IN and TIme out.
View 3 Replies