Exemplo n.º 1
0
        public EmployeeValidation GetEmployeeValidation(int id)
        {
            string             query = "select [dbo].[EmployeeValidation].[Question1], [dbo].[EmployeeValidation].[Question2], [dbo].[EmployeeValidation].[Question3] from [dbo].[EmployeeValidation] where [dbo].[EmployeeValidation].[EmployeeID] = " + id;
            EmployeeValidation e     = new EmployeeValidation();

            using (var command = new SqlCommand(query, con))
            {
                var dependency = new SqlDependency(command);
                dependency.OnChange -= new OnChangeEventHandler(dependency_OnChange);

                dependency.OnChange += new OnChangeEventHandler(dependency_OnChange);

                SqlDataAdapter adapter = new SqlDataAdapter(command);

                DataSet ds = new DataSet();

                adapter.Fill(ds);

                DataTable dTable = ds.Tables[0];

                foreach (DataRow row in dTable.Rows)
                {
                    e.Question1 = row["Question1"].ToString();
                    e.Question2 = row["Question2"].ToString();
                    e.Question3 = row["Question3"].ToString();
                }
            }

            return(e);
        }
Exemplo n.º 2
0
        public int AddEmployeeValidation(int id, EmployeeValidation ev)
        {
            String query   = "insert into EmployeeValidation values(" + id + ", '" + ev.Question1 + "', '" + ev.Question2 + "', '" + ev.Question3 + "')";
            var    command = new SqlCommand(query, con);
            int    err     = 1;

            counter = 0;

            try
            {
                command.ExecuteNonQuery();
                err = 0;
            }
            catch (Exception e)
            {
                err = 1;
            }
            return(err);
        }