public ActionResult Edit(int id) { TechnicalDetailsModels techmod = new TechnicalDetailsModels(); DataTable dbtechnical = new DataTable(); using (SqlConnection sqlcon = new SqlConnection(connectionstring)) { sqlcon.Open(); string editquery = "SELECT * FROM Technical_Details WHERE EmployeeID=@EmployeeID"; SqlDataAdapter sqladp = new SqlDataAdapter(editquery, sqlcon); sqladp.SelectCommand.Parameters.AddWithValue("@EmployeeID", id); sqladp.Fill(dbtechnical); } if (dbtechnical.Rows.Count == 1) { techmod.EmployeeID = Convert.ToInt32(dbtechnical.Rows[0][0].ToString()); techmod.UI = dbtechnical.Rows[0][1].ToString(); techmod.Programming_Languages = dbtechnical.Rows[0][2].ToString(); techmod.ORM_Technologies = dbtechnical.Rows[0][3].ToString(); techmod.Databases = dbtechnical.Rows[0][4].ToString(); return(View(techmod)); } else { return(RedirectToAction("Index")); } }
public string EditTechnical(TechnicalDetailsModels technicaldetails) { int result = 0; try { sqlConnection = OpenConnection(); sqlCommand = new SqlCommand(); sqlCommand.Connection = sqlConnection; sqlCommand.CommandType = CommandType.StoredProcedure; sqlCommand.CommandText = "uspEditTechnicalDetails"; sqlCommand.Parameters.Add("@EmployeeID", SqlDbType.Int).Value = technicaldetails.EmployeeID; sqlCommand.Parameters.Add("@UI", SqlDbType.VarChar).Value = technicaldetails.UI; sqlCommand.Parameters.Add("Programming_Languages", SqlDbType.VarChar).Value = technicaldetails.Programming_Languages; sqlCommand.Parameters.Add("ORM_Technologies", SqlDbType.VarChar).Value = technicaldetails.ORM_Technologies; sqlCommand.Parameters.Add("Databases", SqlDbType.VarChar).Value = technicaldetails.Databases; result = sqlCommand.ExecuteNonQuery(); if (result > 0) { return("success"); } return("failed"); } catch (Exception ex) { return("An error has been occured, please contact administrator:" + ex.Message); } finally { CloseConncetion(sqlConnection); } }
public int SaveTechnical(TechnicalDetailsModels technical) { int result = 0; try { string connectionstring = "Data Source=RAKI;Initial Catalog=PioneerEmployeeDB;" + "Integrated Security=True"; SqlConnection mysqlconnection = new SqlConnection(connectionstring); mysqlconnection.Open(); string sqltechnicaldetails = @"INSERT INTO Technical_Details(UI,Programming_Languages,ORM_Technologies,Databases)VALUES('" + technical.UI + "'," + "'" + technical.Programming_Languages + "'," + "'" + technical.ORM_Technologies + "'," + "'" + technical.Databases + "')"; SqlCommand command; command = new SqlCommand(sqltechnicaldetails, mysqlconnection); result = command.ExecuteNonQuery(); if (result > 0) { MessageBox.Show("Details have been saved Successfully:"); } mysqlconnection.Close(); } catch (Exception ex) { MessageBox.Show("An error has been occured, please contact the administartor: " + ex.Message); } return(result); }
protected void EmployeeIDDropDownList_SelectedIndexChanged(object sender, EventArgs e) { TechnicalDetailsModels technicalmodel = new TechnicalDetailsModels(); TechnicalDataAccess technicaldata = new TechnicalDataAccess(); technicalmodel = technicaldata.GetTechnicalDetails(Convert.ToInt32(EmployeeIDDropDownList.SelectedValue)); UITextBox.Text = technicalmodel.UI; Programming_LanguagesTextBox.Text = technicalmodel.Programming_Languages; ORM_TechnologiesTextBox.Text = technicalmodel.ORM_Technologies; DatabasesTextBox.Text = technicalmodel.Databases; }
public ActionResult Create(TechnicalDetailsModels techmodels) { using (SqlConnection sqlcon = new SqlConnection(connectionstring)) { sqlcon.Open(); string query = "INSERT INTO Technical_Details VALUES(@UI,@Programming_Languages,@ORM_Technologies,@Databases)"; SqlCommand cmd = new SqlCommand(query, sqlcon); cmd.Parameters.AddWithValue("@UI", techmodels.UI); cmd.Parameters.AddWithValue("@Programming_Languages", techmodels.Programming_Languages); cmd.Parameters.AddWithValue("@ORM_Technologies", techmodels.ORM_Technologies); cmd.Parameters.AddWithValue("@Databases", techmodels.Databases); cmd.ExecuteNonQuery(); } return(RedirectToAction("Index")); }
public ActionResult Edit(TechnicalDetailsModels tedmodel) { using (SqlConnection sqlcon = new SqlConnection(connectionstring)) { sqlcon.Open(); string edquery = "UPDATE Technical_Details SET UI=@UI,Programming_Languages=@Programming_Languages,ORM_Technologies=@ORM_Technologies,Databases=@Databases WHERE EmployeeID=@EmployeeID"; SqlCommand cmd = new SqlCommand(edquery, sqlcon); cmd.Parameters.AddWithValue("@EmployeeID", tedmodel.EmployeeID); cmd.Parameters.AddWithValue("@UI", tedmodel.UI); cmd.Parameters.AddWithValue("@Programming_Languages", tedmodel.Programming_Languages); cmd.Parameters.AddWithValue("@ORM_Technologies", tedmodel.ORM_Technologies); cmd.Parameters.AddWithValue("@Databases", tedmodel.Databases); cmd.ExecuteNonQuery(); } return(RedirectToAction("Index")); }
private void button3_Click(object sender, EventArgs e) { try { TechnicalDetailsModels TDModel = new TechnicalDetailsModels() { UI = UItextbox.Text, Programming_Languages = Programmingtextbox.Text, ORM_Technologies = ORMtextbox.Text, Databases = Databasestextbox.Text, }; TechnicalDataAccess technical = new TechnicalDataAccess(); technical.SaveTechnical(TDModel); } catch (Exception ex) { MessageBox.Show("Please enter the values:"); } }
protected void TechnicalDetailsSave_Click(object sender, EventArgs e) { try { TechnicalDetailsModels technicalmodel = new TechnicalDetailsModels() { UI = UITextBox.Text, Programming_Languages = Programming_LanguagesTextBox.Text, ORM_Technologies = ORM_TechnologiesTextBox.Text, Databases = DatabasesTextBox.Text, }; TechnicalDataAccess technicaldata = new TechnicalDataAccess(); string techdata = technicaldata.SaveTechnical(technicalmodel); if (techdata.Equals("success")) { Response.Write("<script>alert('Details have been saved successfully!');</script>"); } } catch (Exception ex) { Response.Write("<script>alert('Please enter the values!" + ex.Message + "');</script>"); } }
public TechnicalDetailsModels GetTechnicalDetails(int employeeid) { TechnicalDetailsModels techdetails = new TechnicalDetailsModels(); sqlConnection = OpenConnection(); sqlCommand = new SqlCommand(); sqlCommand.Connection = sqlConnection; sqlCommand.CommandType = CommandType.StoredProcedure; sqlCommand.CommandText = "uspGetTechnicalDetails"; sqlCommand.Parameters.Add("@EmployeeID", SqlDbType.Int).Value = Convert.ToInt32(employeeid); SqlDataReader technicaldatareader = sqlCommand.ExecuteReader(); while (technicaldatareader.Read()) { techdetails.EmployeeID = technicaldatareader.GetInt32(technicaldatareader.GetOrdinal("EmployeeID")); techdetails.UI = technicaldatareader.GetString(technicaldatareader.GetOrdinal("UI")); techdetails.Programming_Languages = technicaldatareader.GetString(technicaldatareader.GetOrdinal("Programming_Languages")); techdetails.ORM_Technologies = technicaldatareader.GetString(technicaldatareader.GetOrdinal("ORM_Technologies")); techdetails.Databases = technicaldatareader.GetString(technicaldatareader.GetOrdinal("Databases")); } CloseConncetion(sqlConnection); return(techdetails); }
protected void TechnicalDetailsEdit_Click(object sender, EventArgs e) { try { TechnicalDetailsModels tmodels = new TechnicalDetailsModels() { EmployeeID = Convert.ToInt32(EmployeeIDDropDownList.SelectedValue), UI = UITextBox.Text, Programming_Languages = Programming_LanguagesTextBox.Text, ORM_Technologies = ORM_TechnologiesTextBox.Text, Databases = DatabasesTextBox.Text, }; TechnicalDataAccess taccess = new TechnicalDataAccess(); string tdata = taccess.EditTechnical(tmodels); if (tdata.Equals("success")) { Response.Write("<script>alert('Details have been updated successfully!');</script>"); } } catch (Exception ex) { Response.Write("<script>alert('Please enter the values!" + ex.Message + "');</script>"); } }