0% found this document useful (0 votes)
75 views

"Select From Dbo - Project Where Leadid '" "'": Project Project Project Sqlconnection

1. The GetProject method queries a database table to retrieve project details for a given employee ID. 2. The GetEmployee method retrieves an employee object by email from an EmployeeService. 3. The UpdateEmployee method updates an employee record in the database table by calling an EmployeeService method.

Uploaded by

Saini Sandeep
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
75 views

"Select From Dbo - Project Where Leadid '" "'": Project Project Project Sqlconnection

1. The GetProject method queries a database table to retrieve project details for a given employee ID. 2. The GetEmployee method retrieves an employee object by email from an EmployeeService. 3. The UpdateEmployee method updates an employee record in the database table by calling an EmployeeService method.

Uploaded by

Saini Sandeep
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

public Project GetProject(string employeeId)

{
Project proj = new Project();
con = new SqlConnection(ConnectionString);
con.Open();
string query = "Select * from dbo.Project where LeadId ='" + employeeId +
"'";
SqlCommand command = new SqlCommand(query, con);

SqlDataReader rdr = command.ExecuteReader();

while (rdr.Read())
{
proj.ProjectID = rdr[0].ToString();
proj.ProjectName = rdr[1].ToString();
proj.StartDate = Convert.ToDateTime(rdr[2]);
proj.EndDate = Convert.ToDateTime(rdr[3]);
proj.LeadID = rdr[0].ToString();

con.Close();
return proj;

[OperationContract]
Project GetProject(string employeeId);

public Employee GetEmployee(string email)


{
Employee emp = new Employee();
EmployeeService empservice = new EmployeeService();
emp = empservice.GetEmployee(email);
return emp;
}

public void UpdateEmployee(Employee emp)


{
con = new SqlConnection(ConnectionString);
con.Open();
string query = "UPDATE Employee SET EmployeeName='"+emp.EmployeeName+ "',
EmployeeId='"+emp.EmployeeId +"' WHERE EmployeeId='"+emp.EmployeeId+"'";
SqlCommand command = new SqlCommand(query, con);

SqlDataReader rdr = command.ExecuteReader();


con.Close();
}

[OperationContract]
public void UpdateEmployee(Employee emp)
{
//Employee emp = new Employee();
EmployeeService empservices = new EmployeeService();
empservices.UpdateEmployee(emp);

private void btnSave_Click(object sender, RoutedEventArgs e)


{
Employee empUpdate = new Employee();
empUpdate.EmployeeName = txtName.Text;
empUpdate.EmailId = txtEmail.Text;
viewproject.UpdateEmployeeCompleted += new
EventHandler<System.ComponentModel.AsyncCompletedEventArgs>(viewproject_UpdateEmployeeCom
pleted);
viewproject.UpdateEmployeeAsync(empUpdate);
}

void viewproject_UpdateEmployeeCompleted(object sender,


System.ComponentModel.AsyncCompletedEventArgs e)
{
MessageBox.Show("Database Updated");
}

<Grid Grid.Column="2" Grid.Row="1" Height="27" HorizontalAlignment="Left"


Margin="608,300,0,0" Name="grid1" VerticalAlignment="Top" Width="76">
<HyperlinkButton Content="Save" Click="btnSave_Click" Name="btnSave"
Margin="2"
Visibility="Collapsed" HorizontalAlignment="Center"
VerticalAlignment="Center" />
</Grid>
<Grid Height="27" HorizontalAlignment="Left" Margin="514,303,0,0" Name="grid2"
VerticalAlignment="Top" Width="76" Grid.Column="2" Grid.Row="1">
<HyperlinkButton Content="View Appraisal" Name="ViewAppraisal"
Click="ViewAppraisal_Click" HorizontalAlignment="Center" Margin="2"
VerticalAlignment="Center" />
</Grid>

You might also like