示例#1
0
        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 }
            });
        }
示例#2
0
    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();
    }
示例#3
0
        public IHttpActionResult PostEmployeesTable(EmployeesTable employeesTable)
        {
            db.EmployeesTables.Add(employeesTable);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = employeesTable.EmployeeID }, employeesTable));
        }
示例#4
0
        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));
        }
示例#5
0
        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);
	    }
示例#7
0
        public ActionResult DeleteConfirmed(int id)
        {
            EmployeesTable employeesTable = db.EmployeesTables.Find(id);

            db.EmployeesTables.Remove(employeesTable);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
示例#8
0
        public ActionResult <EmployeesTable> AddEmployees([FromBody] EmployeesTable incomingEmployees)
        {
            var db = new ScheduleQuikDbContext();

            db.Employees.Add(incomingEmployees);
            db.SaveChanges();
            return(incomingEmployees);
        }
示例#9
0
 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));
 }
示例#10
0
        public IHttpActionResult GetEmployeesTable(int id)
        {
            EmployeesTable employeesTable = db.EmployeesTables.Find(id);

            if (employeesTable == null)
            {
                return(NotFound());
            }

            return(Ok(employeesTable));
        }
示例#11
0
        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));
        }
示例#12
0
        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));
        }
示例#13
0
        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));
        }
示例#14
0
        // 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));
        }
示例#15
0
        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));
        }
示例#16
0
 public SampleDb()
     : base("Server=(local)\\SQL2017;User ID=sa;Password=Password12!;Initial Catalog=pocodata;")
 {
     Employees = new EmployeesTable(this);
 }
示例#17
0
 public SampleDb()
     : base("Data Source=.; Integrated Security=True; Initial Catalog=pocodata; MultipleActiveResultSets=True;")
 {
     Employees = new EmployeesTable(this);
 }
示例#18
0
    //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;
    }
示例#19
0
    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();
    }
示例#20
0
    //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);
    }