Exemple #1
0
        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);
        }
Exemple #2
0
        public ActionResult DeleteConfirmed(int id)
        {
            Emplyoee emplyoee = db.Emplyoees.Find(id);

            db.Emplyoees.Remove(emplyoee);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemple #3
0
 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));
 }
Exemple #4
0
        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));
        }
Exemple #5
0
        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));
        }
Exemple #6
0
        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);
        }
Exemple #7
0
    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();
    }
Exemple #8
0
        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);
        }
Exemple #9
0
        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");
        }
Exemple #10
0
        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);
        }
Exemple #11
0
        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
        }
Exemple #12
0
 public void AddEmployee(Emplyoee emp)
 {
     dalCon.InsertEmployee(emp);
 }
    public void AddEmp(Emplyoee emp)
    {
        BLL bLL = new BLL();

        bLL.AddEmployee(emp);
    }