protected void employeeDelete(object sender, GridViewDeleteEventArgs e) { Employee emp = context.Employees.FirstOrDefault(x => x.EmployeeID == id); context.Employees.Remove(emp); context.SaveChanges(); Response.Redirect("EmployeeDetails.aspx"); }
protected void placeOrderButton_Click(object sender, EventArgs e) { try { var connectionString = new HospitalDBEntities(); MedicalItem1 medicalItem1 = new MedicalItem1(); medicalItem1.Inventory = Convert.ToInt32(inventoryIDList.SelectedValue); medicalItem1.Name = nameTxt.Text; medicalItem1.Supplier = supplierTxt.Text; medicalItem1.Description = descriptionTxt.Text; medicalItem1.Price = Convert.ToDecimal(priceTxt.Text); medicalItem1.Quantity = Convert.ToInt32(quantityTxt.Text); connectionString.MedicalItems1.Add(medicalItem1); connectionString.SaveChanges(); errorLabel.Text = "Order Placed successfully"; nameTxt.Text = ""; supplierTxt.Text = ""; descriptionTxt.Text = ""; priceTxt.Text = ""; quantityTxt.Text = ""; } catch (NullReferenceException ex) { errorLabel.Text = ex.Message; } }
protected void registerBtn_Click(object sender, EventArgs e) { try { var connectionString = new HospitalDBEntities(); Employee emp = new Employee(); emp.Ward = Convert.ToInt32(wardNumber.Text); emp.EmployeeType = Convert.ToInt32(employeeType.Text); emp.FirstName = firstName.Text; emp.LastName = lastName.Text; emp.PhoneNumber = contactNumber.Text; emp.Address = address.Text; emp.Email = emailID.Text; emp.Password = userPassword.Text; emp.SIN = sinNumber.Text; connectionString.Employees.Add(emp); connectionString.SaveChanges(); wardNumber.Text = " "; employeeType.Text = " "; firstName.Text = " "; lastName.Text = " "; contactNumber.Text = " "; address.Text = " "; emailID.Text = " "; userPassword.Text = " "; sinNumber.Text = " "; registerLblSuccess.Text = "User Registered Successfully with login Employee ID " + emp.EmployeeID; registerLblError.Text = ""; } catch { registerLblError.Text = "User is not registered"; } }