public ActionResult Save(EmployeesTable emp) { bool status = false; if (ModelState.IsValid) { using (MyDatabaseEntities dc = new MyDatabaseEntities()) { if (emp.EmployeeID > 0) { //Edit var v = dc.EmployeesTables.Where(a => a.EmployeeID == emp.EmployeeID).FirstOrDefault(); if (v != null) { v.FirstName = emp.FirstName; v.LastName = emp.LastName; v.EmailID = emp.EmailID; v.City = emp.City; v.Country = emp.Country; } } else { //Save dc.EmployeesTables.Add(emp); } dc.SaveChanges(); status = true; } } return(new JsonResult { Data = new { status = status } }); }
protected void bind_formview(string mode) { //have to use a collection as formview needs to bind to enumerable EmployeesTableCollection _tbl = new EmployeesTableCollection(); if (mode != "Insert") { int _pid = wwi_func.vint(wwi_security.DecryptString(get_token("pid").ToString(), "publiship")); EmployeesTable _ct = new EmployeesTable(_pid); _tbl.Add(_ct); //store original value for name so we can check against database when saving if (this.dxhfOrder.Contains("oldvalue")) { this.dxhfOrder.Remove("oldvalue"); } this.dxhfOrder.Add("oldvalue", _ct.Name); } else { EmployeesTable _ct = new EmployeesTable(); _tbl.Add(_ct); } this.fmvEmployee.DataSource = _tbl; this.fmvEmployee.DataBind(); }
public IHttpActionResult PostEmployeesTable(EmployeesTable employeesTable) { db.EmployeesTables.Add(employeesTable); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = employeesTable.EmployeeID }, employeesTable)); }
public IHttpActionResult PutEmployeesTable(int id, EmployeesTable employeesTable) { if (id != employeesTable.EmployeeID) { return(BadRequest()); } db.Entry(employeesTable).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!EmployeesTableExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IActionResult> Edit(double?id, [Bind("Age,Department,EducationField,EmployeeNumber,EnvironmentSatisfaction,Gender,HourlyRate,JobRole,JobSatisfaction,MaritalStatus,MonthlyIncome,RelationshipSatisfaction,StandardHours,StockOptionLevel")] EmployeesTable employeesTable) { if (id != employeesTable.EmployeeNumber) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(employeesTable); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EmployeesTableExists(employeesTable.EmployeeNumber)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(employeesTable)); }
public void Insert(string Name,int? DepartmentID,int? SectionID,int? OfficeID,string EmailAddress,bool? Live,string Password,string OpeningForm,byte[] Ts,int? DefaultView,byte? IsEditor) { EmployeesTable item = new EmployeesTable(); item.Name = Name; item.DepartmentID = DepartmentID; item.SectionID = SectionID; item.OfficeID = OfficeID; item.EmailAddress = EmailAddress; item.Live = Live; item.Password = Password; item.OpeningForm = OpeningForm; item.Ts = Ts; item.DefaultView = DefaultView; item.IsEditor = IsEditor; item.Save(UserName); }
public ActionResult DeleteConfirmed(int id) { EmployeesTable employeesTable = db.EmployeesTables.Find(id); db.EmployeesTables.Remove(employeesTable); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult <EmployeesTable> AddEmployees([FromBody] EmployeesTable incomingEmployees) { var db = new ScheduleQuikDbContext(); db.Employees.Add(incomingEmployees); db.SaveChanges(); return(incomingEmployees); }
public ActionResult Edit([Bind(Include = "Id,Name,Gender,Salary,Country")] EmployeesTable employeesTable) { if (ModelState.IsValid) { db.Entry(employeesTable).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(employeesTable)); }
public IHttpActionResult GetEmployeesTable(int id) { EmployeesTable employeesTable = db.EmployeesTables.Find(id); if (employeesTable == null) { return(NotFound()); } return(Ok(employeesTable)); }
public ActionResult Create([Bind(Include = "Id,Name,Gender,Salary,Country")] EmployeesTable employeesTable) { if (ModelState.IsValid) { db.EmployeesTables.Add(employeesTable); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(employeesTable)); }
public async Task <IActionResult> Create([Bind("Age,Department,EducationField,EmployeeNumber,EnvironmentSatisfaction,Gender,HourlyRate,JobRole,JobSatisfaction,MaritalStatus,MonthlyIncome,RelationshipSatisfaction,StandardHours,StockOptionLevel")] EmployeesTable employeesTable) { if (ModelState.IsValid) { _context.Add(employeesTable); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(employeesTable)); }
public IHttpActionResult DeleteEmployeesTable(int id) { EmployeesTable employeesTable = db.EmployeesTables.Find(id); if (employeesTable == null) { return(NotFound()); } db.EmployeesTables.Remove(employeesTable); db.SaveChanges(); return(Ok(employeesTable)); }
// GET: EmployeesTables/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } EmployeesTable employeesTable = db.EmployeesTables.Find(id); if (employeesTable == null) { return(HttpNotFound()); } return(View(employeesTable)); }
public ActionResult UpdateEmployees([FromRoute] int id, [FromBody] EmployeesTable newInformation) { var db = new ScheduleQuikDbContext(); // find the employee var employees = db.Employees.FirstOrDefault(f => f.Id == id); if (employees != null) { employees.FirstName = newInformation.FirstName; employees.LastName = newInformation.LastName; employees.PhoneNumber = newInformation.PhoneNumber; employees.EmailAddress = newInformation.EmailAddress; db.SaveChanges(); } else { return(NotFound()); } return(Ok(employees)); }
public SampleDb() : base("Server=(local)\\SQL2017;User ID=sa;Password=Password12!;Initial Catalog=pocodata;") { Employees = new EmployeesTable(this); }
public SampleDb() : base("Data Source=.; Integrated Security=True; Initial Catalog=pocodata; MultipleActiveResultSets=True;") { Employees = new EmployeesTable(this); }
//end update /// <summary> /// new record /// </summary> protected int insert_contact() { int _newid = 0; //original value for countryname string _oldvalue = this.dxhfOrder.Contains("oldvalue") ? this.dxhfOrder.Get("oldvalue").ToString() : ""; try { int? _intnull = null; //new instance of record EmployeesTable _tbl = new EmployeesTable(); //get values off insert form //check duplicate name ASPxTextBox _txt = (ASPxTextBox)this.fmvEmployee.FindControl("dxtxtEmployeeInsert"); if (_txt != null && _txt.Text != "") { string _newvalue = _txt.Text.Trim().ToString(); //country name bool _duplicate = _newvalue != _oldvalue ? wwi_func.value_exists("Name", "EmployeesTable", _newvalue) : false; if (!_duplicate) { //name _tbl.Name = _txt.Text.ToString(); //email _txt = (ASPxTextBox)this.fmvEmployee.FindControl("dxtxtEmailInsert"); if (_txt != null) { _tbl.EmailAddress = _txt.Text.ToString(); } //office ASPxComboBox _cbo = (ASPxComboBox)this.fmvEmployee.FindControl("dxcboOfficeID"); if (_cbo != null) { _tbl.OfficeID = _cbo.Value != null ? wwi_func.vint(_cbo.Value.ToString()) : _intnull; } //department _cbo = (ASPxComboBox)this.fmvEmployee.FindControl("dxcboDepartmentID"); if (_cbo != null) { _tbl.DepartmentID = _cbo.Value != null ? wwi_func.vint(_cbo.Value.ToString()) : _intnull; } //live ASPxCheckBox _ck = (ASPxCheckBox)this.fmvEmployee.FindControl("dxckLiveInsert"); if (_ck != null) { _tbl.Live = _ck.Checked; } _tbl.Save(); //get new id _newid = (int)_tbl.GetPrimaryKeyValue(); }//end if else { string _ex = string.Format("{0} is already in database. This record will not be saved", _newvalue); this.dxlblErr.Text = _ex; this.dxpnlErr.ClientVisible = true; }//end if duplicate }//end if text } catch (Exception ex) { string _ex = ex.Message.ToString(); this.dxlblErr.Text = _ex; this.dxpnlErr.ClientVisible = true; } return _newid; }
protected void bind_formview(string mode) { //have to use a collection as formview needs to bind to enumerable EmployeesTableCollection _tbl = new EmployeesTableCollection(); if (mode != "Insert") { int _pid = wwi_func.vint(wwi_security.DecryptString(get_token("pid").ToString(), "publiship")); EmployeesTable _ct = new EmployeesTable(_pid); _tbl.Add(_ct); //store original value for name so we can check against database when saving if (this.dxhfOrder.Contains("oldvalue")) { this.dxhfOrder.Remove("oldvalue"); } this.dxhfOrder.Add("oldvalue", _ct.Name); } else { EmployeesTable _ct = new EmployeesTable(); _tbl.Add(_ct); } this.fmvEmployee.DataSource = _tbl; this.fmvEmployee.DataBind(); }
//end update /// <summary> /// new record /// </summary> protected int insert_contact() { int _newid = 0; //original value for countryname string _oldvalue = this.dxhfOrder.Contains("oldvalue") ? this.dxhfOrder.Get("oldvalue").ToString() : ""; try { int?_intnull = null; //new instance of record EmployeesTable _tbl = new EmployeesTable(); //get values off insert form //check duplicate name ASPxTextBox _txt = (ASPxTextBox)this.fmvEmployee.FindControl("dxtxtEmployeeInsert"); if (_txt != null && _txt.Text != "") { string _newvalue = _txt.Text.Trim().ToString(); //country name bool _duplicate = _newvalue != _oldvalue?wwi_func.value_exists("Name", "EmployeesTable", _newvalue) : false; if (!_duplicate) { //name _tbl.Name = _txt.Text.ToString(); //email _txt = (ASPxTextBox)this.fmvEmployee.FindControl("dxtxtEmailInsert"); if (_txt != null) { _tbl.EmailAddress = _txt.Text.ToString(); } //office ASPxComboBox _cbo = (ASPxComboBox)this.fmvEmployee.FindControl("dxcboOfficeID"); if (_cbo != null) { _tbl.OfficeID = _cbo.Value != null?wwi_func.vint(_cbo.Value.ToString()) : _intnull; } //department _cbo = (ASPxComboBox)this.fmvEmployee.FindControl("dxcboDepartmentID"); if (_cbo != null) { _tbl.DepartmentID = _cbo.Value != null?wwi_func.vint(_cbo.Value.ToString()) : _intnull; } //live ASPxCheckBox _ck = (ASPxCheckBox)this.fmvEmployee.FindControl("dxckLiveInsert"); if (_ck != null) { _tbl.Live = _ck.Checked; } _tbl.Save(); //get new id _newid = (int)_tbl.GetPrimaryKeyValue(); }//end if else { string _ex = string.Format("{0} is already in database. This record will not be saved", _newvalue); this.dxlblErr.Text = _ex; this.dxpnlErr.ClientVisible = true; } //end if duplicate } //end if text } catch (Exception ex) { string _ex = ex.Message.ToString(); this.dxlblErr.Text = _ex; this.dxpnlErr.ClientVisible = true; } return(_newid); }