Example #1
0
 private void button4_Click(object sender, EventArgs e)
 {
     emp emm = new emp();
     this.Hide();
     emm.ShowDialog();
     this.Close();
 }
Example #2
0
        public async Task <IActionResult> Post([FromBody] emp emp)
        {
            _context.Employee.Add(emp);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("get employee", new { id = emp.Id }, emp));
        }
Example #3
0
        //Q3. Create struct emp having member name and salary, using constructor initialized member. Write display method which will display name and salary
        static void Main(string[] args)
        {
            emp emp1 = new emp("ABC", 10000);

            emp1.display();
            Console.ReadLine();
        }
        // PUT api/employee/5
        //public void Put(int id, [FromBody]EmployeeModel employee)
        //{
        //    try
        //    {
        //        using (var empDbContext = new EmployeeDB())
        //        {
        //            var employeeList = empDbContext.emps.ToList();
        //            var employeeToBeUpdated = employeeList.Find(x => x.empno == id);

        //            emp emp = AdaptToDBEntity(employee);
        //            employeeToBeUpdated.ename = emp.ename;
        //            employeeToBeUpdated.hiredate = emp.hiredate;
        //            employeeToBeUpdated.job = emp.job;
        //            employeeToBeUpdated.sal = emp.sal;

        //            empDbContext.emps.AddOrUpdate(employeeToBeUpdated);
        //            empDbContext.SaveChanges();
        //        }
        //    }
        //    catch (Exception e)
        //    {
        //        Console.WriteLine(e);
        //        throw;
        //    }
        //}

        //public HttpResponseMessage Put(int id, [FromBody]EmployeeModel employee)
        //{
        //    try
        //    {
        //        using (var empDbContext = new EmployeeDB())
        //        {
        //            var employeeList = empDbContext.emps.ToList();
        //            var employeeToBeUpdated = employeeList.Find(x => x.empno == id);

        //            emp emp = AdaptToDBEntity(employee);
        //            employeeToBeUpdated.ename = emp.ename;
        //            employeeToBeUpdated.hiredate = emp.hiredate;
        //            employeeToBeUpdated.job = emp.job;
        //            employeeToBeUpdated.sal = emp.sal;

        //            empDbContext.emps.AddOrUpdate(employeeToBeUpdated);
        //            empDbContext.SaveChanges();
        //            return Request.CreateResponse(HttpStatusCode.Accepted);
        //        }
        //    }
        //    catch (Exception e)
        //    {
        //        Console.WriteLine(e);
        //        return Request.CreateErrorResponse(HttpStatusCode.BadRequest, e);
        //    }
        //}

        public IHttpActionResult Put(int id, [FromBody] EmployeeModel employee)
        {
            try
            {
                using (var empDbContext = new EmployeeDB())
                {
                    var employeeList        = empDbContext.emps.ToList();
                    var employeeToBeUpdated = employeeList.Find(x => x.empno == id);

                    emp emp = AdaptToDBEntity(employee);
                    employeeToBeUpdated.ename    = emp.ename;
                    employeeToBeUpdated.hiredate = emp.hiredate;
                    employeeToBeUpdated.job      = emp.job;
                    employeeToBeUpdated.sal      = emp.sal;

                    empDbContext.emps.AddOrUpdate(employeeToBeUpdated);
                    empDbContext.SaveChanges();
                    return(Ok());
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(Content(HttpStatusCode.BadRequest, e));
            }
        }
Example #5
0
        public async Task <IActionResult> Put(int id, [FromBody] emp emp)
        {
            if (id != emp.Id)
            {
                return(BadRequest());
            }

            _context.Entry(emp).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!EmployeeExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Example #6
0
        static void Main(string[] args)
        {
            Console.WriteLine("1-Math Struct Square & Cube Of Number\n");
            Console.WriteLine("Enter number To be squareed & cubed : ");
            int  n;
            bool b = int.TryParse(Console.ReadLine(), out n);

            Console.WriteLine("Square of {0} : {1}\nCube of {0} : {2}", n, math.sqaure(n), math.cube(n));         //calls the square & cube from math lib

            Console.WriteLine("\n----------------------------------------------------------------\n");

            Console.WriteLine("2-Claculator Struct For Factorial Of Number\n");
            Console.WriteLine("Enter no to find factorial : ");
            int  n1;
            bool b1 = int.TryParse(Console.ReadLine(), out n1);

            calculator.factor(n1);                          //calls the method from calculator lib factor method

            Console.WriteLine("\n----------------------------------------------------------------\n");

            Console.WriteLine("employee Details struct\n");
            Console.WriteLine("Enter Name Of Employee : ");
            string name = Console.ReadLine();

            Console.WriteLine("Enter Salary Of Employee : ");
            double salary;
            bool   b2 = double.TryParse(Console.ReadLine(), out salary);
            emp    e1 = new emp(name, salary);              //creating object of employee

            e1.disp_details();                              //displays the details of employee from emp lib
            Console.ReadLine();
        }
        public IHttpActionResult Postemp(emp emp)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.emps.Add(emp);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (empExists(emp.id))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = emp.id }, emp));
        }
        public IHttpActionResult Putemp(int id, emp emp)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != emp.id)
            {
                return(BadRequest());
            }

            db.Entry(emp).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!empExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public async Task <IActionResult> Edit(int id, [Bind("empid,name,city")] emp emp)
        {
            if (id != emp.empid)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(emp);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!empExists(emp.empid))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(emp));
        }
            public void show()
            {
                //this.personaldetails = 6;(  here this vraiable will not be worked because its is declared as protected indexer emp class so only inherited class can be accesed throughj this operator)
                emp e1 = new emp();

                Console.WriteLine(e1.mobileno);//internal datatype is used but need to create object of class where this internal datatype is declared
                Console.ReadKey();
            }
Example #11
0
        private void จดการขอมลพนกงานToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Hide();
            emp emp = new emp();

            emp.ShowDialog();
            this.Show();
        }
Example #12
0
        public ActionResult DeleteConfirmed(int id)
        {
            emp emp = db.emps.Find(id);

            db.emps.Remove(emp);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #13
0
        public ActionResult showResult()
        {
            emp E = new emp();

            E.Empno  = int.Parse(Request.Form["txtEmpno"]);
            E.Ename  = Request.Form["txtEname"];
            E.Salary = double.Parse(Request.Form["txtSalary"]);
            return(View(E));
        }
Example #14
0
        public ActionResult Sendobject()
        {
            emp E = new emp();

            E.Empno  = 844441;
            E.Ename  = "abhishek";
            E.Salary = 21700;
            return(View(E));
        }
Example #15
0
        public HttpResponseMessage Post([FromBody] emp em)
        {
            context.emps.Add(em);
            context.SaveChanges();
            HttpResponseMessage message = new HttpResponseMessage();

            message.ReasonPhrase = "Created..";
            return(message);
        }
Example #16
0
 public ActionResult Edit([Bind(Include = "pin,EmployeeName,Description")] emp emp)
 {
     if (ModelState.IsValid)
     {
         db.Entry(emp).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(emp));
 }
Example #17
0
 public ActionResult Edit([Bind(Include = "id,name,gender,age,disignation")] emp emp)
 {
     if (ModelState.IsValid)
     {
         db.Entry(emp).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(emp));
 }
 public ActionResult Edit([Bind(Include = "ID,FirstName,LastName")] emp emp)
 {
     if (ModelState.IsValid)
     {
         db.Entry(emp).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(emp));
 }
Example #19
0
 public ActionResult Edit([Bind(Include = "ID,First,Last,email,position")] emp emp)
 {
     if (ModelState.IsValid)
     {
         db.Entry(emp).State = System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(emp));
 }
        public async Task <IActionResult> Create([Bind("empid,name,city")] emp emp)
        {
            if (ModelState.IsValid)
            {
                _context.Add(emp);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(emp));
        }
Example #21
0
        public ActionResult Create([Bind(Include = "pin,EmployeeName,Description")] emp emp)
        {
            if (ModelState.IsValid)
            {
                db.emps.Add(emp);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(emp));
        }
Example #22
0
        public ActionResult Create([Bind(Include = "id,name,gender,age,disignation")] emp emp)
        {
            if (ModelState.IsValid)
            {
                db.emps.Add(emp);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(emp));
        }
        public IHttpActionResult Getemp(int id)
        {
            emp emp = db.emps.Find(id);

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

            return(Ok(emp));
        }
Example #24
0
        public ActionResult sendObjectVB()
        {
            emp E = null;

            E           = new emp();
            E.Empno     = 441;
            E.Ename     = "shek";
            E.Salary    = 700;
            ViewBag.emp = E;
            return(View());
        }
        public ActionResult Create([Bind(Include = "ID,FirstName,LastName")] emp emp)
        {
            if (ModelState.IsValid)
            {
                db.emps.Add(emp);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(emp));
        }
Example #26
0
 public ActionResult Edit([Bind(Include = "empno,ename,job,mgr,hiredate,sal,comm,deptno")] emp emp)
 {
     if (ModelState.IsValid)
     {
         db.Entry(emp).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.deptno = new SelectList(db.depts, "deptno", "dname", emp.deptno);
     return(View(emp));
 }
Example #27
0
        public ActionResult Create([Bind(Include = "empno,ename,job,mgr,hiredate,sal,comm,deptno")] emp emp)
        {
            if (ModelState.IsValid)
            {
                db.emps.Add(emp);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.deptno = new SelectList(db.depts, "deptno", "dname", emp.deptno);
            return(View(emp));
        }
Example #28
0
 public string postemployee(emp e)
 {
     try
     {
         obj.emps.Add(e);
         obj.SaveChanges();
         return("success");
     }
     catch (Exception)
     {
         return("failed");
     }
 }
Example #29
0
        private void button1_Click(object sender, EventArgs e)
        {
            emp employee = new emp();

            employee.EmpName   = textBox1.Text + " " + textBox3.Text;
            employee.EmpSalary = textBox2.Text;
            employee.Sdate     = DateTime.Now.ToString();
            employee.roleID    = Convert.ToInt32(comboBox1.SelectedValue);
            User.addTo(textBox1.Text, "admin");
            employee.UserId = User.selectAll()[User.selectAll().Count - 1].id;
            emp.addTo(employee);
            MessageBox.Show("Done");
        }
Example #30
0
        // GET: emps/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            emp emp = db.emps.Find(id);

            if (emp == null)
            {
                return(HttpNotFound());
            }
            return(View(emp));
        }
        public IHttpActionResult Deleteemp(int id)
        {
            emp emp = db.emps.Find(id);

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

            db.emps.Remove(emp);
            db.SaveChanges();

            return(Ok(emp));
        }