private void employeeToolStripMenuItem_Click(object sender, EventArgs e) { addEmployee l = new addEmployee(); l.MdiParent = this; l.WindowState = FormWindowState.Maximized; l.Show(); }
public long saveEmployee(addEmployee EmployeeToSave) { string sqlString = "INSERT into employees (DirectManager,CountryID,DepartmentID,GIN,Alias,DisplayName,UserPrincipalName,JobCode,MobilePhone,GOLDMedalOwner,QuestOTC) values(" + EmployeeToSave.DirectManager + "," + EmployeeToSave.CountryID + "," + EmployeeToSave.DepartmentID + ",'" + EmployeeToSave.GIN + "','" + EmployeeToSave.Alias + "','" + EmployeeToSave.DisplayName + "','" + EmployeeToSave.UserPrincipalName + "','" + EmployeeToSave.JobCode + "','" + EmployeeToSave.MobilePhone + "','" + EmployeeToSave.GOLDMedalOwner + "'," + EmployeeToSave.QuestOTC + "); "; MySql.Data.MySqlClient.MySqlCommand cmd = new MySql.Data.MySqlClient.MySqlCommand(sqlString, conn); cmd.ExecuteNonQuery(); long id = cmd.LastInsertedId; return(id); }
public HttpResponseMessage Post([FromBody] addEmployee value) { EmployeePersistence ep = new EmployeePersistence(); long id; id = ep.saveEmployee(value); value.empID = id; var resp = new HttpResponseMessage() { Content = new StringContent("[{\"Status\": 200},{\"Message\":\"New employee record has been added to database!\"}]") }; resp.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); return(resp); }
public HttpResponseMessage put(string id, [FromBody] addEmployee value) { EmployeePersistence ep = new EmployeePersistence(); bool recordExisted = false; recordExisted = ep.UpdateEmployee(id, value); HttpResponseMessage response; if (recordExisted) { response = Request.CreateResponse(HttpStatusCode.NoContent); } else { response = Request.CreateResponse(HttpStatusCode.NotFound); } return(response); }
public bool UpdateEmployee(string als, addEmployee EmployeeToUpdate) { MySql.Data.MySqlClient.MySqlDataReader getReader = null; string getString = "SELECT * FROM employees WHERE Alias = '" + als.ToString() + "';"; MySql.Data.MySqlClient.MySqlCommand cmd = new MySql.Data.MySqlClient.MySqlCommand(getString, conn); getReader = cmd.ExecuteReader(); if (getReader.Read()) { getReader.Close(); getString = "UPDATE employees SET DirectManager=" + EmployeeToUpdate.DirectManager + ",CountryID=" + EmployeeToUpdate.CountryID + ",DepartmentID=" + EmployeeToUpdate.DepartmentID + ",GIN='" + EmployeeToUpdate.GIN + "',Alias='" + EmployeeToUpdate.Alias + "',DisplayName='" + EmployeeToUpdate.DisplayName + "',UserPrincipalName='" + EmployeeToUpdate.UserPrincipalName + "',JobCode='" + EmployeeToUpdate.JobCode + "',MobilePhone='" + EmployeeToUpdate.MobilePhone + "',GOLDMedalOwner='" + EmployeeToUpdate.GOLDMedalOwner + "',QuetOTC=" + EmployeeToUpdate.QuestOTC + " WHERE Alias = '" + als.ToString() + "'; "; cmd = new MySql.Data.MySqlClient.MySqlCommand(getString, conn); cmd.ExecuteNonQuery(); return(true); } else { return(false); } }