コード例 #1
0
        public List <clsempprp> disp_rec()
        {
            if (con.State == ConnectionState.Closed)
            {
                con.Open();
            }
            SqlCommand cmd = new SqlCommand("displayemp", con);

            cmd.CommandType = CommandType.StoredProcedure;
            SqlDataReader    dr  = cmd.ExecuteReader();
            List <clsempprp> obj = new List <clsempprp>();

            while (dr.Read())
            {
                clsempprp k = new clsempprp();
                k.Empno   = Convert.ToInt32(dr[0]);
                k.Empname = dr[1].ToString();
                k.Empad   = dr[2].ToString();
                k.Empsal  = Convert.ToInt32(dr[3]);
                obj.Add(k);
            }
            dr.Close();
            cmd.Dispose();
            con.Close();
            return(obj);
        }
コード例 #2
0
        public List <clsempprp> find_rec(Int32 Empno)
        {
            if (con.State == ConnectionState.Closed)
            {
                con.Open();
            }
            SqlCommand cmd = new SqlCommand("findemp", con);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@Empno", SqlDbType.Int).Value = Empno;
            SqlDataReader    dr  = cmd.ExecuteReader();
            List <clsempprp> obj = new List <clsempprp>();

            if (dr.HasRows)
            {
                dr.Read();
                clsempprp k = new clsempprp();
                k.Empno   = Convert.ToInt32(dr[0]);
                k.Empname = dr[1].ToString();
                k.Empad   = dr[2].ToString();
                k.Empsal  = Convert.ToInt32(dr[3]);
                obj.Add(k);
            }
            dr.Close();
            cmd.Dispose();
            con.Close();
            return(obj);
        }
コード例 #3
0
        public void delete_rec(clsempprp p)
        {
            if (con.State == ConnectionState.Closed)
            {
                con.Open();
            }
            SqlCommand cmd = new SqlCommand("deleteemp", con);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@Empno", SqlDbType.Int).Value = p.Empno;
            cmd.ExecuteNonQuery();
            cmd.Dispose();
            con.Close();
        }
コード例 #4
0
        public void save_rec(clsempprp p)
        {
            if (con.State == ConnectionState.Closed)
            {
                con.Open();
            }
            SqlCommand cmd = new SqlCommand("insertemp", con);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@Empno", SqlDbType.Int).Value           = p.Empno;
            cmd.Parameters.Add("@Empname", SqlDbType.VarChar, 50).Value = p.Empname;
            cmd.Parameters.Add("@Empad", SqlDbType.VarChar, 50).Value   = p.Empad;
            cmd.Parameters.Add("@Empsal", SqlDbType.Int).Value          = p.Empsal;
            cmd.ExecuteNonQuery();
            cmd.Dispose();
            con.Close();
        }