public Emplyoee FindEmpById2(int ecode) { Emplyoee emp = new Emplyoee(); cmd = new SqlCommand(); cmd.CommandText = "Select * from tbl_employee where ecode = " + ecode; cmd.Connection = con; //Open Connection con.Open(); //Execute the command and get the database SqlDataReader sdr = cmd.ExecuteReader(); //Read and input emp.Ecode = (int)sdr[0]; emp.Ename = sdr[1].ToString(); emp.Salary = (int)sdr[2]; emp.Deptid = (int)sdr[3]; //Close the connection sdr.Close(); con.Close(); return(emp); }
public ActionResult DeleteConfirmed(int id) { Emplyoee emplyoee = db.Emplyoees.Find(id); db.Emplyoees.Remove(emplyoee); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "Id,FirstName,LastName,EmailID,City,Country")] Emplyoee emplyoee) { if (ModelState.IsValid) { db.Entry(emplyoee).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(emplyoee)); }
public ActionResult Create([Bind(Include = "Id,FirstName,LastName,EmailID,City,Country")] Emplyoee emplyoee) { if (ModelState.IsValid) { db.Emplyoees.Add(emplyoee); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(emplyoee)); }
public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Emplyoee emplyoee = db.Emplyoees.Find(id); if (emplyoee == null) { return(HttpNotFound()); } return(View(emplyoee)); }
public Emplyoee FindEmpById(int ecode) { Emplyoee emp = new Emplyoee(); DataRow[] rows = ds.Tables[0].Select("ecode= " + ecode); DataRow row = rows[0]; emp.Ecode = (int)row[0]; emp.Ename = row[1].ToString(); emp.Salary = (int)row[2]; emp.Deptid = (int)row[3]; return(emp); }
protected void Button2_Click(object sender, EventArgs e) { Emplyoee emp = new Emplyoee { Ecode = int.Parse(TextBox1.Text), Ename = TextBox2.Text, Salary = int.Parse(TextBox3.Text), Deptid = int.Parse(TextBox4.Text), }; HRMSServiceClient proxy = new HRMSServiceClient(); proxy.AddEmp(emp); List <Emplyoee> list = proxy.GetAllEmpForMe().ToList(); GridView1.DataSource = list; GridView1.DataBind(); }
public List <Emplyoee> SelectAllEmp() { List <Emplyoee> empList = new List <Emplyoee>(); //Add all the records from dataset foreach (DataRow row in ds.Tables[0].Rows) { Emplyoee emp = new Emplyoee { Ecode = (int)row[0], Ename = row[1].ToString(), Salary = (int)row[2], Deptid = (int)row[3] }; empList.Add(emp); } return(empList); }
public void InsertEmployee(Emplyoee emp) { //Create a new record as per table in Dataset DataRow row = ds.Tables[0].NewRow(); //Add values to the newly created row row[0] = emp.Ecode; row[1] = emp.Ename; row[2] = emp.Salary; row[3] = emp.Deptid; //Add the row to the Dataset ds.Tables[0].Rows.Add(row); SqlCommandBuilder cb = new SqlCommandBuilder(da); //Save the Dataset da.Update(ds, "tbl_employee"); }
public List <Emplyoee> SelectAllEmp() { List <Emplyoee> empList = new List <Emplyoee>(); //ToDo Select Statement using ADO.NET //Configure command for SELECT cmd = new SqlCommand(); cmd.CommandText = "Select *from tbl_employee"; cmd.Connection = con; //Open Connection con.Open(); //Execute the command and get the database SqlDataReader sdr = cmd.ExecuteReader(); //Read and input while (sdr.Read()) { Emplyoee emp = new Emplyoee { Ecode = (int)sdr[0], Ename = sdr[1].ToString(), Salary = (int)sdr[2], Deptid = (int)sdr[3] }; empList.Add(emp); } //Close the connection sdr.Close(); con.Close(); return(empList); }
public void InsertEmployee(Emplyoee emp) { //ToDo Insert Operation Using SQL cmd = new SqlCommand(); cmd.CommandText = "Insert into tbl_employee values(@ec,@en,@sal,@did)"; //Add parameters values to Command Text cmd.Parameters.Clear(); cmd.Parameters.AddWithValue("@ec", emp.Ecode); cmd.Parameters.AddWithValue("@en", emp.Ename); cmd.Parameters.AddWithValue("@sal", emp.Salary); cmd.Parameters.AddWithValue("@did", emp.Deptid); //attach conection cmd.Connection = con; con.Open(); cmd.ExecuteNonQuery(); con.Close(); //add things }
public void AddEmployee(Emplyoee emp) { dalCon.InsertEmployee(emp); }
public void AddEmp(Emplyoee emp) { BLL bLL = new BLL(); bLL.AddEmployee(emp); }