示例#1
0
        public void ThemHS(HocSinhDTO hsDTO)
        {
            SqlConnection cn  = Connect.getConnection();
            SqlCommand    cmd = new SqlCommand("InsertHocSinh", cn);

            cmd.CommandType = CommandType.StoredProcedure;

            cmd.Parameters.Add("@tenhs", SqlDbType.NVarChar);
            cmd.Parameters.Add("@diachi", SqlDbType.NVarChar);
            cmd.Parameters.Add("@dienthoai", SqlDbType.NVarChar);
            cmd.Parameters.Add("@ngaysinh", SqlDbType.DateTime);
            cmd.Parameters.Add("@malop", SqlDbType.Int);
            cmd.Parameters.Add("@mahs", SqlDbType.Int).Direction = ParameterDirection.Output;

            cmd.Parameters["@tenhs"].Value     = hsDTO.Tenhs;
            cmd.Parameters["@diachi"].Value    = hsDTO.Diachi;
            cmd.Parameters["@dienthoai"].Value = hsDTO.Dienthoai;
            cmd.Parameters["@ngaysinh"].Value  = hsDTO.Ngaysinh;
            cmd.Parameters["@malop"].Value     = hsDTO.Malop;

            cmd.ExecuteNonQuery();

            int maHS = Convert.ToInt32(cmd.Parameters["@mahs"].Value);

            hsDTO.Mahs = maHS;
            cn.Close();
        }
示例#2
0
        public void XoaLop(int malop)
        {
            SqlConnection cn  = Connect.getConnection();
            SqlCommand    cmd = new SqlCommand("DeleteLop", cn);

            cmd.CommandType = CommandType.StoredProcedure;

            cmd.Parameters.Add("@malop", SqlDbType.Int);

            cmd.Parameters["@malop"].Value = malop;
            cmd.ExecuteNonQuery();
            cn.Close();
        }
示例#3
0
        public DataTable LoadDSLop()
        {
            DataTable     dtLop = new DataTable();
            SqlConnection cn    = Connect.getConnection();
            SqlCommand    cmd   = new SqlCommand("LoadDSLop", cn);

            cmd.CommandType = CommandType.StoredProcedure;

            SqlDataAdapter da = new SqlDataAdapter(cmd);

            da.Fill(dtLop);
            cn.Close();
            return(dtLop);
        }
示例#4
0
        public void SuaLop(LopHocDTO lopDTO)
        {
            SqlConnection cn  = Connect.getConnection();
            SqlCommand    cmd = new SqlCommand("UpdateLop", cn);

            cmd.CommandType = CommandType.StoredProcedure;

            cmd.Parameters.Add("@malop", SqlDbType.Int);
            cmd.Parameters.Add("@tenlop", SqlDbType.NVarChar);
            cmd.Parameters.Add("@siso", SqlDbType.Int);

            cmd.Parameters["@malop"].Value  = lopDTO.Malop;
            cmd.Parameters["@tenlop"].Value = lopDTO.Tenlop;
            cmd.Parameters["@siso"].Value   = lopDTO.Siso;

            cmd.ExecuteNonQuery();
            cn.Close();
        }